![]() |
Yay - Bots move to given vector location...
It took a bit of fiddling , but i got it working, so here a little tutorial to get it working for you too (based on botmans template), its not completely step by step, but it has lots of code snippets.
first, make sure the viewangles get updated by WriteUserCmd in the hpb_bot2_usercmd.x file: Code:
// THIS IS OLD.... So, first we need a vector in the bot_t so we get our bot moving to that vector constantly. Since the usercmd calls them viewangles (which is NOT correct) , i call it vViewVector. Code:
typedef struct Code:
//----------------------------------------------------------------------------- Code:
if (pBot->vViewVector != Vector(0,0,0)) Code:
Vector botVec=Vector(0,0,0); 1. get the bot vector itself 2. substract your vector with the botvector 3. and finally set vViewVector to vDir * EDIT: Let me know if it does , or does not, work for you. I could have forgotten something. NOTE: THe bots do not LOOK at the direction, they MOVE at the direction, given the forward speed of the usercmd. (there is no sidespeed set, etc). I am still looking for a proper 'looking' function. |
Re: Yay - Bots move to given vector location...
so, did it work for anyone as well? (or any difficulties?). Or does this silence mean this post is uber l33t? :P
|
Re: Yay - Bots move to given vector location...
I was able to get them to move in the proper YAW direction once I added the viewangles stuff (but I was just setting the YAW directly via a ClientCommand thing I added so that I could change it on the fly).
I looked through the SDK dlls code a bit to try to determine what sets the facing direction properly, but never found it. I won't have time to look at this stuff again until probably late February or early March. botman |
Re: Yay - Bots move to given vector location...
i just hope the looking will be also 'as easy' because frankly i havent seen anything that will help me just yet. I try to find some info on a'fire a bullet' function so i know how they calculate it, but without getting the SDK compiled 100% properly under MSVC i am stuck with searching through files with Windows Commander (which is slow. :S)
|
Re: Yay - Bots move to given vector location...
I gave alfred an email about how to get "EyeAngles" without CBaseEntity/CBasePlayer, just the edict. I'll see if he gives a response, or the bot documentation for the SDK will be released before then :P
|
Re: Yay - Bots move to given vector location...
rofl yeah, well its good to keep on mailing them :D so far we made quite some progress imo in a 'short' amount of time :D
|
Re: Yay - Bots move to given vector location...
Alfred replied to say that you can only change eye angles if you have access to CBasePlayer (as botman said :p) They're working on how to access eye angles through plugins but have no date.
|
Re: Yay - Bots move to given vector location...
cheeseh, i tried ur code , but though i could not test it myself. Asp tried it for me , and he said it did not work? Are you sure it works for player entities as well?
|
Re: Yay - Bots move to given vector location...
The origin code? It works for me as a player, maybe it doesn't work for bots. I haven't tried it for getting bots origins though ...
|
Re: Yay - Bots move to given vector location...
the bots with stefans code ran always towards this corner at the ct spawn in de_cbble near to that bomb site and that fence there. dunno the coordinates yet there, but I wouldnt be surprised if there would be (0,0,0) :)
|
Re: Yay - Bots move to given vector location...
it would not suprise me if it did not work for bots... ;)
|
Re: Yay - Bots move to given vector location...
actually I just tried it with the bots, they got the origin ok, maybe you do need to "GetIServerEntity()" because i was still using that : *changes code on post*
|
Re: Yay - Bots move to given vector location...
I think when the bots spawn, they rotate to face the direction (YAW) of the spawnpoint, then they stay facing that way for the rest of the game.
Try creating your own little CS map with T and CT spawn points that face 0 and 180 degrees and I bet the bots that spawn there will be facing each other (or facing away from each other, whatever). botman |
Re: Yay - Bots move to given vector location...
botman, that would not suprise me, as the spawn points always have had control about the view angles (in Hl1 aswell). Though this was not 'default' in HL1 with fake clients if i remember correctly :)
|
Re: Yay - Bots move to given vector location...
got anymore good news?
|
Re: Yay - Bots move to given vector location...
I'm sure when something changes, someone will post news. No news means nothing has changed.
botman |
Re: Yay - Bots move to given vector location...
something changes
http://johannes.lampel.net/pics/shit/de_cbble0005.jpg SteveC delivered some very helpfull stuff; though its not the neatest way to do it ;) EDIT: BUT there is no neater to way to do it as well! |
Re: Yay - Bots move to given vector location...
** Total Edit ** :P
Alright, well I managed to get SteveC's CBaseEntity trick to work with my bots and got my bots to follow me whilst they look in the same direction (they don't look at me to follow me). I have an example movie of a bot doing this here: http://rcbot.bots-united.com/downloa...er/botmove.zip The movement is actually the same as HL1 but the QAngles were between 0 and 360 instead of -180 and 180, which was confusing me. PHP Code:
PHP Code:
PHP Code:
|
Re: Yay - Bots move to given vector location...
yes, i got this working too, you can see it in the ubframework alpha template.
currently my css bots walk around de_cbble using waypoints! yay. |
Re: Yay - Bots move to given vector location...
crap well when I try it again while changing the viewangles they move all over the place, I think there might be something else to do with the getting the right angle from either world or player forward vector, I'm still a bit unsure
|
Re: Yay - Bots move to given vector location...
ahh god I'm so ignorant :(
The movement is the SAME !! It's just that EyeAngles returns a angle from 0 to 360 instead of -180 to 180 I think. So my old code works fine now (changed in post)... it works perfectly too, the last one was a bit dodgy |
Re: Yay - Bots move to given vector location...
this is what i use:
Code:
Vector vMoveDir; |
Re: Yay - Bots move to given vector location...
Works a treat doesn't it Stefan ;).
Oh and by the way people I think I've worked out how to get the bots to shoot at enemies, (human or bot). But I need to do some testing first, should have a result by the weekend. |
Re: Yay - Bots move to given vector location...
got that working already :P
|
Re: Yay - Bots move to given vector location...
Quote:
|
Re: Yay - Bots move to given vector location...
Yeah, but to get the entity list there may be more than one technique, I'm using the edict list.
I guess we'll have a bot build off for a couple of weeks, then work together to produce a kick ass bot, once we know how everything works. Up for it? |
Re: Yay - Bots move to given vector location...
hey stevec, thats what Bots-United is for... to work together on kick-ass bots. Or alteast, at a kick-ass-framework
my snippet: Code:
void BotFindEnemy(bot_t *pBot) my "FInViewCone" function... is a bit of a fuzz. I do not know if it works 100%, here it is. Btw, i did not notice odd behaviour just yet... Code:
bool FInViewCone (Vector vStart, Vector vLookDir, QAngle viewangles) |
Re: Yay - Bots move to given vector location...
OK, I'll help where I can then.
If you want to fix the //EVIL on the maxplayers you can get the max players when the ServerActivate function is called in the plugin part of the code. And I think there is a get FOV function in the CBasePlayer class we can use, but I'll need to check. It will help with FOV when using snipers etc. |
Re: Yay - Bots move to given vector location...
About maxplayers, yes i know, i am just really lazy to fix that ;)
for FOV, i did a quick search in the base class and the player class but did not find anything yet. I did not use "FOV" as keysearch though. :S Perhaps its there, but i think my function works? :) |
Re: Yay - Bots move to given vector location...
I think I found out how to make bots switch weapons. You must pass in the wpnselect field of the usercmd struct the entity index of the weapon to select. It's not a bitfield like I initially thought. However since I have little clue so far on how to peek around entities, I have not been able to test.
|
Re: Yay - Bots move to given vector location...
small fix to check if a dedicated server;)
Code:
void CUBBOT_Plugin::ClientActive (edict_t *pEntity) edit few engine notes. -- class CBasePlayer pBot->pPlayerEnt -- pPlayerEnt->MaxSpeed (); // max speed pPlayerEnt->IsSuitEquipped (); // armor equipped pPlayerEnt->ArmorValue (); // armor amount pPlayerEnt->GetFOV (); & pPlayerEnt->GetDefaultFOV (); // get current, default fov -- CBaseEntity class pBot->pBaseEntity --- pBaseEntity->GetMaxHealth (); // max health pBaseEntity->GetHealth (); // current health pBaseEntity->GetTeamNumber (); // current team pBaseEntity->TeamID (); // current team`s name // CS:S : 1 = Spectator, 2 = Terrorist, 3 = Counter-Terrorist pBaseEntity->InSameTeam (pBaseEnemy); // is client on the same team enjoy Dubb;) |
Re: Yay - Bots move to given vector location...
great work Dub! Thats something i always wanted to know.
@ pmb, yes i already know you have to do something with that cmd.weaponselect thingy, but how its parsed, thats a clue to me (perhaps an impulse command). /me digs very quick in the code: * found this in usercmd.h (snippet) Code:
// Impulse command issued. Perhaps its the 'menu + submenu' thing. Like, ie, in CS the 4th weapon slot = grenades, and subtype is then a frag/flash/smoke grenade. But this also means you have to keep track of what a bot has because this 'order' changes (depending on what you have bought or not)... |
Re: Yay - Bots move to given vector location...
solution to getting weapon information.
add to the bot_t structure this Code:
CBaseCombatCharacter *pBaseCombatChar; Code:
pBot->pBaseCombatChar = pBot->pBaseEntity->MyCombatCharacterPointer (); Code:
CBaseCombatWeapon *pCurrentWeapon = pBot->pBaseCombatChar->GetActiveWeapon (); |
Re: Yay - Bots move to given vector location...
hmm yes, still remains an ugly hack :) any files we need to include with the project as well? or is that it? :)
*EDIT: i think you can change weapons via that way as well right? But, in CSS this would probably be different compared to the HL2 SDK code... did you test this code you posted here? |
Re: Yay - Bots move to given vector location...
untested the hack, having problem`s compiling with
CBaseCombatWeapon class included. |
Re: Yay - Bots move to given vector location...
i was afraid for that ;)
|
Re: Yay - Bots move to given vector location...
About the pBaseEnt->GetFOV
it does nothing but return a floating point if iw as not mistaken... does not help us much yet ;) |
Re: Yay - Bots move to given vector location...
stefan did you manage to compile accessing pPlayerEnt->GetFOV ()?
i keep getting unresolved external compiler error. Code:
ubbot.obj : error LNK2001: unresolved external symbol "public: int __thiscall CBasePlayer::GetFOV(void)const " (?GetFOV@CBasePlayer@@QBEHXZ) |
Re: Yay - Bots move to given vector location...
Good work Dub!
For finding out what you can access within the classes you need to check for members which are either fully defined within the header file, or are declared with the virtual state. Then you include the header file only and don't need to worry about the linking to the cpp file. However this technique only works because they have derived the 'working' classes from the ones we can see. E.G. for CS the player class is actually CSPlayer. It's not a hack, but it will fail if a mod doesn't follow valves layout to the letter. Also, isn't the float that GetFOV() returns related to the angle of the viewing cone, either degrees or possibly radians? |
Re: Yay - Bots move to given vector location...
thanks steve for the tips, much appreciated :D.
just a quick question, does this mean we can`t use GetFOV () because it`s not declared virtual or in the baseentity header? |
All times are GMT +2. The time now is 19:24. |
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.