![]() |
How to do correct movement
To get the bots to move correctly in my plugin, http://forums.bots-united.com/showthread.php?t=3366 , I used the following function;
Quote:
Quote:
|
Re: How to do correct movement
To build the CUserCmd I used the following code;
Quote:
|
Re: How to do correct movement
The most critical part to get them to turn, and move the way they are facing is to use this line of code;
Quote:
I think that's everything to get the correct movement, with full animation, physics interaction, and possibly ladder use. I'll post my full code sometime tomorrow probably, just incase I've missed something. |
Re: How to do correct movement
How did you manage to compile with CBasePlayer ? The server & plugin builds are different and don't allow having cbasePlayer/CBaseEntity defined because there are hundereds of compile errors when I try. When I also contacted Alfred (valve) he said you cannot access these in plugins and so did botman, so please share your 'secret' :P
(ps: I'm sure all of us would be intrigued to know) :) |
Re: How to do correct movement
1 Attachment(s)
I'm no C++ linker expert (if you know someone who is, let me know :) ), so I don't know what I did that is special. I think the main difference between my plugin and the sample one is that I included cbase.h.
I cannot access all the functions of the CBasePlayer, I get compile errors with many, and if include baseplayer.cpp in the project then all hell breaks loose as you say. One thing I did find was that the class CBotManager is a friend class to CBasePlayer, I think that means you can then access private variables of CBasePlayer. However there is no CBotManager defined anywhere in the SDK, so I define one, but it doesn't seem to help much so I don't know if just defining a class of the right name is enough to become the friend. It could be useful in the future, but you don't need it to do what I'm doing now. Also I found out how to use the Vector class routines (includes the pesky fast sqaure root), you just need to include the mathlib, but then I got exceptions because it wasn't initialised. Initialising it lets it all work, but surely it must be already initialised for the main engine? I just found it a bit strange. Anyway attached is the source for the current build now it's been tidied up. There are still many problems to solve, like how to find enemies. |
Re: How to do correct movement
very interesting. I already had my own way of 'moving to a direction'. I am particularry interested in the aiming part of the bot. I want to do it as much the 'less hacky' way as possible.
I'll see if i can access cBaseEntity without hacking to much around. The above code looks a lot less hacky then the one i saw before... unless i am mistaken of course. |
Re: How to do correct movement
No hacking in the code, well not intentionally anyway. The worst thing is casting the CBaseEntity to the CBasePlayer, but that was copied directly out of valves code.
I hope it works for you too, otherwise I've no idea what I've done to get it to work. o_O |
Re: How to do correct movement
well, i wonder if it will still work after a change in CSS, or that you have to recompile or whatever. Because that is my main concern, the continuity of a project ;)
|
Re: How to do correct movement
looks like the only problem would be if a mod would change the CBasePlayer class, but as I already wondered in HL1, why shouldnt this be done by inheritance ? I mean, if nobody would change it, everything would be fine, but in HL1, almost everyone did ...
|
Re: How to do correct movement
Am I correct in assuming that it would only be a problem if they changed the number/definitions of the functions, they can change the content of the functions and it would be fine? Also you can still get to alot of stuff from the CBaseEntity, but I guess they could change that too, if they were really determined.
|
All times are GMT +2. The time now is 01:50. |
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.