1
0

Simplified Attack() tracing

This commit is contained in:
Tiger Wang 2014-02-12 21:53:21 +00:00
parent a0a44b969e
commit 7ced2f290f

View File

@ -74,8 +74,13 @@ void cAggressiveMonster::Tick(float a_Dt, cChunk & a_Chunk)
CheckEventSeePlayer(); CheckEventSeePlayer();
} }
if (m_Target == NULL)
return;
cTracer LineOfSight(GetWorld()); cTracer LineOfSight(GetWorld());
if (ReachedFinalDestination() && (m_Target != NULL) && !LineOfSight.Trace(GetPosition(), (m_Target->GetPosition() - GetPosition()), (int)(m_Target->GetPosition() - GetPosition()).Length())) Vector3d AttackDirection(m_Target->GetPosition() - GetPosition());
if (ReachedFinalDestination() && !LineOfSight.Trace(GetPosition(), AttackDirection, (int)AttackDirection.Length()))
{ {
// Attack if reached destination, target isn't null, and have a clear line of sight to target (so won't attack through walls) // Attack if reached destination, target isn't null, and have a clear line of sight to target (so won't attack through walls)
Attack(a_Dt / 1000); Attack(a_Dt / 1000);