summaryrefslogtreecommitdiffstats
path: root/src/Mobs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Mobs')
-rw-r--r--src/Mobs/AggressiveMonster.cpp2
-rw-r--r--src/Mobs/CMakeLists.txt76
-rw-r--r--src/Mobs/Creeper.cpp4
-rw-r--r--src/Mobs/Horse.cpp2
-rw-r--r--src/Mobs/Monster.cpp79
-rw-r--r--src/Mobs/Monster.h33
-rw-r--r--src/Mobs/Sheep.cpp4
-rw-r--r--src/Mobs/Skeleton.cpp17
-rw-r--r--src/Mobs/Skeleton.h6
-rw-r--r--src/Mobs/Slime.cpp76
-rw-r--r--src/Mobs/Slime.h13
-rw-r--r--src/Mobs/Villager.cpp6
-rw-r--r--src/Mobs/Villager.h5
-rw-r--r--src/Mobs/Wither.h2
-rw-r--r--src/Mobs/Wolf.cpp8
-rw-r--r--src/Mobs/Zombie.cpp2
-rw-r--r--src/Mobs/Zombie.h8
-rw-r--r--src/Mobs/ZombiePigman.h2
18 files changed, 237 insertions, 108 deletions
diff --git a/src/Mobs/AggressiveMonster.cpp b/src/Mobs/AggressiveMonster.cpp
index de881f4eb..5f5b1853d 100644
--- a/src/Mobs/AggressiveMonster.cpp
+++ b/src/Mobs/AggressiveMonster.cpp
@@ -42,7 +42,7 @@ void cAggressiveMonster::InStateChasing(float a_Dt)
MoveToPosition(m_Target->GetPosition());
}
}
-}
+}
diff --git a/src/Mobs/CMakeLists.txt b/src/Mobs/CMakeLists.txt
index 53c265803..2c092c15f 100644
--- a/src/Mobs/CMakeLists.txt
+++ b/src/Mobs/CMakeLists.txt
@@ -4,9 +4,75 @@ project (MCServer)
include_directories ("${PROJECT_SOURCE_DIR}/../")
-file(GLOB SOURCE
- "*.cpp"
- "*.h"
-)
+SET (SRCS
+ AggressiveMonster.cpp
+ Bat.cpp
+ Blaze.cpp
+ CaveSpider.cpp
+ Chicken.cpp
+ Cow.cpp
+ Creeper.cpp
+ EnderDragon.cpp
+ Enderman.cpp
+ Ghast.cpp
+ Giant.cpp
+ Horse.cpp
+ IronGolem.cpp
+ MagmaCube.cpp
+ Monster.cpp
+ Mooshroom.cpp
+ PassiveAggressiveMonster.cpp
+ PassiveMonster.cpp
+ Pig.cpp
+ Sheep.cpp
+ Skeleton.cpp
+ Slime.cpp
+ SnowGolem.cpp
+ Spider.cpp
+ Squid.cpp
+ Villager.cpp
+ Witch.cpp
+ Wither.cpp
+ Wolf.cpp
+ Zombie.cpp
+ ZombiePigman.cpp)
+
+SET (HDRS
+ AggressiveMonster.h
+ Bat.h
+ Blaze.h
+ CaveSpider.h
+ Chicken.h
+ Cow.h
+ Creeper.h
+ EnderDragon.h
+ Enderman.h
+ Ghast.h
+ Giant.h
+ Horse.h
+ IncludeAllMonsters.h
+ IronGolem.h
+ MagmaCube.h
+ Monster.h
+ Mooshroom.h
+ Ocelot.h
+ PassiveAggressiveMonster.h
+ PassiveMonster.h
+ Pig.h
+ Sheep.h
+ Silverfish.h
+ Skeleton.h
+ Slime.h
+ SnowGolem.h
+ Spider.h
+ Squid.h
+ Villager.h
+ Witch.h
+ Wither.h
+ Wolf.h
+ Zombie.h
+ ZombiePigman.h)
-add_library(Mobs ${SOURCE})
+if(NOT MSVC)
+ add_library(Mobs ${SRCS} ${HDRS})
+endif()
diff --git a/src/Mobs/Creeper.cpp b/src/Mobs/Creeper.cpp
index 8ab09a4c5..02718edf8 100644
--- a/src/Mobs/Creeper.cpp
+++ b/src/Mobs/Creeper.cpp
@@ -37,13 +37,13 @@ void cCreeper::Tick(float a_Dt, cChunk & a_Chunk)
{
if (m_bIsBlowing)
{
- m_ExplodingTimer += 1;
+ m_ExplodingTimer += 1;
}
if (m_ExplodingTimer == 30)
{
m_World->DoExplosionAt((m_bIsCharged ? 5 : 3), GetPosX(), GetPosY(), GetPosZ(), false, esMonster, this);
- Destroy(); // Just in case we aren't killed by the explosion
+ Destroy(); // Just in case we aren't killed by the explosion
}
}
}
diff --git a/src/Mobs/Horse.cpp b/src/Mobs/Horse.cpp
index 9d130301f..67a09d4ab 100644
--- a/src/Mobs/Horse.cpp
+++ b/src/Mobs/Horse.cpp
@@ -63,7 +63,7 @@ void cHorse::Tick(float a_Dt, cChunk & a_Chunk)
m_Attachee->Detach();
m_bIsRearing = true;
}
- }
+ }
else
{
m_bIsTame = true;
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp
index e36634c73..753a44914 100644
--- a/src/Mobs/Monster.cpp
+++ b/src/Mobs/Monster.cpp
@@ -62,7 +62,7 @@ static const struct
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// cMonster:
cMonster::cMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height)
@@ -115,12 +115,10 @@ void cMonster::TickPathFinding()
const int PosY = POSY_TOINT;
const int PosZ = POSZ_TOINT;
- m_FinalDestination.y = (double)FindFirstNonAirBlockPosition(m_FinalDestination.x, m_FinalDestination.z);
-
std::vector<Vector3d> m_PotentialCoordinates;
m_TraversedCoordinates.push_back(Vector3i(PosX, PosY, PosZ));
- static const struct // Define which directions to try to move to
+ static const struct // Define which directions to try to move to
{
int x, z;
} gCrossCoords[] =
@@ -128,7 +126,7 @@ void cMonster::TickPathFinding()
{ 1, 0},
{-1, 0},
{ 0, 1},
- { 0,-1},
+ { 0, -1},
} ;
if ((PosY - 1 < 0) || (PosY + 2 > cChunkDef::Height) /* PosY + 1 will never be true if PosY + 2 is not */)
@@ -201,19 +199,6 @@ void cMonster::TickPathFinding()
-void cMonster::MoveToPosition(const Vector3f & a_Position)
-{
- FinishPathFinding();
-
- m_FinalDestination = a_Position;
- m_bMovingToDestination = true;
- TickPathFinding();
-}
-
-
-
-
-
void cMonster::MoveToPosition(const Vector3d & a_Position)
{
FinishPathFinding();
@@ -227,15 +212,7 @@ void cMonster::MoveToPosition(const Vector3d & a_Position)
bool cMonster::IsCoordinateInTraversedList(Vector3i a_Coords)
{
- for (std::vector<Vector3i>::const_iterator itr = m_TraversedCoordinates.begin(); itr != m_TraversedCoordinates.end(); ++itr)
- {
- if (itr->Equals(a_Coords))
- {
- return true;
- }
- }
-
- return false;
+ return (std::find(m_TraversedCoordinates.begin(), m_TraversedCoordinates.end(), a_Coords) != m_TraversedCoordinates.end());
}
@@ -296,17 +273,15 @@ void cMonster::Tick(float a_Dt, cChunk & a_Chunk)
{
if (m_bOnGround)
{
- m_Destination.y = FindFirstNonAirBlockPosition(m_Destination.x, m_Destination.z);
-
if (DoesPosYRequireJump((int)floor(m_Destination.y)))
{
m_bOnGround = false;
- AddSpeedY(5.2); // Jump!!
+ AddSpeedY(5.2); // Jump!!
}
}
Vector3f Distance = m_Destination - GetPosition();
- if(!ReachedDestination() && !ReachedFinalDestination()) // If we haven't reached any sort of destination, move
+ if(!ReachedDestination() && !ReachedFinalDestination()) // If we haven't reached any sort of destination, move
{
Distance.y = 0;
Distance.Normalize();
@@ -325,20 +300,20 @@ void cMonster::Tick(float a_Dt, cChunk & a_Chunk)
AddSpeedZ(Distance.z);
if (m_EMState == ESCAPING)
- { //Runs Faster when escaping :D otherwise they just walk away
+ { // Runs Faster when escaping :D otherwise they just walk away
SetSpeedX (GetSpeedX() * 2.f);
SetSpeedZ (GetSpeedZ() * 2.f);
}
}
else
{
- if (ReachedFinalDestination()) // If we have reached the ultimate, final destination, stop pathfinding and attack if appropriate
+ if (ReachedFinalDestination()) // If we have reached the ultimate, final destination, stop pathfinding and attack if appropriate
{
FinishPathFinding();
}
else
{
- TickPathFinding(); // We have reached the next point in our path, calculate another point
+ TickPathFinding(); // We have reached the next point in our path, calculate another point
}
}
}
@@ -353,13 +328,13 @@ void cMonster::Tick(float a_Dt, cChunk & a_Chunk)
// If enemy passive we ignore checks for player visibility
InStateIdle(a_Dt);
break;
- }
+ }
case CHASING:
{
// If we do not see a player anymore skip chasing action
InStateChasing(a_Dt);
break;
- }
+ }
case ESCAPING:
{
InStateEscaping(a_Dt);
@@ -439,11 +414,7 @@ void cMonster::HandleFalling()
int cMonster::FindFirstNonAirBlockPosition(double a_PosX, double a_PosZ)
{
int PosY = POSY_TOINT;
-
- if (PosY < 0)
- PosY = 0;
- else if (PosY > cChunkDef::Height)
- PosY = cChunkDef::Height;
+ PosY = Clamp(PosY, 0, cChunkDef::Height);
if (!cBlockInfo::IsSolid(m_World->GetBlock((int)floor(a_PosX), PosY, (int)floor(a_PosZ))))
{
@@ -570,8 +541,8 @@ void cMonster::KilledBy(TakeDamageInfo & a_TDI)
-//Checks to see if EventSeePlayer should be fired
-//monster sez: Do I see the player
+// Checks to see if EventSeePlayer should be fired
+// monster sez: Do I see the player
void cMonster::CheckEventSeePlayer(void)
{
// TODO: Rewrite this to use cWorld's DoWithPlayers()
@@ -588,7 +559,7 @@ void cMonster::CheckEventSeePlayer(void)
void cMonster::CheckEventLostPlayer(void)
-{
+{
if (m_Target != NULL)
{
if ((m_Target->GetPosition() - GetPosition()).Length() > m_SightDistance)
@@ -631,7 +602,7 @@ void cMonster::InStateIdle(float a_Dt)
{
if (m_bMovingToDestination)
{
- return; // Still getting there
+ return; // Still getting there
}
m_IdleInterval += a_Dt;
@@ -640,7 +611,7 @@ void cMonster::InStateIdle(float a_Dt)
{
// At this interval the results are predictable
int rem = m_World->GetTickRandomNumber(6) + 1;
- m_IdleInterval -= 1; // So nothing gets dropped when the server hangs for a few seconds
+ m_IdleInterval -= 1; // So nothing gets dropped when the server hangs for a few seconds
Vector3d Dist;
Dist.x = (double)m_World->GetTickRandomNumber(10) - 5;
@@ -709,16 +680,6 @@ void cMonster::GetMonsterConfig(const AString & a_Name)
bool cMonster::IsUndead(void)
{
- switch (GetMobType())
- {
- case mtZombie:
- case mtZombiePigman:
- case mtSkeleton:
- case mtWither:
- {
- return true;
- }
- }
return false;
}
@@ -867,13 +828,13 @@ cMonster * cMonster::NewMonsterFromType(cMonster::eType a_MobType)
}
case mtSlime:
{
- toReturn = new cSlime(Random.NextInt(2) + 1);
+ toReturn = new cSlime(1 << Random.NextInt(3)); // Size 1, 2 or 4
break;
}
case mtSkeleton:
{
// TODO: Actual detection of spawning in Nether
- toReturn = new cSkeleton(Random.NextInt(1) == 0 ? false : true);
+ toReturn = new cSkeleton((Random.NextInt(1) == 0) ? false : true);
break;
}
case mtVillager:
@@ -928,7 +889,7 @@ cMonster * cMonster::NewMonsterFromType(cMonster::eType a_MobType)
case mtWitch: toReturn = new cWitch(); break;
case mtWither: toReturn = new cWither(); break;
case mtWolf: toReturn = new cWolf(); break;
- case mtZombie: toReturn = new cZombie(false); break; // TODO: Infected zombie parameter
+ case mtZombie: toReturn = new cZombie(false); break; // TODO: Infected zombie parameter
case mtZombiePigman: toReturn = new cZombiePigman(); break;
default:
{
diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h
index 59bcdaa37..ffd078505 100644
--- a/src/Mobs/Monster.h
+++ b/src/Mobs/Monster.h
@@ -61,24 +61,24 @@ public:
enum eFamily
{
- mfHostile = 0, // Spider, Zombies ...
- mfPassive = 1, // Cows, Pigs
- mfAmbient = 2, // Bats
- mfWater = 3, // Squid
+ mfHostile = 0, // Spider, Zombies ...
+ mfPassive = 1, // Cows, Pigs
+ mfAmbient = 2, // Bats
+ mfWater = 3, // Squid
mfNoSpawn,
- mfUnhandled, // Nothing. Be sure this is the last and the others are in order
+ 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;
+ 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
+ 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, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
@@ -92,8 +92,7 @@ public:
virtual void KilledBy(TakeDamageInfo & a_TDI) override;
- virtual void MoveToPosition(const Vector3f & a_Position);
- virtual void MoveToPosition(const Vector3d & a_Position); // tolua_export
+ virtual void MoveToPosition(const Vector3d & a_Position); // tolua_export
virtual bool ReachedDestination(void);
// tolua_begin
@@ -108,7 +107,7 @@ public:
void GetMonsterConfig(const AString & a_Name);
/** Returns whether this mob is undead (skeleton, zombie, etc.) */
- bool IsUndead(void);
+ virtual bool IsUndead(void);
virtual void EventLosePlayer(void);
virtual void CheckEventLostPlayer(void);
@@ -233,7 +232,7 @@ protected:
AString m_SoundHurt;
AString m_SoundDeath;
- float m_AttackRate;
+ float m_AttackRate;
int m_AttackDamage;
int m_AttackRange;
float m_AttackInterval;
@@ -250,13 +249,13 @@ protected:
bool m_BurnsInDaylight;
/** 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);
+ 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);
+ 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);
+ 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);
@@ -265,7 +264,7 @@ protected:
void AddRandomWeaponDropItem(cItems & a_Drops, short a_LootingLevel);
-} ; // tolua_export
+} ; // tolua_export
diff --git a/src/Mobs/Sheep.cpp b/src/Mobs/Sheep.cpp
index 019f9e6a2..7335848b7 100644
--- a/src/Mobs/Sheep.cpp
+++ b/src/Mobs/Sheep.cpp
@@ -93,12 +93,12 @@ void cSheep::Tick(float a_Dt, cChunk & a_Chunk)
if (m_TimeToStopEating > 0)
{
- m_bMovingToDestination = false; // The sheep should not move when he's eating
+ m_bMovingToDestination = false; // The sheep should not move when he's eating
m_TimeToStopEating--;
if (m_TimeToStopEating == 0)
{
- if (m_World->GetBlock(PosX, PosY, PosZ) == E_BLOCK_GRASS) // Make sure grass hasn't been destroyed in the meantime
+ if (m_World->GetBlock(PosX, PosY, PosZ) == E_BLOCK_GRASS) // Make sure grass hasn't been destroyed in the meantime
{
// The sheep ate the grass so we change it to dirt
m_World->SetBlock(PosX, PosY, PosZ, E_BLOCK_DIRT, 0);
diff --git a/src/Mobs/Skeleton.cpp b/src/Mobs/Skeleton.cpp
index 0641a3d57..cd707f4bb 100644
--- a/src/Mobs/Skeleton.cpp
+++ b/src/Mobs/Skeleton.cpp
@@ -4,6 +4,7 @@
#include "Skeleton.h"
#include "../World.h"
#include "../Entities/ArrowEntity.h"
+#include "ClientHandle.h"
@@ -47,7 +48,7 @@ void cSkeleton::GetDrops(cItems & a_Drops, cEntity * a_Killer)
-void cSkeleton::MoveToPosition(const Vector3f & a_Position)
+void cSkeleton::MoveToPosition(const Vector3d & a_Position)
{
// If the destination is sufficiently skylight challenged AND the skeleton isn't on fire then block the movement
if (
@@ -90,3 +91,17 @@ void cSkeleton::Attack(float a_Dt)
m_AttackInterval = 0.0;
}
}
+
+
+
+
+
+void cSkeleton::SpawnOn(cClientHandle & a_ClientHandle)
+{
+ super::SpawnOn(a_ClientHandle);
+ a_ClientHandle.SendEntityEquipment(*this, 0, cItem(E_ITEM_BOW));
+}
+
+
+
+
diff --git a/src/Mobs/Skeleton.h b/src/Mobs/Skeleton.h
index 8f31b42e1..9a121ef48 100644
--- a/src/Mobs/Skeleton.h
+++ b/src/Mobs/Skeleton.h
@@ -18,8 +18,12 @@ public:
CLASS_PROTODEF(cSkeleton);
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
- virtual void MoveToPosition(const Vector3f & a_Position) override;
+ virtual void MoveToPosition(const Vector3d & a_Position) override;
virtual void Attack(float a_Dt) override;
+ virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
+
+ virtual bool IsUndead(void) override { return true; }
+
bool IsWither(void) const { return m_bIsWither; };
private:
diff --git a/src/Mobs/Slime.cpp b/src/Mobs/Slime.cpp
index 52a52bb39..b709ec664 100644
--- a/src/Mobs/Slime.cpp
+++ b/src/Mobs/Slime.cpp
@@ -2,16 +2,25 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "Slime.h"
+#include "FastRandom.h"
+#include "World.h"
-/// Creates a slime of the specified size; size is 1 .. 3, with 1 being the smallest
cSlime::cSlime(int a_Size) :
- super("Slime", mtSlime, "mob.slime.attack", "mob.slime.attack", 0.6 * a_Size, 0.6 * a_Size),
+ super("Slime",
+ mtSlime,
+ Printf("mob.slime.%s", GetSizeName(a_Size).c_str()),
+ Printf("mob.slime.%s", GetSizeName(a_Size).c_str()),
+ 0.6 * a_Size,
+ 0.6 * a_Size
+ ),
m_Size(a_Size)
{
+ SetMaxHealth(a_Size * a_Size);
+ SetAttackDamage(a_Size);
}
@@ -25,7 +34,9 @@ void cSlime::GetDrops(cItems & a_Drops, cEntity * a_Killer)
{
LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting);
}
- if (GetSize() == 1)
+
+ // Only slimes with the size 1 can drop slimeballs.
+ if (m_Size == 1)
{
AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_SLIMEBALL);
}
@@ -34,3 +45,62 @@ void cSlime::GetDrops(cItems & a_Drops, cEntity * a_Killer)
+
+void cSlime::Attack(float a_Dt)
+{
+ if (m_Size > 1)
+ {
+ // Only slimes larger than size 1 attack a player.
+ super::Attack(a_Dt);
+ }
+}
+
+
+
+
+
+void cSlime::KilledBy(TakeDamageInfo & a_TDI)
+{
+ if (GetHealth() > 0)
+ {
+ return;
+ }
+
+ if (m_Size != 1)
+ {
+ cFastRandom Random;
+ int SpawnAmount = 2 + Random.NextInt(3);
+
+ for (int i = 0; i < SpawnAmount; ++i)
+ {
+ double AddX = (i % 2 - 0.5) * m_Size / 4.0;
+ double AddZ = (i / 2 - 0.5) * m_Size / 4.0;
+
+ cSlime * NewSlime = new cSlime(m_Size / 2);
+ NewSlime->SetPosition(GetPosX() + AddX, GetPosY() + 0.5, GetPosZ() + AddZ);
+ NewSlime->SetYaw(Random.NextFloat(1.0f) * 360.0f);
+ m_World->SpawnMobFinalize(NewSlime);
+ }
+ }
+ super::KilledBy(a_TDI);
+}
+
+
+
+
+
+const AString cSlime::GetSizeName(int a_Size) const
+{
+ if (a_Size > 1)
+ {
+ return "big";
+ }
+ else
+ {
+ return "small";
+ }
+}
+
+
+
+
diff --git a/src/Mobs/Slime.h b/src/Mobs/Slime.h
index 782c3113f..15ae113dc 100644
--- a/src/Mobs/Slime.h
+++ b/src/Mobs/Slime.h
@@ -13,17 +13,26 @@ class cSlime :
typedef cAggressiveMonster super;
public:
- /// Creates a slime of the specified size; size is 1 .. 3, with 1 being the smallest
+ /** Creates a slime of the specified size; size can be 1, 2 or 4, with 1 is the smallest and 4 is the tallest. */
cSlime(int a_Size);
CLASS_PROTODEF(cSlime);
+ // cAggressiveMonster overrides:
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
+ virtual void Attack(float a_Dt) override;
+ virtual void KilledBy(TakeDamageInfo & a_TDI) override;
+
int GetSize(void) const { return m_Size; }
+ /** Returns the text describing the slime's size, as used by the client's resource subsystem for sounds.
+ Returns either "big" or "small". */
+ const AString GetSizeName(int a_Size) const;
+
protected:
- /// Size of the slime, 1 .. 3, with 1 being the smallest
+ /** Size of the slime, with 1 being the smallest.
+ Vanilla uses sizes 1, 2 and 4 only. */
int m_Size;
} ;
diff --git a/src/Mobs/Villager.cpp b/src/Mobs/Villager.cpp
index 41283acf4..1cdac7c74 100644
--- a/src/Mobs/Villager.cpp
+++ b/src/Mobs/Villager.cpp
@@ -55,7 +55,7 @@ void cVillager::Tick(float a_Dt, cChunk & a_Chunk)
{
switch (m_Type)
{
- case vtFarmer:
+ case vtFarmer:
{
HandleFarmerPlaceCrops();
}
@@ -138,8 +138,8 @@ void cVillager::HandleFarmerPrepareFarmCrops()
m_CropsPos = Vector3i((int) GetPosX() + X - 5, (int) GetPosY() + Y - 3, (int) GetPosZ() + Z - 5);
MoveToPosition(Vector3f((float) (m_CropsPos.x + 0.5), (float) m_CropsPos.y, (float) (m_CropsPos.z + 0.5)));
return;
- } // for Y loop.
- } // Repeat the procces 5 times.
+ } // for Y loop.
+ } // Repeat the procces 5 times.
}
diff --git a/src/Mobs/Villager.h b/src/Mobs/Villager.h
index abde48407..068dfd835 100644
--- a/src/Mobs/Villager.h
+++ b/src/Mobs/Villager.h
@@ -37,9 +37,8 @@ public:
/** return true if the given blocktype are: crops, potatoes or carrots.*/
bool IsBlockFarmable(BLOCKTYPE a_BlockType);
- //////////////////////////////////////////////////////////////////
// Farmer functions
- /** It searches in a 11x7x11 area for crops. If it found some it will navigate to them.*/
+ /** Searches in a 11x7x11 area for crops. If it found some it will navigate to them.*/
void HandleFarmerPrepareFarmCrops();
/** Looks if the farmer has reached it's destination, and if it's still crops and the destination is closer then 2 blocks it will harvest them.*/
@@ -49,7 +48,7 @@ public:
void HandleFarmerPlaceCrops();
// Get and set functions.
- int GetVilType(void) const { return m_Type; }
+ int GetVilType(void) const { return m_Type; }
Vector3i GetCropsPos(void) const { return m_CropsPos; }
bool DoesHaveActionActivated(void) const { return m_VillagerAction; }
diff --git a/src/Mobs/Wither.h b/src/Mobs/Wither.h
index 7d76f70f5..cc8d1459b 100644
--- a/src/Mobs/Wither.h
+++ b/src/Mobs/Wither.h
@@ -30,6 +30,8 @@ public:
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
virtual void KilledBy(TakeDamageInfo & a_TDI) override;
+
+ virtual bool IsUndead(void) override { return true; }
private:
diff --git a/src/Mobs/Wolf.cpp b/src/Mobs/Wolf.cpp
index e6268abc7..5bb97d30e 100644
--- a/src/Mobs/Wolf.cpp
+++ b/src/Mobs/Wolf.cpp
@@ -36,7 +36,7 @@ bool cWolf::DoTakeDamage(TakeDamageInfo & a_TDI)
{
m_IsAngry = true;
}
- m_World->BroadcastEntityMetadata(*this); // Broadcast health and possibly angry face
+ m_World->BroadcastEntityMetadata(*this); // Broadcast health and possibly angry face
return true;
}
@@ -114,7 +114,7 @@ void cWolf::OnRightClicked(cPlayer & a_Player)
}
case E_ITEM_DYE:
{
- if (a_Player.GetName() == m_OwnerName) // Is the player the owner of the dog?
+ if (a_Player.GetName() == m_OwnerName) // Is the player the owner of the dog?
{
SetCollarColor(15 - a_Player.GetEquippedItem().m_ItemDamage);
if (!a_Player.IsGameModeCreative())
@@ -126,7 +126,7 @@ void cWolf::OnRightClicked(cPlayer & a_Player)
}
default:
{
- if (a_Player.GetName() == m_OwnerName) // Is the player the owner of the dog?
+ if (a_Player.GetName() == m_OwnerName) // Is the player the owner of the dog?
{
SetIsSitting(!IsSitting());
}
@@ -172,7 +172,7 @@ void cWolf::Tick(float a_Dt, cChunk & a_Chunk)
m_World->BroadcastEntityMetadata(*this);
}
- m_FinalDestination = a_Closest_Player->GetPosition(); // So that we will look at a player holding food
+ 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())
diff --git a/src/Mobs/Zombie.cpp b/src/Mobs/Zombie.cpp
index 725790ed9..30225c32d 100644
--- a/src/Mobs/Zombie.cpp
+++ b/src/Mobs/Zombie.cpp
@@ -42,7 +42,7 @@ void cZombie::GetDrops(cItems & a_Drops, cEntity * a_Killer)
-void cZombie::MoveToPosition(const Vector3f & a_Position)
+void cZombie::MoveToPosition(const Vector3d & a_Position)
{
// If the destination is sufficiently skylight challenged AND the skeleton isn't on fire then block the movement
if (
diff --git a/src/Mobs/Zombie.h b/src/Mobs/Zombie.h
index 1ba368f9c..082573d8b 100644
--- a/src/Mobs/Zombie.h
+++ b/src/Mobs/Zombie.h
@@ -17,10 +17,12 @@ public:
CLASS_PROTODEF(cZombie);
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
- virtual void MoveToPosition(const Vector3f & a_Position) override;
+ virtual void MoveToPosition(const Vector3d & a_Position) override;
- bool IsVillagerZombie(void) const {return m_IsVillagerZombie; }
- bool IsConverting (void) const {return m_IsConverting; }
+ virtual bool IsUndead(void) override { return true; }
+
+ bool IsVillagerZombie(void) const { return m_IsVillagerZombie; }
+ bool IsConverting (void) const { return m_IsConverting; }
private:
diff --git a/src/Mobs/ZombiePigman.h b/src/Mobs/ZombiePigman.h
index a2ebc87cb..a4bad7efb 100644
--- a/src/Mobs/ZombiePigman.h
+++ b/src/Mobs/ZombiePigman.h
@@ -18,6 +18,8 @@ public:
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
virtual void KilledBy(TakeDamageInfo & a_TDI) override;
+
+ virtual bool IsUndead(void) override { return true; }
} ;