.:: Bots United ::.  
filebase forums discord server github wiki web
cubebot epodbot fritzbot gravebot grogbot hpbbot ivpbot jkbotti joebot
meanmod podbotmm racc rcbot realbot sandbot shrikebot soulfathermaps yapb

Go Back   .:: Bots United ::. > Developer's Farm > General Bot Coding
General Bot Coding See what a pain it is to get those little mechs shooting around

Reply
 
Thread Tools
Button usage works!!!!
Old
  (#1)
stefanhendriks
RealBot Author
 
stefanhendriks's Avatar
 
Status: Offline
Posts: 3,088
Join Date: Nov 2003
Location: Netherlands
Default Button usage works!!!! - 12-04-2004

YEEEEEHAW. Well i gtg for lunch. But i will give you a simple 'tutorial' how to get the buttonized doors working.

I got them working. DE_RATS works great , (CT side). I will quickly try de_prodigy and such as well.

One downside: the elevator in cs_siege is a sort of func_door, so its very hard to make bots use that elevator well...

Anyway, it works! I GOT THEM USING BUTTONS!!!
ahum.


Author of RealBot, "Arrakis" and "Dune 2 - The Maker" | co-Founder of Bots-United | Fundynamic | Blog | E-Mail me
  
Reply With Quote
Re: Button usage works!!!!
Old
  (#2)
SoUlFaThEr
Moderator
 
SoUlFaThEr's Avatar
 
Status: Offline
Posts: 860
Join Date: Mar 2004
Default Re: Button usage works!!!! - 12-04-2004

wow please talk to PMB about this.........i just asked to to do something about a USE flag or something to get them to use them correctly......

what did you do?????

i think all elevators are func_doors. i made one im my maps cs_soulcity/as_slum(sequels hehe)...but its small(short)......and bots hit that button even when they dont intend to use the 'vator and often die under it getting crushed. if they do it from above they seem to handle it well...but mine is just a square platform and not a "cage" like in cs_siege.



Last edited by SoUlFaThEr; 12-04-2004 at 13:45..
  
Reply With Quote
Re: Button usage works!!!!
Old
  (#3)
Cheeseh
[rcbot]
 
Cheeseh's Avatar
 
Status: Offline
Posts: 361
Join Date: Dec 2003
Location: China
Default Re: Button usage works!!!! - 12-04-2004

huh got what using buttons :O real bot or pod bot with waypoints ?
  
Reply With Quote
Re: Button usage works!!!!
Old
  (#4)
stefanhendriks
RealBot Author
 
stefanhendriks's Avatar
 
Status: Offline
Posts: 3,088
Join Date: Nov 2003
Location: Netherlands
Default Re: Button usage works!!!! - 12-04-2004

Okay, i am back.

Button usage is actually not hard to do, you just have to know what to read.

Requirements (what should your bot have already):
- pathfinder
- some sort of 'main goal' reminder (so it knows its actual goal)
- method to change the path to a temporarily goal
- a path_walk function

Okay:

I will show all my pieces of code and explain what i do.

Most stuff happens in path_walk(). And in my case i handle different situations. I handle 'close to node' first, then i handle walking to the node, and then i handle stuck situations:

order:
- close to node? (YES-> go to next node, exit function)
- close to node? (NO-> walk to node, perform nescesary actions (swim/jump/duck)
- stuck? (should walk?)

When checking if we are close to the node we head for (or waypoint), i fire a tracehull. You can recieve the traceresult there to know if the path is going THROUGH an entity. Most of the time it will be a func_door or a func_door_rotating without button usage, and you just handle doors as you normally do. In this case you have to know a bit more about the door. So, in code:

Code:
  edict_t *pEntityHit = NULL;
  
  //Using TraceHull to detect de_aztec bridge and other entities.
  //DONT_IGNORE_MONSTERS, we reached it only when there are no other bots standing in our way!
UTIL_TraceHull (vOrigin, vNode, dont_ignore_monsters, head_hull,
	pBot->pEdict, &tr);
  // if nothing hit: 
  if (tr.flFraction >= 1.0)
	bReachNode = true;
  else
  {
 // set entity info we hit
   if (tr.pHit)
	pEntityHit = tr.pHit; 
  }
Here you see, when we are obstructed by something, we remember the entity.

In my 'get stuck' part. I first check if my bot should move (perhaps its camping, so its normal and thus not stuck!). This is set in bShouldMove. After that my check for the entity happens:

Code:
  // When blocked by an entity, we should figure out why:
  if (pEntityHit && pBot->pButtonEdict == NULL && bShouldMove &&
   pBot->fButtonTime < gpGlobals->time)
  {
   // hit by a door?
   bool bDoor=false;
   
   // normal door (can be used as an elevator)
   if (strcmp(STRING(pEntityHit->v.classname), "func_door") == 0) bDoor=true;
   // I am not 100% sure about func_wall, but include it anyway
   if (strcmp(STRING(pEntityHit->v.classname), "func_wall") == 0) bDoor=true;
   // rotating door
   if (strcmp(STRING(pEntityHit->v.classname), "func_door_rotating") == 0) bDoor=true;
   
   if (bDoor)
   {
  // check if we have to 'use' it
  if (FBitSet ( pEntityHit->v.spawnflags, SF_DOOR_USE_ONLY ))
  {
   // use only, press use and wait
   pBot->vHead = VecBModelOrigin(pEntityHit);
   pBot->vBody = pBot->vHead;
   UTIL_BotPressKey(pBot, IN_USE);
   pBot->f_wait_time = gpGlobals->time + 0.5;   
  }
 
  // this thing has a name (needs button to activate)
  if (STRING(pEntityHit->v.targetname))
  {
   // find this entity
   edict_t *pButtonEdict = NULL;
   edict_t *pent = NULL;
   TraceResult trb;	 
   
   // search for all buttons
   while ((pent = UTIL_FindEntityByClassname (pent, "func_button")) != NULL)
   {
	// skip anything that could be 'self' (unlikely)
	if (pent == pEntityHit)
	 continue; 
	
	// get vectr
	Vector vPentVector = VecBModelOrigin (pent);   
   
	// found button entity
	if (strcmp(STRING(pent->v.target), STRING(pEntityHit->v.targetname)) == 0)
	{ 
	 UTIL_TraceLine (pBot->pEdict->v.origin, vPentVector, ignore_monsters, dont_ignore_glass, pBot->pEdict, &trb);
	 bool isGood=false;
	 
	 // if nothing hit: 
	 if (trb.flFraction >= 1.0)
	  isGood=true;
	 else
	 {
	  // we hit this button we check for
	  if (trb.pHit == pent)
	   isGood=true;
	 }	 
	 if (isGood)
	 {
	  // Button found to head for!
	  pButtonEdict = pent;
	  break;
	 }
	 else
	 {	  
	  // we failed here
	  // it is probably a button 'on the other side of the wall'
	  // as most doors have 2 buttons to access it (ie prodigy)
	 }
	}
   }
   // We have found a button to go to
   if (pButtonEdict)
   {
	// Get its vector
	Vector vButtonVector = VecBModelOrigin (pButtonEdict);
	// Search a node close to it
	int iButtonNode = close(vButtonVector, NODE_ZONE*2, pButtonEdict);
	
	// When node found, create path to it
	if (iButtonNode > -1)
	{
	 // Get current node
	 int iCurrentNode = close(pBot->pEdict->v.origin, NODE_ZONE, pBot->pEdict);
	 // when valid...
	 if (iCurrentNode > -1)
	 {
	  pBot->bot_pathid = -1;
	  path(iCurrentNode, iButtonNode, pBot->iIndex, pBot, PATH_NONE);
	  pBot->pButtonEdict = pButtonEdict;
	  return;
	 }
	 
	} // button node
   } // pButtonEdict found
  }
   }
  }
Okay. So here is actually a big deal of the code already. In short:

- hit by an entity:
- figure out classname
- when classname is a door type (func_door or func_door_rotating, func_wall is questionable? (MAPPERS??)).
- figure out the targetname of this door.
- find a func_button with the same TARGET as the doors TARGETNAME (they are linked)
- be sure you can reach this button
- create a path to it
- remember its entity

you need to remember this entity so you can override your 'head looking' with it.

At the very top (before my NEARNODE check) i have this code:

Code:
  // when pButtonEdict is filled in, we check if we are close!
  if (pBot->pButtonEdict)
  {
   Vector vButtonVector = VecBModelOrigin ( pBot->pButtonEdict);
 if (func_distance(pBot->pEdict->v.origin, vButtonVector) < 90)
 {
  TraceResult trb; 
  // TRACELINE ON PURPOSE!
  UTIL_TraceLine (pBot->pEdict->v.origin, vButtonVector, ignore_monsters, dont_ignore_glass, pBot->pEdict, &trb);
  
  bool isGood=false;
  // if nothing hit: 
  if (trb.flFraction >= 1.0)
   isGood=true;
  else
  {
   // we hit this button we check for
   if (trb.pHit == pBot->pButtonEdict)
	isGood=true;
  }  
  if (isGood)
  {
   pBot->vHead = vButtonVector;
   pBot->vBody = pBot->vHead;
   // kill edict in memory
   pBot->pButtonEdict = NULL;
   
   // press use
   UTIL_BotPressKey(pBot, IN_USE);
   SERVER_PRINT("This button i was looking for, is close, i can see it, i use it!!!\n");
   
   // wait a little
   pBot->f_wait_time = gpGlobals->time + 0.5;
   pBot->fButtonTime = gpGlobals->time + 5.0;
   return;
  }
  return;
 }  
  }
this will check if we are heading for a button already; if so, we check our distance to it. Face to it, and press USE. There is not always the need of pressing USE! So the above code should be updated by checking the spawnflags. Hence, it works for now. I will update the code later.


In overall:
it took me 1 hour to get it working basicly. It is not hard to implement, it does not require special moves, so in theory its even easier than ladder usage


Author of RealBot, "Arrakis" and "Dune 2 - The Maker" | co-Founder of Bots-United | Fundynamic | Blog | E-Mail me
  
Reply With Quote
Re: Button usage works!!!!
Old
  (#5)
Onno Kreuzinger
aka: memed / Server Admin
 
Onno Kreuzinger's Avatar
 
Status: Offline
Posts: 705
Join Date: Jan 2004
Location: germany
Default Re: Button usage works!!!! - 12-04-2004

thats great stuff stefan
when will your easter egg become playable, that feature would maka my favourite map fully bot playable (cs_bigbrother_beta1)


sunny morning view from my balcony:

see our WIKI!
see our filebase!
  
Reply With Quote
Re: Button usage works!!!!
Old
  (#6)
stefanhendriks
RealBot Author
 
stefanhendriks's Avatar
 
Status: Offline
Posts: 3,088
Join Date: Nov 2003
Location: Netherlands
Default Re: Button usage works!!!! - 12-04-2004

well. I don't know

Also, the new rb is more strict in what is walkable or not. So sometime syou have to manually create some connections to get doors working properly. But thats just a minor thing. You can still distribute your RBN file properly.

I will now test it with de_prodigy, i do not expect problems though


Author of RealBot, "Arrakis" and "Dune 2 - The Maker" | co-Founder of Bots-United | Fundynamic | Blog | E-Mail me
  
Reply With Quote
Re: Button usage works!!!!
Old
  (#7)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: Button usage works!!!! - 12-04-2004

Bravo Stefan!

This code will come in handy soon in RACC



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
  
Reply With Quote
Re: Button usage works!!!!
Old
  (#8)
stefanhendriks
RealBot Author
 
stefanhendriks's Avatar
 
Status: Offline
Posts: 3,088
Join Date: Nov 2003
Location: Netherlands
Default Re: Button usage works!!!! - 12-04-2004

thx all.

Notice:

de_prodigy does NOT use a func_door and func_button relationship. I am currently working on my code to make this work as well:

de_prodigy (and likely some more maps...) use trigger_multiple. I think its an area which the entity has to touch in order to 'open' or to 'activate' something.

In this case de_prodigy has 3 doors for sure that work like BS.

the 2 doors you have to go through as a terrorist, both use trigger_multiple to get them open. The 3rd door needs a button search, so i have to change the search that it will also find trigger_multiple stuff.

For the moment it can find this entity and its target, but the traceline fails. I am going to figure out why, perhaps its because i have ignore_monsters. Or perhaps due something else. But i am close to get this working. When it does, i post my updated code here


Author of RealBot, "Arrakis" and "Dune 2 - The Maker" | co-Founder of Bots-United | Fundynamic | Blog | E-Mail me
  
Reply With Quote
Re: Button usage works!!!!
Old
  (#9)
@$3.1415rin
Council Member, Author of JoeBOT
 
@$3.1415rin's Avatar
 
Status: Offline
Posts: 1,381
Join Date: Nov 2003
Location: Germany
Default Re: Button usage works!!!! - 12-04-2004

that system looks pretty similar to old joebot's one


  
Reply With Quote
Re: Button usage works!!!!
Old
  (#10)
stefanhendriks
RealBot Author
 
stefanhendriks's Avatar
 
Status: Offline
Posts: 3,088
Join Date: Nov 2003
Location: Netherlands
Default Re: Button usage works!!!! - 12-04-2004



i figured de_prodigy is a pain in the ass. So far the bot can go from the inside to the outside using the button. But when going from the outside, the button is somehow 'not detectable'. As if it is not hit by a traceline or whatever. I use tracehull now for that, but it still does not seem to be detected?


Author of RealBot, "Arrakis" and "Dune 2 - The Maker" | co-Founder of Bots-United | Fundynamic | Blog | E-Mail me
  
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com