summaryrefslogtreecommitdiffstats
path: root/src/Mobs/Behaviors/BehaviorAttacker.h
diff options
context:
space:
mode:
authorLogicParrot <LogicParrot@users.noreply.github.com>2017-08-30 10:29:29 +0200
committerLogicParrot <LogicParrot@users.noreply.github.com>2017-08-30 10:29:29 +0200
commit7f7c743204bb7fddfd439bcfa84943ba0fe31755 (patch)
treeacd72b62c5bc33dbb45b9ac1b5853f9970d7a45c /src/Mobs/Behaviors/BehaviorAttacker.h
parenttargetStrikeRange (diff)
downloadcuberite-7f7c743204bb7fddfd439bcfa84943ba0fe31755.tar
cuberite-7f7c743204bb7fddfd439bcfa84943ba0fe31755.tar.gz
cuberite-7f7c743204bb7fddfd439bcfa84943ba0fe31755.tar.bz2
cuberite-7f7c743204bb7fddfd439bcfa84943ba0fe31755.tar.lz
cuberite-7f7c743204bb7fddfd439bcfa84943ba0fe31755.tar.xz
cuberite-7f7c743204bb7fddfd439bcfa84943ba0fe31755.tar.zst
cuberite-7f7c743204bb7fddfd439bcfa84943ba0fe31755.zip
Diffstat (limited to 'src/Mobs/Behaviors/BehaviorAttacker.h')
-rw-r--r--src/Mobs/Behaviors/BehaviorAttacker.h43
1 files changed, 23 insertions, 20 deletions
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;
+
};