View Single Post
Re: How to detect entity [properties] ?
Old
  (#8)
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: How to detect entity [properties] ? - 28-05-2004

I don't understand why all this stuff is needed.

Wouldn't it be more simple to have something like this :
Code:
#define FLAG_ALLIES 2
#define FLAG_AXIS 1
#define FLAG_FREE 0
Code:
int GetFlagType (edict_t *pFlagEdict)
{
   // look inside pFlagEdict's entvars and stop by the model...
   if (strcmp ("models/w_aflag.mdl", STRING (pFlagEdict->v.model)) == 0)
	  return (FLAG_ALLIES); // this one is an allied flag
   else if (strcmp ("models/w_gflag.mdl", STRING (pFlagEdict->v.model)) == 0)
	  return (FLAG_AXIS); // this one is an evil nazi flag
   else
	  return (FLAG_FREE); // if none of the above, the flag must be free
}
and then later on use it like this
Code:
// in BotFindItem()
int flag_team = GetFlagType (pent);
 
if ((strcmp("dod_control_point", item_name) == 0) && (flag_team == FLAG_ALLIES))
   // do stuff for allies flag
else if ((strcmp("dod_control_point", item_name) == 0) && (flag_team == FLAG_AXIS))
   // do stuff for axis flag
else if ((strcmp("dod_control_point", item_name) == 0) && (flag_team == FLAG_FREE))
   // do stuff for free flag



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