summaryrefslogtreecommitdiffstats
path: root/src/Mobs/AggressiveMonster.cpp
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2020-12-18 21:48:32 +0100
committerTiger Wang <ziwei.tiger@outlook.com>2020-12-21 14:52:23 +0100
commit47c0b48bfd5df90cf889574c5634542d2aaa8873 (patch)
treea45252c6fa1add902671ea07eebf2bd49f0bec85 /src/Mobs/AggressiveMonster.cpp
parentChunk: use FAST_FLOOR_DIV (diff)
downloadcuberite-47c0b48bfd5df90cf889574c5634542d2aaa8873.tar
cuberite-47c0b48bfd5df90cf889574c5634542d2aaa8873.tar.gz
cuberite-47c0b48bfd5df90cf889574c5634542d2aaa8873.tar.bz2
cuberite-47c0b48bfd5df90cf889574c5634542d2aaa8873.tar.lz
cuberite-47c0b48bfd5df90cf889574c5634542d2aaa8873.tar.xz
cuberite-47c0b48bfd5df90cf889574c5634542d2aaa8873.tar.zst
cuberite-47c0b48bfd5df90cf889574c5634542d2aaa8873.zip
Diffstat (limited to '')
-rw-r--r--src/Mobs/AggressiveMonster.cpp25
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)
)
{