summaryrefslogtreecommitdiffstats
path: root/src/Mobs/Behaviors/BehaviorBrave.cpp
diff options
context:
space:
mode:
authorLogicParrot <LogicParrot@users.noreply.github.com>2017-08-30 09:36:24 +0200
committerLogicParrot <LogicParrot@users.noreply.github.com>2017-08-30 09:36:24 +0200
commit5eadfdb281f1b602fe3aa3724096545a685b96e1 (patch)
tree82aa8107e23cefef770505529208ee5f7b1e5d6f /src/Mobs/Behaviors/BehaviorBrave.cpp
parentAdded BehaviorBrave, chaser > attacker (diff)
downloadcuberite-5eadfdb281f1b602fe3aa3724096545a685b96e1.tar
cuberite-5eadfdb281f1b602fe3aa3724096545a685b96e1.tar.gz
cuberite-5eadfdb281f1b602fe3aa3724096545a685b96e1.tar.bz2
cuberite-5eadfdb281f1b602fe3aa3724096545a685b96e1.tar.lz
cuberite-5eadfdb281f1b602fe3aa3724096545a685b96e1.tar.xz
cuberite-5eadfdb281f1b602fe3aa3724096545a685b96e1.tar.zst
cuberite-5eadfdb281f1b602fe3aa3724096545a685b96e1.zip
Diffstat (limited to 'src/Mobs/Behaviors/BehaviorBrave.cpp')
-rw-r--r--src/Mobs/Behaviors/BehaviorBrave.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/Mobs/Behaviors/BehaviorBrave.cpp b/src/Mobs/Behaviors/BehaviorBrave.cpp
index e69de29bb..6aba310a1 100644
--- a/src/Mobs/Behaviors/BehaviorBrave.cpp
+++ b/src/Mobs/Behaviors/BehaviorBrave.cpp
@@ -0,0 +1,27 @@
+#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
+
+#include "BehaviorBrave.h"
+#include "BehaviorAttacker.h"
+#include "../Monster.h"
+#include "../../Entities/Entity.h"
+
+void cBehaviorBrave::AttachToMonster(cMonster & a_Parent)
+{
+ m_Parent = &a_Parent;
+ m_Parent->AttachDoTakeDamageBehavior(this);
+}
+
+
+
+
+void cBehaviorBrave::DoTakeDamage(TakeDamageInfo & a_TDI)
+{
+ cBehaviorAttacker * AttackBehavior = m_Parent->GetBehaviorAttacker();
+ if ((AttackBehavior != nullptr) && (a_TDI.Attacker != m_Parent) &&
+ (a_TDI.Attacker != nullptr) && (a_TDI.Attacker->IsPawn())
+ )
+ {
+ AttackBehavior->SetTarget(static_cast<cPawn*>(a_TDI.Attacker));
+ }
+}
+