summaryrefslogtreecommitdiffstats
path: root/src/Mobs
diff options
context:
space:
mode:
authorSafwat Halaby <SafwatHalaby@users.noreply.github.com>2015-12-13 07:01:45 +0100
committerSafwat Halaby <SafwatHalaby@users.noreply.github.com>2015-12-13 07:01:45 +0100
commite4a237bad0396e750cf830e4825866057c497760 (patch)
tree5d1c1ab5b3dd6b86ccfbcaef0400d25261bc4760 /src/Mobs
parentMerge pull request #2668 from SafwatHalaby/decouple2 (diff)
parentFixed mobs attacking Creative Mode players (diff)
downloadcuberite-e4a237bad0396e750cf830e4825866057c497760.tar
cuberite-e4a237bad0396e750cf830e4825866057c497760.tar.gz
cuberite-e4a237bad0396e750cf830e4825866057c497760.tar.bz2
cuberite-e4a237bad0396e750cf830e4825866057c497760.tar.lz
cuberite-e4a237bad0396e750cf830e4825866057c497760.tar.xz
cuberite-e4a237bad0396e750cf830e4825866057c497760.tar.zst
cuberite-e4a237bad0396e750cf830e4825866057c497760.zip
Diffstat (limited to 'src/Mobs')
-rw-r--r--src/Mobs/AggressiveMonster.cpp10
-rw-r--r--src/Mobs/Monster.cpp16
2 files changed, 15 insertions, 11 deletions
diff --git a/src/Mobs/AggressiveMonster.cpp b/src/Mobs/AggressiveMonster.cpp
index a7a1eeef5..309f6d985 100644
--- a/src/Mobs/AggressiveMonster.cpp
+++ b/src/Mobs/AggressiveMonster.cpp
@@ -28,14 +28,6 @@ void cAggressiveMonster::InStateChasing(std::chrono::milliseconds a_Dt)
if (m_Target != nullptr)
{
- if (m_Target->IsPlayer())
- {
- if (static_cast<cPlayer *>(m_Target)->IsGameModeCreative())
- {
- m_EMState = IDLE;
- return;
- }
- }
MoveToPosition(m_Target->GetPosition());
}
}
@@ -103,6 +95,6 @@ bool cAggressiveMonster::Attack(std::chrono::milliseconds a_Dt)
// Setting this higher gives us more wiggle room for attackrate
m_AttackInterval = 0.0;
m_Target->TakeDamage(dtMobAttack, this, m_AttackDamage, 0);
-
+
return true;
}
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp
index 3f7153fb3..38bec857c 100644
--- a/src/Mobs/Monster.cpp
+++ b/src/Mobs/Monster.cpp
@@ -231,9 +231,21 @@ void cMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
++m_TicksSinceLastDamaged;
}
- if ((m_Target != nullptr) && m_Target->IsDestroyed())
+ if ((m_Target != nullptr))
{
- m_Target = nullptr;
+ if (m_Target->IsDestroyed())
+ {
+ m_Target = nullptr;
+ }
+ else if (m_Target->IsPlayer())
+ {
+ if (static_cast<cPlayer *>(m_Target)->IsGameModeCreative())
+ {
+ m_Target = nullptr;
+ m_EMState = IDLE;
+ return;
+ }
+ }
}
// Process the undead burning in daylight.