.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   General Bot Coding (http://forums.bots-united.com/forumdisplay.php?f=24)
-   -   How to know if a someone's crosshair is on someone else? (http://forums.bots-united.com/showthread.php?t=6252)

Nameless 18-04-2007 15:50

How to know if a someone's crosshair is on someone else?
 
Here I have 2 persons, A and B lets say.

If A is aiming at B, how can I know that?

I've tried using edict->v_angle and some vector functions but no luck, any advices?

KWo 19-04-2007 09:15

Re: How to know if a someone's crosshair is on someone else?
 
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.

Nameless 19-04-2007 13:41

Re: How to know if a someone's crosshair is on someone else?
 
Thanks it worked.


All times are GMT +2. The time now is 04:28.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.