summaryrefslogtreecommitdiffstats
path: root/src/Mobs
diff options
context:
space:
mode:
authorHowaner <franzi.moos@googlemail.com>2014-11-18 14:56:32 +0100
committerHowaner <franzi.moos@googlemail.com>2014-11-18 14:56:32 +0100
commit42120e2ea5db0cdb9920ff1c5efef33e0f496d48 (patch)
tree20ba1ae0a53f757cb8814b6cd6a466fe5acf1308 /src/Mobs
parentFixed compile errors. (diff)
parentMerge pull request #1598 from mc-server/SignEditor (diff)
downloadcuberite-42120e2ea5db0cdb9920ff1c5efef33e0f496d48.tar
cuberite-42120e2ea5db0cdb9920ff1c5efef33e0f496d48.tar.gz
cuberite-42120e2ea5db0cdb9920ff1c5efef33e0f496d48.tar.bz2
cuberite-42120e2ea5db0cdb9920ff1c5efef33e0f496d48.tar.lz
cuberite-42120e2ea5db0cdb9920ff1c5efef33e0f496d48.tar.xz
cuberite-42120e2ea5db0cdb9920ff1c5efef33e0f496d48.tar.zst
cuberite-42120e2ea5db0cdb9920ff1c5efef33e0f496d48.zip
Diffstat (limited to '')
-rw-r--r--src/Mobs/AggressiveMonster.cpp6
-rw-r--r--src/Mobs/Blaze.cpp8
-rw-r--r--src/Mobs/Blaze.h2
-rw-r--r--src/Mobs/CMakeLists.txt1
-rw-r--r--src/Mobs/CaveSpider.cpp4
-rw-r--r--src/Mobs/CaveSpider.h2
-rw-r--r--src/Mobs/Chicken.cpp2
-rw-r--r--src/Mobs/Chicken.h2
-rw-r--r--src/Mobs/Cow.cpp2
-rw-r--r--src/Mobs/Cow.h2
-rw-r--r--src/Mobs/Creeper.cpp4
-rw-r--r--src/Mobs/Creeper.h2
-rw-r--r--src/Mobs/EnderDragon.h2
-rw-r--r--src/Mobs/Enderman.cpp28
-rw-r--r--src/Mobs/Enderman.h3
-rw-r--r--src/Mobs/Ghast.cpp8
-rw-r--r--src/Mobs/Ghast.h2
-rw-r--r--src/Mobs/Giant.h2
-rw-r--r--src/Mobs/Horse.cpp6
-rw-r--r--src/Mobs/Horse.h2
-rw-r--r--src/Mobs/IronGolem.h2
-rw-r--r--src/Mobs/MagmaCube.h2
-rw-r--r--src/Mobs/Monster.cpp38
-rw-r--r--src/Mobs/Monster.h63
-rw-r--r--src/Mobs/MonsterTypes.h13
-rw-r--r--src/Mobs/Mooshroom.cpp2
-rw-r--r--src/Mobs/Mooshroom.h2
-rw-r--r--src/Mobs/PassiveAggressiveMonster.cpp2
-rw-r--r--src/Mobs/PassiveMonster.cpp4
-rw-r--r--src/Mobs/Pig.cpp6
-rw-r--r--src/Mobs/Pig.h2
-rw-r--r--src/Mobs/Sheep.cpp2
-rw-r--r--src/Mobs/Sheep.h2
-rw-r--r--src/Mobs/Skeleton.cpp8
-rw-r--r--src/Mobs/Skeleton.h2
-rw-r--r--src/Mobs/Slime.cpp2
-rw-r--r--src/Mobs/Slime.h2
-rw-r--r--src/Mobs/SnowGolem.h2
-rw-r--r--src/Mobs/Spider.cpp4
-rw-r--r--src/Mobs/Spider.h2
-rw-r--r--src/Mobs/Squid.cpp2
-rw-r--r--src/Mobs/Squid.h2
-rw-r--r--src/Mobs/Villager.cpp2
-rw-r--r--src/Mobs/Witch.cpp2
-rw-r--r--src/Mobs/Witch.h2
-rw-r--r--src/Mobs/Wither.h2
-rw-r--r--src/Mobs/Wolf.cpp4
-rw-r--r--src/Mobs/Zombie.cpp2
-rw-r--r--src/Mobs/Zombie.h2
-rw-r--r--src/Mobs/ZombiePigman.cpp4
-rw-r--r--src/Mobs/ZombiePigman.h2
51 files changed, 158 insertions, 120 deletions
diff --git a/src/Mobs/AggressiveMonster.cpp b/src/Mobs/AggressiveMonster.cpp
index be2f71f7a..41ef26e2a 100644
--- a/src/Mobs/AggressiveMonster.cpp
+++ b/src/Mobs/AggressiveMonster.cpp
@@ -26,7 +26,7 @@ void cAggressiveMonster::InStateChasing(float a_Dt)
{
super::InStateChasing(a_Dt);
- if (m_Target != NULL)
+ if (m_Target != nullptr)
{
if (m_Target->IsPlayer())
{
@@ -74,7 +74,7 @@ void cAggressiveMonster::Tick(float a_Dt, cChunk & a_Chunk)
CheckEventSeePlayer();
}
- if (m_Target == NULL)
+ if (m_Target == nullptr)
return;
cTracer LineOfSight(GetWorld());
@@ -95,7 +95,7 @@ void cAggressiveMonster::Attack(float a_Dt)
{
m_AttackInterval += a_Dt * m_AttackRate;
- if ((m_Target == NULL) || (m_AttackInterval < 3.0))
+ if ((m_Target == nullptr) || (m_AttackInterval < 3.0))
{
return;
}
diff --git a/src/Mobs/Blaze.cpp b/src/Mobs/Blaze.cpp
index b4104d530..16869c79d 100644
--- a/src/Mobs/Blaze.cpp
+++ b/src/Mobs/Blaze.cpp
@@ -19,7 +19,7 @@ cBlaze::cBlaze(void) :
void cBlaze::GetDrops(cItems & a_Drops, cEntity * a_Killer)
{
- if ((a_Killer != NULL) && (a_Killer->IsPlayer() || a_Killer->IsA("cWolf")))
+ if ((a_Killer != nullptr) && (a_Killer->IsPlayer() || a_Killer->IsA("cWolf")))
{
int LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting);
AddRandomDropItem(a_Drops, 0, 1 + LootingLevel, E_ITEM_BLAZE_ROD);
@@ -34,20 +34,20 @@ void cBlaze::Attack(float a_Dt)
{
m_AttackInterval += a_Dt * m_AttackRate;
- if (m_Target != NULL && m_AttackInterval > 3.0)
+ if (m_Target != nullptr && m_AttackInterval > 3.0)
{
// Setting this higher gives us more wiggle room for attackrate
Vector3d Speed = GetLookVector() * 20;
Speed.y = Speed.y + 1;
cFireChargeEntity * FireCharge = new cFireChargeEntity(this, GetPosX(), GetPosY() + 1, GetPosZ(), Speed);
- if (FireCharge == NULL)
+ if (FireCharge == nullptr)
{
return;
}
if (!FireCharge->Initialize(*m_World))
{
delete FireCharge;
- FireCharge = NULL;
+ FireCharge = nullptr;
return;
}
m_World->BroadcastSpawnEntity(*FireCharge);
diff --git a/src/Mobs/Blaze.h b/src/Mobs/Blaze.h
index f283b1070..e2a4ad9f1 100644
--- a/src/Mobs/Blaze.h
+++ b/src/Mobs/Blaze.h
@@ -17,6 +17,6 @@ public:
CLASS_PROTODEF(cBlaze)
- virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
+ virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
virtual void Attack(float a_Dt) override;
} ;
diff --git a/src/Mobs/CMakeLists.txt b/src/Mobs/CMakeLists.txt
index 2c092c15f..bbbb9287a 100644
--- a/src/Mobs/CMakeLists.txt
+++ b/src/Mobs/CMakeLists.txt
@@ -54,6 +54,7 @@ SET (HDRS
IronGolem.h
MagmaCube.h
Monster.h
+ MonsterTypes.h
Mooshroom.h
Ocelot.h
PassiveAggressiveMonster.h
diff --git a/src/Mobs/CaveSpider.cpp b/src/Mobs/CaveSpider.cpp
index 118a6e93b..045b47e73 100644
--- a/src/Mobs/CaveSpider.cpp
+++ b/src/Mobs/CaveSpider.cpp
@@ -45,12 +45,12 @@ void cCaveSpider::Attack(float a_Dt)
void cCaveSpider::GetDrops(cItems & a_Drops, cEntity * a_Killer)
{
int LootingLevel = 0;
- if (a_Killer != NULL)
+ if (a_Killer != nullptr)
{
LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting);
}
AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_STRING);
- if ((a_Killer != NULL) && (a_Killer->IsPlayer() || a_Killer->IsA("cWolf")))
+ if ((a_Killer != nullptr) && (a_Killer->IsPlayer() || a_Killer->IsA("cWolf")))
{
AddRandomUncommonDropItem(a_Drops, 33.0f, E_ITEM_SPIDER_EYE);
}
diff --git a/src/Mobs/CaveSpider.h b/src/Mobs/CaveSpider.h
index f9ed10e1b..494ba1360 100644
--- a/src/Mobs/CaveSpider.h
+++ b/src/Mobs/CaveSpider.h
@@ -18,7 +18,7 @@ public:
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
virtual void Attack(float a_Dt) override;
- virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
+ virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
} ;
diff --git a/src/Mobs/Chicken.cpp b/src/Mobs/Chicken.cpp
index f7e44238f..634867cfa 100644
--- a/src/Mobs/Chicken.cpp
+++ b/src/Mobs/Chicken.cpp
@@ -49,7 +49,7 @@ void cChicken::Tick(float a_Dt, cChunk & a_Chunk)
void cChicken::GetDrops(cItems & a_Drops, cEntity * a_Killer)
{
int LootingLevel = 0;
- if (a_Killer != NULL)
+ if (a_Killer != nullptr)
{
LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting);
}
diff --git a/src/Mobs/Chicken.h b/src/Mobs/Chicken.h
index b1a50b61c..07b921884 100644
--- a/src/Mobs/Chicken.h
+++ b/src/Mobs/Chicken.h
@@ -16,7 +16,7 @@ public:
CLASS_PROTODEF(cChicken)
- virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
+ virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
virtual const cItem GetFollowedItem(void) const override { return cItem(E_ITEM_SEEDS); }
diff --git a/src/Mobs/Cow.cpp b/src/Mobs/Cow.cpp
index 9914df6b5..7dc6f3f37 100644
--- a/src/Mobs/Cow.cpp
+++ b/src/Mobs/Cow.cpp
@@ -22,7 +22,7 @@ cCow::cCow(void) :
void cCow::GetDrops(cItems & a_Drops, cEntity * a_Killer)
{
int LootingLevel = 0;
- if (a_Killer != NULL)
+ if (a_Killer != nullptr)
{
LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting);
}
diff --git a/src/Mobs/Cow.h b/src/Mobs/Cow.h
index 8814b7e09..ee1a4fafe 100644
--- a/src/Mobs/Cow.h
+++ b/src/Mobs/Cow.h
@@ -17,7 +17,7 @@ public:
CLASS_PROTODEF(cCow)
- virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
+ virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
virtual void OnRightClicked(cPlayer & a_Player) override;
virtual const cItem GetFollowedItem(void) const override { return cItem(E_ITEM_WHEAT); }
diff --git a/src/Mobs/Creeper.cpp b/src/Mobs/Creeper.cpp
index 02718edf8..a073224cf 100644
--- a/src/Mobs/Creeper.cpp
+++ b/src/Mobs/Creeper.cpp
@@ -61,13 +61,13 @@ void cCreeper::GetDrops(cItems & a_Drops, cEntity * a_Killer)
}
int LootingLevel = 0;
- if (a_Killer != NULL)
+ if (a_Killer != nullptr)
{
LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting);
}
AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_GUNPOWDER);
- if ((a_Killer != NULL) && a_Killer->IsProjectile() && (((cProjectileEntity *)a_Killer)->GetCreatorUniqueID() >= 0))
+ if ((a_Killer != nullptr) && a_Killer->IsProjectile() && (((cProjectileEntity *)a_Killer)->GetCreatorUniqueID() >= 0))
{
class cProjectileCreatorCallback : public cEntityCallback
{
diff --git a/src/Mobs/Creeper.h b/src/Mobs/Creeper.h
index 747daca09..bf3272e22 100644
--- a/src/Mobs/Creeper.h
+++ b/src/Mobs/Creeper.h
@@ -17,7 +17,7 @@ public:
CLASS_PROTODEF(cCreeper)
- virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
+ virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
virtual void Attack(float a_Dt) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
diff --git a/src/Mobs/EnderDragon.h b/src/Mobs/EnderDragon.h
index 1d4cd657c..e4ca9dcf9 100644
--- a/src/Mobs/EnderDragon.h
+++ b/src/Mobs/EnderDragon.h
@@ -17,7 +17,7 @@ public:
CLASS_PROTODEF(cEnderDragon)
- virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
+ virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
} ;
diff --git a/src/Mobs/Enderman.cpp b/src/Mobs/Enderman.cpp
index 51255beb3..56ea10245 100644
--- a/src/Mobs/Enderman.cpp
+++ b/src/Mobs/Enderman.cpp
@@ -15,7 +15,7 @@ class cPlayerLookCheck :
{
public:
cPlayerLookCheck(Vector3d a_EndermanPos, int a_SightDistance) :
- m_Player(NULL),
+ m_Player(nullptr),
m_EndermanPos(a_EndermanPos),
m_SightDistance(a_SightDistance)
{
@@ -92,7 +92,7 @@ cEnderman::cEnderman(void) :
void cEnderman::GetDrops(cItems & a_Drops, cEntity * a_Killer)
{
int LootingLevel = 0;
- if (a_Killer != NULL)
+ if (a_Killer != nullptr)
{
LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting);
}
@@ -104,7 +104,7 @@ void cEnderman::GetDrops(cItems & a_Drops, cEntity * a_Killer)
void cEnderman::CheckEventSeePlayer()
{
- if (m_Target != NULL)
+ if (m_Target != nullptr)
{
return;
}
@@ -115,7 +115,7 @@ void cEnderman::CheckEventSeePlayer()
return;
}
- ASSERT(Callback.GetPlayer() != NULL);
+ ASSERT(Callback.GetPlayer() != nullptr);
if (!CheckLight())
{
@@ -181,3 +181,23 @@ bool cEnderman::CheckLight()
return true;
}
+
+
+
+
+
+void cEnderman::Tick(float a_Dt, cChunk & a_Chunk)
+{
+ super::Tick(a_Dt, a_Chunk);
+
+ // TODO take damage in rain
+
+ // Take damage when touching water, drowning damage seems to be most appropriate
+ if (IsSwimming())
+ {
+ EventLosePlayer();
+ TakeDamage(dtDrowning, nullptr, 1, 0);
+ // TODO teleport to a safe location
+ }
+
+}
diff --git a/src/Mobs/Enderman.h b/src/Mobs/Enderman.h
index 4583746e7..28bbceb84 100644
--- a/src/Mobs/Enderman.h
+++ b/src/Mobs/Enderman.h
@@ -17,10 +17,11 @@ public:
CLASS_PROTODEF(cEnderman)
- virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
+ virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
virtual void CheckEventSeePlayer(void) override;
virtual void CheckEventLostPlayer(void) override;
virtual void EventLosePlayer(void) override;
+ virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
bool IsScreaming(void) const {return m_bIsScreaming; }
BLOCKTYPE GetCarriedBlock(void) const {return CarriedBlock; }
diff --git a/src/Mobs/Ghast.cpp b/src/Mobs/Ghast.cpp
index 6aac14779..c65c0d29a 100644
--- a/src/Mobs/Ghast.cpp
+++ b/src/Mobs/Ghast.cpp
@@ -20,7 +20,7 @@ cGhast::cGhast(void) :
void cGhast::GetDrops(cItems & a_Drops, cEntity * a_Killer)
{
int LootingLevel = 0;
- if (a_Killer != NULL)
+ if (a_Killer != nullptr)
{
LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting);
}
@@ -36,20 +36,20 @@ void cGhast::Attack(float a_Dt)
{
m_AttackInterval += a_Dt * m_AttackRate;
- if (m_Target != NULL && m_AttackInterval > 3.0)
+ if (m_Target != nullptr && m_AttackInterval > 3.0)
{
// Setting this higher gives us more wiggle room for attackrate
Vector3d Speed = GetLookVector() * 20;
Speed.y = Speed.y + 1;
cGhastFireballEntity * GhastBall = new cGhastFireballEntity(this, GetPosX(), GetPosY() + 1, GetPosZ(), Speed);
- if (GhastBall == NULL)
+ if (GhastBall == nullptr)
{
return;
}
if (!GhastBall->Initialize(*m_World))
{
delete GhastBall;
- GhastBall = NULL;
+ GhastBall = nullptr;
return;
}
m_World->BroadcastSpawnEntity(*GhastBall);
diff --git a/src/Mobs/Ghast.h b/src/Mobs/Ghast.h
index 1d4e6b94a..a28940a01 100644
--- a/src/Mobs/Ghast.h
+++ b/src/Mobs/Ghast.h
@@ -17,7 +17,7 @@ public:
CLASS_PROTODEF(cGhast)
- virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
+ virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
virtual void Attack(float a_Dt) override;
bool IsCharging(void) const {return false; }
diff --git a/src/Mobs/Giant.h b/src/Mobs/Giant.h
index 7c04c9b4f..8d3060940 100644
--- a/src/Mobs/Giant.h
+++ b/src/Mobs/Giant.h
@@ -17,7 +17,7 @@ public:
CLASS_PROTODEF(cGiant)
- virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
+ virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
} ;
diff --git a/src/Mobs/Horse.cpp b/src/Mobs/Horse.cpp
index 67a09d4ab..d92f0d023 100644
--- a/src/Mobs/Horse.cpp
+++ b/src/Mobs/Horse.cpp
@@ -49,7 +49,7 @@ void cHorse::Tick(float a_Dt, cChunk & a_Chunk)
}
}
- if ((m_Attachee != NULL) && (!m_bIsTame))
+ if ((m_Attachee != nullptr) && (!m_bIsTame))
{
if (m_TameAttemptTimes < m_TimesToTame)
{
@@ -113,7 +113,7 @@ void cHorse::OnRightClicked(cPlayer & a_Player)
}
else
{
- if (m_Attachee != NULL)
+ if (m_Attachee != nullptr)
{
if (m_Attachee->GetUniqueID() == a_Player.GetUniqueID())
{
@@ -141,7 +141,7 @@ void cHorse::OnRightClicked(cPlayer & a_Player)
void cHorse::GetDrops(cItems & a_Drops, cEntity * a_Killer)
{
int LootingLevel = 0;
- if (a_Killer != NULL)
+ if (a_Killer != nullptr)
{
LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting);
}
diff --git a/src/Mobs/Horse.h b/src/Mobs/Horse.h
index 47189b3b0..4c644e512 100644
--- a/src/Mobs/Horse.h
+++ b/src/Mobs/Horse.h
@@ -17,7 +17,7 @@ public:
CLASS_PROTODEF(cHorse)
- virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
+ virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
virtual void OnRightClicked(cPlayer & a_Player) override;
diff --git a/src/Mobs/IronGolem.h b/src/Mobs/IronGolem.h
index c5341ed76..721ca2701 100644
--- a/src/Mobs/IronGolem.h
+++ b/src/Mobs/IronGolem.h
@@ -17,7 +17,7 @@ public:
CLASS_PROTODEF(cIronGolem)
- virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
+ virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
// Iron golems do not drown nor float
virtual void HandleAir(void) override {}
diff --git a/src/Mobs/MagmaCube.h b/src/Mobs/MagmaCube.h
index bfe63fa2e..d66ea423a 100644
--- a/src/Mobs/MagmaCube.h
+++ b/src/Mobs/MagmaCube.h
@@ -17,7 +17,7 @@ public:
CLASS_PROTODEF(cMagmaCube)
- virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
+ virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
int GetSize(void) const { return m_Size; }
protected:
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp
index 12ca6bbbe..23b4d9f45 100644
--- a/src/Mobs/Monster.cpp
+++ b/src/Mobs/Monster.cpp
@@ -62,6 +62,16 @@ static const struct
+eMonsterType StringToMobType(const AString & a_MobString)
+{
+ LOGWARNING("%s: Function is obsolete, use cMonster::StringToMobType() instead", __FUNCTION__);
+ return cMonster::StringToMobType(a_MobString);
+}
+
+
+
+
+
////////////////////////////////////////////////////////////////////////////////
// cMonster:
@@ -69,7 +79,7 @@ cMonster::cMonster(const AString & a_ConfigName, eMonsterType a_MobType, const A
: super(etMonster, a_Width, a_Height)
, m_EMState(IDLE)
, m_EMPersonality(AGGRESSIVE)
- , m_Target(NULL)
+ , m_Target(nullptr)
, m_bMovingToDestination(false)
, m_LastGroundHeight(POSY_TOINT)
, m_IdleInterval(0)
@@ -264,8 +274,8 @@ void cMonster::Tick(float a_Dt, cChunk & a_Chunk)
return;
}
- if ((m_Target != NULL) && m_Target->IsDestroyed())
- m_Target = NULL;
+ if ((m_Target != nullptr) && m_Target->IsDestroyed())
+ m_Target = nullptr;
// Burning in daylight
HandleDaylightBurning(a_Chunk);
@@ -369,7 +379,7 @@ void cMonster::Tick(float a_Dt, cChunk & a_Chunk)
void cMonster::SetPitchAndYawFromDestination()
{
Vector3d FinalDestination = m_FinalDestination;
- if (m_Target != NULL)
+ if (m_Target != nullptr)
{
if (m_Target->IsPlayer())
{
@@ -413,7 +423,7 @@ void cMonster::HandleFalling()
if (Damage > 0)
{
- TakeDamage(dtFalling, NULL, Damage, Damage, 0);
+ TakeDamage(dtFalling, nullptr, Damage, Damage, 0);
// Fall particles
GetWorld()->BroadcastSoundParticleEffect(2006, POSX_TOINT, POSY_TOINT - 1, POSZ_TOINT, Damage /* Used as particle effect speed modifier */);
@@ -469,7 +479,7 @@ bool cMonster::DoTakeDamage(TakeDamageInfo & a_TDI)
m_World->BroadcastSoundEffect(m_SoundHurt, GetPosX(), GetPosY(), GetPosZ(), 1.0f, 0.8f);
}
- if (a_TDI.Attacker != NULL)
+ if (a_TDI.Attacker != nullptr)
{
m_Target = a_TDI.Attacker;
}
@@ -546,7 +556,7 @@ void cMonster::KilledBy(TakeDamageInfo & a_TDI)
break;
}
}
- if ((a_TDI.Attacker != NULL) && (!IsBaby()))
+ if ((a_TDI.Attacker != nullptr) && (!IsBaby()))
{
m_World->SpawnExperienceOrb(GetPosX(), GetPosY(), GetPosZ(), Reward);
}
@@ -583,7 +593,7 @@ void cMonster::CheckEventSeePlayer(void)
// TODO: Rewrite this to use cWorld's DoWithPlayers()
cPlayer * Closest = m_World->FindClosestPlayer(GetPosition(), (float)m_SightDistance, false);
- if (Closest != NULL)
+ if (Closest != nullptr)
{
EventSeePlayer(Closest);
}
@@ -595,7 +605,7 @@ void cMonster::CheckEventSeePlayer(void)
void cMonster::CheckEventLostPlayer(void)
{
- if (m_Target != NULL)
+ if (m_Target != nullptr)
{
if ((m_Target->GetPosition() - GetPosition()).Length() > m_SightDistance)
{
@@ -625,7 +635,7 @@ void cMonster::EventSeePlayer(cEntity * a_SeenPlayer)
void cMonster::EventLosePlayer(void)
{
- m_Target = NULL;
+ m_Target = nullptr;
m_EMState = IDLE;
}
@@ -687,7 +697,7 @@ void cMonster::InStateEscaping(float a_Dt)
{
UNUSED(a_Dt);
- if (m_Target != NULL)
+ if (m_Target != nullptr)
{
Vector3d newloc = GetPosition();
newloc.x = (m_Target->GetPosition().x < newloc.x)? (newloc.x + m_SightDistance): (newloc.x - m_SightDistance);
@@ -714,7 +724,7 @@ void cMonster::SetCustomName(const AString & a_CustomName)
m_CustomName = a_CustomName.substr(0, 64);
}
- if (m_World != NULL)
+ if (m_World != nullptr)
{
m_World->BroadcastEntityMetadata(*this);
}
@@ -727,7 +737,7 @@ void cMonster::SetCustomName(const AString & a_CustomName)
void cMonster::SetCustomNameAlwaysVisible(bool a_CustomNameAlwaysVisible)
{
m_CustomNameAlwaysVisible = a_CustomNameAlwaysVisible;
- if (m_World != NULL)
+ if (m_World != nullptr)
{
m_World->BroadcastEntityMetadata(*this);
}
@@ -883,7 +893,7 @@ int cMonster::GetSpawnDelay(cMonster::eFamily a_MobFamily)
cMonster * cMonster::NewMonsterFromType(eMonsterType a_MobType)
{
cFastRandom Random;
- cMonster * toReturn = NULL;
+ cMonster * toReturn = nullptr;
// Create the mob entity
switch (a_MobType)
diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h
index 0fa620b3a..96c2a6bdd 100644
--- a/src/Mobs/Monster.h
+++ b/src/Mobs/Monster.h
@@ -25,9 +25,6 @@ class cMonster :
typedef cPawn super;
public:
- //Depreciated
- typedef eMonsterType eType;
-
enum eFamily
{
mfHostile = 0, // Spider, Zombies ...
@@ -38,12 +35,12 @@ public:
mfNoSpawn,
mfUnhandled, // Nothing. Be sure this is the last and the others are in order
} ;
-
+
// tolua_end
-
+
enum MState{ATTACKING, IDLE, CHASING, ESCAPING} m_EMState;
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))
@@ -52,47 +49,47 @@ public:
cMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
CLASS_PROTODEF(cMonster)
-
+
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
-
+
virtual void KilledBy(TakeDamageInfo & a_TDI) override;
virtual void OnRightClicked(cPlayer & a_Player) override;
virtual void MoveToPosition(const Vector3d & a_Position); // tolua_export
virtual bool ReachedDestination(void);
-
+
// tolua_begin
eMonsterType GetMobType(void) const { return m_MobType; }
eFamily GetMobFamily(void) const;
// tolua_end
-
+
virtual void CheckEventSeePlayer(void);
virtual void EventSeePlayer(cEntity * a_Player);
-
+
/// Reads the monster configuration for the specified monster name and assigns it to this object.
void GetMonsterConfig(const AString & a_Name);
-
+
/** Returns whether this mob is undead (skeleton, zombie, etc.) */
virtual bool IsUndead(void);
-
+
virtual void EventLosePlayer(void);
virtual void CheckEventLostPlayer(void);
-
+
virtual void InStateIdle (float a_Dt);
virtual void InStateChasing (float a_Dt);
virtual void InStateEscaping(float a_Dt);
-
- int GetAttackRate() { return (int)m_AttackRate; }
+
+ int GetAttackRate() { return static_cast<int>(m_AttackRate); }
void SetAttackRate(float a_AttackRate) { m_AttackRate = a_AttackRate; }
void SetAttackRange(int a_AttackRange) { m_AttackRange = a_AttackRange; }
void SetAttackDamage(int a_AttackDamage) { m_AttackDamage = a_AttackDamage; }
void SetSightDistance(int a_SightDistance) { m_SightDistance = a_SightDistance; }
-
+
float GetDropChanceWeapon() { return m_DropChanceWeapon; }
float GetDropChanceHelmet() { return m_DropChanceHelmet; }
float GetDropChanceChestplate() { return m_DropChanceChestplate; }
@@ -105,7 +102,7 @@ public:
void SetDropChanceLeggings(float a_DropChanceLeggings) { m_DropChanceLeggings = a_DropChanceLeggings; }
void SetDropChanceBoots(float a_DropChanceBoots) { m_DropChanceBoots = a_DropChanceBoots; }
void SetCanPickUpLoot(bool a_CanPickUpLoot) { m_CanPickUpLoot = a_CanPickUpLoot; }
-
+
/// Sets whether the mob burns in daylight. Only evaluated at next burn-decision tick
void SetBurnsInDaylight(bool a_BurnsInDaylight) { m_BurnsInDaylight = a_BurnsInDaylight; }
@@ -116,7 +113,7 @@ public:
virtual bool IsBaby (void) const { return false; }
virtual bool IsTame (void) const { return false; }
virtual bool IsSitting (void) const { return false; }
-
+
// tolua_begin
/** Returns true if the monster has a custom name. */
@@ -138,10 +135,10 @@ public:
/// Translates MobType enum to a string, empty string if unknown
static AString MobTypeToString(eMonsterType a_MobType);
-
+
/// Translates MobType string to the enum, mtInvalidType if not recognized
static eMonsterType StringToMobType(const AString & a_MobTypeName);
-
+
/// Returns the mob family based on the type
static eFamily FamilyFromType(eMonsterType a_MobType);
@@ -149,7 +146,7 @@ public:
static int GetSpawnDelay(cMonster::eFamily a_MobFamily);
// tolua_end
-
+
/** Creates a new object of the specified mob.
a_MobType is the type of the mob to be created
Asserts and returns null if mob type is not specified
@@ -157,7 +154,7 @@ public:
static cMonster * NewMonsterFromType(eMonsterType a_MobType);
protected:
-
+
/* ======= PATHFINDING ======= */
/** A pointer to the entity this mobile is aiming to reach */
@@ -171,7 +168,7 @@ protected:
/** Stores if mobile is currently moving towards the ultimate, final destination */
bool m_bMovingToDestination;
-
+
/** Finds the first non-air block position (not the highest, as cWorld::GetHeight does)
If current Y is nonsolid, goes down to try to find a solid block, then returns that + 1
If current Y is solid, goes up to find first nonsolid block, and returns that */
@@ -230,14 +227,14 @@ protected:
int m_AttackRange;
float m_AttackInterval;
int m_SightDistance;
-
+
float m_DropChanceWeapon;
float m_DropChanceHelmet;
float m_DropChanceChestplate;
float m_DropChanceLeggings;
float m_DropChanceBoots;
bool m_CanPickUpLoot;
-
+
void HandleDaylightBurning(cChunk & a_Chunk);
bool m_BurnsInDaylight;
@@ -245,22 +242,18 @@ protected:
/** Adds a random number of a_Item between a_Min and a_Max to itemdrops a_Drops*/
void AddRandomDropItem(cItems & a_Drops, unsigned int a_Min, unsigned int a_Max, short a_Item, short a_ItemHealth = 0);
-
+
/** Adds a item a_Item with the chance of a_Chance (in percent) to itemdrops a_Drops*/
void AddRandomUncommonDropItem(cItems & a_Drops, float a_Chance, short a_Item, short a_ItemHealth = 0);
-
+
/** Adds one rare item out of the list of rare items a_Items modified by the looting level a_LootingLevel(I-III or custom) to the itemdrop a_Drops*/
void AddRandomRareDropItem(cItems & a_Drops, cItems & a_Items, short a_LootingLevel);
-
+
/** Adds armor that is equipped with the chance saved in m_DropChance[...] (this will be greter than 1 if piccked up or 0.085 + (0.01 per LootingLevel) if born with) to the drop*/
void AddRandomArmorDropItem(cItems & a_Drops, short a_LootingLevel);
-
+
/** Adds weapon that is equipped with the chance saved in m_DropChance[...] (this will be greter than 1 if piccked up or 0.085 + (0.01 per LootingLevel) if born with) to the drop*/
void AddRandomWeaponDropItem(cItems & a_Drops, short a_LootingLevel);
-
-
-} ; // tolua_export
-
-
+} ; // tolua_export
diff --git a/src/Mobs/MonsterTypes.h b/src/Mobs/MonsterTypes.h
index 7a73e99f4..852eb3446 100644
--- a/src/Mobs/MonsterTypes.h
+++ b/src/Mobs/MonsterTypes.h
@@ -37,5 +37,18 @@ enum eMonsterType
mtZombie = E_META_SPAWN_EGG_ZOMBIE,
mtZombiePigman = E_META_SPAWN_EGG_ZOMBIE_PIGMAN,
} ;
+
+
+
+
+
+/** Translates a mob string ("ocelot") to mobtype (mtOcelot).
+OBSOLETE, use cMonster::StringToMobType() instead.
+Implemented in Monster.cpp. */
+extern eMonsterType StringToMobType(const AString & a_MobString);
+
// tolua_end
+
+
+
diff --git a/src/Mobs/Mooshroom.cpp b/src/Mobs/Mooshroom.cpp
index 99958720f..ec533cfca 100644
--- a/src/Mobs/Mooshroom.cpp
+++ b/src/Mobs/Mooshroom.cpp
@@ -25,7 +25,7 @@ cMooshroom::cMooshroom(void) :
void cMooshroom::GetDrops(cItems & a_Drops, cEntity * a_Killer)
{
int LootingLevel = 0;
- if (a_Killer != NULL)
+ if (a_Killer != nullptr)
{
LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting);
}
diff --git a/src/Mobs/Mooshroom.h b/src/Mobs/Mooshroom.h
index fb002c2bf..754725c92 100644
--- a/src/Mobs/Mooshroom.h
+++ b/src/Mobs/Mooshroom.h
@@ -17,7 +17,7 @@ public:
CLASS_PROTODEF(cMooshroom)
- virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
+ virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
virtual void OnRightClicked(cPlayer & a_Player) override;
virtual const cItem GetFollowedItem(void) const override { return cItem(E_ITEM_WHEAT); }
diff --git a/src/Mobs/PassiveAggressiveMonster.cpp b/src/Mobs/PassiveAggressiveMonster.cpp
index e0cc2fd21..cb8650cb9 100644
--- a/src/Mobs/PassiveAggressiveMonster.cpp
+++ b/src/Mobs/PassiveAggressiveMonster.cpp
@@ -26,7 +26,7 @@ bool cPassiveAggressiveMonster::DoTakeDamage(TakeDamageInfo & a_TDI)
return false;
}
- if ((m_Target != NULL) && (m_Target->IsPlayer()))
+ if ((m_Target != nullptr) && (m_Target->IsPlayer()))
{
if (!((cPlayer *)m_Target)->IsGameModeCreative())
{
diff --git a/src/Mobs/PassiveMonster.cpp b/src/Mobs/PassiveMonster.cpp
index be3043e3d..1048616d0 100644
--- a/src/Mobs/PassiveMonster.cpp
+++ b/src/Mobs/PassiveMonster.cpp
@@ -24,7 +24,7 @@ bool cPassiveMonster::DoTakeDamage(TakeDamageInfo & a_TDI)
{
return false;
}
- if ((a_TDI.Attacker != this) && (a_TDI.Attacker != NULL))
+ if ((a_TDI.Attacker != this) && (a_TDI.Attacker != nullptr))
{
m_EMState = ESCAPING;
}
@@ -49,7 +49,7 @@ void cPassiveMonster::Tick(float a_Dt, cChunk & a_Chunk)
return;
}
cPlayer * a_Closest_Player = m_World->FindClosestPlayer(GetPosition(), (float)m_SightDistance);
- if (a_Closest_Player != NULL)
+ if (a_Closest_Player != nullptr)
{
if (a_Closest_Player->GetEquippedItem().IsEqual(FollowedItem))
{
diff --git a/src/Mobs/Pig.cpp b/src/Mobs/Pig.cpp
index 1f77cf613..55a4412ca 100644
--- a/src/Mobs/Pig.cpp
+++ b/src/Mobs/Pig.cpp
@@ -22,7 +22,7 @@ cPig::cPig(void) :
void cPig::GetDrops(cItems & a_Drops, cEntity * a_Killer)
{
int LootingLevel = 0;
- if (a_Killer != NULL)
+ if (a_Killer != nullptr)
{
LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting);
}
@@ -41,7 +41,7 @@ void cPig::OnRightClicked(cPlayer & a_Player)
{
if (m_bIsSaddled)
{
- if (m_Attachee != NULL)
+ if (m_Attachee != nullptr)
{
if (m_Attachee->GetUniqueID() == a_Player.GetUniqueID())
{
@@ -85,7 +85,7 @@ void cPig::Tick(float a_Dt, cChunk & a_Chunk)
super::Tick(a_Dt, a_Chunk);
// If the attachee player is holding a carrot-on-stick, let them drive this pig:
- if (m_bIsSaddled && (m_Attachee != NULL))
+ if (m_bIsSaddled && (m_Attachee != nullptr))
{
if (m_Attachee->IsPlayer() && (m_Attachee->GetEquippedWeapon().m_ItemType == E_ITEM_CARROT_ON_STICK))
{
diff --git a/src/Mobs/Pig.h b/src/Mobs/Pig.h
index 534a0ca6f..953850b3a 100644
--- a/src/Mobs/Pig.h
+++ b/src/Mobs/Pig.h
@@ -17,7 +17,7 @@ public:
CLASS_PROTODEF(cPig)
- virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
+ virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
virtual void OnRightClicked(cPlayer & a_Player) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
diff --git a/src/Mobs/Sheep.cpp b/src/Mobs/Sheep.cpp
index cbb33cb90..c46404391 100644
--- a/src/Mobs/Sheep.cpp
+++ b/src/Mobs/Sheep.cpp
@@ -41,7 +41,7 @@ void cSheep::GetDrops(cItems & a_Drops, cEntity * a_Killer)
}
int LootingLevel = 0;
- if (a_Killer != NULL)
+ if (a_Killer != nullptr)
{
LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting);
}
diff --git a/src/Mobs/Sheep.h b/src/Mobs/Sheep.h
index 28e1c7254..16d5fddd3 100644
--- a/src/Mobs/Sheep.h
+++ b/src/Mobs/Sheep.h
@@ -22,7 +22,7 @@ public:
CLASS_PROTODEF(cSheep)
- virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
+ virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
virtual void OnRightClicked(cPlayer & a_Player) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
diff --git a/src/Mobs/Skeleton.cpp b/src/Mobs/Skeleton.cpp
index cd707f4bb..f17bc307c 100644
--- a/src/Mobs/Skeleton.cpp
+++ b/src/Mobs/Skeleton.cpp
@@ -23,7 +23,7 @@ cSkeleton::cSkeleton(bool IsWither) :
void cSkeleton::GetDrops(cItems & a_Drops, cEntity * a_Killer)
{
int LootingLevel = 0;
- if (a_Killer != NULL)
+ if (a_Killer != nullptr)
{
LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting);
}
@@ -71,20 +71,20 @@ void cSkeleton::Attack(float a_Dt)
{
m_AttackInterval += a_Dt * m_AttackRate;
- if (m_Target != NULL && m_AttackInterval > 3.0)
+ if (m_Target != nullptr && m_AttackInterval > 3.0)
{
// Setting this higher gives us more wiggle room for attackrate
Vector3d Speed = GetLookVector() * 20;
Speed.y = Speed.y + 1;
cArrowEntity * Arrow = new cArrowEntity(this, GetPosX(), GetPosY() + 1, GetPosZ(), Speed);
- if (Arrow == NULL)
+ if (Arrow == nullptr)
{
return;
}
if (!Arrow->Initialize(*m_World))
{
delete Arrow;
- Arrow = NULL;
+ Arrow = nullptr;
return;
}
m_World->BroadcastSpawnEntity(*Arrow);
diff --git a/src/Mobs/Skeleton.h b/src/Mobs/Skeleton.h
index 577588b32..cd1c6c3f0 100644
--- a/src/Mobs/Skeleton.h
+++ b/src/Mobs/Skeleton.h
@@ -17,7 +17,7 @@ public:
CLASS_PROTODEF(cSkeleton)
- virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
+ virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
virtual void MoveToPosition(const Vector3d & a_Position) override;
virtual void Attack(float a_Dt) override;
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
diff --git a/src/Mobs/Slime.cpp b/src/Mobs/Slime.cpp
index b709ec664..1c68c5189 100644
--- a/src/Mobs/Slime.cpp
+++ b/src/Mobs/Slime.cpp
@@ -30,7 +30,7 @@ cSlime::cSlime(int a_Size) :
void cSlime::GetDrops(cItems & a_Drops, cEntity * a_Killer)
{
int LootingLevel = 0;
- if (a_Killer != NULL)
+ if (a_Killer != nullptr)
{
LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting);
}
diff --git a/src/Mobs/Slime.h b/src/Mobs/Slime.h
index f0b800f94..a177a279c 100644
--- a/src/Mobs/Slime.h
+++ b/src/Mobs/Slime.h
@@ -19,7 +19,7 @@ public:
CLASS_PROTODEF(cSlime)
// cAggressiveMonster overrides:
- virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
+ virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
virtual void Attack(float a_Dt) override;
virtual void KilledBy(TakeDamageInfo & a_TDI) override;
diff --git a/src/Mobs/SnowGolem.h b/src/Mobs/SnowGolem.h
index aba89e52d..f036b1867 100644
--- a/src/Mobs/SnowGolem.h
+++ b/src/Mobs/SnowGolem.h
@@ -18,7 +18,7 @@ public:
CLASS_PROTODEF(cSnowGolem)
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
- virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
+ virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
} ;
diff --git a/src/Mobs/Spider.cpp b/src/Mobs/Spider.cpp
index 8b978ff6b..deb263c41 100644
--- a/src/Mobs/Spider.cpp
+++ b/src/Mobs/Spider.cpp
@@ -19,12 +19,12 @@ cSpider::cSpider(void) :
void cSpider::GetDrops(cItems & a_Drops, cEntity * a_Killer)
{
int LootingLevel = 0;
- if (a_Killer != NULL)
+ if (a_Killer != nullptr)
{
LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting);
}
AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_STRING);
- if ((a_Killer != NULL) && (a_Killer->IsPlayer() || a_Killer->IsA("cWolf")))
+ if ((a_Killer != nullptr) && (a_Killer->IsPlayer() || a_Killer->IsA("cWolf")))
{
AddRandomUncommonDropItem(a_Drops, 33.0f, E_ITEM_SPIDER_EYE);
}
diff --git a/src/Mobs/Spider.h b/src/Mobs/Spider.h
index 813d2e266..24134c00f 100644
--- a/src/Mobs/Spider.h
+++ b/src/Mobs/Spider.h
@@ -17,7 +17,7 @@ public:
CLASS_PROTODEF(cSpider)
- virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
+ virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
} ;
diff --git a/src/Mobs/Squid.cpp b/src/Mobs/Squid.cpp
index bd0e141a0..59ee963ae 100644
--- a/src/Mobs/Squid.cpp
+++ b/src/Mobs/Squid.cpp
@@ -22,7 +22,7 @@ void cSquid::GetDrops(cItems & a_Drops, cEntity * a_Killer)
{
// Drops 0-3 Ink Sacs
int LootingLevel = 0;
- if (a_Killer != NULL)
+ if (a_Killer != nullptr)
{
LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting);
}
diff --git a/src/Mobs/Squid.h b/src/Mobs/Squid.h
index b57340427..a46d738c6 100644
--- a/src/Mobs/Squid.h
+++ b/src/Mobs/Squid.h
@@ -19,7 +19,7 @@ public:
CLASS_PROTODEF(cSquid)
- virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
+ virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
// Squids do not drown (or float)
virtual void HandleAir(void) override {}
diff --git a/src/Mobs/Villager.cpp b/src/Mobs/Villager.cpp
index 0efd5501e..5c9999a59 100644
--- a/src/Mobs/Villager.cpp
+++ b/src/Mobs/Villager.cpp
@@ -30,7 +30,7 @@ bool cVillager::DoTakeDamage(TakeDamageInfo & a_TDI)
return false;
}
- if ((a_TDI.Attacker != NULL) && a_TDI.Attacker->IsPlayer())
+ if ((a_TDI.Attacker != nullptr) && a_TDI.Attacker->IsPlayer())
{
if (m_World->GetTickRandomNumber(5) == 3)
{
diff --git a/src/Mobs/Witch.cpp b/src/Mobs/Witch.cpp
index 6956f7b7a..747a11f97 100644
--- a/src/Mobs/Witch.cpp
+++ b/src/Mobs/Witch.cpp
@@ -19,7 +19,7 @@ cWitch::cWitch(void) :
void cWitch::GetDrops(cItems & a_Drops, cEntity * a_Killer)
{
int LootingLevel = 0;
- if (a_Killer != NULL)
+ if (a_Killer != nullptr)
{
LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting);
}
diff --git a/src/Mobs/Witch.h b/src/Mobs/Witch.h
index bd059f61d..03691fef1 100644
--- a/src/Mobs/Witch.h
+++ b/src/Mobs/Witch.h
@@ -18,7 +18,7 @@ public:
CLASS_PROTODEF(cWitch)
- virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
+ virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
bool IsAngry(void) const {return ((m_EMState == ATTACKING) || (m_EMState == CHASING)); }
} ;
diff --git a/src/Mobs/Wither.h b/src/Mobs/Wither.h
index 2403823ed..a20fed3d3 100644
--- a/src/Mobs/Wither.h
+++ b/src/Mobs/Wither.h
@@ -26,7 +26,7 @@ public:
// cEntity overrides
virtual bool Initialize(cWorld & a_World) override;
- virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
+ virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
virtual void KilledBy(TakeDamageInfo & a_TDI) override;
diff --git a/src/Mobs/Wolf.cpp b/src/Mobs/Wolf.cpp
index 4fe1ff1d6..4711d5a7a 100644
--- a/src/Mobs/Wolf.cpp
+++ b/src/Mobs/Wolf.cpp
@@ -47,7 +47,7 @@ void cWolf::Attack(float a_Dt)
{
UNUSED(a_Dt);
- if ((m_Target != NULL) && (m_Target->IsPlayer()))
+ if ((m_Target != nullptr) && (m_Target->IsPlayer()))
{
if (((cPlayer *)m_Target)->GetName() != m_OwnerName)
{
@@ -157,7 +157,7 @@ void cWolf::Tick(float a_Dt, cChunk & a_Chunk)
}
cPlayer * a_Closest_Player = m_World->FindClosestPlayer(GetPosition(), (float)m_SightDistance);
- if (a_Closest_Player != NULL)
+ if (a_Closest_Player != nullptr)
{
switch (a_Closest_Player->GetEquippedItem().m_ItemType)
{
diff --git a/src/Mobs/Zombie.cpp b/src/Mobs/Zombie.cpp
index 30225c32d..63042e252 100644
--- a/src/Mobs/Zombie.cpp
+++ b/src/Mobs/Zombie.cpp
@@ -24,7 +24,7 @@ cZombie::cZombie(bool a_IsVillagerZombie) :
void cZombie::GetDrops(cItems & a_Drops, cEntity * a_Killer)
{
int LootingLevel = 0;
- if (a_Killer != NULL)
+ if (a_Killer != nullptr)
{
LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting);
}
diff --git a/src/Mobs/Zombie.h b/src/Mobs/Zombie.h
index 118b6e6e7..809c2a6fe 100644
--- a/src/Mobs/Zombie.h
+++ b/src/Mobs/Zombie.h
@@ -16,7 +16,7 @@ public:
CLASS_PROTODEF(cZombie)
- virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
+ virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
virtual void MoveToPosition(const Vector3d & a_Position) override;
virtual bool IsUndead(void) override { return true; }
diff --git a/src/Mobs/ZombiePigman.cpp b/src/Mobs/ZombiePigman.cpp
index 05350f877..8b415b0af 100644
--- a/src/Mobs/ZombiePigman.cpp
+++ b/src/Mobs/ZombiePigman.cpp
@@ -19,7 +19,7 @@ cZombiePigman::cZombiePigman(void) :
void cZombiePigman::GetDrops(cItems & a_Drops, cEntity * a_Killer)
{
int LootingLevel = 0;
- if (a_Killer != NULL)
+ if (a_Killer != nullptr)
{
LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting);
}
@@ -41,7 +41,7 @@ void cZombiePigman::KilledBy(TakeDamageInfo & a_TDI)
{
super::KilledBy(a_TDI);
- if ((a_TDI.Attacker != NULL) && (a_TDI.Attacker->IsPlayer()))
+ if ((a_TDI.Attacker != nullptr) && (a_TDI.Attacker->IsPlayer()))
{
// TODO: Anger all nearby zombie pigmen
// TODO: In vanilla, if one player angers ZPs, do they attack any nearby player, or only that one attacker?
diff --git a/src/Mobs/ZombiePigman.h b/src/Mobs/ZombiePigman.h
index bae0115eb..d8b886ca4 100644
--- a/src/Mobs/ZombiePigman.h
+++ b/src/Mobs/ZombiePigman.h
@@ -16,7 +16,7 @@ public:
CLASS_PROTODEF(cZombiePigman)
- virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
+ virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
virtual void KilledBy(TakeDamageInfo & a_TDI) override;
virtual bool IsUndead(void) override { return true; }