summaryrefslogtreecommitdiffstats
path: root/src/Mobs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Mobs/CMakeLists.txt1
-rw-r--r--src/Mobs/CaveSpider.cpp (renamed from src/Mobs/Cavespider.cpp)11
-rw-r--r--src/Mobs/CaveSpider.h (renamed from src/Mobs/Cavespider.h)5
-rw-r--r--src/Mobs/IncludeAllMonsters.h6
-rw-r--r--src/Mobs/MagmaCube.cpp (renamed from src/Mobs/Magmacube.cpp)3
-rw-r--r--src/Mobs/MagmaCube.h (renamed from src/Mobs/Magmacube.h)1
-rw-r--r--src/Mobs/Monster.cpp48
-rw-r--r--src/Mobs/Monster.h4
-rw-r--r--src/Mobs/Sheep.cpp9
-rw-r--r--src/Mobs/Villager.cpp2
-rw-r--r--src/Mobs/Wolf.cpp4
-rw-r--r--src/Mobs/Wolf.h2
-rw-r--r--src/Mobs/ZombiePigman.cpp (renamed from src/Mobs/Zombiepigman.cpp)3
-rw-r--r--src/Mobs/ZombiePigman.h (renamed from src/Mobs/Zombiepigman.h)1
14 files changed, 57 insertions, 43 deletions
diff --git a/src/Mobs/CMakeLists.txt b/src/Mobs/CMakeLists.txt
index 87fbfd2fc..53c265803 100644
--- a/src/Mobs/CMakeLists.txt
+++ b/src/Mobs/CMakeLists.txt
@@ -6,6 +6,7 @@ include_directories ("${PROJECT_SOURCE_DIR}/../")
file(GLOB SOURCE
"*.cpp"
+ "*.h"
)
add_library(Mobs ${SOURCE})
diff --git a/src/Mobs/Cavespider.cpp b/src/Mobs/CaveSpider.cpp
index 94e93283d..56ecd2d28 100644
--- a/src/Mobs/Cavespider.cpp
+++ b/src/Mobs/CaveSpider.cpp
@@ -1,15 +1,14 @@
-
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
-#include "Cavespider.h"
+#include "CaveSpider.h"
#include "../World.h"
-cCavespider::cCavespider(void) :
- super("Cavespider", mtCaveSpider, "mob.spider.say", "mob.spider.death", 0.7, 0.5)
+cCaveSpider::cCaveSpider(void) :
+ super("CaveSpider", mtCaveSpider, "mob.spider.say", "mob.spider.death", 0.7, 0.5)
{
}
@@ -17,7 +16,7 @@ cCavespider::cCavespider(void) :
-void cCavespider::Tick(float a_Dt, cChunk & a_Chunk)
+void cCaveSpider::Tick(float a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
@@ -29,7 +28,7 @@ void cCavespider::Tick(float a_Dt, cChunk & a_Chunk)
-void cCavespider::GetDrops(cItems & a_Drops, cEntity * a_Killer)
+void cCaveSpider::GetDrops(cItems & a_Drops, cEntity * a_Killer)
{
int LootingLevel = 0;
if (a_Killer != NULL)
diff --git a/src/Mobs/Cavespider.h b/src/Mobs/CaveSpider.h
index 10ea03f7b..be9f174f9 100644
--- a/src/Mobs/Cavespider.h
+++ b/src/Mobs/CaveSpider.h
@@ -1,4 +1,3 @@
-
#pragma once
#include "AggressiveMonster.h"
@@ -7,13 +6,13 @@
-class cCavespider :
+class cCaveSpider :
public cAggressiveMonster
{
typedef cAggressiveMonster super;
public:
- cCavespider(void);
+ cCaveSpider(void);
CLASS_PROTODEF(cCaveSpider);
diff --git a/src/Mobs/IncludeAllMonsters.h b/src/Mobs/IncludeAllMonsters.h
index 1b436a11f..3460db993 100644
--- a/src/Mobs/IncludeAllMonsters.h
+++ b/src/Mobs/IncludeAllMonsters.h
@@ -1,6 +1,6 @@
#include "Bat.h"
#include "Blaze.h"
-#include "Cavespider.h"
+#include "CaveSpider.h"
#include "Chicken.h"
#include "Cow.h"
#include "Creeper.h"
@@ -10,7 +10,7 @@
#include "Giant.h"
#include "Horse.h"
#include "IronGolem.h"
-#include "Magmacube.h"
+#include "MagmaCube.h"
#include "Mooshroom.h"
#include "Ocelot.h"
#include "Pig.h"
@@ -26,4 +26,4 @@
#include "Wither.h"
#include "Wolf.h"
#include "Zombie.h"
-#include "Zombiepigman.h"
+#include "ZombiePigman.h"
diff --git a/src/Mobs/Magmacube.cpp b/src/Mobs/MagmaCube.cpp
index 05405f082..3e9abc108 100644
--- a/src/Mobs/Magmacube.cpp
+++ b/src/Mobs/MagmaCube.cpp
@@ -1,7 +1,6 @@
-
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
-#include "Magmacube.h"
+#include "MagmaCube.h"
diff --git a/src/Mobs/Magmacube.h b/src/Mobs/MagmaCube.h
index 130952970..43065cae5 100644
--- a/src/Mobs/Magmacube.h
+++ b/src/Mobs/MagmaCube.h
@@ -1,4 +1,3 @@
-
#pragma once
#include "AggressiveMonster.h"
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp
index aa6071515..eb8480268 100644
--- a/src/Mobs/Monster.cpp
+++ b/src/Mobs/Monster.cpp
@@ -111,9 +111,9 @@ void cMonster::SpawnOn(cClientHandle & a_Client)
void cMonster::TickPathFinding()
{
- const int PosX = (int)floor(GetPosX());
- const int PosY = (int)floor(GetPosY());
- const int PosZ = (int)floor(GetPosZ());
+ const int PosX = POSX_TOINT;
+ const int PosY = POSY_TOINT;
+ const int PosZ = POSZ_TOINT;
m_FinalDestination.y = (double)FindFirstNonAirBlockPosition(m_FinalDestination.x, m_FinalDestination.z);
@@ -148,13 +148,27 @@ void cMonster::TickPathFinding()
BLOCKTYPE BlockAtY = m_World->GetBlock(gCrossCoords[i].x + PosX, PosY, gCrossCoords[i].z + PosZ);
BLOCKTYPE BlockAtYP = m_World->GetBlock(gCrossCoords[i].x + PosX, PosY + 1, gCrossCoords[i].z + PosZ);
BLOCKTYPE BlockAtYPP = m_World->GetBlock(gCrossCoords[i].x + PosX, PosY + 2, gCrossCoords[i].z + PosZ);
- BLOCKTYPE BlockAtYM = m_World->GetBlock(gCrossCoords[i].x + PosX, PosY - 1, gCrossCoords[i].z + PosZ);
-
- if ((!cBlockInfo::IsSolid(BlockAtY)) && (!cBlockInfo::IsSolid(BlockAtYP)) && (!IsBlockLava(BlockAtYM)) && (BlockAtY != E_BLOCK_FENCE) && (BlockAtY != E_BLOCK_FENCE_GATE))
+ int LowestY = FindFirstNonAirBlockPosition(gCrossCoords[i].x + PosX, gCrossCoords[i].z + PosZ);
+ BLOCKTYPE BlockAtLowestY = m_World->GetBlock(gCrossCoords[i].x + PosX, LowestY, gCrossCoords[i].z + PosZ);
+
+ if (
+ (!cBlockInfo::IsSolid(BlockAtY)) &&
+ (!cBlockInfo::IsSolid(BlockAtYP)) &&
+ (!IsBlockLava(BlockAtLowestY)) &&
+ (BlockAtLowestY != E_BLOCK_CACTUS) &&
+ (PosY - LowestY < FALL_DAMAGE_HEIGHT)
+ )
{
m_PotentialCoordinates.push_back(Vector3d((gCrossCoords[i].x + PosX), PosY, gCrossCoords[i].z + PosZ));
}
- else if ((cBlockInfo::IsSolid(BlockAtY)) && (!cBlockInfo::IsSolid(BlockAtYP)) && (!cBlockInfo::IsSolid(BlockAtYPP)) && (!IsBlockLava(BlockAtYM)) && (BlockAtY != E_BLOCK_FENCE) && (BlockAtY != E_BLOCK_FENCE_GATE))
+ else if (
+ (cBlockInfo::IsSolid(BlockAtY)) &&
+ (BlockAtY != E_BLOCK_CACTUS) &&
+ (!cBlockInfo::IsSolid(BlockAtYP)) &&
+ (!cBlockInfo::IsSolid(BlockAtYPP)) &&
+ (BlockAtY != E_BLOCK_FENCE) &&
+ (BlockAtY != E_BLOCK_FENCE_GATE)
+ )
{
m_PotentialCoordinates.push_back(Vector3d((gCrossCoords[i].x + PosX), PosY + 1, gCrossCoords[i].z + PosZ));
}
@@ -402,7 +416,7 @@ void cMonster::HandleFalling()
GetWorld()->BroadcastSoundParticleEffect(2006, POSX_TOINT, POSY_TOINT - 1, POSZ_TOINT, Damage /* Used as particle effect speed modifier */);
}
- m_LastGroundHeight = (int)floor(GetPosY());
+ m_LastGroundHeight = POSY_TOINT;
}
}
@@ -411,7 +425,7 @@ void cMonster::HandleFalling()
int cMonster::FindFirstNonAirBlockPosition(double a_PosX, double a_PosZ)
{
- int PosY = (int)floor(GetPosY());
+ int PosY = POSY_TOINT;
if (PosY < 0)
PosY = 0;
@@ -526,7 +540,10 @@ void cMonster::KilledBy(cEntity * a_Killer)
break;
}
}
- m_World->SpawnExperienceOrb(GetPosX(), GetPosY(), GetPosZ(), Reward);
+ if ((a_Killer != NULL) && (!IsBaby()))
+ {
+ m_World->SpawnExperienceOrb(GetPosX(), GetPosY(), GetPosZ(), Reward);
+ }
m_DestroyTimer = 0;
}
@@ -842,7 +859,7 @@ cMonster * cMonster::NewMonsterFromType(cMonster::eType a_MobType)
case mtBat: toReturn = new cBat(); break;
case mtBlaze: toReturn = new cBlaze(); break;
- case mtCaveSpider: toReturn = new cCavespider(); break;
+ case mtCaveSpider: toReturn = new cCaveSpider(); break;
case mtChicken: toReturn = new cChicken(); break;
case mtCow: toReturn = new cCow(); break;
case mtCreeper: toReturn = new cCreeper(); break;
@@ -966,15 +983,15 @@ void cMonster::HandleDaylightBurning(cChunk & a_Chunk)
return;
}
- int RelY = (int)floor(GetPosY());
+ int RelY = POSY_TOINT;
if ((RelY < 0) || (RelY >= cChunkDef::Height))
{
// Outside the world
return;
}
- int RelX = (int)floor(GetPosX()) - GetChunkX() * cChunkDef::Width;
- int RelZ = (int)floor(GetPosZ()) - GetChunkZ() * cChunkDef::Width;
+ int RelX = POSX_TOINT - GetChunkX() * cChunkDef::Width;
+ int RelZ = POSZ_TOINT - GetChunkZ() * cChunkDef::Width;
if (!a_Chunk.IsLightValid())
{
@@ -986,7 +1003,8 @@ void cMonster::HandleDaylightBurning(cChunk & a_Chunk)
(a_Chunk.GetSkyLight(RelX, RelY, RelZ) == 15) && // In the daylight
(a_Chunk.GetBlock(RelX, RelY, RelZ) != E_BLOCK_SOULSAND) && // Not on soulsand
(GetWorld()->GetTimeOfDay() < (12000 + 1000)) && // It is nighttime
- !IsOnFire() // Not already burning
+ !IsOnFire() && // Not already burning
+ (GetWorld()->GetWeather() != eWeather_Rain) // Not raining
)
{
// Burn for 100 ticks, then decide again
diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h
index 776426a0d..70b3783fc 100644
--- a/src/Mobs/Monster.h
+++ b/src/Mobs/Monster.h
@@ -185,14 +185,14 @@ protected:
inline bool IsNextYPosReachable(int a_PosY)
{
return (
- (a_PosY <= (int)floor(GetPosY())) ||
+ (a_PosY <= POSY_TOINT) ||
DoesPosYRequireJump(a_PosY)
);
}
/** Returns if a monster can reach a given height by jumping */
inline bool DoesPosYRequireJump(int a_PosY)
{
- return ((a_PosY > (int)floor(GetPosY())) && (a_PosY == (int)floor(GetPosY()) + 1));
+ return ((a_PosY > POSY_TOINT) && (a_PosY == POSY_TOINT + 1));
}
/** A semi-temporary list to store the traversed coordinates during active pathfinding so we don't visit them again */
diff --git a/src/Mobs/Sheep.cpp b/src/Mobs/Sheep.cpp
index c64360153..5a6b760af 100644
--- a/src/Mobs/Sheep.cpp
+++ b/src/Mobs/Sheep.cpp
@@ -36,7 +36,8 @@ void cSheep::GetDrops(cItems & a_Drops, cEntity * a_Killer)
void cSheep::OnRightClicked(cPlayer & a_Player)
{
- if ((a_Player.GetEquippedItem().m_ItemType == E_ITEM_SHEARS) && (!m_IsSheared))
+ const cItem & EquippedItem = a_Player.GetEquippedItem();
+ if ((EquippedItem.m_ItemType == E_ITEM_SHEARS) && (!m_IsSheared))
{
m_IsSheared = true;
m_World->BroadcastEntityMetadata(*this);
@@ -51,9 +52,9 @@ void cSheep::OnRightClicked(cPlayer & a_Player)
Drops.push_back(cItem(E_BLOCK_WOOL, NumDrops, m_WoolColor));
m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10);
}
- if ((a_Player.GetEquippedItem().m_ItemType == E_ITEM_DYE) && (m_WoolColor != 15 - a_Player.GetEquippedItem().m_ItemDamage))
+ else if ((EquippedItem.m_ItemType == E_ITEM_DYE) && (m_WoolColor != 15 - EquippedItem.m_ItemDamage))
{
- m_WoolColor = 15 - a_Player.GetEquippedItem().m_ItemDamage;
+ m_WoolColor = 15 - EquippedItem.m_ItemDamage;
if (!a_Player.IsGameModeCreative())
{
a_Player.GetInventory().RemoveOneEquippedItem();
@@ -101,7 +102,7 @@ void cSheep::Tick(float a_Dt, cChunk & a_Chunk)
{
if (m_World->GetBlock(PosX, PosY, PosZ) == E_BLOCK_GRASS)
{
- m_World->BroadcastEntityStatus(*this, ENTITY_STATUS_SHEEP_EATING);
+ m_World->BroadcastEntityStatus(*this, esSheepEating);
m_TimeToStopEating = 40;
}
}
diff --git a/src/Mobs/Villager.cpp b/src/Mobs/Villager.cpp
index bbd8d6aaa..d049acc1e 100644
--- a/src/Mobs/Villager.cpp
+++ b/src/Mobs/Villager.cpp
@@ -30,7 +30,7 @@ void cVillager::DoTakeDamage(TakeDamageInfo & a_TDI)
{
if (m_World->GetTickRandomNumber(5) == 3)
{
- m_World->BroadcastEntityStatus(*this, ENTITY_STATUS_VILLAGER_ANGRY);
+ m_World->BroadcastEntityStatus(*this, esVillagerAngry);
}
}
}
diff --git a/src/Mobs/Wolf.cpp b/src/Mobs/Wolf.cpp
index 0d3619166..f02b8a4fc 100644
--- a/src/Mobs/Wolf.cpp
+++ b/src/Mobs/Wolf.cpp
@@ -75,12 +75,12 @@ void cWolf::OnRightClicked(cPlayer & a_Player)
SetMaxHealth(20);
SetIsTame(true);
SetOwner(a_Player.GetName());
- m_World->BroadcastEntityStatus(*this, ENTITY_STATUS_WOLF_TAMED);
+ m_World->BroadcastEntityStatus(*this, esWolfTamed);
m_World->BroadcastParticleEffect("heart", (float) GetPosX(), (float) GetPosY(), (float) GetPosZ(), 0, 0, 0, 0, 5);
}
else
{
- m_World->BroadcastEntityStatus(*this, ENTITY_STATUS_WOLF_TAMING);
+ m_World->BroadcastEntityStatus(*this, esWolfTaming);
m_World->BroadcastParticleEffect("smoke", (float) GetPosX(), (float) GetPosY(), (float) GetPosZ(), 0, 0, 0, 0, 5);
}
}
diff --git a/src/Mobs/Wolf.h b/src/Mobs/Wolf.h
index 9e5ad03c7..5925373e1 100644
--- a/src/Mobs/Wolf.h
+++ b/src/Mobs/Wolf.h
@@ -37,7 +37,7 @@ public:
void SetIsTame (bool a_IsTame) { m_IsTame = a_IsTame; }
void SetIsBegging (bool a_IsBegging) { m_IsBegging = a_IsBegging; }
void SetIsAngry (bool a_IsAngry) { m_IsAngry = a_IsAngry; }
- void SetOwner (AString a_NewOwner) { m_OwnerName = a_NewOwner; }
+ void SetOwner (const AString & a_NewOwner) { m_OwnerName = a_NewOwner; }
void SetCollarColor(int a_CollarColor) { m_CollarColor = a_CollarColor; }
protected:
diff --git a/src/Mobs/Zombiepigman.cpp b/src/Mobs/ZombiePigman.cpp
index a0142b566..c9d94face 100644
--- a/src/Mobs/Zombiepigman.cpp
+++ b/src/Mobs/ZombiePigman.cpp
@@ -1,7 +1,6 @@
-
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
-#include "Zombiepigman.h"
+#include "ZombiePigman.h"
#include "../World.h"
diff --git a/src/Mobs/Zombiepigman.h b/src/Mobs/ZombiePigman.h
index 67991d56a..ab3cebf6d 100644
--- a/src/Mobs/Zombiepigman.h
+++ b/src/Mobs/ZombiePigman.h
@@ -1,4 +1,3 @@
-
#pragma once
#include "PassiveAggressiveMonster.h"