diff options
author | LogicParrot <LogicParrot@users.noreply.github.com> | 2016-01-12 11:52:23 +0100 |
---|---|---|
committer | LogicParrot <LogicParrot@users.noreply.github.com> | 2016-01-12 12:27:03 +0100 |
commit | e0f13f9f269e56a43fa69b061e72cc98c98050dc (patch) | |
tree | 9f72f545a4622181a0a3e77817301631595f3f87 | |
parent | Merge pull request #2857 from LogicParrot/wolf (diff) | |
download | cuberite-e0f13f9f269e56a43fa69b061e72cc98c98050dc.tar cuberite-e0f13f9f269e56a43fa69b061e72cc98c98050dc.tar.gz cuberite-e0f13f9f269e56a43fa69b061e72cc98c98050dc.tar.bz2 cuberite-e0f13f9f269e56a43fa69b061e72cc98c98050dc.tar.lz cuberite-e0f13f9f269e56a43fa69b061e72cc98c98050dc.tar.xz cuberite-e0f13f9f269e56a43fa69b061e72cc98c98050dc.tar.zst cuberite-e0f13f9f269e56a43fa69b061e72cc98c98050dc.zip |
-rw-r--r-- | src/Mobs/Wolf.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
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<cPlayer *>(m_Target)->GetName() == m_OwnerName) + { + m_Target = nullptr; // Our owner has hurt himself, avoid attacking them. + } + if (m_Target->IsMob() && static_cast<cMonster *>(m_Target)->GetMobType() == mtWolf) + { + cWolf * Wolf = static_cast<cWolf *>(m_Target); + if (Wolf->GetOwnerUUID() == GetOwnerUUID()) + { + m_Target = nullptr; // Our owner attacked one of their wolves. Abort attacking wolf. + } + } } } |