From cb640ffea4a51a10db2e379ada8dc0487378ba09 Mon Sep 17 00:00:00 2001 From: bibo38 Date: Wed, 12 Oct 2016 14:38:45 +0200 Subject: Spectators added (#2852) --- src/Mobs/Monster.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/Mobs/Monster.cpp') diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index acd8f0145..ece59828e 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -265,7 +265,7 @@ void cMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) if (GetTarget()->IsPlayer()) { - if (static_cast(GetTarget())->IsGameModeCreative()) + if (!static_cast(GetTarget())->CanMobsTarget()) { SetTarget(nullptr); m_EMState = IDLE; @@ -471,7 +471,13 @@ bool cMonster::DoTakeDamage(TakeDamageInfo & a_TDI) if ((a_TDI.Attacker != nullptr) && a_TDI.Attacker->IsPawn()) { - SetTarget(static_cast(a_TDI.Attacker)); + if ( + (!a_TDI.Attacker->IsPlayer()) || + (static_cast(a_TDI.Attacker)->CanMobsTarget()) + ) + { + SetTarget(static_cast(a_TDI.Attacker)); + } m_TicksSinceLastDamaged = 0; } return true; @@ -617,11 +623,10 @@ void cMonster::CheckEventLostPlayer(void) // What to do if player is seen // default to change state to chasing -void cMonster::EventSeePlayer(cEntity * a_SeenPlayer, cChunk & a_Chunk) +void cMonster::EventSeePlayer(cPlayer * a_SeenPlayer, cChunk & a_Chunk) { UNUSED(a_Chunk); - ASSERT(a_SeenPlayer->IsPlayer()); - SetTarget(static_cast(a_SeenPlayer)); + SetTarget(a_SeenPlayer); } -- cgit v1.2.3