From afb65224879ccced98c5a3699f7732dc37fe3f40 Mon Sep 17 00:00:00 2001 From: LogicParrot Date: Sat, 2 Sep 2017 19:51:32 +0300 Subject: Working spiders and cave spiders using behaviors --- src/Mobs/Behaviors/BehaviorAggressive.cpp | 2 +- src/Mobs/Behaviors/BehaviorAggressive.h | 2 +- src/Mobs/Behaviors/BehaviorAttacker.cpp | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-) (limited to 'src/Mobs/Behaviors') 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 ShouldBeAggressiveFunction; +typedef std::function 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 ( -- cgit v1.2.3