1
0

Replaced strange algebra with dot product.

10 degrees is a completely arbitary constant I pulled from nowhere. Feel free to adjust this value.
This commit is contained in:
worktycho 2014-06-04 14:16:24 +01:00 committed by archshift
parent 5d4f70a7a5
commit 0690788cdf

View File

@ -42,12 +42,14 @@ public:
return false; return false;
} }
Direction.Normalize();
Vector3d LookVector = a_Player->GetLookVector(); Vector3d LookVector = a_Player->GetLookVector();
LookVector.Normalize(); double dot = Direction.Dot(LookVector);
if ((Direction - LookVector).SqrLength() > 0.02) // 0.09 rad ~ 5 degrees.
// If the players crosshars are 10 degrees from the line linking the endermen
// It counts as looking.
if (dot > cos(0.09))
{ {
return false; return false;
} }
@ -140,4 +142,4 @@ void cEnderman::EventLosePlayer()
super::EventLosePlayer(); super::EventLosePlayer();
m_bIsScreaming = false; m_bIsScreaming = false;
GetWorld()->BroadcastEntityMetadata(*this); GetWorld()->BroadcastEntityMetadata(*this);
} }