View Single Post
Re: Sensing grenades in-flight
Old
  (#2)
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: Sensing grenades in-flight - 15-04-2004

Grenade entities are class-named "grenade", simply that

There are several ways to detect them, but this one will work:
Code:
   edict_t *pGrenade = NULL;

   // is there an armed grenade near here?
   while (!FNullEnt (pGrenade = UTIL_FindEntityInSphere (pGrenade, pPlayer->v_origin, 300)))
   {
	  if (strcmp ("grenade", STRING (pGrenade->v.classname)) == 0)
		 continue; // discard entity if it is NOT an armed grenade
 
	  // do stuff with grenade (check if bot can see it and check the grenade's velocity...



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