diff options
author | LogicParrot <LogicParrot@users.noreply.github.com> | 2017-08-30 14:16:53 +0200 |
---|---|---|
committer | LogicParrot <LogicParrot@users.noreply.github.com> | 2017-08-30 14:16:53 +0200 |
commit | d712e754c6d2ff28540ff454a86ce41c6e1f5253 (patch) | |
tree | c17cbc929c1a113740638e1eae7b3c3270267af9 /src/Mobs/Behaviors | |
parent | BehaviorAttacker (diff) | |
download | cuberite-d712e754c6d2ff28540ff454a86ce41c6e1f5253.tar cuberite-d712e754c6d2ff28540ff454a86ce41c6e1f5253.tar.gz cuberite-d712e754c6d2ff28540ff454a86ce41c6e1f5253.tar.bz2 cuberite-d712e754c6d2ff28540ff454a86ce41c6e1f5253.tar.lz cuberite-d712e754c6d2ff28540ff454a86ce41c6e1f5253.tar.xz cuberite-d712e754c6d2ff28540ff454a86ce41c6e1f5253.tar.zst cuberite-d712e754c6d2ff28540ff454a86ce41c6e1f5253.zip |
Diffstat (limited to 'src/Mobs/Behaviors')
-rw-r--r-- | src/Mobs/Behaviors/BehaviorAttacker.cpp | 2 | ||||
-rw-r--r-- | src/Mobs/Behaviors/BehaviorAttacker.h | 6 | ||||
-rw-r--r-- | src/Mobs/Behaviors/BehaviorAttackerMelee.cpp | 8 | ||||
-rw-r--r-- | src/Mobs/Behaviors/BehaviorAttackerMelee.h | 2 |
4 files changed, 10 insertions, 8 deletions
diff --git a/src/Mobs/Behaviors/BehaviorAttacker.cpp b/src/Mobs/Behaviors/BehaviorAttacker.cpp index 30c18019e..00eb53179 100644 --- a/src/Mobs/Behaviors/BehaviorAttacker.cpp +++ b/src/Mobs/Behaviors/BehaviorAttacker.cpp @@ -57,7 +57,7 @@ void cBehaviorAttacker::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) if (m_IsStriking) { - if (StrikeTarget(a_Dt, a_Chunk, ++m_StrikeTickCnt)) + if (StrikeTarget(++m_StrikeTickCnt)) { m_Parent->UnpinBehavior(this); m_IsStriking = false; diff --git a/src/Mobs/Behaviors/BehaviorAttacker.h b/src/Mobs/Behaviors/BehaviorAttacker.h index 099cb1987..4d99fda21 100644 --- a/src/Mobs/Behaviors/BehaviorAttacker.h +++ b/src/Mobs/Behaviors/BehaviorAttacker.h @@ -49,7 +49,7 @@ protected: it returns false. a_StrikeTickCnt tracks how many times it was called. It is 1 the first call. It increments by 1 each call. This mechanism allows multi-tick attacks, like blazes shooting multiple fireballs, but most attacks are single tick and return true the first call. */ - virtual bool StrikeTarget(std::chrono::milliseconds a_Dt, cChunk & a_Chunk, int a_StrikeTickCnt) = 0; + virtual bool StrikeTarget(int a_StrikeTickCnt) = 0; // Target related methods bool TargetIsInStrikeRadius(); @@ -69,14 +69,14 @@ protected: int m_TicksSinceLastDamaged; // How many ticks ago were we last damaged by a player? bool m_IsStriking; -private: /** Our parent */ cMonster * m_Parent; +private: + // The mob we want to attack cPawn * m_Target; - int m_StrikeTickCnt; }; diff --git a/src/Mobs/Behaviors/BehaviorAttackerMelee.cpp b/src/Mobs/Behaviors/BehaviorAttackerMelee.cpp index 42e88c637..337d8d216 100644 --- a/src/Mobs/Behaviors/BehaviorAttackerMelee.cpp +++ b/src/Mobs/Behaviors/BehaviorAttackerMelee.cpp @@ -3,9 +3,11 @@ #include "BehaviorAttackerMelee.h" #include "../Monster.h" #include "../../Entities/Pawn.h" +#include "../../BlockID.h" -bool cBehaviorAttackerMelee::StrikeTarget(std::chrono::milliseconds a_Dt, cChunk & a_Chunk, int a_StrikeTickCnt) +bool cBehaviorAttackerMelee::StrikeTarget(int a_StrikeTickCnt) { - GetTarget()->TakeDamage(dtMobAttack, this, m_AttackDamage, 0); - return true; + UNUSED(a_StrikeTickCnt); + GetTarget()->TakeDamage(dtMobAttack, m_Parent, m_AttackDamage, 0); + return true; // Finish the strike. It only takes 1 tick. } diff --git a/src/Mobs/Behaviors/BehaviorAttackerMelee.h b/src/Mobs/Behaviors/BehaviorAttackerMelee.h index 6bfda0aa3..49a51ff71 100644 --- a/src/Mobs/Behaviors/BehaviorAttackerMelee.h +++ b/src/Mobs/Behaviors/BehaviorAttackerMelee.h @@ -7,5 +7,5 @@ This behavior does not make sense in combination with BehaviorCoward. */ class cBehaviorAttackerMelee : cBehaviorAttacker { public: - bool StrikeTarget(std::chrono::milliseconds a_Dt, cChunk & a_Chunk, int a_StrikeTickCnt) override; + bool StrikeTarget(int a_StrikeTickCnt) override; }; |