diff options
Diffstat (limited to '')
-rw-r--r-- | src/Mobs/AggressiveMonster.cpp | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/src/Mobs/AggressiveMonster.cpp b/src/Mobs/AggressiveMonster.cpp index a904ac2da..17912a090 100644 --- a/src/Mobs/AggressiveMonster.cpp +++ b/src/Mobs/AggressiveMonster.cpp @@ -38,11 +38,6 @@ void cAggressiveMonster::InStateChasing(std::chrono::milliseconds a_Dt, cChunk & void cAggressiveMonster::EventSeePlayer(cPlayer * a_Player, cChunk & a_Chunk) { - if (!a_Player->CanMobsTarget()) - { - return; - } - Super::EventSeePlayer(a_Player, a_Chunk); m_EMState = CHASING; } @@ -60,27 +55,25 @@ void cAggressiveMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) return; } + // Set or clear m_Target depending on rules for this Monster: if (m_EMState == CHASING) { - CheckEventLostPlayer(); + CheckEventLostPlayer(a_Dt); } else { CheckEventSeePlayer(a_Chunk); } - auto target = GetTarget(); - if (target == nullptr) - { - return; - } - - // TODO: Currently all mobs see through lava, but only Nether-native mobs should be able to. - Vector3d MyHeadPosition = GetPosition() + Vector3d(0, GetHeight(), 0); - Vector3d TargetPosition = target->GetPosition() + Vector3d(0, target->GetHeight(), 0); if ( + (GetTarget() != nullptr) && TargetIsInRange() && - cLineBlockTracer::LineOfSightTrace(*GetWorld(), MyHeadPosition, TargetPosition, cLineBlockTracer::losAirWaterLava) && + cLineBlockTracer::LineOfSightTrace( + *GetWorld(), + GetPosition().addedY(GetHeight()), + GetTarget()->GetPosition().addedY(GetTarget()->GetHeight()), + cLineBlockTracer::losAirWaterLava // TODO: Currently all mobs see through lava, but only Nether-native mobs should be able to. + ) && (GetHealth() > 0.0) ) { |