summaryrefslogtreecommitdiffstats
path: root/src/Mobs/Behaviors
diff options
context:
space:
mode:
Diffstat (limited to 'src/Mobs/Behaviors')
-rw-r--r--src/Mobs/Behaviors/BehaviorAggressive.cpp2
-rw-r--r--src/Mobs/Behaviors/BehaviorAggressive.h2
-rw-r--r--src/Mobs/Behaviors/BehaviorAttacker.cpp6
3 files changed, 8 insertions, 2 deletions
diff --git a/src/Mobs/Behaviors/BehaviorAggressive.cpp b/src/Mobs/Behaviors/BehaviorAggressive.cpp
index 3b0cf6eea..8cbacf5fa 100644
--- a/src/Mobs/Behaviors/BehaviorAggressive.cpp
+++ b/src/Mobs/Behaviors/BehaviorAggressive.cpp
@@ -33,7 +33,7 @@ void cBehaviorAggressive::PreTick(std::chrono::milliseconds a_Dt, cChunk & a_Chu
if (--m_AgressionCheckCountdown == 0)
{
m_AgressionCheckCountdown = 40;
- m_ShouldBeAgressive = m_ShouldBeAggressiveFunction(*this, *m_Parent);
+ m_ShouldBeAgressive = m_ShouldBeAggressiveFunction(*this, *m_Parent, a_Chunk);
}
}
diff --git a/src/Mobs/Behaviors/BehaviorAggressive.h b/src/Mobs/Behaviors/BehaviorAggressive.h
index 434565a65..923d646e0 100644
--- a/src/Mobs/Behaviors/BehaviorAggressive.h
+++ b/src/Mobs/Behaviors/BehaviorAggressive.h
@@ -9,7 +9,7 @@ class cBehaviorAggressive;
/** The mob is agressive toward specific mobtypes, or toward the player.
This Behavior has a dependency on BehaviorAttacker. */
-typedef std::function<bool(cBehaviorAggressive & a_Behavior, cMonster & a_Monster)> ShouldBeAggressiveFunction;
+typedef std::function<bool(cBehaviorAggressive & a_Behavior, cMonster & a_Monster, cChunk & a_Chunk)> ShouldBeAggressiveFunction;
class cBehaviorAggressive : public cBehavior
{
diff --git a/src/Mobs/Behaviors/BehaviorAttacker.cpp b/src/Mobs/Behaviors/BehaviorAttacker.cpp
index 50ce8f6ad..dd3b48de2 100644
--- a/src/Mobs/Behaviors/BehaviorAttacker.cpp
+++ b/src/Mobs/Behaviors/BehaviorAttacker.cpp
@@ -15,6 +15,7 @@ cBehaviorAttacker::cBehaviorAttacker() :
, m_AttackCoolDownTicksLeft(0)
, m_IsStriking(false)
, m_Target(nullptr)
+ , m_ShouldRetaliate(true)
{
}
@@ -130,6 +131,11 @@ void cBehaviorAttacker::PostTick(std::chrono::milliseconds a_Dt, cChunk & a_Chun
void cBehaviorAttacker::DoTakeDamage(TakeDamageInfo & a_TDI)
{
+ if (!m_ShouldRetaliate)
+ {
+ return;
+ }
+
if ((a_TDI.Attacker != nullptr) && a_TDI.Attacker->IsPawn())
{
if (