diff options
author | andrew <xdotftw@gmail.com> | 2014-02-20 14:37:15 +0100 |
---|---|---|
committer | andrew <xdotftw@gmail.com> | 2014-02-20 14:37:15 +0100 |
commit | 83d3a2eedf88a3a180b9dfc4c706838d7f99382a (patch) | |
tree | d96970727615c681efe3bf76793015cead438394 /src/Mobs/AggressiveMonster.cpp | |
parent | cMapDecorator: Implemented random rotations (diff) | |
parent | APIDump: Fixed cBlockArea:GetRelBlockType() return types. (diff) | |
download | cuberite-83d3a2eedf88a3a180b9dfc4c706838d7f99382a.tar cuberite-83d3a2eedf88a3a180b9dfc4c706838d7f99382a.tar.gz cuberite-83d3a2eedf88a3a180b9dfc4c706838d7f99382a.tar.bz2 cuberite-83d3a2eedf88a3a180b9dfc4c706838d7f99382a.tar.lz cuberite-83d3a2eedf88a3a180b9dfc4c706838d7f99382a.tar.xz cuberite-83d3a2eedf88a3a180b9dfc4c706838d7f99382a.tar.zst cuberite-83d3a2eedf88a3a180b9dfc4c706838d7f99382a.zip |
Diffstat (limited to 'src/Mobs/AggressiveMonster.cpp')
-rw-r--r-- | src/Mobs/AggressiveMonster.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/Mobs/AggressiveMonster.cpp b/src/Mobs/AggressiveMonster.cpp index f2f0c404c..0901f85a9 100644 --- a/src/Mobs/AggressiveMonster.cpp +++ b/src/Mobs/AggressiveMonster.cpp @@ -5,7 +5,7 @@ #include "../World.h" #include "../Entities/Player.h" -#include "../MersenneTwister.h" +#include "../Tracer.h" @@ -73,6 +73,18 @@ void cAggressiveMonster::Tick(float a_Dt, cChunk & a_Chunk) { CheckEventSeePlayer(); } + + if (m_Target == NULL) + return; + + cTracer LineOfSight(GetWorld()); + 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(a_Dt / 1000); + } } @@ -81,7 +93,7 @@ void cAggressiveMonster::Tick(float a_Dt, cChunk & a_Chunk) void cAggressiveMonster::Attack(float a_Dt) { - super::Attack(a_Dt); + m_AttackInterval += a_Dt * m_AttackRate; if ((m_Target != NULL) && (m_AttackInterval > 3.0)) { |