diff options
author | LogicParrot <LogicParrot@users.noreply.github.com> | 2017-08-23 18:40:23 +0200 |
---|---|---|
committer | LogicParrot <LogicParrot@users.noreply.github.com> | 2017-08-23 18:40:23 +0200 |
commit | 4dd4ccef715a50fb1b833c91ca33988b2a951737 (patch) | |
tree | e500a14e152942c8ded0727c53a81fe52be44f15 /src/Mobs/Behaviors/BehaviorChaser.cpp | |
parent | d (diff) | |
download | cuberite-4dd4ccef715a50fb1b833c91ca33988b2a951737.tar cuberite-4dd4ccef715a50fb1b833c91ca33988b2a951737.tar.gz cuberite-4dd4ccef715a50fb1b833c91ca33988b2a951737.tar.bz2 cuberite-4dd4ccef715a50fb1b833c91ca33988b2a951737.tar.lz cuberite-4dd4ccef715a50fb1b833c91ca33988b2a951737.tar.xz cuberite-4dd4ccef715a50fb1b833c91ca33988b2a951737.tar.zst cuberite-4dd4ccef715a50fb1b833c91ca33988b2a951737.zip |
Diffstat (limited to 'src/Mobs/Behaviors/BehaviorChaser.cpp')
-rw-r--r-- | src/Mobs/Behaviors/BehaviorChaser.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/Mobs/Behaviors/BehaviorChaser.cpp b/src/Mobs/Behaviors/BehaviorChaser.cpp index 2cdafe98f..3ac7c5123 100644 --- a/src/Mobs/Behaviors/BehaviorChaser.cpp +++ b/src/Mobs/Behaviors/BehaviorChaser.cpp @@ -23,8 +23,18 @@ cBehaviorChaser::cBehaviorChaser(cMonster * a_Parent) : +bool cBehaviorChaser::IsControlDesired() +{ + // If we have a target, we have something to do! Return true and control the mob Ticks. + // Otherwise return false. + return (GetTarget() != nullptr); +} + + -bool cBehaviorChaser::Tick() + + +void cBehaviorChaser::Tick() { // Stop targeting out of range targets if (GetTarget() != nullptr) @@ -45,10 +55,8 @@ bool cBehaviorChaser::Tick() // Not important now, but important for future extensibility, e.g. // cow chases wheat but using the netherman approacher to teleport around. } - return true; } } - return false; } void cBehaviorChaser::ApproachTarget() @@ -146,6 +154,7 @@ bool cBehaviorChaser::TargetIsInStrikeRange() Attack(a_Dt); } */ + return ((m_Target->GetPosition() - m_Parent->GetPosition()).SqrLength() < (m_AttackRange * m_AttackRange)); } |