summaryrefslogtreecommitdiffstats
path: root/src/Mobs
diff options
context:
space:
mode:
authorLogicParrot <LogicParrot@users.noreply.github.com>2017-09-01 21:55:17 +0200
committerLogicParrot <LogicParrot@users.noreply.github.com>2017-09-01 21:55:17 +0200
commitf8b9400713cbb96f61c1515132aa6af99c73d600 (patch)
tree7ec1ca42f4d23426b103ec89169c4dd57f7c6194 /src/Mobs
parentmerge (diff)
downloadcuberite-f8b9400713cbb96f61c1515132aa6af99c73d600.tar
cuberite-f8b9400713cbb96f61c1515132aa6af99c73d600.tar.gz
cuberite-f8b9400713cbb96f61c1515132aa6af99c73d600.tar.bz2
cuberite-f8b9400713cbb96f61c1515132aa6af99c73d600.tar.lz
cuberite-f8b9400713cbb96f61c1515132aa6af99c73d600.tar.xz
cuberite-f8b9400713cbb96f61c1515132aa6af99c73d600.tar.zst
cuberite-f8b9400713cbb96f61c1515132aa6af99c73d600.zip
Diffstat (limited to 'src/Mobs')
-rw-r--r--src/Mobs/Bat.cpp9
-rw-r--r--src/Mobs/Behaviors/BehaviorAttacker.cpp7
-rw-r--r--src/Mobs/Behaviors/BehaviorAttacker.h2
-rw-r--r--src/Mobs/Behaviors/BehaviorCoward.cpp3
-rw-r--r--src/Mobs/Behaviors/BehaviorCoward.h1
-rw-r--r--src/Mobs/Behaviors/BehaviorDayLightBurner.cpp12
-rw-r--r--src/Mobs/Behaviors/BehaviorDayLightBurner.h2
-rw-r--r--src/Mobs/Behaviors/BehaviorWanderer.cpp3
-rw-r--r--src/Mobs/Behaviors/BehaviorWanderer.h1
-rw-r--r--src/Mobs/Blaze.cpp3
-rw-r--r--src/Mobs/CaveSpider.cpp3
-rw-r--r--src/Mobs/Chicken.cpp3
-rw-r--r--src/Mobs/Cow.cpp3
-rw-r--r--src/Mobs/Creeper.cpp3
-rw-r--r--src/Mobs/EnderDragon.cpp3
-rw-r--r--src/Mobs/Enderman.cpp3
-rw-r--r--src/Mobs/Ghast.cpp3
-rw-r--r--src/Mobs/Giant.cpp3
-rw-r--r--src/Mobs/Guardian.cpp3
-rw-r--r--src/Mobs/Horse.cpp3
-rw-r--r--src/Mobs/IronGolem.cpp3
-rw-r--r--src/Mobs/MagmaCube.cpp3
-rw-r--r--src/Mobs/Monster.cpp57
-rw-r--r--src/Mobs/Monster.h14
-rw-r--r--src/Mobs/Mooshroom.cpp3
-rw-r--r--src/Mobs/Ocelot.cpp3
-rw-r--r--src/Mobs/PathFinder.cpp25
-rw-r--r--src/Mobs/PathFinder.h13
-rw-r--r--src/Mobs/Pig.cpp3
-rw-r--r--src/Mobs/Rabbit.cpp9
-rw-r--r--src/Mobs/Sheep.cpp4
-rw-r--r--src/Mobs/Silverfish.h3
-rw-r--r--src/Mobs/Skeleton.cpp3
-rw-r--r--src/Mobs/Slime.cpp4
-rw-r--r--src/Mobs/SnowGolem.cpp3
-rw-r--r--src/Mobs/Spider.cpp3
-rw-r--r--src/Mobs/Squid.cpp3
-rw-r--r--src/Mobs/Villager.cpp3
-rw-r--r--src/Mobs/Witch.cpp3
-rw-r--r--src/Mobs/Wither.cpp3
-rw-r--r--src/Mobs/Wolf.cpp335
-rw-r--r--src/Mobs/Zombie.cpp4
-rw-r--r--src/Mobs/ZombiePigman.cpp3
43 files changed, 145 insertions, 435 deletions
diff --git a/src/Mobs/Bat.cpp b/src/Mobs/Bat.cpp
index 906b99320..a95bc00d4 100644
--- a/src/Mobs/Bat.cpp
+++ b/src/Mobs/Bat.cpp
@@ -5,12 +5,11 @@
#include "../Chunk.h"
cBat::cBat(void) :
- super("Bat", mtBat, "entity.bat.hurt", "entity.bat.death", 0.5, 0.9)
+ super(mtBat, "entity.bat.hurt", "entity.bat.death", 0.5, 0.9)
{
- SetGravity(-2.0f);
- SetAirDrag(0.05f);
-
-
+ SetGravity(-2.0f);
+ SetAirDrag(0.05f);
+ GetMonsterConfig("Bat");
}
diff --git a/src/Mobs/Behaviors/BehaviorAttacker.cpp b/src/Mobs/Behaviors/BehaviorAttacker.cpp
index 031b5ddf9..2f25bd3aa 100644
--- a/src/Mobs/Behaviors/BehaviorAttacker.cpp
+++ b/src/Mobs/Behaviors/BehaviorAttacker.cpp
@@ -13,7 +13,6 @@ cBehaviorAttacker::cBehaviorAttacker() :
, m_AttackDamage(1)
, m_AttackRange(1)
, m_AttackCoolDownTicksLeft(0)
- , m_TicksSinceLastDamaged(100)
, m_IsStriking(false)
, m_Target(nullptr)
{
@@ -117,11 +116,6 @@ void cBehaviorAttacker::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
void cBehaviorAttacker::PostTick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
- if (m_TicksSinceLastDamaged < 100)
- {
- ++m_TicksSinceLastDamaged;
- }
-
if (m_AttackCoolDownTicksLeft > 0)
{
m_AttackCoolDownTicksLeft -= 1;
@@ -143,7 +137,6 @@ void cBehaviorAttacker::DoTakeDamage(TakeDamageInfo & a_TDI)
{
SetTarget(static_cast<cPawn*>(a_TDI.Attacker));
}
- m_TicksSinceLastDamaged = 0;
}
}
diff --git a/src/Mobs/Behaviors/BehaviorAttacker.h b/src/Mobs/Behaviors/BehaviorAttacker.h
index 78ed70994..c047cde50 100644
--- a/src/Mobs/Behaviors/BehaviorAttacker.h
+++ b/src/Mobs/Behaviors/BehaviorAttacker.h
@@ -65,8 +65,6 @@ protected:
int m_AttackRange;
int m_AttackCoolDownTicksLeft;
- int m_TicksSinceLastDamaged; // How many ticks ago were we last damaged by a player?
-
bool m_IsStriking;
/** Our parent */
diff --git a/src/Mobs/Behaviors/BehaviorCoward.cpp b/src/Mobs/Behaviors/BehaviorCoward.cpp
index e1b0d2a25..55a5932cd 100644
--- a/src/Mobs/Behaviors/BehaviorCoward.cpp
+++ b/src/Mobs/Behaviors/BehaviorCoward.cpp
@@ -40,7 +40,6 @@ bool cBehaviorCoward::ControlStarting(std::chrono::milliseconds a_Dt, cChunk & a
{
UNUSED(a_Dt);
UNUSED(a_Chunk);
- m_OldDontCare = m_Parent->GetPathFinder().getDontCare();
m_Parent->GetPathFinder().setDontCare(true); // We don't care we're we are going when
// wandering. If a path is not found, the pathfinder just modifies our destination.
m_Parent->SetRelativeWalkSpeed(m_Parent->GetRelativeWalkSpeed() * 3);
@@ -53,7 +52,7 @@ bool cBehaviorCoward::ControlEnding(std::chrono::milliseconds a_Dt, cChunk & a_C
UNUSED(a_Dt);
UNUSED(a_Chunk);
m_Parent->SetRelativeWalkSpeed(m_Parent->GetRelativeWalkSpeed() / 3);
- m_Parent->GetPathFinder().setDontCare(m_OldDontCare);
+ m_Parent->GetPathFinder().setDontCare(false);
return true;
}
diff --git a/src/Mobs/Behaviors/BehaviorCoward.h b/src/Mobs/Behaviors/BehaviorCoward.h
index 16d68872c..3232f807b 100644
--- a/src/Mobs/Behaviors/BehaviorCoward.h
+++ b/src/Mobs/Behaviors/BehaviorCoward.h
@@ -19,5 +19,4 @@ public:
private:
cMonster * m_Parent; // Our Parent
cEntity * m_Attacker; // The entity we're running away from
- bool m_OldDontCare;
};
diff --git a/src/Mobs/Behaviors/BehaviorDayLightBurner.cpp b/src/Mobs/Behaviors/BehaviorDayLightBurner.cpp
index 0b0faed08..1271574fe 100644
--- a/src/Mobs/Behaviors/BehaviorDayLightBurner.cpp
+++ b/src/Mobs/Behaviors/BehaviorDayLightBurner.cpp
@@ -4,7 +4,6 @@
#include "../Monster.h"
#include "../../Entities/Player.h"
#include "../../Entities/Entity.h"
-
#include "../../Chunk.h"
@@ -15,6 +14,7 @@ void cBehaviorDayLightBurner::AttachToMonster(cMonster & a_Parent)
{
m_Parent = &a_Parent;
m_Parent->AttachPostTickBehavior(this);
+ m_Parent->GetPathFinder().SetAvoidSunlight(true);
}
@@ -35,7 +35,7 @@ void cBehaviorDayLightBurner::PostTick(std::chrono::milliseconds a_Dt, cChunk &
return;
}
- if (!m_Parent->IsOnFire() && WouldBurnAt(m_Parent->GetPosition(), a_Chunk))
+ if (!m_Parent->IsOnFire() && WouldBurnAt(m_Parent->GetPosition(), a_Chunk, *m_Parent))
{
// Burn for 100 ticks, then decide again
m_Parent->StartBurning(100);
@@ -45,7 +45,7 @@ void cBehaviorDayLightBurner::PostTick(std::chrono::milliseconds a_Dt, cChunk &
-bool cBehaviorDayLightBurner::WouldBurnAt(Vector3d a_Location, cChunk & a_Chunk)
+bool cBehaviorDayLightBurner::WouldBurnAt(Vector3d a_Location, cChunk & a_Chunk, cMonster & a_Monster)
{
int RelY = FloorC(a_Location.y);
if (RelY <= 0)
@@ -67,11 +67,11 @@ bool cBehaviorDayLightBurner::WouldBurnAt(Vector3d a_Location, cChunk & a_Chunk)
if (
(Chunk->GetBlock(Rel.x, Rel.y, Rel.z) != E_BLOCK_SOULSAND) && // Not on soulsand
- (m_Parent->GetWorld()->GetTimeOfDay() < 12000 + 1000) && // Daytime
- m_Parent->GetWorld()->IsWeatherSunnyAt(static_cast<int>(m_Parent->GetPosX()), static_cast<int>(m_Parent->GetPosZ())) // Not raining
+ (a_Monster.GetWorld()->GetTimeOfDay() < 12000 + 1000) && // Daytime
+ a_Monster.GetWorld()->IsWeatherSunnyAt(static_cast<int>(a_Monster.GetPosX()), static_cast<int>(a_Monster.GetPosZ())) // Not raining
)
{
- int MobHeight = CeilC(a_Location.y + m_Parent->GetHeight()) - 1; // The height of the mob head
+ int MobHeight = CeilC(a_Location.y + a_Monster.GetHeight()) - 1; // The height of the mob head
if (MobHeight >= cChunkDef::Height)
{
return true;
diff --git a/src/Mobs/Behaviors/BehaviorDayLightBurner.h b/src/Mobs/Behaviors/BehaviorDayLightBurner.h
index 07812b9db..920f9d5c7 100644
--- a/src/Mobs/Behaviors/BehaviorDayLightBurner.h
+++ b/src/Mobs/Behaviors/BehaviorDayLightBurner.h
@@ -9,7 +9,7 @@ class cBehaviorDayLightBurner : cBehavior
public:
void AttachToMonster(cMonster & a_Parent);
void PostTick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
- bool WouldBurnAt(Vector3d a_Location, cChunk & a_Chunk);
+ static bool WouldBurnAt(Vector3d a_Location, cChunk & a_Chunk, cMonster & a_Monster);
private:
cMonster * m_Parent; // Our Parent
diff --git a/src/Mobs/Behaviors/BehaviorWanderer.cpp b/src/Mobs/Behaviors/BehaviorWanderer.cpp
index a37609aa4..cc03d55cb 100644
--- a/src/Mobs/Behaviors/BehaviorWanderer.cpp
+++ b/src/Mobs/Behaviors/BehaviorWanderer.cpp
@@ -39,7 +39,6 @@ bool cBehaviorWanderer::ControlStarting(std::chrono::milliseconds a_Dt, cChunk &
{
UNUSED(a_Dt);
UNUSED(a_Chunk);
- m_OldDontCare = m_Parent->GetPathFinder().getDontCare();
m_Parent->GetPathFinder().setDontCare(true); // We don't care we're we are going when
// wandering. If a path is not found, the pathfinder just modifies our destination.
return true;
@@ -50,7 +49,7 @@ bool cBehaviorWanderer::ControlEnding(std::chrono::milliseconds a_Dt, cChunk & a
{
UNUSED(a_Dt);
UNUSED(a_Chunk);
- m_Parent->GetPathFinder().setDontCare(m_OldDontCare);
+ m_Parent->GetPathFinder().setDontCare(false);
return true;
}
diff --git a/src/Mobs/Behaviors/BehaviorWanderer.h b/src/Mobs/Behaviors/BehaviorWanderer.h
index 219ad32c3..24c8885bf 100644
--- a/src/Mobs/Behaviors/BehaviorWanderer.h
+++ b/src/Mobs/Behaviors/BehaviorWanderer.h
@@ -21,5 +21,4 @@ public:
private:
cMonster * m_Parent; // Our Parent
std::chrono::milliseconds m_IdleInterval;
- bool m_OldDontCare;
};
diff --git a/src/Mobs/Blaze.cpp b/src/Mobs/Blaze.cpp
index df54be1fd..5778c7ef2 100644
--- a/src/Mobs/Blaze.cpp
+++ b/src/Mobs/Blaze.cpp
@@ -9,11 +9,12 @@
cBlaze::cBlaze(void) :
- super("Blaze", mtBlaze, "entity.blaze.hurt", "entity.blaze.death", 0.6, 1.8)
+ super(mtBlaze, "entity.blaze.hurt", "entity.blaze.death", 0.6, 1.8)
{
m_EMPersonality = AGGRESSIVE;
SetGravity(-8.0f);
SetAirDrag(0.05f);
+ GetMonsterConfig("Blaze");
}
diff --git a/src/Mobs/CaveSpider.cpp b/src/Mobs/CaveSpider.cpp
index 0e33282c0..ba58cdf71 100644
--- a/src/Mobs/CaveSpider.cpp
+++ b/src/Mobs/CaveSpider.cpp
@@ -8,9 +8,10 @@
cCaveSpider::cCaveSpider(void) :
- super("CaveSpider", mtCaveSpider, "entity.spider.hurt", "entity.spider.death", 0.7, 0.5)
+ super(mtCaveSpider, "entity.spider.hurt", "entity.spider.death", 0.7, 0.5)
{
m_EMPersonality = AGGRESSIVE;
+ GetMonsterConfig("CaveSpider");
}
diff --git a/src/Mobs/Chicken.cpp b/src/Mobs/Chicken.cpp
index a7b27fc11..556f02319 100644
--- a/src/Mobs/Chicken.cpp
+++ b/src/Mobs/Chicken.cpp
@@ -6,7 +6,7 @@
cChicken::cChicken(void) :
- super("Chicken", mtChicken, "entity.chicken.hurt", "entity.chicken.death", 0.3, 0.4)
+ super(mtChicken, "entity.chicken.hurt", "entity.chicken.death", 0.3, 0.4)
{
SetGravity(-2.0f);
SetAirDrag(0.0f);
@@ -16,6 +16,7 @@ cChicken::cChicken(void) :
m_BehaviorItemFollower.AttachToMonster(*this);
m_BehaviorWanderer.AttachToMonster(*this);
m_BehaviorItemDropper.AttachToMonster(*this);
+ GetMonsterConfig("Chicken");
}
diff --git a/src/Mobs/Cow.cpp b/src/Mobs/Cow.cpp
index 3d94986bb..6c142b04b 100644
--- a/src/Mobs/Cow.cpp
+++ b/src/Mobs/Cow.cpp
@@ -7,7 +7,7 @@
cCow::cCow(void) :
- super("Cow", mtCow, "entity.cow.hurt", "entity.cow.death", 0.9, 1.3),
+ super(mtCow, "entity.cow.hurt", "entity.cow.death", 0.9, 1.3),
m_BehaviorItemReplacer(E_ITEM_BUCKET, E_ITEM_MILK)
{
m_EMPersonality = PASSIVE;
@@ -16,6 +16,7 @@ cCow::cCow(void) :
m_BehaviorItemFollower.AttachToMonster(*this);
m_BehaviorWanderer.AttachToMonster(*this);
m_BehaviorItemReplacer.AttachToMonster(*this);
+ GetMonsterConfig("Cow");
}
diff --git a/src/Mobs/Creeper.cpp b/src/Mobs/Creeper.cpp
index c05076a1a..042db9686 100644
--- a/src/Mobs/Creeper.cpp
+++ b/src/Mobs/Creeper.cpp
@@ -11,13 +11,14 @@
cCreeper::cCreeper(void) :
- super("Creeper", mtCreeper, "entity.creeper.hurt", "entity.creeper.death", 0.6, 1.8),
+ super(mtCreeper, "entity.creeper.hurt", "entity.creeper.death", 0.6, 1.8),
m_bIsBlowing(false),
m_bIsCharged(false),
m_BurnedWithFlintAndSteel(false),
m_ExplodingTimer(0)
{
m_EMPersonality = AGGRESSIVE;
+ GetMonsterConfig("Creeper");
}
diff --git a/src/Mobs/EnderDragon.cpp b/src/Mobs/EnderDragon.cpp
index 4db5baf87..8fc42556b 100644
--- a/src/Mobs/EnderDragon.cpp
+++ b/src/Mobs/EnderDragon.cpp
@@ -9,9 +9,10 @@
cEnderDragon::cEnderDragon(void) :
// TODO: Vanilla source says this, but is it right? Dragons fly, they don't stand
- super("EnderDragon", mtEnderDragon, "entity.enderdragon.hurt", "entity.enderdragon.death", 16.0, 8.0)
+ super(mtEnderDragon, "entity.enderdragon.hurt", "entity.enderdragon.death", 16.0, 8.0)
{
m_EMPersonality = AGGRESSIVE;
+ GetMonsterConfig("EnderDragon");
}
diff --git a/src/Mobs/Enderman.cpp b/src/Mobs/Enderman.cpp
index 65b771406..be9329d06 100644
--- a/src/Mobs/Enderman.cpp
+++ b/src/Mobs/Enderman.cpp
@@ -73,12 +73,13 @@ protected:
cEnderman::cEnderman(void) :
- super("Enderman", mtEnderman, "entity.endermen.hurt", "entity.endermen.death", 0.5, 2.9),
+ super(mtEnderman, "entity.endermen.hurt", "entity.endermen.death", 0.5, 2.9),
m_bIsScreaming(false),
CarriedBlock(E_BLOCK_AIR),
CarriedMeta(0)
{
m_EMPersonality = PASSIVE;
+ GetMonsterConfig("Enderman");
}
diff --git a/src/Mobs/Ghast.cpp b/src/Mobs/Ghast.cpp
index d9cd31f45..7f051e3cc 100644
--- a/src/Mobs/Ghast.cpp
+++ b/src/Mobs/Ghast.cpp
@@ -9,9 +9,10 @@
cGhast::cGhast(void) :
- super("Ghast", mtGhast, "entity.ghast.hurt", "entity.ghast.death", 4, 4)
+ super(mtGhast, "entity.ghast.hurt", "entity.ghast.death", 4, 4)
{
m_EMPersonality = AGGRESSIVE;
+ GetMonsterConfig("Ghast");
}
diff --git a/src/Mobs/Giant.cpp b/src/Mobs/Giant.cpp
index c25b4e6a0..ff1f8604c 100644
--- a/src/Mobs/Giant.cpp
+++ b/src/Mobs/Giant.cpp
@@ -8,9 +8,10 @@
cGiant::cGiant(void) :
- super("Giant", mtGiant, "entity.zombie.hurt", "entity.zombie.death", 3.6, 10.8)
+ super(mtGiant, "entity.zombie.hurt", "entity.zombie.death", 3.6, 10.8)
{
m_EMPersonality = AGGRESSIVE;
+ GetMonsterConfig("Giant");
}
diff --git a/src/Mobs/Guardian.cpp b/src/Mobs/Guardian.cpp
index ca6b04d55..c5fc0405d 100644
--- a/src/Mobs/Guardian.cpp
+++ b/src/Mobs/Guardian.cpp
@@ -9,9 +9,10 @@
cGuardian::cGuardian(void) :
- super("Guardian", mtGuardian, "entity.guardian.hurt", "entity.guardian.death", 0.875, 0.8)
+ super(mtGuardian, "entity.guardian.hurt", "entity.guardian.death", 0.875, 0.8)
{
m_EMPersonality = AGGRESSIVE;
+ GetMonsterConfig("Guardian");
}
diff --git a/src/Mobs/Horse.cpp b/src/Mobs/Horse.cpp
index 6ff53df69..c3d805b69 100644
--- a/src/Mobs/Horse.cpp
+++ b/src/Mobs/Horse.cpp
@@ -11,7 +11,7 @@
cHorse::cHorse(int Type, int Color, int Style, int TameTimes) :
- super("Horse", mtHorse, "entity.horse.hurt", "entity.horse.death", 1.4, 1.6),
+ super(mtHorse, "entity.horse.hurt", "entity.horse.death", 1.4, 1.6),
m_bHasChest(false),
m_bIsEating(false),
m_bIsRearing(false),
@@ -32,6 +32,7 @@ cHorse::cHorse(int Type, int Color, int Style, int TameTimes) :
m_BehaviorCoward.AttachToMonster(*this);
m_BehaviorItemFollower.AttachToMonster(*this);
m_BehaviorWanderer.AttachToMonster(*this);
+ GetMonsterConfig("Horse");
}
diff --git a/src/Mobs/IronGolem.cpp b/src/Mobs/IronGolem.cpp
index 223161c68..366ea76c4 100644
--- a/src/Mobs/IronGolem.cpp
+++ b/src/Mobs/IronGolem.cpp
@@ -8,9 +8,10 @@
cIronGolem::cIronGolem(void) :
- super("IronGolem", mtIronGolem, "entity.irongolem.hurt", "entity.irongolem.death", 1.4, 2.9)
+ super(mtIronGolem, "entity.irongolem.hurt", "entity.irongolem.death", 1.4, 2.9)
{
m_EMPersonality = PASSIVE;
+ GetMonsterConfig("IronGolem");
}
diff --git a/src/Mobs/MagmaCube.cpp b/src/Mobs/MagmaCube.cpp
index dd4e6916e..c1927241e 100644
--- a/src/Mobs/MagmaCube.cpp
+++ b/src/Mobs/MagmaCube.cpp
@@ -7,10 +7,11 @@
cMagmaCube::cMagmaCube(int a_Size) :
- super("MagmaCube", mtMagmaCube, Printf("entity.%smagmacube.hurt", GetSizeName(a_Size).c_str()), Printf("entity.%smagmacube.death", GetSizeName(a_Size).c_str()), 0.6 * a_Size, 0.6 * a_Size),
+ super(mtMagmaCube, Printf("entity.%smagmacube.hurt", GetSizeName(a_Size).c_str()), Printf("entity.%smagmacube.death", GetSizeName(a_Size).c_str()), 0.6 * a_Size, 0.6 * a_Size),
m_Size(a_Size)
{
m_EMPersonality = AGGRESSIVE;
+ GetMonsterConfig("MagmaCube");
}
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp
index f16120b55..ae2d601cc 100644
--- a/src/Mobs/Monster.cpp
+++ b/src/Mobs/Monster.cpp
@@ -83,11 +83,11 @@ static const struct
////////////////////////////////////////////////////////////////////////////////
// cMonster:
-cMonster::cMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height)
+cMonster::cMonster(eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height)
: super(etMonster, a_Width, a_Height)
+ , m_EMPersonality(AGGRESSIVE)
, m_BehaviorBreederPointer(nullptr)
, m_BehaviorAttackerPointer(nullptr)
- , m_EMPersonality(AGGRESSIVE)
, m_NearestPlayerIsStale(true)
, m_PathFinder(a_Width, a_Height)
, m_PathfinderActivated(false)
@@ -119,11 +119,9 @@ cMonster::cMonster(const AString & a_ConfigName, eMonsterType a_MobType, const A
, m_NewTickControllingBehavior(nullptr)
, m_PinnedBehavior(nullptr)
, m_TickControllingBehaviorState(Normal)
+ , m_TicksSinceLastDamaged(1000)
{
- if (!a_ConfigName.empty())
- {
- GetMonsterConfig(a_ConfigName);
- }
+
}
@@ -141,8 +139,6 @@ cMonster::~cMonster()
void cMonster::Destroy(bool a_ShouldBroadcast)
{
- //mobtodo Destroy vs Destroyed
-
// mobTodo behavior for leash
if (IsLeashed())
{
@@ -431,27 +427,24 @@ void cMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
}
else
{
- // mobToDo fix dont care
// Note that m_NextWayPointPosition is actually returned by GetNextWayPoint)
switch (m_PathFinder.GetNextWayPoint(*Chunk, GetPosition(), &m_FinalDestination, &m_NextWayPointPosition))
{
case ePathFinderStatus::PATH_FOUND:
{
- /* If I burn in daylight, and I won't burn where I'm standing, and I'll burn in my next position, and at least one of those is true:
- 1. I am idle
- 2. I was not hurt by a player recently.
- Then STOP. */
+ // mobTodo move this logic to cPathfinder or to something
+ // more generic in cPath.
if (
- //mobTodo emstate
- /* (GetBehaviorDayLightBurner() != nullptr) && (m_TicksSinceLastDamaged >= 100) &&
- GetBehaviorDayLightBurner()->WouldBurnAt(m_NextWayPointPosition, *Chunk) &&
- !(GetBehaviorDayLightBurner()->WouldBurnAt(GetPosition(), *Chunk)) */
- 1 == 0
-
- // This logic should probably be in chaser
+ // I am supposed to avoid daylight
+ (m_PathFinder.GetAvoidSunlight()) &&
+ // I was not hurt recently
+ (m_TicksSinceLastDamaged >= 100) &&
+ // I won't burn where I stand now
+ cBehaviorDayLightBurner::WouldBurnAt(m_NextWayPointPosition, *Chunk, *this) &&
+ // I will burn where I'm going to
+ !(cBehaviorDayLightBurner::WouldBurnAt(GetPosition(), *Chunk, *this))
)
{
- // If we burn in daylight, and we would burn at the next step, and we won't burn where we are right now, and we weren't provoked recently:
StopMovingToPosition();
}
else
@@ -496,6 +489,11 @@ void cMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
m_World->BroadcastEntityMetadata(*this);
}
}
+
+ if (m_TicksSinceLastDamaged < 1000)
+ {
+ ++m_TicksSinceLastDamaged;
+ }
}
@@ -648,6 +646,8 @@ bool cMonster::DoTakeDamage(TakeDamageInfo & a_TDI)
Behavior->DoTakeDamage(a_TDI);
}
+ m_TicksSinceLastDamaged = 0;
+
return true;
}
@@ -1331,24 +1331,9 @@ void cMonster::AttachTickBehavior(cBehavior * a_Behavior)
void cMonster::AttachDestroyBehavior(cBehavior * a_Behavior)
{
-<<<<<<< HEAD
ASSERT(a_Behavior != nullptr);
m_AttachedDestroyBehaviors.push_back(a_Behavior);
}
-=======
- // If the Y coord is out of range, return the most logical result without considering anything else:
- int RelY = FloorC(a_Location.y);
- if (RelY >= cChunkDef::Height)
- {
- // Always burn above the world
- return true;
- }
- if (RelY <= 0)
- {
- // The mob is about to die, no point in burning
- return false;
- }
->>>>>>> master
diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h
index 760edb0e9..be3d64e06 100644
--- a/src/Mobs/Monster.h
+++ b/src/Mobs/Monster.h
@@ -13,13 +13,8 @@ class cClientHandle;
//Behavior fwds
-class cPassiveMonster;
-class cBehaviorAggressive;
class cBehaviorBreeder;
class cBehaviorAttacker;
-class cBehaviorStriker;
-class cBehaviorWanderer;
-class cBehaviorDayLightBurner;
class cBehavior;
// tolua_begin
@@ -45,11 +40,10 @@ public:
enum MPersonality{PASSIVE, AGGRESSIVE, COWARDLY} m_EMPersonality;
/** Creates the mob object.
- If a_ConfigName is not empty, the configuration is loaded using GetMonsterConfig()
a_MobType is the type of the mob (also used in the protocol ( http://wiki.vg/Entities#Mobs 2012_12_22))
a_SoundHurt and a_SoundDeath are assigned into m_SoundHurt and m_SoundDeath, respectively
*/
- cMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
+ cMonster(eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
virtual ~cMonster() override;
@@ -199,14 +193,15 @@ public:
bool IsPathFinderActivated() const;
- // Behavior getters (most are probably not used. mobTodo - cleanup most of them)
+ // Behavior getters for the rare occasion where we need "polymorphism"
+ // Currently only for attacking and breeding.
cBehaviorBreeder * GetBehaviorBreeder();
const cBehaviorBreeder * GetBehaviorBreeder() const;
cBehaviorAttacker * GetBehaviorAttacker();\
cBehaviorBreeder * m_BehaviorBreederPointer;
cBehaviorAttacker * m_BehaviorAttackerPointer;
- // Polymorphic behavior functions
+ // Polymorphic monster-specific functions that behaviors may use
virtual void InheritFromParents(cMonster * a_Parent1, cMonster * a_Parent2);
virtual void GetFollowedItems(cItems & a_Items);
virtual void GetBreedingItems(cItems & a_Items);
@@ -352,4 +347,5 @@ private:
cBehavior * m_PinnedBehavior;
enum TickState{NewControlStarting, OldControlEnding, Normal} m_TickControllingBehaviorState;
+ int m_TicksSinceLastDamaged; // How many ticks ago were we last damaged by a player?
} ; // tolua_export
diff --git a/src/Mobs/Mooshroom.cpp b/src/Mobs/Mooshroom.cpp
index 91baaee66..aa5209ecf 100644
--- a/src/Mobs/Mooshroom.cpp
+++ b/src/Mobs/Mooshroom.cpp
@@ -14,13 +14,14 @@
cMooshroom::cMooshroom(void) :
- super("Mooshroom", mtMooshroom, "entity.cow.hurt", "entity.cow.death", 0.9, 1.3)
+ super(mtMooshroom, "entity.cow.hurt", "entity.cow.death", 0.9, 1.3)
{
m_EMPersonality = PASSIVE;
m_BehaviorBreeder.AttachToMonster(*this);
m_BehaviorCoward.AttachToMonster(*this);
m_BehaviorItemFollower.AttachToMonster(*this);
m_BehaviorWanderer.AttachToMonster(*this);
+ GetMonsterConfig("Mooshroom");
}
diff --git a/src/Mobs/Ocelot.cpp b/src/Mobs/Ocelot.cpp
index 183cb74c4..35a805994 100644
--- a/src/Mobs/Ocelot.cpp
+++ b/src/Mobs/Ocelot.cpp
@@ -13,7 +13,7 @@
cOcelot::cOcelot(void) :
- super("Ocelot", mtOcelot, "entity.cat.hurt", "entity.cat.death", 0.6, 0.8),
+ super(mtOcelot, "entity.cat.hurt", "entity.cat.death", 0.6, 0.8),
m_IsSitting(false),
m_IsTame(false),
m_IsBegging(false),
@@ -21,6 +21,7 @@ cOcelot::cOcelot(void) :
m_OwnerName("")
{
m_EMPersonality = PASSIVE;
+ GetMonsterConfig("Ocelot");
}
diff --git a/src/Mobs/PathFinder.cpp b/src/Mobs/PathFinder.cpp
index ca5df2cd6..8fdcb1ae6 100644
--- a/src/Mobs/PathFinder.cpp
+++ b/src/Mobs/PathFinder.cpp
@@ -10,7 +10,8 @@ cPathFinder::cPathFinder(double a_MobWidth, double a_MobHeight) :
m_Path(),
m_GiveUpCounter(0),
m_NotFoundCooldown(0),
- m_DontCare(false)
+ m_DontCare(false),
+ m_AvoidSunlight(false)
{
m_Width = a_MobWidth;
m_Height = a_MobHeight;
@@ -167,7 +168,7 @@ ePathFinderStatus cPathFinder::GetNextWayPoint(cChunk & a_Chunk, const Vector3d
-void cPathFinder::setDontCare(bool a_DontCare)
+void cPathFinder::SetDontCare(bool a_DontCare)
{
m_DontCare = a_DontCare;
}
@@ -176,7 +177,7 @@ void cPathFinder::setDontCare(bool a_DontCare)
-bool cPathFinder::getDontCare()
+bool cPathFinder::GetDontCare()
{
return m_DontCare;
}
@@ -185,6 +186,24 @@ bool cPathFinder::getDontCare()
+void cPathFinder::SetAvoidSunlight(bool a_AvoidSunlight)
+{
+ m_AvoidSunlight = a_AvoidSunlight;
+}
+
+
+
+
+
+bool cPathFinder::GetAvoidSunlight()
+{
+ return m_AvoidSunlight;
+}
+
+
+
+
+
void cPathFinder::ResetPathFinding(cChunk &a_Chunk)
{
m_GiveUpCounter = 40;
diff --git a/src/Mobs/PathFinder.h b/src/Mobs/PathFinder.h
index 19f1d0c14..252ac29ff 100644
--- a/src/Mobs/PathFinder.h
+++ b/src/Mobs/PathFinder.h
@@ -40,10 +40,16 @@ public:
ePathFinderStatus GetNextWayPoint(cChunk & a_Chunk, const Vector3d & a_Source, Vector3d * a_Destination, Vector3d * a_OutputWaypoint);
/** Sets the dontCare value. See the GetNextWayPoint documentation for details. */
- void setDontCare(bool a_DontCare);
+ void SetDontCare(bool a_DontCare);
/** Returns the current dontCare value. */
- bool getDontCare();
+ bool GetDontCare();
+
+ /** If true, the mob will try avoiding sunlight. */
+ void SetAvoidSunlight(bool a_AvoidSunlight);
+
+ /** Returns the current AvoidSunlight value. */
+ bool GetAvoidSunlight();
private:
/** The width of the Mob which owns this PathFinder. */
@@ -85,6 +91,9 @@ private:
in an GetNextWayPoint call. */
bool m_DontCare;
+ /** If true, */
+ bool m_AvoidSunlight;
+
/** Ensures the location is not in the air or under water.
May change the Y coordinate of the given vector.
1. If a_Vector is the position of water, a_Vector's Y will be modified to point to the first air block above it.
diff --git a/src/Mobs/Pig.cpp b/src/Mobs/Pig.cpp
index ce5e9dca0..e6cc197bb 100644
--- a/src/Mobs/Pig.cpp
+++ b/src/Mobs/Pig.cpp
@@ -10,7 +10,7 @@
cPig::cPig(void) :
- super("Pig", mtPig, "entity.pig.hurt", "entity.pig.death", 0.9, 0.9),
+ super(mtPig, "entity.pig.hurt", "entity.pig.death", 0.9, 0.9),
m_bIsSaddled(false)
{
m_EMPersonality = PASSIVE;
@@ -18,6 +18,7 @@ cPig::cPig(void) :
m_BehaviorCoward.AttachToMonster(*this);
m_BehaviorItemFollower.AttachToMonster(*this);
m_BehaviorWanderer.AttachToMonster(*this);
+ GetMonsterConfig("Pig");
}
diff --git a/src/Mobs/Rabbit.cpp b/src/Mobs/Rabbit.cpp
index 0be458e3b..a4a71a44d 100644
--- a/src/Mobs/Rabbit.cpp
+++ b/src/Mobs/Rabbit.cpp
@@ -19,6 +19,7 @@ cRabbit::cRabbit(void) :
m_BehaviorCoward.AttachToMonster(*this);
m_BehaviorItemFollower.AttachToMonster(*this);
m_BehaviorWanderer.AttachToMonster(*this);
+ GetMonsterConfig("Rabbit");
}
@@ -26,10 +27,16 @@ cRabbit::cRabbit(void) :
cRabbit::cRabbit(eRabbitType Type, int MoreCarrotTicks) :
- super("Rabbit", mtRabbit, "entity.rabbit.hurt", "entity.rabbit.death", 0.82, 0.68),
+ super(mtRabbit, "entity.rabbit.hurt", "entity.rabbit.death", 0.82, 0.68),
m_Type(Type),
m_MoreCarrotTicks(MoreCarrotTicks)
{
+ m_EMPersonality = PASSIVE;
+ m_BehaviorBreeder.AttachToMonster(*this);
+ m_BehaviorCoward.AttachToMonster(*this);
+ m_BehaviorItemFollower.AttachToMonster(*this);
+ m_BehaviorWanderer.AttachToMonster(*this);
+ GetMonsterConfig("Rabbit");
}
diff --git a/src/Mobs/Sheep.cpp b/src/Mobs/Sheep.cpp
index bd69db6c2..001b80294 100644
--- a/src/Mobs/Sheep.cpp
+++ b/src/Mobs/Sheep.cpp
@@ -12,7 +12,7 @@
cSheep::cSheep(int a_Color) :
- super("Sheep", mtSheep, "entity.sheep.hurt", "entity.sheep.death", 0.6, 1.3),
+ super(mtSheep, "entity.sheep.hurt", "entity.sheep.death", 0.6, 1.3),
m_TimeToStopEating(-1),
m_IsSheared(false),
m_WoolColor(a_Color)
@@ -33,6 +33,8 @@ cSheep::cSheep(int a_Color) :
{
m_WoolColor = 0;
}
+
+ GetMonsterConfig("Sheep");
}
diff --git a/src/Mobs/Silverfish.h b/src/Mobs/Silverfish.h
index 20b75474d..c4dd9f912 100644
--- a/src/Mobs/Silverfish.h
+++ b/src/Mobs/Silverfish.h
@@ -14,8 +14,9 @@ class cSilverfish :
public:
cSilverfish(void) :
- super("Silverfish", mtSilverfish, "entity.silverfish.hurt", "entity.silverfish.death", 0.3, 0.7)
+ super(mtSilverfish, "entity.silverfish.hurt", "entity.silverfish.death", 0.3, 0.7)
{
+ GetMonsterConfig("Silverfish");
}
CLASS_PROTODEF(cSilverfish)
diff --git a/src/Mobs/Skeleton.cpp b/src/Mobs/Skeleton.cpp
index 15be6c790..69e3e0f55 100644
--- a/src/Mobs/Skeleton.cpp
+++ b/src/Mobs/Skeleton.cpp
@@ -10,10 +10,11 @@
cSkeleton::cSkeleton(bool IsWither) :
- super("Skeleton", mtSkeleton, "entity.skeleton.hurt", "entity.skeleton.death", 0.6, 1.8),
+ super(mtSkeleton, "entity.skeleton.hurt", "entity.skeleton.death", 0.6, 1.8),
m_bIsWither(IsWither)
{
m_EMPersonality = AGGRESSIVE;
+ GetMonsterConfig("Skeleton");
}
diff --git a/src/Mobs/Slime.cpp b/src/Mobs/Slime.cpp
index d5409ec11..10898fa4c 100644
--- a/src/Mobs/Slime.cpp
+++ b/src/Mobs/Slime.cpp
@@ -10,8 +10,7 @@
cSlime::cSlime(int a_Size) :
- super("Slime",
- mtSlime,
+ super(mtSlime,
Printf("entity.%sslime.hurt", GetSizeName(a_Size).c_str()),
Printf("entity.%sslime.death", GetSizeName(a_Size).c_str()),
0.6 * a_Size,
@@ -22,6 +21,7 @@ cSlime::cSlime(int a_Size) :
m_EMPersonality = AGGRESSIVE;
SetMaxHealth(a_Size * a_Size);
// SetAttackDamage(a_Size); //mobTodo myBehavior.setaTTACKDamage
+ GetMonsterConfig("Slime");
}
diff --git a/src/Mobs/SnowGolem.cpp b/src/Mobs/SnowGolem.cpp
index fd8ce1112..4c9fa2a02 100644
--- a/src/Mobs/SnowGolem.cpp
+++ b/src/Mobs/SnowGolem.cpp
@@ -9,9 +9,10 @@
cSnowGolem::cSnowGolem(void) :
- super("SnowGolem", mtSnowGolem, "entity.snowman.hurt", "entity.snowman.death", 0.4, 1.8)
+ super(mtSnowGolem, "entity.snowman.hurt", "entity.snowman.death", 0.4, 1.8)
{
m_EMPersonality = PASSIVE;
+ GetMonsterConfig("SnowGolem");
}
diff --git a/src/Mobs/Spider.cpp b/src/Mobs/Spider.cpp
index e8d65157c..a656c9c30 100644
--- a/src/Mobs/Spider.cpp
+++ b/src/Mobs/Spider.cpp
@@ -9,9 +9,10 @@
cSpider::cSpider(void) :
- super("Spider", mtSpider, "entity.spider.hurt", "entity.spider.death", 1.4, 0.9)
+ super(mtSpider, "entity.spider.hurt", "entity.spider.death", 1.4, 0.9)
{
m_EMPersonality = AGGRESSIVE;
+ GetMonsterConfig("Spider");
}
diff --git a/src/Mobs/Squid.cpp b/src/Mobs/Squid.cpp
index 69f918935..0f35fe634 100644
--- a/src/Mobs/Squid.cpp
+++ b/src/Mobs/Squid.cpp
@@ -9,10 +9,11 @@
cSquid::cSquid(void) :
- super("Squid", mtSquid, "entity.squid.hurt", "entity.squid.death", 0.95, 0.95)
+ super(mtSquid, "entity.squid.hurt", "entity.squid.death", 0.95, 0.95)
{
m_EMPersonality = PASSIVE;
m_BehaviorDoNothing.AttachToMonster(*this);
+ GetMonsterConfig("Squid");
}
diff --git a/src/Mobs/Villager.cpp b/src/Mobs/Villager.cpp
index ded1bfbdb..84514177b 100644
--- a/src/Mobs/Villager.cpp
+++ b/src/Mobs/Villager.cpp
@@ -12,7 +12,7 @@
cVillager::cVillager(eVillagerType VillagerType) :
- super("Villager", mtVillager, "entity.villager.hurt", "entity.villager.death", 0.6, 1.8),
+ super(mtVillager, "entity.villager.hurt", "entity.villager.death", 0.6, 1.8),
m_ActionCountDown(-1),
m_Type(VillagerType),
m_VillagerAction(false)
@@ -22,6 +22,7 @@ cVillager::cVillager(eVillagerType VillagerType) :
m_BehaviorCoward.AttachToMonster(*this);
m_BehaviorItemFollower.AttachToMonster(*this);
m_BehaviorWanderer.AttachToMonster(*this);
+ GetMonsterConfig("Villager");
}
diff --git a/src/Mobs/Witch.cpp b/src/Mobs/Witch.cpp
index e9baf5512..6aaca82c8 100644
--- a/src/Mobs/Witch.cpp
+++ b/src/Mobs/Witch.cpp
@@ -9,9 +9,10 @@
cWitch::cWitch(void) :
- super("Witch", mtWitch, "entity.witch.hurt", "entity.witch.death", 0.6, 1.8)
+ super(mtWitch, "entity.witch.hurt", "entity.witch.death", 0.6, 1.8)
{
m_EMPersonality = AGGRESSIVE;
+ GetMonsterConfig("Witch");
}
diff --git a/src/Mobs/Wither.cpp b/src/Mobs/Wither.cpp
index 195c90fd2..adb7305df 100644
--- a/src/Mobs/Wither.cpp
+++ b/src/Mobs/Wither.cpp
@@ -11,12 +11,13 @@
cWither::cWither(void) :
- super("Wither", mtWither, "entity.wither.hurt", "entity.wither.death", 0.9, 4.0),
+ super(mtWither, "entity.wither.hurt", "entity.wither.death", 0.9, 4.0),
m_WitherInvulnerableTicks(220)
{
SetMaxHealth(300);
SetHealth(GetMaxHealth() / 3);
m_EMPersonality = AGGRESSIVE;
+ GetMonsterConfig("Wither");
}
diff --git a/src/Mobs/Wolf.cpp b/src/Mobs/Wolf.cpp
index f1c082ce7..bf49c70f8 100644
--- a/src/Mobs/Wolf.cpp
+++ b/src/Mobs/Wolf.cpp
@@ -12,7 +12,7 @@
cWolf::cWolf(void) :
- super("Wolf", mtWolf, "entity.wolf.hurt", "entity.wolf.death", 0.6, 0.8),
+ super(mtWolf, "entity.wolf.hurt", "entity.wolf.death", 0.6, 0.8),
m_IsSitting(false),
m_IsTame(false),
m_IsBegging(false),
@@ -23,6 +23,7 @@ cWolf::cWolf(void) :
{
m_RelativeWalkSpeed = 2;
m_EMPersonality = PASSIVE;
+ GetMonsterConfig("Wolf");
}
@@ -31,44 +32,7 @@ cWolf::cWolf(void) :
bool cWolf::DoTakeDamage(TakeDamageInfo & a_TDI)
{
- /*
- cPawn * PreviousTarget = GetTarget();
- if (!super::DoTakeDamage(a_TDI))
- {
- return false;
- }
-
- if ((a_TDI.Attacker != nullptr) && a_TDI.Attacker->IsPawn())
- {
- auto currTarget = GetTarget();
- if ((currTarget != nullptr) && currTarget->IsPlayer())
- {
- if (m_IsTame)
- {
- if ((static_cast<cPlayer*>(currTarget)->GetUUID() == m_OwnerUUID))
- {
- SetTarget(PreviousTarget); // Do not attack owner
- }
- else
- {
- SetIsSitting(false);
- NotifyAlliesOfFight(static_cast<cPawn*>(a_TDI.Attacker));
- }
- }
- else
- {
- m_IsAngry = true;
- }
- }
- else if (m_IsTame)
- {
- SetIsSitting(false);
- NotifyAlliesOfFight(static_cast<cPawn*>(a_TDI.Attacker));
- }
- }
-
- m_World->BroadcastEntityMetadata(*this); // Broadcast health and possibly angry face
- return true;*/
+ /*TODO bring from master and adapt*/
}
@@ -77,95 +41,16 @@ bool cWolf::DoTakeDamage(TakeDamageInfo & a_TDI)
void cWolf::NotifyAlliesOfFight(cPawn * a_Opponent)
{
- /*
- if (GetOwnerName() == "")
- {
- return;
- }
- m_NotificationCooldown = 15;
-
- m_World->DoWithPlayerByUUID(m_OwnerUUID, [=](cPlayer & a_Player)
- {
- a_Player.NotifyNearbyWolves(a_Opponent, false);
- return false;
- }
-<<<<<<< HEAD
- public:
- cPawn * m_Opponent;
- } Callback;
-
- Callback.m_Opponent = a_Opponent;
- m_World->DoWithPlayerByUUID(m_OwnerUUID, Callback);*/
-=======
- );
->>>>>>> master
+ /*TODO bring from master and adapt*/
}
-/*bool cWolf::Attack(std::chrono::milliseconds a_Dt)
-{
- UNUSED(a_Dt);
-
- if ((GetTarget() != nullptr) && (GetTarget()->IsPlayer()))
- {
- if (static_cast<cPlayer *>(GetTarget())->GetUUID() == m_OwnerUUID)
- {
- SetTarget(nullptr);
- return false;
- }
- }
-
- NotifyAlliesOfFight(static_cast<cPawn*>(GetTarget()));
- return super::Attack(a_Dt);
-
-}*/
-
void cWolf::ReceiveNearbyFightInfo(const cUUID & a_PlayerID, cPawn * a_Opponent, bool a_IsPlayerInvolved)
{
- /*
- if (
- (a_Opponent == nullptr) || IsSitting() || (!IsTame()) ||
- (!a_Opponent->IsPawn()) || (a_PlayerID != m_OwnerUUID)
- )
- {
- return;
- }
-
- // If we already have a target
- if (GetTarget() != nullptr)
- {
- // If a wolf is asking for help and we already have a target, do nothing
- if (!a_IsPlayerInvolved)
- {
- return;
- }
- // If a player is asking for help and we already have a target,
- // there's a 50% chance of helping and a 50% chance of doing nothing
- // This helps spread a wolf pack's targets over several mobs
- else if (GetRandomProvider().RandBool())
- {
- return;
- }
- }
-
- if (a_Opponent->IsPlayer() && static_cast<cPlayer *>(a_Opponent)->GetUUID() == m_OwnerUUID)
- {
- return; // Our owner has hurt himself, avoid attacking them.
- }
-
- if (a_Opponent->IsMob() && static_cast<cMonster *>(a_Opponent)->GetMobType() == mtWolf)
- {
- cWolf * Wolf = static_cast<cWolf *>(a_Opponent);
- if (Wolf->GetOwnerUUID() == GetOwnerUUID())
- {
- return; // Our owner attacked one of their wolves. Abort attacking wolf.
- }
- }
-
- SetTarget(a_Opponent);
+ /*TODO bring from master and adapt
*/
}
@@ -176,82 +61,7 @@ void cWolf::ReceiveNearbyFightInfo(const cUUID & a_PlayerID, cPawn * a_Opponent,
void cWolf::OnRightClicked(cPlayer & a_Player)
{
- /*const cItem & EquippedItem = a_Player.GetEquippedItem();
- const int EquippedItemType = EquippedItem.m_ItemType;
-
- if (!IsTame() && !IsAngry())
- {
- // If the player is holding a bone, try to tame the wolf:
- if (EquippedItemType == E_ITEM_BONE)
- {
- if (!a_Player.IsGameModeCreative())
- {
- a_Player.GetInventory().RemoveOneEquippedItem();
- }
-
- if (GetRandomProvider().RandBool(0.125))
- {
- // Taming succeeded
- SetMaxHealth(20);
- SetIsTame(true);
- SetOwner(a_Player.GetName(), a_Player.GetUUID());
- m_World->BroadcastEntityStatus(*this, esWolfTamed);
- m_World->GetBroadcaster().BroadcastParticleEffect("heart", static_cast<Vector3f>(GetPosition()), Vector3f{}, 0, 5);
- }
- else
- {
- // Taming failed
- m_World->BroadcastEntityStatus(*this, esWolfTaming);
- m_World->GetBroadcaster().BroadcastParticleEffect("smoke", static_cast<Vector3f>(GetPosition()), Vector3f{}, 0, 5);
- }
- }
- }
- else if (IsTame())
- {
- // Feed the wolf, restoring its health, or dye its collar:
- switch (EquippedItemType)
- {
- case E_ITEM_RAW_BEEF:
- case E_ITEM_STEAK:
- case E_ITEM_RAW_PORKCHOP:
- case E_ITEM_COOKED_PORKCHOP:
- case E_ITEM_RAW_CHICKEN:
- case E_ITEM_COOKED_CHICKEN:
- case E_ITEM_ROTTEN_FLESH:
- {
- if (m_Health < m_MaxHealth)
- {
- Heal(ItemHandler(EquippedItemType)->GetFoodInfo(&EquippedItem).FoodLevel);
- if (!a_Player.IsGameModeCreative())
- {
- a_Player.GetInventory().RemoveOneEquippedItem();
- }
- }
- break;
- }
- case E_ITEM_DYE:
- {
- if (a_Player.GetUUID() == m_OwnerUUID) // Is the player the owner of the dog?
- {
- SetCollarColor(EquippedItem.m_ItemDamage);
- if (!a_Player.IsGameModeCreative())
- {
- a_Player.GetInventory().RemoveOneEquippedItem();
- }
- }
- break;
- }
- default:
- {
- if (a_Player.GetUUID() == m_OwnerUUID) // Is the player the owner of the dog?
- {
- SetIsSitting(!IsSitting());
- }
- }
- }
- }
-
- m_World->BroadcastEntityMetadata(*this);
+ /*TODO bring from master and adapt
*/
}
@@ -264,92 +74,7 @@ void cWolf::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
//mobTodo behaviors!
/*
- if (!IsAngry())
- {
- cMonster::Tick(a_Dt, a_Chunk);
- if (m_NotificationCooldown > 0)
- {
- m_NotificationCooldown -= 1;
- }
- }
- else
- {
- super::Tick(a_Dt, a_Chunk);
- }
-
- if (!IsTicking())
- {
- // The base class tick destroyed us
- return;
- }
-
- if (GetTarget() == nullptr)
- {
- cPlayer * a_Closest_Player = m_World->FindClosestPlayer(GetPosition(), static_cast<float>(m_SightDistance));
- if (a_Closest_Player != nullptr)
- {
- switch (a_Closest_Player->GetEquippedItem().m_ItemType)
- {
- case E_ITEM_BONE:
- case E_ITEM_RAW_BEEF:
- case E_ITEM_STEAK:
- case E_ITEM_RAW_CHICKEN:
- case E_ITEM_COOKED_CHICKEN:
- case E_ITEM_ROTTEN_FLESH:
- case E_ITEM_RAW_PORKCHOP:
- case E_ITEM_COOKED_PORKCHOP:
- {
- if (!IsBegging())
- {
- SetIsBegging(true);
- m_World->BroadcastEntityMetadata(*this);
- }
-
- m_FinalDestination = a_Closest_Player->GetPosition(); // So that we will look at a player holding food
-
- // Don't move to the player if the wolf is sitting.
- if (!IsSitting())
- {
- MoveToPosition(a_Closest_Player->GetPosition());
- }
-
- break;
- }
- default:
- {
- if (IsBegging())
- {
- SetIsBegging(false);
- m_World->BroadcastEntityMetadata(*this);
- }
- }
- }
- }
- }
- else
- {
- if (IsSitting())
- {
- SetTarget(nullptr);
- }
- else
- {
- MoveToPosition(GetTarget()->GetPosition());
- if (TargetIsInRange())
- {
- // Attack(a_Dt); mobTodo
- }
- }
- }
-
- if (IsTame() && !IsSitting())
- {
- TickFollowPlayer();
- }
- else if (IsSitting())
- {
- StopMovingToPosition();
- }
+ TODO bring from master and adapt
*/
}
@@ -359,52 +84,8 @@ void cWolf::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
void cWolf::TickFollowPlayer()
{
-<<<<<<< HEAD
/*
- class cCallback :
- public cPlayerListCallback
-=======
- Vector3d OwnerPos;
- bool OwnerFlying;
- auto Callback = [&](cPlayer & a_Player)
->>>>>>> master
- {
- OwnerPos = a_Player.GetPosition();
- OwnerFlying = a_Player.IsFlying();
- return true;
- };
-
- if (m_World->DoWithPlayerByUUID(m_OwnerUUID, Callback))
- {
- // The player is present in the world, follow him:
- double Distance = (OwnerPos - GetPosition()).Length();
- if (Distance > 20)
- {
- if (!OwnerFlying)
- {
- OwnerPos.y = FindFirstNonAirBlockPosition(OwnerPos.x, OwnerPos.z);
- TeleportToCoords(OwnerPos.x, OwnerPos.y, OwnerPos.z);
- SetTarget(nullptr);
- }
- }
- if (Distance < 2)
- {
- if (GetTarget() == nullptr)
- {
- StopMovingToPosition();
- }
- }
- else
- {
- if (GetTarget() == nullptr)
- {
- if (!OwnerFlying)
- {
- MoveToPosition(OwnerPos);
- }
- }
- }
- }
+ TODO bring from master and adapt
*/
}
diff --git a/src/Mobs/Zombie.cpp b/src/Mobs/Zombie.cpp
index 43c1fa3d9..7a74e46e1 100644
--- a/src/Mobs/Zombie.cpp
+++ b/src/Mobs/Zombie.cpp
@@ -10,7 +10,7 @@
cZombie::cZombie(bool a_IsVillagerZombie) :
- super("Zombie", mtZombie, "entity.zombie.hurt", "entity.zombie.death", 0.6, 1.8),
+ super(mtZombie, "entity.zombie.hurt", "entity.zombie.death", 0.6, 1.8),
m_IsVillagerZombie(a_IsVillagerZombie),
m_IsConverting(false)
{
@@ -21,7 +21,7 @@ cZombie::cZombie(bool a_IsVillagerZombie) :
m_BehaviorAggressive.AttachToMonster(*this);
m_BehaviourDayLightBurner.AttachToMonster(*this);
GetMonsterConfig("Zombie");
- // Todo I need the config to load after attaching the Behaviors but this is not clean.
+ // mobTodo I need the config to load after attaching the Behaviors but this is not clean.
}
diff --git a/src/Mobs/ZombiePigman.cpp b/src/Mobs/ZombiePigman.cpp
index 07dbf4aa0..3b3a93709 100644
--- a/src/Mobs/ZombiePigman.cpp
+++ b/src/Mobs/ZombiePigman.cpp
@@ -9,9 +9,10 @@
cZombiePigman::cZombiePigman(void) :
- super("ZombiePigman", mtZombiePigman, "entity.zombie_pig.hurt", "entity.zombie_pig.death", 0.6, 1.8)
+ super(mtZombiePigman, "entity.zombie_pig.hurt", "entity.zombie_pig.death", 0.6, 1.8)
{
m_EMPersonality = PASSIVE;
+ GetMonsterConfig("ZombiePigman");
}