summaryrefslogtreecommitdiffstats
path: root/src/Mobs/Behaviors
diff options
context:
space:
mode:
Diffstat (limited to 'src/Mobs/Behaviors')
-rw-r--r--src/Mobs/Behaviors/Behavior.cpp1
-rw-r--r--src/Mobs/Behaviors/Behavior.h2
-rw-r--r--src/Mobs/Behaviors/BehaviorChaser.cpp15
-rw-r--r--src/Mobs/Behaviors/BehaviorChaser.h5
4 files changed, 18 insertions, 5 deletions
diff --git a/src/Mobs/Behaviors/Behavior.cpp b/src/Mobs/Behaviors/Behavior.cpp
index e7c8a2c8b..a8f719f66 100644
--- a/src/Mobs/Behaviors/Behavior.cpp
+++ b/src/Mobs/Behaviors/Behavior.cpp
@@ -8,6 +8,7 @@
bool cBehavior::IsControlDesired()
{
+ LOGD("ERROR: Probably forgot to implement cBehavior::IsControlDesired but implement cBehavior::Tick");
return false;
}
diff --git a/src/Mobs/Behaviors/Behavior.h b/src/Mobs/Behaviors/Behavior.h
index c3e5cad8e..ce719f7e4 100644
--- a/src/Mobs/Behaviors/Behavior.h
+++ b/src/Mobs/Behaviors/Behavior.h
@@ -1,3 +1,5 @@
+#pragma once
+
class cBehavior
{
public:
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));
}
diff --git a/src/Mobs/Behaviors/BehaviorChaser.h b/src/Mobs/Behaviors/BehaviorChaser.h
index e924a9db3..75f3fc121 100644
--- a/src/Mobs/Behaviors/BehaviorChaser.h
+++ b/src/Mobs/Behaviors/BehaviorChaser.h
@@ -13,14 +13,15 @@ class cBehaviorStriker;
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
+class cBehaviorChaser : public cBehavior
{
public:
cBehaviorChaser(cMonster * a_Parent);
// Functions our host Monster should invoke:
- bool Tick() override;
+ bool IsControlDesired() override;
+ void Tick() override;
void Destroyed() override;
void PostTick() override;