![]() |
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.
|
Re: How to do correct movement
yes, thats the problem. But since this bot seems to work with CS, there MUST be an enheritance at the CSS side! And since HL2DM will be released soon (its source i believe). It could mean that the bot should work on HL2DM as well..
|
Re: How to do correct movement
hey i do notice your bot walks and looks the same way right? How about looking to direction A and walking to direction B?
|
Re: How to do correct movement
I was planning on doing that in the same way as you do when playing HL, using the sideways speed to simulate the strafe keys. A bot could also do it at any angle not just at 45degrees (like a player) by just using different ratios of forward speed and sidespeed.
|
Re: How to do correct movement
I think the animations should also work correctly when you do it that way.
|
Re: How to do correct movement
this will be pretty complicated when you want to look into several directions and walk just a path. I do know strafing is a way for combat, but i also thought , as with HL1 bot coding you could just pass 2 different angles (one for body, one for head) to get the same result. Its up to the coder to smoothen this out, but this would be most ideal (and easy).
|
Re: How to do correct movement
I could add two vectors to the CBot class which contain the movement direction and the viewing direction, then it would be quite easy to 'say' "look there and walk here". I'll get on it right away infact.
|
Re: How to do correct movement
great ;) i can't work on this right now, but i am quite anxious to see what you got working there! :D
|
Re: How to do correct movement
Whenever I compile your source, I get all the same compile errors I usually get when I try to include cbase.h,
see, whenever I just include cbase.h, I get "syntax error identifier: x... syntax error: identifier y... syntax..." surely you must have linked something differently? Sorry but I'd just like to know how to get CBasePlayer or CBaseEntity in a plugin as I'd like to do it by myself, and then I'll leave you alone :P |
Re: How to do correct movement
same problem here ...
|
Re: How to do correct movement
there is no workspace included in the project, perhaps you need to do that so we can see what you link differently...
|
Re: How to do correct movement
that are primarily compile errors, no linking errors
|
Re: How to do correct movement
There is a visual C++ .NET workspace, I guess you're still using VC 6 :) ?
edit: yeah I think there is just something missing to compile it properly. |
Re: How to do correct movement
Yeah I just got a message from my brother having the same problem, so I'm starting from a blank SDK just incase I cahnged something in the main files. Hopefully I'll have a working solution shortly.
|
Re: How to do correct movement
1 Attachment(s)
doh, something so annoying is solved by something so easy;
just add GAME_DLL to your preprocessor defines, and (fingers crossed) it should be problem sorted. |
Re: How to do correct movement
that wasnt the reason I guess ... still lots of errors
|
Re: How to do correct movement
It works for your SCBot source, but not with my bot, I get even more errors than I used to. (1761 errors to be exact!) (also seems a bit of a hack since it isn't the game dll we're building)
|
Re: How to do correct movement
that last zip file steve uploaded doesnt even work here ...
|
Re: How to do correct movement
It does work for me o_O . Just this second I just created a new Source SDK (under the name test2) and extracted the above file /|\ into the utils/SCbot dir and it compiled first time.
You will probably need to do a re-build though. The problem was in the file public/networkvar.h, on line 421 they have a preprocessor if statement which only creates the CNetworkHandleBase class if you have defined CLIENT_DLL or GAME_DLL. I didn't define either (i had modified the file in earlier attempts) but defining GAME_DLL works perfectly. |
Re: How to do correct movement
Quote:
And the only reason it's a 'hack' is because valve forces us to define one to get the Networkvar.h to compile properly. The first time I had commented the #if statement on line 421 of Networkvar.h, so I didn't need to define either DLL type. I can see your point though that I'm missleading the engine a little tiny bit. |
Re: How to do correct movement
works now, reisnatlleds the sdk again ... dunno what was the reason
|
Re: How to do correct movement
the SDK had an update, perhaps you need to re-build the source from a new SDK as SteveC did ;)
|
Re: How to do correct movement
I'm compiling the SCBot source with the same SDK code as my bot, SCBot compiles fine with the CBasePlayer stuff, mine doesn't even with the GAME_DLL thing and stuff, it;s confusin me ???:(
|
Re: How to do correct movement
Some of the functions within CBasePlayer don't work, they create linking errors. I think it's related to what the function calls, e.g. if it calls stuff from within the base entity class.
|
Re: How to do correct movement
I saw in your post you figured how to do walking to A , aiming at B
got any hints/source on that? :D |
Re: How to do correct movement
I think the latest souce zip in this thread contains the code for moving one way and looking in the other. But I don't think it will be very tidy, so not too readable.
It's quite easy now the math utilities are working because you can do tricky stuff in one line. =) |
Re: How to do correct movement
i got this principle working already as well; thx for the code snippets. I don't think i need more ;)
http://johannes.lampel.net/pics/shit/de_cbble0005.jpg thx for mr joe / asp for his screeny and testing, man i have to reinstall MSVC! :( |
Re: How to do correct movement
I could compile the second zip file he posted fine, but I was unable to find where you defined GAME_DLL, which file did you put that in if you mind me asking?
|
Re: How to do correct movement
you can define stuff in the properties of your project, so you don't need to write that defines directly to some file ( which you might forget to load here and there, and then you'd be fucked up )
|
Re: How to do correct movement
I'm having trouble getting bots to face something, they never turn to look at anything when I set the cmd.viewangles to the angles I want. Is there something I'm missing? I'm using SteveC's CBasePlayer way of issuing a command:
PHP Code:
|
Re: How to do correct movement
Did you include the line of code to set the fixangle type to none?
It's in post 3 of this thread. |
All times are GMT +2. The time now is 18:51. |
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.