diff options
author | LogicParrot <LogicParrot@users.noreply.github.com> | 2017-09-02 15:30:55 +0200 |
---|---|---|
committer | LogicParrot <LogicParrot@users.noreply.github.com> | 2017-09-02 15:30:55 +0200 |
commit | e8dd3278eaf66a49eea74769d1215944d6985d58 (patch) | |
tree | 1c2bf2cb4ea065586daf1812f43725f6689dac1c /src/Mobs/Behaviors/BehaviorAttacker.h | |
parent | squsshme (diff) | |
download | cuberite-e8dd3278eaf66a49eea74769d1215944d6985d58.tar cuberite-e8dd3278eaf66a49eea74769d1215944d6985d58.tar.gz cuberite-e8dd3278eaf66a49eea74769d1215944d6985d58.tar.bz2 cuberite-e8dd3278eaf66a49eea74769d1215944d6985d58.tar.lz cuberite-e8dd3278eaf66a49eea74769d1215944d6985d58.tar.xz cuberite-e8dd3278eaf66a49eea74769d1215944d6985d58.tar.zst cuberite-e8dd3278eaf66a49eea74769d1215944d6985d58.zip |
Diffstat (limited to 'src/Mobs/Behaviors/BehaviorAttacker.h')
-rw-r--r-- | src/Mobs/Behaviors/BehaviorAttacker.h | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/Mobs/Behaviors/BehaviorAttacker.h b/src/Mobs/Behaviors/BehaviorAttacker.h index eeb6de2a0..de375d60e 100644 --- a/src/Mobs/Behaviors/BehaviorAttacker.h +++ b/src/Mobs/Behaviors/BehaviorAttacker.h @@ -35,26 +35,29 @@ public: /** Sets a new target. Forgets the older target if present. Set this to nullptr to unset target. */ void SetTarget(cPawn * a_Target); - /** Makes the mob strike a target the next tick. Ignores the strike cooldown. - * Ignored if already striking or if no target is set. */ - void StrikeTarget(); + /** Makes the mob perform a strike the next tick. Ignores the strike cooldown. + * Ignored if already striking. Some attack behaviors do not require a target + to be set (e.g. creeper explosion). The behaviors that require a target + ignore this call if the target is null. */ + void Strike(); /** Makes the mob strike a target the next tick only if the strike cooldown permits it. * Ignored if already striking or if no target is set. */ - void StrikeTargetIfReady(); + void StrikeIfReady(); protected: /** Called when the actual attack should be made. Will be called again and again every tick until 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 DoStrikeTarget(int a_StrikeTickCnt) = 0; + fireballs, but most attacks are single tick and return true the first call. Target is not guaranteed to be valid + during these calls. The behavior is pinned until true is returned, meaning no other behaviors can tick. */ + virtual bool DoStrike(int a_StrikeTickCnt) = 0; // Target related methods bool TargetIsInStrikeRadius(); bool TargetIsInLineOfSight(); bool TargetTooFar(); - void StrikeTargetIfReady(std::chrono::milliseconds a_Dt, cChunk & a_Chunk); + void StrikeIfReady(std::chrono::milliseconds a_Dt, cChunk & a_Chunk); // Cooldown stuff void ResetStrikeCooldown(); |