summaryrefslogtreecommitdiffstats
path: root/src/Mobs/AggressiveMonster.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Mobs/AggressiveMonster.cpp')
-rw-r--r--src/Mobs/AggressiveMonster.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/Mobs/AggressiveMonster.cpp b/src/Mobs/AggressiveMonster.cpp
index 526b39e39..648599999 100644
--- a/src/Mobs/AggressiveMonster.cpp
+++ b/src/Mobs/AggressiveMonster.cpp
@@ -36,11 +36,7 @@ void cAggressiveMonster::InStateChasing(std::chrono::milliseconds a_Dt)
return;
}
}
-
- if (!IsMovingToTargetPosition())
- {
- MoveToPosition(m_Target->GetPosition());
- }
+ MoveToPosition(m_Target->GetPosition());
}
}
@@ -80,9 +76,11 @@ void cAggressiveMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
}
cTracer LineOfSight(GetWorld());
- Vector3d AttackDirection(m_Target->GetPosition() - GetPosition());
+ Vector3d MyHeadPosition = GetPosition() + Vector3d(0, GetHeight(), 0);
+ Vector3d AttackDirection(m_Target->GetPosition() + Vector3d(0, m_Target->GetHeight(), 0) - MyHeadPosition);
- if (ReachedFinalDestination() && !LineOfSight.Trace(GetPosition(), AttackDirection, (int)AttackDirection.Length()))
+
+ if (ReachedFinalDestination() && !LineOfSight.Trace(MyHeadPosition, AttackDirection, static_cast<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(a_Dt);
@@ -100,7 +98,7 @@ void cAggressiveMonster::Attack(std::chrono::milliseconds a_Dt)
{
return;
}
-
+
// Setting this higher gives us more wiggle room for attackrate
m_AttackInterval = 0.0;
m_Target->TakeDamage(dtMobAttack, this, m_AttackDamage, 0);