I am really bad with vectors, anyone can help with an algorithm which checks that entity see the client in the 90 degrees? ( In front of entity, not on the back )
I tried
PHP Code:
Get angle of rotating of the entity
by
GetEntPropVector(entity, Prop_Send, "m_angRotation", flAngle)
and compare it to the client eye position
stock float GetVector2Ddegrees(float vFirst[3], float vSecond[3])
{
#if !defined PI
#define PI 3.14159265
#endif
static float flAngle;
flAngle = ((vFirst[0] * vSecond[0] + vFirst[1] * vSecond[1]) / (SquareRoot(vFirst[0] * vFirst[0] + vFirst[1]*vFirst[1]) * SquareRoot(vSecond[0] * vSecond[0] + vSecond[1] * vSecond[1])));
return ArcCosine(Angle) / 180.0 * PI;
}
Smth like that but also with GetClientAimTarget but just for entity
PHP Code:
stock bool CanSeeEachOther(int entityIndex, int targetIndex, float flDistance = 0.0, float flHeight = 50.0)
{
// Validate target
if (IsPlayerExist(targetIndex))
{
float vEntPosition[3]; float vTargetPosition[3];
GetEntPropVector(entityIndex, Prop_Send, "m_vecOrigin", vEntPosition);
vMonsterPosition[2] += flHeight;
GetClientEyePosition(targetIndex, vTargetPosition);
if (flDistance == 0.0 || GetVectorDistance(vEntPosition, vTargetPosition, false) < flDistance)
{
Handle hTrace = TR_TraceRayFilterEx(vEntPosition, vTargetPosition, MASK_SOLID_BRUSHONLY, RayType_EndPoint, ......);
if(TR_DidHit(hTrace))
{
CloseHandle(hTrace);
return false;
}
CloseHandle(hTrace);
return true;
}
}
return false;
}
But i couldnt get right value, help please. Thanks a milion
__________________