From e0f13f9f269e56a43fa69b061e72cc98c98050dc Mon Sep 17 00:00:00 2001 From: LogicParrot Date: Tue, 12 Jan 2016 12:52:23 +0200 Subject: Friendly wolf attack safety checks --- src/Mobs/Wolf.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/Mobs/Wolf.cpp') diff --git a/src/Mobs/Wolf.cpp b/src/Mobs/Wolf.cpp index c755e9058..f659571b1 100644 --- a/src/Mobs/Wolf.cpp +++ b/src/Mobs/Wolf.cpp @@ -45,6 +45,7 @@ bool cWolf::DoTakeDamage(TakeDamageInfo & a_TDI) + bool cWolf::Attack(std::chrono::milliseconds a_Dt) { UNUSED(a_Dt); @@ -74,9 +75,21 @@ bool cWolf::Attack(std::chrono::milliseconds a_Dt) void cWolf::NearbyPlayerIsFighting(cPlayer * a_Player, cEntity * a_Opponent) { - if ((m_Target == nullptr) && (a_Player->GetName() == m_OwnerName) && !IsSitting()) + if ((m_Target == nullptr) && (a_Player->GetName() == m_OwnerName) && !IsSitting() && (a_Opponent->IsPawn())) { m_Target = a_Opponent; + if (m_Target->IsPlayer() && static_cast(m_Target)->GetName() == m_OwnerName) + { + m_Target = nullptr; // Our owner has hurt himself, avoid attacking them. + } + if (m_Target->IsMob() && static_cast(m_Target)->GetMobType() == mtWolf) + { + cWolf * Wolf = static_cast(m_Target); + if (Wolf->GetOwnerUUID() == GetOwnerUUID()) + { + m_Target = nullptr; // Our owner attacked one of their wolves. Abort attacking wolf. + } + } } } -- cgit v1.2.3