summaryrefslogtreecommitdiffstats
path: root/src/Entities/Player.cpp
diff options
context:
space:
mode:
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);