summaryrefslogtreecommitdiffstats
path: root/src/Entities/Player.cpp
diff options
context:
space:
mode:
authorLogicParrot <LogicParrot@users.noreply.github.com>2016-01-11 20:34:41 +0100
committerLogicParrot <LogicParrot@users.noreply.github.com>2016-01-12 10:47:59 +0100
commit359e772dee0ef4595c8ad982f17e13725f255219 (patch)
tree4c784bee23613af41e0dda909b90c1c2fd7140a6 /src/Entities/Player.cpp
parentMerge pull request #2848 from Nakkar/master (diff)
downloadcuberite-359e772dee0ef4595c8ad982f17e13725f255219.tar
cuberite-359e772dee0ef4595c8ad982f17e13725f255219.tar.gz
cuberite-359e772dee0ef4595c8ad982f17e13725f255219.tar.bz2
cuberite-359e772dee0ef4595c8ad982f17e13725f255219.tar.lz
cuberite-359e772dee0ef4595c8ad982f17e13725f255219.tar.xz
cuberite-359e772dee0ef4595c8ad982f17e13725f255219.tar.zst
cuberite-359e772dee0ef4595c8ad982f17e13725f255219.zip
Diffstat (limited to 'src/Entities/Player.cpp')
-rw-r--r--src/Entities/Player.cpp39
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);