diff options
author | LogicParrot <LogicParrot@users.noreply.github.com> | 2016-01-12 11:13:36 +0100 |
---|---|---|
committer | LogicParrot <LogicParrot@users.noreply.github.com> | 2016-01-12 11:13:36 +0100 |
commit | e2a053263f4798f879392756bb056eabf0ade3a4 (patch) | |
tree | 5d543baa8842fe74c4ed66984860be483d28c627 /src/Entities/Player.cpp | |
parent | Merge pull request #2853 from cuberite/DetailedBlockAreaLogging (diff) | |
parent | Tamed wolf assists owner (attack / defence) (diff) | |
download | cuberite-e2a053263f4798f879392756bb056eabf0ade3a4.tar cuberite-e2a053263f4798f879392756bb056eabf0ade3a4.tar.gz cuberite-e2a053263f4798f879392756bb056eabf0ade3a4.tar.bz2 cuberite-e2a053263f4798f879392756bb056eabf0ade3a4.tar.lz cuberite-e2a053263f4798f879392756bb056eabf0ade3a4.tar.xz cuberite-e2a053263f4798f879392756bb056eabf0ade3a4.tar.zst cuberite-e2a053263f4798f879392756bb056eabf0ade3a4.zip |
Diffstat (limited to 'src/Entities/Player.cpp')
-rw-r--r-- | src/Entities/Player.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 80f07cb65..c5a1e0f95 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -2,6 +2,8 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "Player.h" +#include "Mobs/Wolf.h" +#include "../BoundingBox.h" #include <unordered_map> #include "../ChatColor.h" #include "../Server.h" @@ -850,6 +852,7 @@ bool cPlayer::DoTakeDamage(TakeDamageInfo & a_TDI) AddFoodExhaustion(0.3f); SendHealth(); + NotifyFriendlyWolves(a_TDI.Attacker); m_Stats.AddValue(statDamageTaken, FloorC<StatValue>(a_TDI.FinalDamage * 10 + 0.5)); return true; } @@ -860,6 +863,42 @@ bool cPlayer::DoTakeDamage(TakeDamageInfo & a_TDI) +void cPlayer::NotifyFriendlyWolves(cEntity * a_Opponent) +{ + class LookForWolves : public cEntityCallback + { + public: + cPlayer * m_Player; + cEntity * m_Attacker; + + LookForWolves(cPlayer * a_Me, cEntity * a_MyAttacker) : + m_Player(a_Me), + m_Attacker(a_MyAttacker) + { + } + + virtual bool Item(cEntity * a_Entity) override + { + if (a_Entity->IsMob()) + { + cMonster * Mob = static_cast<cMonster*>(a_Entity); + if (Mob->GetMobType() == mtWolf) + { + cWolf * Wolf = static_cast<cWolf*>(Mob); + Wolf->NearbyPlayerIsFighting(m_Player, m_Attacker); + } + } + return false; + } + } Callback(this, a_Opponent); + + m_World->ForEachEntityInBox(cBoundingBox(GetPosition(), 16, 16), Callback); +} + + + + + void cPlayer::KilledBy(TakeDamageInfo & a_TDI) { super::KilledBy(a_TDI); |