View Single Post
Re: How to know if a someone's crosshair is on someone else?
Old
  (#2)
KWo
Developer of PODBot mm
 
KWo's Avatar
 
Status: Offline
Posts: 3,425
Join Date: Apr 2004
Default Re: How to know if a someone's crosshair is on someone else? - 19-04-2007

Basicaly we are using DotProduct function to consider aiming.
Code:
(...)
 float flDot = GetShootingConeDeviation (pEdict, &vecEnemy);

 if (flDot > 0.99) 
{
       pBot->bWantsToFire = TRUE;
}
(...)

float GetShootingConeDeviation (edict_t *pEdict, Vector *pvecPosition)
{
   Vector vecDir = (*pvecPosition - GetGunPosition (pEdict)).Normalize ();
   Vector vecAngle = pEdict->v.v_angle;

   MAKE_VECTORS (vecAngle);

   // He's facing it, he meant it
   return (DotProduct (gpGlobals->v_forward, vecDir));
}
I hope that helps You.
  
Reply With Quote