summaryrefslogtreecommitdiffstats
path: root/src/Mobs/AggressiveMonster.cpp
diff options
context:
space:
mode:
authortycho <work.tycho@gmail.com>2015-05-23 12:31:03 +0200
committertycho <work.tycho@gmail.com>2015-05-23 12:31:03 +0200
commit1577a080ee4e2fb5baaee8c8c98149eb8418b6c6 (patch)
treef8d9453f07a7475562b68ccfbfa92ad817a206be /src/Mobs/AggressiveMonster.cpp
parentFix tests (diff)
parentMerge pull request #2108 from mc-server/tgh-boolean (diff)
downloadcuberite-1577a080ee4e2fb5baaee8c8c98149eb8418b6c6.tar
cuberite-1577a080ee4e2fb5baaee8c8c98149eb8418b6c6.tar.gz
cuberite-1577a080ee4e2fb5baaee8c8c98149eb8418b6c6.tar.bz2
cuberite-1577a080ee4e2fb5baaee8c8c98149eb8418b6c6.tar.lz
cuberite-1577a080ee4e2fb5baaee8c8c98149eb8418b6c6.tar.xz
cuberite-1577a080ee4e2fb5baaee8c8c98149eb8418b6c6.tar.zst
cuberite-1577a080ee4e2fb5baaee8c8c98149eb8418b6c6.zip
Diffstat (limited to 'src/Mobs/AggressiveMonster.cpp')
-rw-r--r--src/Mobs/AggressiveMonster.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/Mobs/AggressiveMonster.cpp b/src/Mobs/AggressiveMonster.cpp
index 055ff47d2..648599999 100644
--- a/src/Mobs/AggressiveMonster.cpp
+++ b/src/Mobs/AggressiveMonster.cpp
@@ -76,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);