summaryrefslogtreecommitdiffstats
path: root/src/Mobs/Behaviors
diff options
context:
space:
mode:
authorLogicParrot <LogicParrot@users.noreply.github.com>2017-08-30 09:27:09 +0200
committerLogicParrot <LogicParrot@users.noreply.github.com>2017-08-30 09:27:09 +0200
commitf29f9d45cecdd66097fc1ec287df9b6b84f11732 (patch)
tree68806cd7eb0d669d5737daf159f2ae07c9c7ac84 /src/Mobs/Behaviors
parentMuch safer raw pointers to entities (diff)
downloadcuberite-f29f9d45cecdd66097fc1ec287df9b6b84f11732.tar
cuberite-f29f9d45cecdd66097fc1ec287df9b6b84f11732.tar.gz
cuberite-f29f9d45cecdd66097fc1ec287df9b6b84f11732.tar.bz2
cuberite-f29f9d45cecdd66097fc1ec287df9b6b84f11732.tar.lz
cuberite-f29f9d45cecdd66097fc1ec287df9b6b84f11732.tar.xz
cuberite-f29f9d45cecdd66097fc1ec287df9b6b84f11732.tar.zst
cuberite-f29f9d45cecdd66097fc1ec287df9b6b84f11732.zip
Diffstat (limited to 'src/Mobs/Behaviors')
-rw-r--r--src/Mobs/Behaviors/BehaviorAggressive.h4
-rw-r--r--src/Mobs/Behaviors/BehaviorAttacker.cpp (renamed from src/Mobs/Behaviors/BehaviorChaser.cpp)37
-rw-r--r--src/Mobs/Behaviors/BehaviorAttacker.h (renamed from src/Mobs/Behaviors/BehaviorChaser.h)8
-rw-r--r--src/Mobs/Behaviors/BehaviorBrave.cpp0
-rw-r--r--src/Mobs/Behaviors/BehaviorBrave.h0
-rw-r--r--src/Mobs/Behaviors/CMakeLists.txt6
6 files changed, 28 insertions, 27 deletions
diff --git a/src/Mobs/Behaviors/BehaviorAggressive.h b/src/Mobs/Behaviors/BehaviorAggressive.h
index 88c226b27..944eee36c 100644
--- a/src/Mobs/Behaviors/BehaviorAggressive.h
+++ b/src/Mobs/Behaviors/BehaviorAggressive.h
@@ -4,7 +4,7 @@
class cBehaviorAggressive;
#include "Behavior.h"
-class cBehaviorChaser;
+class cBehaviorAttacker;
/** The mob is agressive toward specific mobtypes, or toward the player.
This Behavior has a dependency on BehaviorChaser. */
@@ -26,7 +26,7 @@ private:
// Our parent
cMonster * m_Parent;
- cBehaviorChaser * m_ParentChaser;
+ cBehaviorAttacker * m_ParentChaser;
// The mob we want to attack
cPawn * m_Target;
diff --git a/src/Mobs/Behaviors/BehaviorChaser.cpp b/src/Mobs/Behaviors/BehaviorAttacker.cpp
index dd9f193d6..14ce8a264 100644
--- a/src/Mobs/Behaviors/BehaviorChaser.cpp
+++ b/src/Mobs/Behaviors/BehaviorAttacker.cpp
@@ -1,7 +1,7 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
-#include "BehaviorChaser.h"
+#include "BehaviorAttacker.h"
#include "BehaviorStriker.h"
#include "../Monster.h"
#include "../../Entities/Pawn.h"
@@ -9,7 +9,7 @@
-cBehaviorChaser::cBehaviorChaser() :
+cBehaviorAttacker::cBehaviorAttacker() :
m_AttackRate(3)
, m_AttackDamage(1)
, m_AttackRange(1)
@@ -23,7 +23,7 @@ cBehaviorChaser::cBehaviorChaser() :
-void cBehaviorChaser::AttachToMonster(cMonster & a_Parent, cBehaviorStriker & a_ParentStriker)
+void cBehaviorAttacker::AttachToMonster(cMonster & a_Parent, cBehaviorStriker & a_ParentStriker)
{
m_Parent = &a_Parent;
m_ParentStriker = &a_ParentStriker;
@@ -37,7 +37,7 @@ void cBehaviorChaser::AttachToMonster(cMonster & a_Parent, cBehaviorStriker & a_
-bool cBehaviorChaser::IsControlDesired(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
+bool cBehaviorAttacker::IsControlDesired(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
UNUSED(a_Dt);
UNUSED(a_Chunk);
@@ -50,7 +50,7 @@ bool cBehaviorChaser::IsControlDesired(std::chrono::milliseconds a_Dt, cChunk &
-void cBehaviorChaser::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
+void cBehaviorAttacker::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
UNUSED(a_Dt);
UNUSED(a_Chunk);
@@ -93,15 +93,14 @@ void cBehaviorChaser::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
}
}
-void cBehaviorChaser::ApproachTarget()
+void cBehaviorAttacker::ApproachTarget()
{
- // potential mobTodo inheritence for creaper approachers, etc
m_Parent->MoveToPosition(m_Target->GetPosition());
}
-void cBehaviorChaser::PostTick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
+void cBehaviorAttacker::PostTick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
if (m_TicksSinceLastDamaged < 100)
{
@@ -118,7 +117,7 @@ void cBehaviorChaser::PostTick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
-void cBehaviorChaser::DoTakeDamage(TakeDamageInfo & a_TDI)
+void cBehaviorAttacker::DoTakeDamage(TakeDamageInfo & a_TDI)
{
if ((a_TDI.Attacker != nullptr) && a_TDI.Attacker->IsPawn())
{
@@ -137,7 +136,7 @@ void cBehaviorChaser::DoTakeDamage(TakeDamageInfo & a_TDI)
-void cBehaviorChaser::Destroyed()
+void cBehaviorAttacker::Destroyed()
{
SetTarget(nullptr);
}
@@ -146,7 +145,7 @@ void cBehaviorChaser::Destroyed()
-void cBehaviorChaser::SetAttackRate(float a_AttackRate)
+void cBehaviorAttacker::SetAttackRate(float a_AttackRate)
{
m_AttackRate = a_AttackRate;
}
@@ -155,7 +154,7 @@ void cBehaviorChaser::SetAttackRate(float a_AttackRate)
-void cBehaviorChaser::SetAttackRange(int a_AttackRange)
+void cBehaviorAttacker::SetAttackRange(int a_AttackRange)
{
m_AttackRange = a_AttackRange;
}
@@ -164,7 +163,7 @@ void cBehaviorChaser::SetAttackRange(int a_AttackRange)
-void cBehaviorChaser::SetAttackDamage(int a_AttackDamage)
+void cBehaviorAttacker::SetAttackDamage(int a_AttackDamage)
{
m_AttackDamage = a_AttackDamage;
}
@@ -172,7 +171,7 @@ void cBehaviorChaser::SetAttackDamage(int a_AttackDamage)
-cPawn * cBehaviorChaser::GetTarget()
+cPawn * cBehaviorAttacker::GetTarget()
{
return m_Target;
}
@@ -181,7 +180,7 @@ cPawn * cBehaviorChaser::GetTarget()
-void cBehaviorChaser::SetTarget(cPawn * a_Target)
+void cBehaviorAttacker::SetTarget(cPawn * a_Target)
{
m_Target = a_Target;
}
@@ -190,7 +189,7 @@ void cBehaviorChaser::SetTarget(cPawn * a_Target)
-bool cBehaviorChaser::TargetIsInStrikeRange()
+bool cBehaviorAttacker::TargetIsInStrikeRange()
{
ASSERT(m_Target != nullptr);
ASSERT(m_Parent != nullptr);
@@ -219,7 +218,7 @@ bool cBehaviorChaser::TargetIsInStrikeRange()
-bool cBehaviorChaser::TargetOutOfSight()
+bool cBehaviorAttacker::TargetOutOfSight()
{
ASSERT(m_Target != nullptr);
if ((GetTarget()->GetPosition() - m_Parent->GetPosition()).Length() > m_Parent->GetSightDistance())
@@ -233,7 +232,7 @@ bool cBehaviorChaser::TargetOutOfSight()
-void cBehaviorChaser::ResetStrikeCooldown()
+void cBehaviorAttacker::ResetStrikeCooldown()
{
m_AttackCoolDownTicksLeft = static_cast<int>(3 * 20 * m_AttackRate); // A second has 20 ticks, an attack rate of 1 means 1 hit every 3 seconds
}
@@ -242,7 +241,7 @@ void cBehaviorChaser::ResetStrikeCooldown()
-void cBehaviorChaser::StrikeTarget()
+void cBehaviorAttacker::StrikeTarget()
{
if (m_AttackCoolDownTicksLeft != 0)
{
diff --git a/src/Mobs/Behaviors/BehaviorChaser.h b/src/Mobs/Behaviors/BehaviorAttacker.h
index 20b60a921..67592acba 100644
--- a/src/Mobs/Behaviors/BehaviorChaser.h
+++ b/src/Mobs/Behaviors/BehaviorAttacker.h
@@ -1,20 +1,20 @@
#pragma once
-class cBehaviorChaser;
+class cBehaviorAttacker;
#include "Behavior.h"
class cBehaviorStriker;
-/** Grants chase capability to the mob. Note that this is not the same as agression!
+/** 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 cBehavior
+class cBehaviorAttacker : public cBehavior
{
public:
- cBehaviorChaser();
+ cBehaviorAttacker();
void AttachToMonster(cMonster & a_Parent, cBehaviorStriker & a_ParentStriker);
// Functions our host Monster should invoke:
diff --git a/src/Mobs/Behaviors/BehaviorBrave.cpp b/src/Mobs/Behaviors/BehaviorBrave.cpp
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/src/Mobs/Behaviors/BehaviorBrave.cpp
diff --git a/src/Mobs/Behaviors/BehaviorBrave.h b/src/Mobs/Behaviors/BehaviorBrave.h
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/src/Mobs/Behaviors/BehaviorBrave.h
diff --git a/src/Mobs/Behaviors/CMakeLists.txt b/src/Mobs/Behaviors/CMakeLists.txt
index a075cd12c..9aa3a1a4a 100644
--- a/src/Mobs/Behaviors/CMakeLists.txt
+++ b/src/Mobs/Behaviors/CMakeLists.txt
@@ -7,8 +7,9 @@ include_directories ("${PROJECT_SOURCE_DIR}/../")
SET (SRCS
Behavior.cpp
BehaviorAggressive.cpp
+ BehaviorAttacker.cpp
+ BehaviorBrave.cpp
BehaviorBreeder.cpp
- BehaviorChaser.cpp
BehaviorDoNothing.cpp
BehaviorDayLightBurner.cpp
BehaviorCoward.cpp
@@ -22,8 +23,9 @@ SET (SRCS
SET (HDRS
Behavior.h
BehaviorAggressive.h
+ BehaviorAttacker.h
+ BehaviorBrave.h
BehaviorBreeder.h
- BehaviorChaser.h
BehaviorDoNothing.h
BehaviorDayLightBurner.h
BehaviorCoward.h