summaryrefslogtreecommitdiffstats
path: root/src/Mobs/Monster.cpp
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2014-07-22 11:24:28 +0200
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2014-07-22 11:24:28 +0200
commit3385ed56b86a7816892e199fdda177ebb3a33966 (patch)
treee4ebda8e1fc245e9a84c3c4b363c05bbbad3a85f /src/Mobs/Monster.cpp
parentSuggestions (diff)
parentUpdated prefabs to current Gallery content. (diff)
downloadcuberite-3385ed56b86a7816892e199fdda177ebb3a33966.tar
cuberite-3385ed56b86a7816892e199fdda177ebb3a33966.tar.gz
cuberite-3385ed56b86a7816892e199fdda177ebb3a33966.tar.bz2
cuberite-3385ed56b86a7816892e199fdda177ebb3a33966.tar.lz
cuberite-3385ed56b86a7816892e199fdda177ebb3a33966.tar.xz
cuberite-3385ed56b86a7816892e199fdda177ebb3a33966.tar.zst
cuberite-3385ed56b86a7816892e199fdda177ebb3a33966.zip
Diffstat (limited to 'src/Mobs/Monster.cpp')
-rw-r--r--src/Mobs/Monster.cpp24
1 files changed, 5 insertions, 19 deletions
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp
index 78ac36f91..622a67816 100644
--- a/src/Mobs/Monster.cpp
+++ b/src/Mobs/Monster.cpp
@@ -126,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 */)
@@ -281,7 +281,7 @@ void cMonster::Tick(float a_Dt, cChunk & a_Chunk)
}
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();
@@ -414,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))))
{
@@ -684,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;
}
@@ -842,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: