View Single Post
Re: Sensing grenades in-flight
Old
  (#4)
stefanhendriks
RealBot Author
 
stefanhendriks's Avatar
 
Status: Offline
Posts: 3,088
Join Date: Nov 2003
Location: Netherlands
Default Re: Sensing grenades in-flight - 15-04-2004

Well i identify grenades like this, i don't even care about detonated or not right now.

Code:
edict_t *pent = NULL;
	while ((pent = UTIL_FindEntityByClassname (pent, "grenade")) != NULL)
	{
	 if (UTIL_GetGrenadeType (pent) == ... any type you want ...) // see below
	 {

// do what you want
	 }
	}
and here the grenadetype thingy:

Code:
//////////////////////////////////
// UTIL_getGrenadeType function // - Stefan
//////////////////////////////////
int
UTIL_GetGrenadeType (edict_t * pEntity)
{
  char model_name[32];
  strcpy (model_name, STRING (pEntity->v.model));
  if (strcmp (model_name, "models/w_hegrenade.mdl") == 0)
	return 1;   // He grenade
  if (strcmp (model_name, "models/w_flashbang.mdl") == 0)
	return 2;   // FlashBang
  if (strcmp (model_name, "models/w_smokegrenade.mdl") == 0)
	return 3;   // SmokeGrenade
  if (strcmp (model_name, "models/w_c4.mdl") == 0)
	return 4;   // C4 Explosive
  return 0;
}


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