NSEntity: add method IsFacing() which should make some common sneakish tasks easier.

This commit is contained in:
Marco Cawthorne 2023-01-18 19:01:56 -08:00
parent fae4bc09e5
commit 655b5fa33e
Signed by: eukara
GPG Key ID: CE2032F0A2882A22
2 changed files with 10 additions and 0 deletions

View File

@ -351,6 +351,9 @@ public:
of any entity class that you want to support think functions in.
This saves you the effort of writing your own routines and methods. */
nonvirtual void HandleThink(void);
/** Returns either true or false depending on if this entity is facing the entity in question. */
nonvirtual bool IsFacing(entity);
};
#ifdef CLIENT

View File

@ -892,6 +892,13 @@ void NSEntity::HandleThink( void ) {
}
}
bool NSEntity::IsFacing(entity target)
{
vector vecDiff = normalize(target.origin - origin);
makevectors(angles);
return ((vecDiff * v_forward) > 0 ) ? true : false;
}
#ifdef CLIENT
void
NSEntity_ReadEntity(bool new)