From 7f7c743204bb7fddfd439bcfa84943ba0fe31755 Mon Sep 17 00:00:00 2001 From: LogicParrot Date: Wed, 30 Aug 2017 11:29:29 +0300 Subject: Attacker updates --- src/Mobs/Behaviors/BehaviorAttacker.h | 43 +++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 20 deletions(-) (limited to 'src/Mobs/Behaviors/BehaviorAttacker.h') diff --git a/src/Mobs/Behaviors/BehaviorAttacker.h b/src/Mobs/Behaviors/BehaviorAttacker.h index 67592acba..4573f9a4a 100644 --- a/src/Mobs/Behaviors/BehaviorAttacker.h +++ b/src/Mobs/Behaviors/BehaviorAttacker.h @@ -17,39 +17,32 @@ public: cBehaviorAttacker(); void AttachToMonster(cMonster & a_Parent, cBehaviorStriker & a_ParentStriker); - // Functions our host Monster should invoke: - bool IsControlDesired(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; - void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; - void Destroyed() override; - void PostTick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; - void DoTakeDamage(TakeDamageInfo & a_TDI) override; // Our host monster will call these once it loads its config file void SetAttackRate(float a_AttackRate); void SetAttackRange(int a_AttackRange); void SetAttackDamage(int a_AttackDamage); + // Behavior functions + virtual bool IsControlDesired(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; + virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; + void Destroyed() override; + virtual void PostTick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; + void DoTakeDamage(TakeDamageInfo & a_TDI) override; + /** Returns the target pointer, or a nullptr if we're not targeting anyone. */ cPawn * GetTarget(); - /** Sets the target. */ + /** Sets a new target. Forgets the older target if present. */ void SetTarget(cPawn * a_Target); protected: - void ApproachTarget(); - // virtual void ApproachTarget() = 0; //mobTodo -private: + virtual void StrikeTarget() = 0; - /** Our parent */ - cMonster * m_Parent; - cBehaviorStriker * m_ParentStriker; - - // The mob we want to attack - cPawn * m_Target; - - // Target stuff - bool TargetIsInStrikeRange(); + // Target related methods + bool TargetIsInStrikeRadius(); + bool TargetIsInStrikeRadiusAndLineOfSight(); bool TargetOutOfSight(); - void StrikeTarget(); + void StrikeTargetIfReady(); // Cooldown stuff void ResetStrikeCooldown(); @@ -61,4 +54,14 @@ private: int m_AttackCoolDownTicksLeft; int m_TicksSinceLastDamaged; // How many ticks ago were we last damaged by a player? + + bool m_IsStriking; +private: + + /** Our parent */ + cMonster * m_Parent; + + // The mob we want to attack + cPawn * m_Target; + }; -- cgit v1.2.3