diff options
author | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2014-02-12 22:53:21 +0100 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2014-02-12 22:53:21 +0100 |
commit | 7ced2f290fc2018d93e324d384d87cfd826312a5 (patch) | |
tree | b56cad1e29e5af4d92b138b2ad34d7b2af1b9d14 /src/Mobs/AggressiveMonster.cpp | |
parent | Improved pressure plates (diff) | |
download | cuberite-7ced2f290fc2018d93e324d384d87cfd826312a5.tar cuberite-7ced2f290fc2018d93e324d384d87cfd826312a5.tar.gz cuberite-7ced2f290fc2018d93e324d384d87cfd826312a5.tar.bz2 cuberite-7ced2f290fc2018d93e324d384d87cfd826312a5.tar.lz cuberite-7ced2f290fc2018d93e324d384d87cfd826312a5.tar.xz cuberite-7ced2f290fc2018d93e324d384d87cfd826312a5.tar.zst cuberite-7ced2f290fc2018d93e324d384d87cfd826312a5.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Mobs/AggressiveMonster.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/Mobs/AggressiveMonster.cpp b/src/Mobs/AggressiveMonster.cpp index 7da9f4fc2..0901f85a9 100644 --- a/src/Mobs/AggressiveMonster.cpp +++ b/src/Mobs/AggressiveMonster.cpp @@ -74,8 +74,13 @@ void cAggressiveMonster::Tick(float a_Dt, cChunk & a_Chunk) CheckEventSeePlayer(); } + if (m_Target == NULL) + return; + 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(a_Dt / 1000); |