summaryrefslogtreecommitdiffstats
path: root/src/Mobs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Mobs')
-rw-r--r--src/Mobs/Bat.cpp2
-rw-r--r--src/Mobs/Bat.h5
-rw-r--r--src/Mobs/Behaviors/BehaviorAggressive.cpp24
-rw-r--r--src/Mobs/Behaviors/BehaviorAggressive.h9
-rw-r--r--src/Mobs/Behaviors/BehaviorAttackerMelee.cpp14
-rw-r--r--src/Mobs/Behaviors/BehaviorAttackerMelee.h6
-rw-r--r--src/Mobs/Behaviors/BehaviorAttackerSuicideBomber.cpp4
-rw-r--r--src/Mobs/CaveSpider.cpp37
-rw-r--r--src/Mobs/CaveSpider.h11
-rw-r--r--src/Mobs/Creeper.h1
-rw-r--r--src/Mobs/EnderDragon.cpp1
-rw-r--r--src/Mobs/EnderDragon.h4
-rw-r--r--src/Mobs/Ghast.cpp1
-rw-r--r--src/Mobs/Ghast.h5
-rw-r--r--src/Mobs/Giant.cpp1
-rw-r--r--src/Mobs/Giant.h5
-rw-r--r--src/Mobs/IronGolem.cpp1
-rw-r--r--src/Mobs/IronGolem.h5
-rw-r--r--src/Mobs/MagmaCube.cpp1
-rw-r--r--src/Mobs/MagmaCube.h5
-rw-r--r--src/Mobs/Silverfish.h6
-rw-r--r--src/Mobs/SnowGolem.cpp1
-rw-r--r--src/Mobs/SnowGolem.h5
-rw-r--r--src/Mobs/Spider.cpp10
-rw-r--r--src/Mobs/Villager.cpp5
-rw-r--r--src/Mobs/Villager.h9
-rw-r--r--src/Mobs/Witch.cpp1
-rw-r--r--src/Mobs/Witch.h5
-rw-r--r--src/Mobs/Wither.cpp1
-rw-r--r--src/Mobs/Wither.h3
-rw-r--r--src/Mobs/ZombiePigman.cpp3
-rw-r--r--src/Mobs/ZombiePigman.h11
32 files changed, 153 insertions, 49 deletions
diff --git a/src/Mobs/Bat.cpp b/src/Mobs/Bat.cpp
index a95bc00d4..317dc50dc 100644
--- a/src/Mobs/Bat.cpp
+++ b/src/Mobs/Bat.cpp
@@ -9,6 +9,8 @@ cBat::cBat(void) :
{
SetGravity(-2.0f);
SetAirDrag(0.05f);
+ m_EMPersonality = PASSIVE;
+ m_BehaviorWanderer.AttachToMonster(*this);
GetMonsterConfig("Bat");
}
diff --git a/src/Mobs/Bat.h b/src/Mobs/Bat.h
index 0c3ed647f..cdda2e1c7 100644
--- a/src/Mobs/Bat.h
+++ b/src/Mobs/Bat.h
@@ -2,7 +2,7 @@
#pragma once
#include "Monster.h"
-
+#include "Behaviors/BehaviorWanderer.h"
@@ -18,6 +18,9 @@ public:
CLASS_PROTODEF(cBat)
bool IsHanging(void) const {return false; }
+
+private:
+ cBehaviorWanderer m_BehaviorWanderer;
} ;
diff --git a/src/Mobs/Behaviors/BehaviorAggressive.cpp b/src/Mobs/Behaviors/BehaviorAggressive.cpp
index 2e3333e89..3b0cf6eea 100644
--- a/src/Mobs/Behaviors/BehaviorAggressive.cpp
+++ b/src/Mobs/Behaviors/BehaviorAggressive.cpp
@@ -6,6 +6,16 @@
#include "../../Chunk.h"
#include "../../Entities/Player.h"
+
+
+cBehaviorAggressive::cBehaviorAggressive(ShouldBeAggressiveFunction a_ShouldBeAggressiveFunction)
+ : m_ShouldBeAggressiveFunction(a_ShouldBeAggressiveFunction)
+ , m_ShouldBeAgressive(true)
+ , m_AgressionCheckCountdown(1)
+{
+
+}
+
void cBehaviorAggressive::AttachToMonster(cMonster & a_Parent)
{
m_Parent = &a_Parent;
@@ -18,6 +28,20 @@ void cBehaviorAggressive::PreTick(std::chrono::milliseconds a_Dt, cChunk & a_Chu
UNUSED(a_Dt);
UNUSED(a_Chunk);
+ if (m_ShouldBeAggressiveFunction != nullptr)
+ {
+ if (--m_AgressionCheckCountdown == 0)
+ {
+ m_AgressionCheckCountdown = 40;
+ m_ShouldBeAgressive = m_ShouldBeAggressiveFunction(*this, *m_Parent);
+ }
+ }
+
+ if (!m_ShouldBeAgressive)
+ {
+ return;
+ }
+
// Target something new if we have no target
cBehaviorAttacker * BehaviorAttacker = m_Parent->GetBehaviorAttacker();
if ((BehaviorAttacker != nullptr) && (BehaviorAttacker->GetTarget() == nullptr))
diff --git a/src/Mobs/Behaviors/BehaviorAggressive.h b/src/Mobs/Behaviors/BehaviorAggressive.h
index 840d925d5..434565a65 100644
--- a/src/Mobs/Behaviors/BehaviorAggressive.h
+++ b/src/Mobs/Behaviors/BehaviorAggressive.h
@@ -4,13 +4,18 @@
class cBehaviorAggressive;
#include "Behavior.h"
+#include <functional>
/** The mob is agressive toward specific mobtypes, or toward the player.
This Behavior has a dependency on BehaviorAttacker. */
+
+typedef std::function<bool(cBehaviorAggressive & a_Behavior, cMonster & a_Monster)> ShouldBeAggressiveFunction;
+
class cBehaviorAggressive : public cBehavior
{
public:
+ cBehaviorAggressive(ShouldBeAggressiveFunction a_ShouldBeAggressiveFunction = nullptr);
void AttachToMonster(cMonster & a_Parent);
// cBehaviorAggressive(cMonster * a_Parent, bool a_HatesPlayer);
@@ -28,4 +33,8 @@ private:
// The mob we want to attack
cPawn * m_Target;
+
+ ShouldBeAggressiveFunction m_ShouldBeAggressiveFunction;
+ bool m_ShouldBeAgressive;
+ int m_AgressionCheckCountdown;
};
diff --git a/src/Mobs/Behaviors/BehaviorAttackerMelee.cpp b/src/Mobs/Behaviors/BehaviorAttackerMelee.cpp
index 2bc0ef29d..3d25f34b4 100644
--- a/src/Mobs/Behaviors/BehaviorAttackerMelee.cpp
+++ b/src/Mobs/Behaviors/BehaviorAttackerMelee.cpp
@@ -5,9 +5,23 @@
#include "../../Entities/Pawn.h"
#include "../../BlockID.h"
+cBehaviorAttackerMelee::cBehaviorAttackerMelee(PostAttackFunction a_PostAttackFunction)
+ : m_PostAttackFunction(a_PostAttackFunction)
+{
+
+}
+
+
+
+
+
bool cBehaviorAttackerMelee::DoStrike(int a_StrikeTickCnt)
{
UNUSED(a_StrikeTickCnt);
GetTarget()->TakeDamage(dtMobAttack, m_Parent, m_AttackDamage, 0);
+ if (m_PostAttackFunction != nullptr)
+ {
+ m_PostAttackFunction(*this, *m_Parent, *GetTarget());
+ }
return true; // Finish the strike. It only takes 1 tick.
}
diff --git a/src/Mobs/Behaviors/BehaviorAttackerMelee.h b/src/Mobs/Behaviors/BehaviorAttackerMelee.h
index 617b9d321..69d626fbc 100644
--- a/src/Mobs/Behaviors/BehaviorAttackerMelee.h
+++ b/src/Mobs/Behaviors/BehaviorAttackerMelee.h
@@ -1,11 +1,17 @@
#pragma once
#include "BehaviorAttacker.h"
+#include <functional>
+class cBehaviorAttackerMelee;
/** Grants the mob that ability to approach a target and then melee attack it.
Use BehaviorAttackerMelee::SetTarget to attack. */
+typedef std::function<void(cBehaviorAttackerMelee & a_Behavior, cMonster & a_Attacker, cPawn & a_Attacked)> PostAttackFunction;
class cBehaviorAttackerMelee : public cBehaviorAttacker
{
public:
+ cBehaviorAttackerMelee(PostAttackFunction a_PostAttackFunction = nullptr);
bool DoStrike(int a_StrikeTickCnt) override;
+private:
+ PostAttackFunction m_PostAttackFunction;
};
diff --git a/src/Mobs/Behaviors/BehaviorAttackerSuicideBomber.cpp b/src/Mobs/Behaviors/BehaviorAttackerSuicideBomber.cpp
index bab9fd88f..843cc58ef 100644
--- a/src/Mobs/Behaviors/BehaviorAttackerSuicideBomber.cpp
+++ b/src/Mobs/Behaviors/BehaviorAttackerSuicideBomber.cpp
@@ -35,13 +35,9 @@ bool cBehaviorAttackerSuicideBomber::DoStrike(int a_StrikeTickCnt)
{
UNUSED(a_StrikeTickCnt);
-
- LOGD("Suicide doStrike");
-
// phase 1: start blowing up
if (a_StrikeTickCnt == 1)
{
- LOGD("Suicide START");
ASSERT(!m_bIsBlowing);
m_Parent->GetWorld()->BroadcastSoundEffect("entity.creeper.primed", m_Parent->GetPosX(), m_Parent->GetPosY(), m_Parent->GetPosZ(), 1.f, (0.75f + (static_cast<float>((m_Parent->GetUniqueID() * 23) % 32)) / 64));
diff --git a/src/Mobs/CaveSpider.cpp b/src/Mobs/CaveSpider.cpp
index ba58cdf71..505e6a9df 100644
--- a/src/Mobs/CaveSpider.cpp
+++ b/src/Mobs/CaveSpider.cpp
@@ -2,15 +2,29 @@
#include "CaveSpider.h"
#include "../World.h"
+#include "Mobs/Behaviors/BehaviorAttackerMelee.h"
+
+
+void CaveSpiderPostAttack(cBehaviorAttackerMelee & a_Behavior, cMonster & a_Attacker, cPawn & a_Attacked)
+{
+ UNUSED(a_Behavior);
+ UNUSED(a_Attacker);
+ // TODO: Easy = no poison, Medium = 7 seconds, Hard = 15 seconds
+ a_Attacked.AddEntityEffect(cEntityEffect::effPoison, 7 * 20, 0);
+}
-cCaveSpider::cCaveSpider(void) :
- super(mtCaveSpider, "entity.spider.hurt", "entity.spider.death", 0.7, 0.5)
+cCaveSpider::cCaveSpider(void)
+ : super(mtCaveSpider, "entity.spider.hurt", "entity.spider.death", 0.7, 0.5)
+ , m_BehaviorAttackerMelee(CaveSpiderPostAttack)
{
m_EMPersonality = AGGRESSIVE;
+ m_BehaviorAttackerMelee.AttachToMonster(*this);
+ m_BehaviorWanderer.AttachToMonster(*this);
+ m_BehaviorAggressive.AttachToMonster(*this);
GetMonsterConfig("CaveSpider");
}
@@ -33,25 +47,6 @@ void cCaveSpider::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
-/*
-bool cCaveSpider::Attack(std::chrono::milliseconds a_Dt)
-{
- if (!super::Attack(a_Dt))
- {
- return false;
- }
-
- if (GetTarget()->IsPawn())
- {
- // TODO: Easy = no poison, Medium = 7 seconds, Hard = 15 seconds
- static_cast<cPawn *>(GetTarget())->AddEntityEffect(cEntityEffect::effPoison, 7 * 20, 0);
- }
- return true;
-}*/
-
-
-
-
void cCaveSpider::GetDrops(cItems & a_Drops, cEntity * a_Killer)
{
diff --git a/src/Mobs/CaveSpider.h b/src/Mobs/CaveSpider.h
index f59809d03..c7a660c75 100644
--- a/src/Mobs/CaveSpider.h
+++ b/src/Mobs/CaveSpider.h
@@ -1,7 +1,9 @@
#pragma once
#include "Monster.h"
-
+#include "Behaviors/BehaviorAttackerMelee.h"
+#include "Behaviors/BehaviorWanderer.h"
+#include "Behaviors/BehaviorAggressive.h"
@@ -18,6 +20,13 @@ public:
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
+
+ // tick behaviors
+ cBehaviorAttackerMelee m_BehaviorAttackerMelee;
+ cBehaviorWanderer m_BehaviorWanderer;
+
+ // other behaviors
+ cBehaviorAggressive m_BehaviorAggressive;
} ;
diff --git a/src/Mobs/Creeper.h b/src/Mobs/Creeper.h
index c08a6e451..85b94c397 100644
--- a/src/Mobs/Creeper.h
+++ b/src/Mobs/Creeper.h
@@ -5,7 +5,6 @@
#include "Behaviors/BehaviorAttackerSuicideBomber.h"
#include "Behaviors/BehaviorWanderer.h"
#include "Behaviors/BehaviorAggressive.h"
-#include "Behaviors/BehaviorDayLightBurner.h"
diff --git a/src/Mobs/EnderDragon.cpp b/src/Mobs/EnderDragon.cpp
index 8fc42556b..902c1d629 100644
--- a/src/Mobs/EnderDragon.cpp
+++ b/src/Mobs/EnderDragon.cpp
@@ -12,6 +12,7 @@ cEnderDragon::cEnderDragon(void) :
super(mtEnderDragon, "entity.enderdragon.hurt", "entity.enderdragon.death", 16.0, 8.0)
{
m_EMPersonality = AGGRESSIVE;
+ m_BehaviorDoNothing.AttachToMonster(*this);
GetMonsterConfig("EnderDragon");
}
diff --git a/src/Mobs/EnderDragon.h b/src/Mobs/EnderDragon.h
index 0528af77c..b756aab17 100644
--- a/src/Mobs/EnderDragon.h
+++ b/src/Mobs/EnderDragon.h
@@ -2,6 +2,7 @@
#pragma once
#include "Monster.h"
+#include "Behaviors/BehaviorDoNothing.h"
class cEnderDragon :
public cMonster
@@ -14,6 +15,9 @@ public:
CLASS_PROTODEF(cEnderDragon)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
+
+private:
+ cBehaviorDoNothing m_BehaviorDoNothing;
} ;
diff --git a/src/Mobs/Ghast.cpp b/src/Mobs/Ghast.cpp
index 7f051e3cc..913d88c7f 100644
--- a/src/Mobs/Ghast.cpp
+++ b/src/Mobs/Ghast.cpp
@@ -12,6 +12,7 @@ cGhast::cGhast(void) :
super(mtGhast, "entity.ghast.hurt", "entity.ghast.death", 4, 4)
{
m_EMPersonality = AGGRESSIVE;
+ m_BehaviorDoNothing.AttachToMonster(*this);
GetMonsterConfig("Ghast");
}
diff --git a/src/Mobs/Ghast.h b/src/Mobs/Ghast.h
index 7fea31ae8..014e9c0dc 100644
--- a/src/Mobs/Ghast.h
+++ b/src/Mobs/Ghast.h
@@ -1,6 +1,6 @@
#pragma once
#include "Monster.h"
-
+#include "Behaviors/BehaviorDoNothing.h"
@@ -18,6 +18,9 @@ public:
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
bool IsCharging(void) const {return false; }
+
+private:
+ cBehaviorDoNothing m_BehaviorDoNothing;
} ;
diff --git a/src/Mobs/Giant.cpp b/src/Mobs/Giant.cpp
index ff1f8604c..3dc621865 100644
--- a/src/Mobs/Giant.cpp
+++ b/src/Mobs/Giant.cpp
@@ -11,6 +11,7 @@ cGiant::cGiant(void) :
super(mtGiant, "entity.zombie.hurt", "entity.zombie.death", 3.6, 10.8)
{
m_EMPersonality = AGGRESSIVE;
+ m_BehaviorDoNothing.AttachToMonster(*this);
GetMonsterConfig("Giant");
}
diff --git a/src/Mobs/Giant.h b/src/Mobs/Giant.h
index f1734437b..9cd7c2865 100644
--- a/src/Mobs/Giant.h
+++ b/src/Mobs/Giant.h
@@ -2,7 +2,7 @@
#pragma once
#include "Monster.h"
-
+#include "Behaviors/BehaviorDoNothing.h"
@@ -18,6 +18,9 @@ public:
CLASS_PROTODEF(cGiant)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
+
+private:
+ cBehaviorDoNothing m_BehaviorDoNothing;
} ;
diff --git a/src/Mobs/IronGolem.cpp b/src/Mobs/IronGolem.cpp
index 366ea76c4..a6fd5e8c4 100644
--- a/src/Mobs/IronGolem.cpp
+++ b/src/Mobs/IronGolem.cpp
@@ -11,6 +11,7 @@ cIronGolem::cIronGolem(void) :
super(mtIronGolem, "entity.irongolem.hurt", "entity.irongolem.death", 1.4, 2.9)
{
m_EMPersonality = PASSIVE;
+ m_BehaviorWanderer.AttachToMonster(*this);
GetMonsterConfig("IronGolem");
}
diff --git a/src/Mobs/IronGolem.h b/src/Mobs/IronGolem.h
index c35452e3b..ea1cc759d 100644
--- a/src/Mobs/IronGolem.h
+++ b/src/Mobs/IronGolem.h
@@ -2,7 +2,7 @@
#pragma once
#include "Monster.h"
-
+#include "Behaviors/BehaviorWanderer.h"
@@ -22,6 +22,9 @@ public:
// Iron golems do not drown nor float
virtual void HandleAir(void) override {}
virtual void SetSwimState(cChunk & a_Chunk) override {}
+
+private:
+ cBehaviorWanderer m_BehaviorWanderer;
} ;
diff --git a/src/Mobs/MagmaCube.cpp b/src/Mobs/MagmaCube.cpp
index c1927241e..2891605c8 100644
--- a/src/Mobs/MagmaCube.cpp
+++ b/src/Mobs/MagmaCube.cpp
@@ -11,6 +11,7 @@ cMagmaCube::cMagmaCube(int a_Size) :
m_Size(a_Size)
{
m_EMPersonality = AGGRESSIVE;
+ m_BehaviorDoNothing.AttachToMonster(*this);
GetMonsterConfig("MagmaCube");
}
diff --git a/src/Mobs/MagmaCube.h b/src/Mobs/MagmaCube.h
index 960ff0c90..4cfc1c27d 100644
--- a/src/Mobs/MagmaCube.h
+++ b/src/Mobs/MagmaCube.h
@@ -1,7 +1,7 @@
#pragma once
#include "Monster.h"
-
+#include "Behaviors/BehaviorDoNothing.h"
@@ -28,6 +28,9 @@ protected:
/** Size of the MagmaCube, with 1 being the smallest */
int m_Size;
+
+private:
+ cBehaviorDoNothing m_BehaviorDoNothing;
} ;
diff --git a/src/Mobs/Silverfish.h b/src/Mobs/Silverfish.h
index c4dd9f912..72b772a2c 100644
--- a/src/Mobs/Silverfish.h
+++ b/src/Mobs/Silverfish.h
@@ -2,7 +2,7 @@
#pragma once
#include "Monster.h"
-
+#include "Behaviors/BehaviorDoNothing.h"
@@ -16,10 +16,14 @@ public:
cSilverfish(void) :
super(mtSilverfish, "entity.silverfish.hurt", "entity.silverfish.death", 0.3, 0.7)
{
+ m_BehaviorDoNothing.AttachToMonster(*this);
GetMonsterConfig("Silverfish");
}
CLASS_PROTODEF(cSilverfish)
+
+private:
+ cBehaviorDoNothing m_BehaviorDoNothing;
} ;
diff --git a/src/Mobs/SnowGolem.cpp b/src/Mobs/SnowGolem.cpp
index 4c9fa2a02..9e0295785 100644
--- a/src/Mobs/SnowGolem.cpp
+++ b/src/Mobs/SnowGolem.cpp
@@ -12,6 +12,7 @@ cSnowGolem::cSnowGolem(void) :
super(mtSnowGolem, "entity.snowman.hurt", "entity.snowman.death", 0.4, 1.8)
{
m_EMPersonality = PASSIVE;
+ m_BehaviorWanderer.AttachToMonster(*this);
GetMonsterConfig("SnowGolem");
}
diff --git a/src/Mobs/SnowGolem.h b/src/Mobs/SnowGolem.h
index 59026b3ec..0170a57a9 100644
--- a/src/Mobs/SnowGolem.h
+++ b/src/Mobs/SnowGolem.h
@@ -2,7 +2,7 @@
#pragma once
#include "Monster.h"
-
+#include "Behaviors/BehaviorWanderer.h"
@@ -19,6 +19,9 @@ public:
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
+
+private:
+ cBehaviorWanderer m_BehaviorWanderer;
} ;
diff --git a/src/Mobs/Spider.cpp b/src/Mobs/Spider.cpp
index a656c9c30..15c8d5769 100644
--- a/src/Mobs/Spider.cpp
+++ b/src/Mobs/Spider.cpp
@@ -7,11 +7,19 @@
#include "../Entities/Player.h"
#include "../Chunk.h"
+bool AggressiveAtNightFunction(cBehaviorAggressive & a_Behavior, cMonster & a_Monster)
+{
+
+}
cSpider::cSpider(void) :
- super(mtSpider, "entity.spider.hurt", "entity.spider.death", 1.4, 0.9)
+ super(mtSpider, "entity.spider.hurt", "entity.spider.death", 1.4, 0.9) ,
+ m_BehaviorAggressive(AggressiveAtNightFunction)
{
m_EMPersonality = AGGRESSIVE;
+ m_BehaviorAttackerMelee.AttachToMonster(*this);
+ m_BehaviorWanderer.AttachToMonster(*this);
+ m_BehaviorAggressive.AttachToMonster(*this);
GetMonsterConfig("Spider");
}
diff --git a/src/Mobs/Villager.cpp b/src/Mobs/Villager.cpp
index 84514177b..ed3b3305f 100644
--- a/src/Mobs/Villager.cpp
+++ b/src/Mobs/Villager.cpp
@@ -18,10 +18,7 @@ cVillager::cVillager(eVillagerType VillagerType) :
m_VillagerAction(false)
{
m_EMPersonality = PASSIVE;
- m_BehaviorBreeder.AttachToMonster(*this);
- m_BehaviorCoward.AttachToMonster(*this);
- m_BehaviorItemFollower.AttachToMonster(*this);
- m_BehaviorWanderer.AttachToMonster(*this);
+ m_BehaviorDoNothing.AttachToMonster(*this);
GetMonsterConfig("Villager");
}
diff --git a/src/Mobs/Villager.h b/src/Mobs/Villager.h
index 141193212..72c7c7301 100644
--- a/src/Mobs/Villager.h
+++ b/src/Mobs/Villager.h
@@ -10,7 +10,7 @@
#include "Behaviors/BehaviorWanderer.h"
#include "Monster.h"
-
+#include "Behaviors/BehaviorDoNothing.h"
class cVillager :
public cMonster
@@ -59,17 +59,12 @@ public:
private:
// Tick controlling behaviors
- cBehaviorBreeder m_BehaviorBreeder;
- cBehaviorItemFollower m_BehaviorItemFollower;
- cBehaviorCoward m_BehaviorCoward;
- cBehaviorWanderer m_BehaviorWanderer;
-
+ cBehaviorDoNothing m_BehaviorDoNothing;
int m_ActionCountDown;
int m_Type;
bool m_VillagerAction;
Vector3i m_CropsPos;
-
} ;
diff --git a/src/Mobs/Witch.cpp b/src/Mobs/Witch.cpp
index 6aaca82c8..43edf4b43 100644
--- a/src/Mobs/Witch.cpp
+++ b/src/Mobs/Witch.cpp
@@ -12,6 +12,7 @@ cWitch::cWitch(void) :
super(mtWitch, "entity.witch.hurt", "entity.witch.death", 0.6, 1.8)
{
m_EMPersonality = AGGRESSIVE;
+ m_BehaviorDoNothing.AttachToMonster(*this);
GetMonsterConfig("Witch");
}
diff --git a/src/Mobs/Witch.h b/src/Mobs/Witch.h
index 7013f998a..a57016a2a 100644
--- a/src/Mobs/Witch.h
+++ b/src/Mobs/Witch.h
@@ -2,7 +2,7 @@
#pragma once
#include "Monster.h"
-
+#include "Behaviors/BehaviorDoNothing.h"
@@ -19,6 +19,9 @@ public:
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
bool IsAngry() const { return false; }
+
+private:
+ cBehaviorDoNothing m_BehaviorDoNothing;
} ;
diff --git a/src/Mobs/Wither.cpp b/src/Mobs/Wither.cpp
index e58d47426..a76ac80a1 100644
--- a/src/Mobs/Wither.cpp
+++ b/src/Mobs/Wither.cpp
@@ -17,6 +17,7 @@ cWither::cWither(void) :
SetMaxHealth(300);
SetHealth(GetMaxHealth() / 3);
m_EMPersonality = AGGRESSIVE;
+ m_BehaviorDoNothing.AttachToMonster(*this);
GetMonsterConfig("Wither");
}
diff --git a/src/Mobs/Wither.h b/src/Mobs/Wither.h
index 023fc773c..39a2d5020 100644
--- a/src/Mobs/Wither.h
+++ b/src/Mobs/Wither.h
@@ -2,7 +2,7 @@
#pragma once
#include "Monster.h"
-
+#include "Behaviors/BehaviorDoNothing.h"
@@ -33,6 +33,7 @@ public:
virtual bool IsUndead(void) override { return true; }
private:
+ cBehaviorDoNothing m_BehaviorDoNothing;
/** The number of ticks of invulnerability left after being initially created. Zero once invulnerability has expired. */
unsigned int m_WitherInvulnerableTicks;
diff --git a/src/Mobs/ZombiePigman.cpp b/src/Mobs/ZombiePigman.cpp
index 3b3a93709..d817902f8 100644
--- a/src/Mobs/ZombiePigman.cpp
+++ b/src/Mobs/ZombiePigman.cpp
@@ -12,6 +12,9 @@ cZombiePigman::cZombiePigman(void) :
super(mtZombiePigman, "entity.zombie_pig.hurt", "entity.zombie_pig.death", 0.6, 1.8)
{
m_EMPersonality = PASSIVE;
+ m_BehaviorAttackerMelee.AttachToMonster(*this);
+ m_BehaviorWanderer.AttachToMonster(*this);
+ m_BehaviorAggressive.AttachToMonster(*this);
GetMonsterConfig("ZombiePigman");
}
diff --git a/src/Mobs/ZombiePigman.h b/src/Mobs/ZombiePigman.h
index dad420da7..e3bab0539 100644
--- a/src/Mobs/ZombiePigman.h
+++ b/src/Mobs/ZombiePigman.h
@@ -1,7 +1,9 @@
#pragma once
#include "Monster.h"
-
+#include "Behaviors/BehaviorAttackerMelee.h"
+#include "Behaviors/BehaviorWanderer.h"
+#include "Behaviors/BehaviorAggressive.h"
@@ -21,6 +23,13 @@ public:
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
virtual bool IsUndead(void) override { return true; }
+
+ // tick behaviors
+ cBehaviorAttackerMelee m_BehaviorAttackerMelee;
+ cBehaviorWanderer m_BehaviorWanderer;
+
+ // other behaviors
+ cBehaviorAggressive m_BehaviorAggressive;
} ;