diff options
author | LogicParrot <LogicParrot@users.noreply.github.com> | 2016-01-12 12:41:20 +0100 |
---|---|---|
committer | LogicParrot <LogicParrot@users.noreply.github.com> | 2016-01-12 12:41:20 +0100 |
commit | e64790db749fd0d779ab36f08bce4a782e5f16df (patch) | |
tree | 9f72f545a4622181a0a3e77817301631595f3f87 /src | |
parent | Merge pull request #2857 from LogicParrot/wolf (diff) | |
parent | Friendly wolf attack safety checks (diff) | |
download | cuberite-e64790db749fd0d779ab36f08bce4a782e5f16df.tar cuberite-e64790db749fd0d779ab36f08bce4a782e5f16df.tar.gz cuberite-e64790db749fd0d779ab36f08bce4a782e5f16df.tar.bz2 cuberite-e64790db749fd0d779ab36f08bce4a782e5f16df.tar.lz cuberite-e64790db749fd0d779ab36f08bce4a782e5f16df.tar.xz cuberite-e64790db749fd0d779ab36f08bce4a782e5f16df.tar.zst cuberite-e64790db749fd0d779ab36f08bce4a782e5f16df.zip |
Diffstat (limited to 'src')
-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. + } + } } } |