.:: Bots United ::.  
filebase forums discord server github wiki web
cubebot epodbot fritzbot gravebot grogbot hpbbot ivpbot jkbotti joebot
meanmod podbotmm racc rcbot realbot sandbot shrikebot soulfathermaps yapb

Go Back   .:: Bots United ::. > Developer's Farm > General Bot Coding
General Bot Coding See what a pain it is to get those little mechs shooting around

Reply
 
Thread Tools
How to know if a someone's crosshair is on someone else?
Old
  (#1)
Nameless
Member
 
Status: Offline
Posts: 4
Join Date: Dec 2006
Default How to know if a someone's crosshair is on someone else? - 18-04-2007

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?
  
Reply With Quote
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
Re: How to know if a someone's crosshair is on someone else?
Old
  (#3)
Nameless
Member
 
Status: Offline
Posts: 4
Join Date: Dec 2006
Default Re: How to know if a someone's crosshair is on someone else? - 19-04-2007

Thanks it worked.
  
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com