diff options
author | LogicParrot <LogicParrot@users.noreply.github.com> | 2017-08-22 12:23:03 +0200 |
---|---|---|
committer | LogicParrot <LogicParrot@users.noreply.github.com> | 2017-08-22 19:55:30 +0200 |
commit | 80d9c26c12a5be619a757d0251525664bf7065a6 (patch) | |
tree | 66d4f553ae12fd90dd94ffde9b85f595319ba5cb /src/Mobs/Behaviors/BehaviorChaser.h | |
parent | Added check in cEntity::TickBurning for whether the entity is planning to change worlds. (#3943) (diff) | |
download | cuberite-80d9c26c12a5be619a757d0251525664bf7065a6.tar cuberite-80d9c26c12a5be619a757d0251525664bf7065a6.tar.gz cuberite-80d9c26c12a5be619a757d0251525664bf7065a6.tar.bz2 cuberite-80d9c26c12a5be619a757d0251525664bf7065a6.tar.lz cuberite-80d9c26c12a5be619a757d0251525664bf7065a6.tar.xz cuberite-80d9c26c12a5be619a757d0251525664bf7065a6.tar.zst cuberite-80d9c26c12a5be619a757d0251525664bf7065a6.zip |
Diffstat (limited to 'src/Mobs/Behaviors/BehaviorChaser.h')
-rw-r--r-- | src/Mobs/Behaviors/BehaviorChaser.h | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/Mobs/Behaviors/BehaviorChaser.h b/src/Mobs/Behaviors/BehaviorChaser.h new file mode 100644 index 000000000..fff5ebfa3 --- /dev/null +++ b/src/Mobs/Behaviors/BehaviorChaser.h @@ -0,0 +1,62 @@ + +#pragma once + +class cMonster; +class cPawn; +class cBehaviorStriker; + + +/** Grants attack capability to the mob. Note that this is not the same as agression! +The mob may possess this trait and not attack anyone or only attack when provoked. +Unlike most traits, this one has several forms, and therefore it is an abstract type +You should use one of its derived classes, and you cannot use it directly. */ +class cBehaviorChaser +{ + +public: + cBehaviorChaser(cMonster * a_Parent); + + // Functions our host Monster should invoke: + bool ActiveTick(); + void Destroyed(); + void Tick(); + + // 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); + + /** Returns the target pointer, or a nullptr if we're not targeting anyone. */ + cPawn * GetTarget(); + + /** Sets the target. */ + void SetTarget(cPawn * a_Target); + + virtual ~cBehaviorChaser(); +protected: + virtual void ApproachTarget() = 0; +private: + + /** Our parent */ + cMonster * m_Parent; + cBehaviorStriker * m_StrikeBehavior; + + // The mob we want to attack + cPawn * m_Target; + + // Target stuff + bool TargetIsInStrikeRange(); + bool TargetOutOfSight(); + void StrikeTarget(); + + // Cooldown stuff + void ResetStrikeCooldown(); + + // Our attacking parameters (Set by the setter methods, loaded from a config file in cMonster) + float m_AttackRate; + int m_AttackDamage; + int m_AttackRange; + int m_AttackCoolDownTicksLeft; + + int m_TicksSinceLastDamaged; // How many ticks ago were we last damaged by a player? +}; |