summaryrefslogtreecommitdiffstats
path: root/src/Mobs/Monster.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Mobs/Monster.cpp38
1 files changed, 24 insertions, 14 deletions
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)