1
0
Fork 0

Added first test to show the object can be created

This commit is contained in:
Tycho 2014-09-17 18:40:10 +01:00
parent 26a4845a99
commit 6e7c0e33b5
46 changed files with 683 additions and 458 deletions

View File

@ -129,6 +129,8 @@ set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/Bindings.cpp PROPER
set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/Bindings.h PROPERTIES GENERATED TRUE)
set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/LuaState_Call.inc PROPERTIES GENERATED TRUE)
set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/Bindings.cpp PROPERTIES COMPILE_FLAGS -Wno-error)
if(NOT MSVC)
add_library(Bindings ${SRCS} ${HDRS})

View File

@ -109,7 +109,7 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum)
{
double MobX = 0.5 + (DispX + DispChunk->GetPosX() * cChunkDef::Width);
double MobZ = 0.5 + (DispZ + DispChunk->GetPosZ() * cChunkDef::Width);
if (m_World->SpawnMob(MobX, DispY, MobZ, (cMonster::eType)m_Contents.GetSlot(a_SlotNum).m_ItemDamage) >= 0)
if (m_World->SpawnMob(MobX, DispY, MobZ, (eMonsterType)m_Contents.GetSlot(a_SlotNum).m_ItemDamage) >= 0)
{
m_Contents.ChangeSlotCount(a_SlotNum, -1);
}

View File

@ -261,34 +261,34 @@ int StringToMobType(const AString & a_MobString)
const char * m_String;
} MobMap [] =
{
{cMonster::mtCreeper, "Creeper"},
{cMonster::mtSkeleton, "Skeleton"},
{cMonster::mtSpider, "Spider"},
{cMonster::mtGiant, "Giant"},
{cMonster::mtZombie, "Zombie"},
{cMonster::mtSlime, "Slime"},
{cMonster::mtGhast, "Ghast"},
{cMonster::mtZombiePigman, "ZombiePigman"},
{cMonster::mtEnderman, "Enderman"},
{cMonster::mtCaveSpider, "CaveSpider"},
{cMonster::mtSilverfish, "SilverFish"},
{cMonster::mtBlaze, "Blaze"},
{cMonster::mtMagmaCube, "MagmaCube"},
{cMonster::mtEnderDragon, "EnderDragon"},
{cMonster::mtWither, "Wither"},
{cMonster::mtBat, "Bat"},
{cMonster::mtWitch, "Witch"},
{cMonster::mtPig, "Pig"},
{cMonster::mtSheep, "Sheep"},
{cMonster::mtCow, "Cow"},
{cMonster::mtChicken, "Chicken"},
{cMonster::mtSquid, "Squid"},
{cMonster::mtWolf, "Wolf"},
{cMonster::mtMooshroom, "Mooshroom"},
{cMonster::mtSnowGolem, "SnowGolem"},
{cMonster::mtOcelot, "Ocelot"},
{cMonster::mtIronGolem, "IronGolem"},
{cMonster::mtVillager, "Villager"},
{mtCreeper, "Creeper"},
{mtSkeleton, "Skeleton"},
{mtSpider, "Spider"},
{mtGiant, "Giant"},
{mtZombie, "Zombie"},
{mtSlime, "Slime"},
{mtGhast, "Ghast"},
{mtZombiePigman, "ZombiePigman"},
{mtEnderman, "Enderman"},
{mtCaveSpider, "CaveSpider"},
{mtSilverfish, "SilverFish"},
{mtBlaze, "Blaze"},
{mtMagmaCube, "MagmaCube"},
{mtEnderDragon, "EnderDragon"},
{mtWither, "Wither"},
{mtBat, "Bat"},
{mtWitch, "Witch"},
{mtPig, "Pig"},
{mtSheep, "Sheep"},
{mtCow, "Cow"},
{mtChicken, "Chicken"},
{mtSquid, "Squid"},
{mtWolf, "Wolf"},
{mtMooshroom, "Mooshroom"},
{mtSnowGolem, "SnowGolem"},
{mtOcelot, "Ocelot"},
{mtIronGolem, "IronGolem"},
{mtVillager, "Villager"},
};
for (size_t i = 0; i < ARRAYCOUNT(MobMap); i++)
{

View File

@ -6,26 +6,6 @@
cBlockInfo::cBlockInfo()
: m_LightValue(0x00)
, m_SpreadLightFalloff(0x0f)
, m_Transparent(false)
, m_OneHitDig(false)
, m_PistonBreakable(false)
, m_IsSnowable(false)
, m_IsSolid(true)
, m_FullyOccupiesVoxel(false)
, m_CanBeTerraformed(false)
, m_PlaceSound("")
, m_Handler(NULL)
{}
cBlockInfo::~cBlockInfo()
{
delete m_Handler;
@ -33,28 +13,6 @@ cBlockInfo::~cBlockInfo()
}
/** This accessor makes sure that the cBlockInfo structures are properly initialized exactly once.
It does so by using the C++ singleton approximation - storing the actual singleton as the function's static variable.
It works only if it is called for the first time before the app spawns other threads. */
cBlockInfo & cBlockInfo::Get(BLOCKTYPE a_Type)
{
static cBlockInfo ms_Info[256];
static bool IsBlockInfoInitialized = false;
if (!IsBlockInfoInitialized)
{
cBlockInfo::Initialize(ms_Info);
IsBlockInfoInitialized = true;
}
return ms_Info[a_Type];
}
void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
{
for (unsigned int i = 0; i < 256; ++i)

View File

@ -11,14 +11,27 @@ class cBlockHandler;
// tolua_begin
class cBlockInfo
{
public:
/** Returns the associated BlockInfo structure for the specified block type. */
static cBlockInfo & Get(BLOCKTYPE a_Type);
/** This accessor makes sure that the cBlockInfo structures are properly initialized exactly once.
It does so by using the C++ singleton approximation - storing the actual singleton as the function's static variable.
It works only if it is called for the first time before the app spawns other threads. */
static cBlockInfo & Get(BLOCKTYPE a_Type)
{
static cBlockInfo ms_Info[256];
static bool IsBlockInfoInitialized = false;
if (!IsBlockInfoInitialized)
{
cBlockInfo::Initialize(ms_Info);
IsBlockInfoInitialized = true;
}
return ms_Info[a_Type];
}
/** How much light do the blocks emit on their own? */
@ -78,7 +91,19 @@ protected:
typedef cBlockInfo cBlockInfoArray[256];
/** Creates a default BlockInfo structure, initializes all values to their defaults */
cBlockInfo();
cBlockInfo()
: m_LightValue(0x00)
, m_SpreadLightFalloff(0x0f)
, m_Transparent(false)
, m_OneHitDig(false)
, m_PistonBreakable(false)
, m_IsSnowable(false)
, m_IsSolid(true)
, m_FullyOccupiesVoxel(false)
, m_CanBeTerraformed(false)
, m_PlaceSound("")
, m_Handler(NULL)
{}
/** Cleans up the stored values */
~cBlockInfo();

View File

@ -151,7 +151,7 @@ public:
a_ChunkInterface.SetBlock(a_WorldInterface, a_BlockX - 1, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0);
// Spawn the wither:
a_WorldInterface.SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, cMonster::mtWither);
a_WorldInterface.SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, mtWither);
// Award Achievement
a_WorldInterface.ForEachPlayer(PlayerCallback);
@ -181,7 +181,7 @@ public:
a_ChunkInterface.SetBlock(a_WorldInterface, a_BlockX, a_BlockY, a_BlockZ - 1, E_BLOCK_AIR, 0);
// Spawn the wither:
a_WorldInterface.SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, cMonster::mtWither);
a_WorldInterface.SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, mtWither);
// Award Achievement
a_WorldInterface.ForEachPlayer(PlayerCallback);

View File

@ -4,7 +4,7 @@
#include "BlockHandler.h"
class cWorld;
class cBlockPistonHandler :

View File

@ -50,7 +50,7 @@ public:
int PosX = a_Chunk.GetPosX() * cChunkDef::Width + a_RelX;
int PosZ = a_Chunk.GetPosZ() * cChunkDef::Width + a_RelZ;
a_WorldInterface.SpawnMob(PosX, a_RelY, PosZ, cMonster::mtZombiePigman);
a_WorldInterface.SpawnMob(PosX, a_RelY, PosZ, mtZombiePigman);
}
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override

View File

@ -36,7 +36,7 @@ public:
a_ChunkInterface.FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0);
a_ChunkInterface.FastSetBlock(a_BlockX, a_BlockY - 1, a_BlockZ, E_BLOCK_AIR, 0);
a_ChunkInterface.FastSetBlock(a_BlockX, a_BlockY - 2, a_BlockZ, E_BLOCK_AIR, 0);
a_WorldInterface.SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, cMonster::mtSnowGolem);
a_WorldInterface.SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, mtSnowGolem);
return;
}
@ -61,7 +61,7 @@ public:
a_ChunkInterface.FastSetBlock(a_BlockX, a_BlockY - 2, a_BlockZ, E_BLOCK_AIR, 0);
// Spawn the golem:
a_WorldInterface.SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, cMonster::mtIronGolem);
a_WorldInterface.SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, mtIronGolem);
}
else if (
(a_ChunkInterface.GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ + 1) == E_BLOCK_IRON_BLOCK) &&
@ -76,7 +76,7 @@ public:
a_ChunkInterface.FastSetBlock(a_BlockX, a_BlockY - 2, a_BlockZ, E_BLOCK_AIR, 0);
// Spawn the golem:
a_WorldInterface.SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, cMonster::mtIronGolem);
a_WorldInterface.SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, mtIronGolem);
}
}

View File

@ -2,8 +2,74 @@
#include "Globals.h"
#include "ChunkInterface.h"
#include "ChunkMap.h"
#include "BlockHandler.h"
BLOCKTYPE cChunkInterface::GetBlock(int a_BlockX, int a_BlockY, int a_BlockZ)
{
return m_ChunkMap->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
}
BLOCKTYPE cChunkInterface::GetBlock(const Vector3i & a_Pos)
{
return GetBlock(a_Pos.x, a_Pos.y, a_Pos.z);
}
NIBBLETYPE cChunkInterface::GetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ)
{
return m_ChunkMap->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
}
bool cChunkInterface::GetBlockTypeMeta(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta)
{
return m_ChunkMap->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta);
}
/** Sets the block at the specified coords to the specified value.
Full processing, incl. updating neighbors, is performed.
*/
void cChunkInterface::SetBlock(cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
m_ChunkMap->SetBlock(a_WorldInterface, a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta);
}
void cChunkInterface::SetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_MetaData)
{
m_ChunkMap->SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, a_MetaData);
}
void cChunkInterface::QueueSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, int a_TickDelay, BLOCKTYPE a_PreviousBlockType, cWorldInterface & a_WorldInterface)
{
m_ChunkMap->QueueSetBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_WorldInterface.GetWorldAge() + a_TickDelay, a_PreviousBlockType);
}
/** Sets the block at the specified coords to the specified value.
The replacement doesn't trigger block updates.
The replaced blocks aren't checked for block entities (block entity is leaked if it exists at this block)
*/
void cChunkInterface::FastSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
m_ChunkMap->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta);
}
void cChunkInterface::FastSetBlock(const Vector3i & a_Pos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
FastSetBlock( a_Pos.x, a_Pos.y, a_Pos.z, a_BlockType, a_BlockMeta);
}
void cChunkInterface::UseBlockEntity(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
{
m_ChunkMap->UseBlockEntity(a_Player, a_BlockX, a_BlockY, a_BlockZ);
}
bool cChunkInterface::ForEachChunkInRect(int a_MinChunkX, int a_MaxChunkX, int a_MinChunkZ, int a_MaxChunkZ, cChunkDataCallback & a_Callback)
{
return m_ChunkMap->ForEachChunkInRect(a_MinChunkX, a_MaxChunkX, a_MinChunkZ, a_MaxChunkZ, a_Callback);
}
bool cChunkInterface::WriteBlockArea(cBlockArea & a_Area, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes)
{
return m_ChunkMap->WriteBlockArea(a_Area, a_MinBlockX, a_MinBlockY, a_MinBlockZ, a_DataTypes);
}
bool cChunkInterface::DigBlock(cWorldInterface & a_WorldInterface, int a_X, int a_Y, int a_Z)
{
cBlockHandler * Handler = cBlockInfo::GetHandler(GetBlock(a_X, a_Y, a_Z));

View File

@ -1,13 +1,12 @@
#pragma once
#include "../ChunkMap.h"
#include "../ForEachChunkProvider.h"
#include "WorldInterface.h"
class cChunkMap;
class cChunkInterface:
public cForEachChunkProvider
@ -16,70 +15,34 @@ public:
cChunkInterface(cChunkMap * a_ChunkMap) : m_ChunkMap(a_ChunkMap) {}
BLOCKTYPE GetBlock(int a_BlockX, int a_BlockY, int a_BlockZ)
{
return m_ChunkMap->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
}
BLOCKTYPE GetBlock(const Vector3i & a_Pos)
{
return GetBlock(a_Pos.x, a_Pos.y, a_Pos.z);
}
NIBBLETYPE GetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ)
{
return m_ChunkMap->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
}
BLOCKTYPE GetBlock(int a_BlockX, int a_BlockY, int a_BlockZ);
BLOCKTYPE GetBlock(const Vector3i & a_Pos);
NIBBLETYPE GetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ);
bool GetBlockTypeMeta(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta)
{
return m_ChunkMap->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta);
}
bool GetBlockTypeMeta(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta);
/** Sets the block at the specified coords to the specified value.
Full processing, incl. updating neighbors, is performed.
*/
void SetBlock(cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
m_ChunkMap->SetBlock(a_WorldInterface, a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta);
}
void SetBlock(cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
void SetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_MetaData)
{
m_ChunkMap->SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, a_MetaData);
}
void SetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_MetaData);
void QueueSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, int a_TickDelay, BLOCKTYPE a_PreviousBlockType, cWorldInterface & a_WorldInterface)
{
m_ChunkMap->QueueSetBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_WorldInterface.GetWorldAge() + a_TickDelay, a_PreviousBlockType);
}
void QueueSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, int a_TickDelay, BLOCKTYPE a_PreviousBlockType, cWorldInterface & a_WorldInterface);
/** Sets the block at the specified coords to the specified value.
The replacement doesn't trigger block updates.
The replaced blocks aren't checked for block entities (block entity is leaked if it exists at this block)
*/
void FastSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
m_ChunkMap->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta);
}
void FastSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
void FastSetBlock(const Vector3i & a_Pos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
FastSetBlock( a_Pos.x, a_Pos.y, a_Pos.z, a_BlockType, a_BlockMeta);
}
void FastSetBlock(const Vector3i & a_Pos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
void UseBlockEntity(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
{
m_ChunkMap->UseBlockEntity(a_Player, a_BlockX, a_BlockY, a_BlockZ);
}
void UseBlockEntity(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ);
virtual bool ForEachChunkInRect(int a_MinChunkX, int a_MaxChunkX, int a_MinChunkZ, int a_MaxChunkZ, cChunkDataCallback & a_Callback) override
{
return m_ChunkMap->ForEachChunkInRect(a_MinChunkX, a_MaxChunkX, a_MinChunkZ, a_MaxChunkZ, a_Callback);
}
virtual bool ForEachChunkInRect(int a_MinChunkX, int a_MaxChunkX, int a_MinChunkZ, int a_MaxChunkZ, cChunkDataCallback & a_Callback) override;
virtual bool WriteBlockArea(cBlockArea & a_Area, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes) override
{
return m_ChunkMap->WriteBlockArea(a_Area, a_MinBlockX, a_MinBlockY, a_MinBlockZ, a_DataTypes);
}
virtual bool WriteBlockArea(cBlockArea & a_Area, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes) override;
bool DigBlock(cWorldInterface & a_WorldInterface, int a_X, int a_Y, int a_Z);

View File

@ -2,14 +2,15 @@
#pragma once
#include "BroadcastInterface.h"
#include "../Mobs/Monster.h"
#include "../Mobs/MonsterTypes.h"
class cItems;
typedef cItemCallback<cBlockEntity> cBlockEntityCallback;
class cMonster;
class cPlayer;
class cWorldInterface
@ -33,7 +34,7 @@ public:
virtual void SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_SpeedX, double a_SpeedY, double a_SpeedZ, bool IsPlayerCreated = false) = 0;
/** Spawns a mob of the specified type. Returns the mob's EntityID if recognized and spawned, <0 otherwise */
virtual int SpawnMob(double a_PosX, double a_PosY, double a_PosZ, cMonster::eType a_MonsterType) = 0;
virtual int SpawnMob(double a_PosX, double a_PosY, double a_PosZ, eMonsterType a_MonsterType) = 0;
/** Calls the callback for the block entity at the specified coords; returns false if there's no block entity at those coords, true if found */
virtual bool DoWithBlockEntityAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBlockEntityCallback & a_Callback) = 0;

View File

@ -334,10 +334,10 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
cMonster * Monster = (cMonster *)this;
switch (Monster->GetMobType())
{
case cMonster::mtSkeleton:
case cMonster::mtZombie:
case cMonster::mtWither:
case cMonster::mtZombiePigman:
case mtSkeleton:
case mtZombie:
case mtWither:
case mtZombiePigman:
{
a_TDI.FinalDamage += (int)ceil(2.5 * SmiteLevel);
break;
@ -352,9 +352,9 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
cMonster * Monster = (cMonster *)this;
switch (Monster->GetMobType())
{
case cMonster::mtSpider:
case cMonster::mtCaveSpider:
case cMonster::mtSilverfish:
case mtSpider:
case mtCaveSpider:
case mtSilverfish:
{
a_TDI.RawDamage += (int)ceil(2.5 * BaneOfArthropodsLevel);
// TODO: Add slowness effect
@ -384,9 +384,9 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
cMonster * Monster = (cMonster *)this;
switch (Monster->GetMobType())
{
case cMonster::mtGhast:
case cMonster::mtZombiePigman:
case cMonster::mtMagmaCube:
case mtGhast:
case mtZombiePigman:
case mtMagmaCube:
{
break;
};

View File

@ -349,8 +349,8 @@ void cEntityEffectPoison::OnTick(cPawn & a_Target)
// Doesn't effect undead mobs, spiders
if (
Target.IsUndead() ||
(Target.GetMobType() == cMonster::mtSpider) ||
(Target.GetMobType() == cMonster::mtCaveSpider)
(Target.GetMobType() == mtSpider) ||
(Target.GetMobType() == mtCaveSpider)
)
{
return;

View File

@ -2003,8 +2003,8 @@ void cPlayer::UpdateMovementStats(const Vector3d & a_DeltaPos)
cMonster * Monster = (cMonster *)m_AttachedTo;
switch (Monster->GetMobType())
{
case cMonster::mtPig: m_Stats.AddValue(statDistPig, Value); break;
case cMonster::mtHorse: m_Stats.AddValue(statDistHorse, Value); break;
case mtPig: m_Stats.AddValue(statDistPig, Value); break;
case mtHorse: m_Stats.AddValue(statDistHorse, Value); break;
default: break;
}
break;

View File

@ -48,13 +48,13 @@ void cThrownEggEntity::TrySpawnChicken(const Vector3d & a_HitPos)
{
if (m_World->GetTickRandomNumber(7) == 1)
{
m_World->SpawnMob(a_HitPos.x, a_HitPos.y, a_HitPos.z, cMonster::mtChicken);
m_World->SpawnMob(a_HitPos.x, a_HitPos.y, a_HitPos.z, mtChicken);
}
else if (m_World->GetTickRandomNumber(32) == 1)
{
m_World->SpawnMob(a_HitPos.x, a_HitPos.y, a_HitPos.z, cMonster::mtChicken);
m_World->SpawnMob(a_HitPos.x, a_HitPos.y, a_HitPos.z, cMonster::mtChicken);
m_World->SpawnMob(a_HitPos.x, a_HitPos.y, a_HitPos.z, cMonster::mtChicken);
m_World->SpawnMob(a_HitPos.x, a_HitPos.y, a_HitPos.z, cMonster::mtChicken);
m_World->SpawnMob(a_HitPos.x, a_HitPos.y, a_HitPos.z, mtChicken);
m_World->SpawnMob(a_HitPos.x, a_HitPos.y, a_HitPos.z, mtChicken);
m_World->SpawnMob(a_HitPos.x, a_HitPos.y, a_HitPos.z, mtChicken);
m_World->SpawnMob(a_HitPos.x, a_HitPos.y, a_HitPos.z, mtChicken);
}
}

View File

@ -32,8 +32,8 @@ void cThrownSnowballEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d &
int TotalDamage = 0;
if (a_EntityHit.IsMob())
{
cMonster::eType MobType = ((cMonster &) a_EntityHit).GetMobType();
if (MobType == cMonster::mtBlaze)
eMonsterType MobType = ((cMonster &) a_EntityHit).GetMobType();
if (MobType == mtBlaze)
{
TotalDamage = 3;
}

View File

@ -15,6 +15,7 @@
#include "../Simulator/FluidSimulator.h" // for cFluidSimulator::CanWashAway()
#include "../Simulator/FireSimulator.h"
#include "../World.h"
#include "inifile/iniFile.h"

View File

@ -261,6 +261,27 @@ void inline LOGERROR(const char* a_Format, ...)
vprintf(a_Format, argList);
va_end(argList);
}
void inline LOGWARNING(const char* a_Format, ...) FORMATSTRING(1, 2);
void inline LOGWARNING(const char* a_Format, ...)
{
va_list argList;
va_start(argList, a_Format);
vprintf(a_Format, argList);
va_end(argList);
}
void inline LOGD(const char* a_Format, ...) FORMATSTRING(1, 2);
void inline LOGD(const char* a_Format, ...)
{
va_list argList;
va_start(argList, a_Format);
vprintf(a_Format, argList);
va_end(argList);
}
#endif

View File

@ -33,9 +33,9 @@ public:
a_BlockY--;
}
cMonster::eType MonsterType = ItemDamageToMonsterType(a_Item.m_ItemDamage);
eMonsterType MonsterType = ItemDamageToMonsterType(a_Item.m_ItemDamage);
if (
(MonsterType != cMonster::mtInvalidType) && // Valid monster type
(MonsterType != mtInvalidType) && // Valid monster type
(a_World->SpawnMob(a_BlockX + 0.5, a_BlockY, a_BlockZ + 0.5, MonsterType) >= 0)) // Spawning succeeded
{
if (!a_Player->IsGameModeCreative())
@ -52,36 +52,36 @@ public:
/** Converts the Spawn egg item damage to the monster type to spawn.
Returns mtInvalidType for invalid damage values. */
static cMonster::eType ItemDamageToMonsterType(short a_ItemDamage)
static eMonsterType ItemDamageToMonsterType(short a_ItemDamage)
{
switch (a_ItemDamage)
{
case E_META_SPAWN_EGG_BAT: return cMonster::mtBat;
case E_META_SPAWN_EGG_BLAZE: return cMonster::mtBlaze;
case E_META_SPAWN_EGG_CAVE_SPIDER: return cMonster::mtCaveSpider;
case E_META_SPAWN_EGG_CHICKEN: return cMonster::mtChicken;
case E_META_SPAWN_EGG_COW: return cMonster::mtCow;
case E_META_SPAWN_EGG_CREEPER: return cMonster::mtCreeper;
case E_META_SPAWN_EGG_ENDERMAN: return cMonster::mtEnderman;
case E_META_SPAWN_EGG_GHAST: return cMonster::mtGhast;
case E_META_SPAWN_EGG_HORSE: return cMonster::mtHorse;
case E_META_SPAWN_EGG_MAGMA_CUBE: return cMonster::mtMagmaCube;
case E_META_SPAWN_EGG_MOOSHROOM: return cMonster::mtMooshroom;
case E_META_SPAWN_EGG_OCELOT: return cMonster::mtOcelot;
case E_META_SPAWN_EGG_PIG: return cMonster::mtPig;
case E_META_SPAWN_EGG_SHEEP: return cMonster::mtSheep;
case E_META_SPAWN_EGG_SILVERFISH: return cMonster::mtSilverfish;
case E_META_SPAWN_EGG_SKELETON: return cMonster::mtSkeleton;
case E_META_SPAWN_EGG_SLIME: return cMonster::mtSlime;
case E_META_SPAWN_EGG_SPIDER: return cMonster::mtSpider;
case E_META_SPAWN_EGG_SQUID: return cMonster::mtSquid;
case E_META_SPAWN_EGG_VILLAGER: return cMonster::mtVillager;
case E_META_SPAWN_EGG_WITCH: return cMonster::mtWitch;
case E_META_SPAWN_EGG_WOLF: return cMonster::mtWolf;
case E_META_SPAWN_EGG_ZOMBIE: return cMonster::mtZombie;
case E_META_SPAWN_EGG_ZOMBIE_PIGMAN: return cMonster::mtZombiePigman;
case E_META_SPAWN_EGG_BAT: return mtBat;
case E_META_SPAWN_EGG_BLAZE: return mtBlaze;
case E_META_SPAWN_EGG_CAVE_SPIDER: return mtCaveSpider;
case E_META_SPAWN_EGG_CHICKEN: return mtChicken;
case E_META_SPAWN_EGG_COW: return mtCow;
case E_META_SPAWN_EGG_CREEPER: return mtCreeper;
case E_META_SPAWN_EGG_ENDERMAN: return mtEnderman;
case E_META_SPAWN_EGG_GHAST: return mtGhast;
case E_META_SPAWN_EGG_HORSE: return mtHorse;
case E_META_SPAWN_EGG_MAGMA_CUBE: return mtMagmaCube;
case E_META_SPAWN_EGG_MOOSHROOM: return mtMooshroom;
case E_META_SPAWN_EGG_OCELOT: return mtOcelot;
case E_META_SPAWN_EGG_PIG: return mtPig;
case E_META_SPAWN_EGG_SHEEP: return mtSheep;
case E_META_SPAWN_EGG_SILVERFISH: return mtSilverfish;
case E_META_SPAWN_EGG_SKELETON: return mtSkeleton;
case E_META_SPAWN_EGG_SLIME: return mtSlime;
case E_META_SPAWN_EGG_SPIDER: return mtSpider;
case E_META_SPAWN_EGG_SQUID: return mtSquid;
case E_META_SPAWN_EGG_VILLAGER: return mtVillager;
case E_META_SPAWN_EGG_WITCH: return mtWitch;
case E_META_SPAWN_EGG_WOLF: return mtWolf;
case E_META_SPAWN_EGG_ZOMBIE: return mtZombie;
case E_META_SPAWN_EGG_ZOMBIE_PIGMAN: return mtZombiePigman;
}
return cMonster::mtInvalidType;
return mtInvalidType;
}
} ;

View File

@ -8,12 +8,12 @@
cMobSpawner::cMobSpawner(cMonster::eFamily a_MonsterFamily, const std::set<cMonster::eType>& a_AllowedTypes) :
cMobSpawner::cMobSpawner(cMonster::eFamily a_MonsterFamily, const std::set<eMonsterType>& a_AllowedTypes) :
m_MonsterFamily(a_MonsterFamily),
m_NewPack(true),
m_MobType(cMonster::mtInvalidType)
m_MobType(mtInvalidType)
{
for (std::set<cMonster::eType>::const_iterator itr = a_AllowedTypes.begin(); itr != a_AllowedTypes.end(); ++itr)
for (std::set<eMonsterType>::const_iterator itr = a_AllowedTypes.begin(); itr != a_AllowedTypes.end(); ++itr)
{
if (cMonster::FamilyFromType(*itr) == a_MonsterFamily)
{
@ -44,9 +44,9 @@ bool cMobSpawner::CheckPackCenter(BLOCKTYPE a_BlockType)
void cMobSpawner::addIfAllowed(cMonster::eType toAdd, std::set<cMonster::eType>& toAddIn)
void cMobSpawner::addIfAllowed(eMonsterType toAdd, std::set<eMonsterType>& toAddIn)
{
std::set<cMonster::eType>::iterator itr = m_AllowedTypes.find(toAdd);
std::set<eMonsterType>::iterator itr = m_AllowedTypes.find(toAdd);
if (itr != m_AllowedTypes.end())
{
toAddIn.insert(toAdd);
@ -57,49 +57,49 @@ void cMobSpawner::addIfAllowed(cMonster::eType toAdd, std::set<cMonster::eType>&
cMonster::eType cMobSpawner::ChooseMobType(EMCSBiome a_Biome)
eMonsterType cMobSpawner::ChooseMobType(EMCSBiome a_Biome)
{
std::set<cMonster::eType> allowedMobs;
std::set<eMonsterType> allowedMobs;
if (a_Biome == biMushroomIsland || a_Biome == biMushroomShore)
{
addIfAllowed(cMonster::mtMooshroom, allowedMobs);
addIfAllowed(mtMooshroom, allowedMobs);
}
else if (a_Biome == biNether)
{
addIfAllowed(cMonster::mtGhast, allowedMobs);
addIfAllowed(cMonster::mtZombiePigman, allowedMobs);
addIfAllowed(cMonster::mtMagmaCube, allowedMobs);
addIfAllowed(mtGhast, allowedMobs);
addIfAllowed(mtZombiePigman, allowedMobs);
addIfAllowed(mtMagmaCube, allowedMobs);
}
else if (a_Biome == biEnd)
{
addIfAllowed(cMonster::mtEnderman, allowedMobs);
addIfAllowed(mtEnderman, allowedMobs);
}
else
{
addIfAllowed(cMonster::mtBat, allowedMobs);
addIfAllowed(cMonster::mtSpider, allowedMobs);
addIfAllowed(cMonster::mtZombie, allowedMobs);
addIfAllowed(cMonster::mtSkeleton, allowedMobs);
addIfAllowed(cMonster::mtCreeper, allowedMobs);
addIfAllowed(cMonster::mtSquid, allowedMobs);
addIfAllowed(mtBat, allowedMobs);
addIfAllowed(mtSpider, allowedMobs);
addIfAllowed(mtZombie, allowedMobs);
addIfAllowed(mtSkeleton, allowedMobs);
addIfAllowed(mtCreeper, allowedMobs);
addIfAllowed(mtSquid, allowedMobs);
if (a_Biome != biDesert && a_Biome != biBeach && a_Biome != biOcean)
{
addIfAllowed(cMonster::mtSheep, allowedMobs);
addIfAllowed(cMonster::mtPig, allowedMobs);
addIfAllowed(cMonster::mtCow, allowedMobs);
addIfAllowed(cMonster::mtChicken, allowedMobs);
addIfAllowed(cMonster::mtEnderman, allowedMobs);
addIfAllowed(cMonster::mtSlime, allowedMobs); // MG TODO : much more complicated rule
addIfAllowed(mtSheep, allowedMobs);
addIfAllowed(mtPig, allowedMobs);
addIfAllowed(mtCow, allowedMobs);
addIfAllowed(mtChicken, allowedMobs);
addIfAllowed(mtEnderman, allowedMobs);
addIfAllowed(mtSlime, allowedMobs); // MG TODO : much more complicated rule
if (a_Biome == biForest || a_Biome == biForestHills || a_Biome == biTaiga || a_Biome == biTaigaHills)
{
addIfAllowed(cMonster::mtWolf, allowedMobs);
addIfAllowed(mtWolf, allowedMobs);
}
else if (a_Biome == biJungle || a_Biome == biJungleHills)
{
addIfAllowed(cMonster::mtOcelot, allowedMobs);
addIfAllowed(mtOcelot, allowedMobs);
}
}
}
@ -107,7 +107,7 @@ cMonster::eType cMobSpawner::ChooseMobType(EMCSBiome a_Biome)
size_t allowedMobsSize = allowedMobs.size();
if (allowedMobsSize > 0)
{
std::set<cMonster::eType>::iterator itr = allowedMobs.begin();
std::set<eMonsterType>::iterator itr = allowedMobs.begin();
int iRandom = m_Random.NextInt((int)allowedMobsSize, a_Biome);
for (int i = 0; i < iRandom; i++)
@ -117,14 +117,14 @@ cMonster::eType cMobSpawner::ChooseMobType(EMCSBiome a_Biome)
return *itr;
}
return cMonster::mtInvalidType;
return mtInvalidType;
}
bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, cMonster::eType a_MobType, EMCSBiome a_Biome)
bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, eMonsterType a_MobType, EMCSBiome a_Biome)
{
BLOCKTYPE TargetBlock = E_BLOCK_AIR;
if (m_AllowedTypes.find(a_MobType) != m_AllowedTypes.end() && a_Chunk->UnboundedRelGetBlockType(a_RelX, a_RelY, a_RelZ, TargetBlock))
@ -143,21 +143,21 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R
switch (a_MobType)
{
case cMonster::mtSquid:
case mtSquid:
{
return IsBlockWater(TargetBlock) && (a_RelY >= 45) && (a_RelY <= 62);
}
case cMonster::mtBat:
case mtBat:
{
return (a_RelY <= 63) && (BlockLight <= 4) && (SkyLight <= 4) && (TargetBlock == E_BLOCK_AIR) && !cBlockInfo::IsTransparent(BlockAbove);
}
case cMonster::mtChicken:
case cMonster::mtCow:
case cMonster::mtPig:
case cMonster::mtHorse:
case cMonster::mtSheep:
case mtChicken:
case mtCow:
case mtPig:
case mtHorse:
case mtSheep:
{
return (
(TargetBlock == E_BLOCK_AIR) &&
@ -168,7 +168,7 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R
);
}
case cMonster::mtOcelot:
case mtOcelot:
{
return (
(TargetBlock == E_BLOCK_AIR) &&
@ -181,7 +181,7 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R
);
}
case cMonster::mtEnderman:
case mtEnderman:
{
if (a_RelY < 250)
{
@ -202,7 +202,7 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R
break;
}
case cMonster::mtSpider:
case mtSpider:
{
bool CanSpawn = true;
bool HasFloor = false;
@ -228,9 +228,9 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R
return CanSpawn && HasFloor && (SkyLight <= 7) && (BlockLight <= 7);
}
case cMonster::mtCreeper:
case cMonster::mtSkeleton:
case cMonster::mtZombie:
case mtCreeper:
case mtSkeleton:
case mtZombie:
{
return (
(TargetBlock == E_BLOCK_AIR) &&
@ -242,8 +242,8 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R
);
}
case cMonster::mtMagmaCube:
case cMonster::mtSlime:
case mtMagmaCube:
case mtSlime:
{
return (
(TargetBlock == E_BLOCK_AIR) &&
@ -255,8 +255,8 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R
);
}
case cMonster::mtGhast:
case cMonster::mtZombiePigman:
case mtGhast:
case mtZombiePigman:
{
return (
(TargetBlock == E_BLOCK_AIR) &&
@ -266,7 +266,7 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R
);
}
case cMonster::mtWolf:
case mtWolf:
{
return (
(TargetBlock == E_BLOCK_GRASS) &&
@ -305,15 +305,15 @@ cMonster* cMobSpawner::TryToSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY,
if (m_NewPack)
{
m_MobType = ChooseMobType(a_Biome);
if (m_MobType == cMonster::mtInvalidType)
if (m_MobType == mtInvalidType)
{
return toReturn;
}
if (m_MobType == cMonster::mtWolf)
if (m_MobType == mtWolf)
{
a_MaxPackSize = 8;
}
else if (m_MobType == cMonster::mtGhast)
else if (m_MobType == mtGhast)
{
a_MaxPackSize = 1;
}

View File

@ -30,7 +30,7 @@ public :
// a_AllowedTypes is the set of types allowed for mobs it will spawn. Empty set
// would result in no spawn at all
// Allowed mobs thah are not of the right Family will not be include (no warning)
cMobSpawner(cMonster::eFamily MobFamily, const std::set<cMonster::eType> & a_AllowedTypes);
cMobSpawner(cMonster::eFamily MobFamily, const std::set<eMonsterType> & a_AllowedTypes);
/// Check if specified block can be a Pack center for this spawner
bool CheckPackCenter(BLOCKTYPE a_BlockType);
@ -53,20 +53,20 @@ public :
protected :
// return true if specified type of mob can spawn on specified block
bool CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, cMonster::eType a_MobType, EMCSBiome a_Biome);
bool CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, eMonsterType a_MobType, EMCSBiome a_Biome);
// return a random type that can spawn on specified biome.
// returns E_ENTITY_TYPE_DONOTUSE if none is possible
cMonster::eType ChooseMobType(EMCSBiome a_Biome);
eMonsterType ChooseMobType(EMCSBiome a_Biome);
// add toAdd inside toAddIn, if toAdd is in m_AllowedTypes
void addIfAllowed(cMonster::eType toAdd, std::set<cMonster::eType> & toAddIn);
void addIfAllowed(eMonsterType toAdd, std::set<eMonsterType> & toAddIn);
protected :
cMonster::eFamily m_MonsterFamily;
std::set<cMonster::eType> m_AllowedTypes;
std::set<eMonsterType> m_AllowedTypes;
bool m_NewPack;
cMonster::eType m_MobType;
eMonsterType m_MobType;
std::set<cMonster*> m_Spawned;
cFastRandom m_Random;
} ;

View File

@ -11,7 +11,7 @@
cAggressiveMonster::cAggressiveMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height) :
cAggressiveMonster::cAggressiveMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height) :
super(a_ConfigName, a_MobType, a_SoundHurt, a_SoundDeath, a_Width, a_Height)
{
m_EMPersonality = AGGRESSIVE;

View File

@ -14,7 +14,7 @@ class cAggressiveMonster :
public:
cAggressiveMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
cAggressiveMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
virtual void Tick (float a_Dt, cChunk & a_Chunk) override;
virtual void InStateChasing(float a_Dt) override;

View File

@ -24,38 +24,38 @@ The strings need to be lowercase (for more efficient comparisons in StringToMobT
*/
static const struct
{
cMonster::eType m_Type;
eMonsterType m_Type;
const char * m_lcName;
} g_MobTypeNames[] =
{
{cMonster::mtBat, "bat"},
{cMonster::mtBlaze, "blaze"},
{cMonster::mtCaveSpider, "cavespider"},
{cMonster::mtChicken, "chicken"},
{cMonster::mtCow, "cow"},
{cMonster::mtCreeper, "creeper"},
{cMonster::mtEnderman, "enderman"},
{cMonster::mtEnderDragon, "enderdragon"},
{cMonster::mtGhast, "ghast"},
{cMonster::mtHorse, "horse"},
{cMonster::mtIronGolem, "irongolem"},
{cMonster::mtMagmaCube, "magmacube"},
{cMonster::mtMooshroom, "mooshroom"},
{cMonster::mtOcelot, "ocelot"},
{cMonster::mtPig, "pig"},
{cMonster::mtSheep, "sheep"},
{cMonster::mtSilverfish, "silverfish"},
{cMonster::mtSkeleton, "skeleton"},
{cMonster::mtSlime, "slime"},
{cMonster::mtSnowGolem, "snowgolem"},
{cMonster::mtSpider, "spider"},
{cMonster::mtSquid, "squid"},
{cMonster::mtVillager, "villager"},
{cMonster::mtWitch, "witch"},
{cMonster::mtWither, "wither"},
{cMonster::mtWolf, "wolf"},
{cMonster::mtZombie, "zombie"},
{cMonster::mtZombiePigman, "zombiepigman"},
{mtBat, "bat"},
{mtBlaze, "blaze"},
{mtCaveSpider, "cavespider"},
{mtChicken, "chicken"},
{mtCow, "cow"},
{mtCreeper, "creeper"},
{mtEnderman, "enderman"},
{mtEnderDragon, "enderdragon"},
{mtGhast, "ghast"},
{mtHorse, "horse"},
{mtIronGolem, "irongolem"},
{mtMagmaCube, "magmacube"},
{mtMooshroom, "mooshroom"},
{mtOcelot, "ocelot"},
{mtPig, "pig"},
{mtSheep, "sheep"},
{mtSilverfish, "silverfish"},
{mtSkeleton, "skeleton"},
{mtSlime, "slime"},
{mtSnowGolem, "snowgolem"},
{mtSpider, "spider"},
{mtSquid, "squid"},
{mtVillager, "villager"},
{mtWitch, "witch"},
{mtWither, "wither"},
{mtWolf, "wolf"},
{mtZombie, "zombie"},
{mtZombiePigman, "zombiepigman"},
} ;
@ -65,7 +65,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)
cMonster::cMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height)
: super(etMonster, a_Width, a_Height)
, m_EMState(IDLE)
, m_EMPersonality(AGGRESSIVE)
@ -485,50 +485,50 @@ void cMonster::KilledBy(TakeDamageInfo & a_TDI)
switch (m_MobType)
{
// Animals
case cMonster::mtChicken:
case cMonster::mtCow:
case cMonster::mtHorse:
case cMonster::mtPig:
case cMonster::mtSheep:
case cMonster::mtSquid:
case cMonster::mtMooshroom:
case cMonster::mtOcelot:
case cMonster::mtWolf:
case mtChicken:
case mtCow:
case mtHorse:
case mtPig:
case mtSheep:
case mtSquid:
case mtMooshroom:
case mtOcelot:
case mtWolf:
{
Reward = m_World->GetTickRandomNumber(2) + 1;
break;
}
// Monsters
case cMonster::mtCaveSpider:
case cMonster::mtCreeper:
case cMonster::mtEnderman:
case cMonster::mtGhast:
case cMonster::mtSilverfish:
case cMonster::mtSkeleton:
case cMonster::mtSpider:
case cMonster::mtWitch:
case cMonster::mtZombie:
case cMonster::mtZombiePigman:
case cMonster::mtSlime:
case cMonster::mtMagmaCube:
case mtCaveSpider:
case mtCreeper:
case mtEnderman:
case mtGhast:
case mtSilverfish:
case mtSkeleton:
case mtSpider:
case mtWitch:
case mtZombie:
case mtZombiePigman:
case mtSlime:
case mtMagmaCube:
{
Reward = 6 + (m_World->GetTickRandomNumber(2));
break;
}
case cMonster::mtBlaze:
case mtBlaze:
{
Reward = 10;
break;
}
// Bosses
case cMonster::mtEnderDragon:
case mtEnderDragon:
{
Reward = 12000;
break;
}
case cMonster::mtWither:
case mtWither:
{
Reward = 50;
break;
@ -697,7 +697,7 @@ bool cMonster::IsUndead(void)
AString cMonster::MobTypeToString(cMonster::eType a_MobType)
AString cMonster::MobTypeToString(eMonsterType a_MobType)
{
// Mob types aren't sorted, so we need to search linearly:
for (size_t i = 0; i < ARRAYCOUNT(g_MobTypeNames); i++)
@ -716,7 +716,7 @@ AString cMonster::MobTypeToString(cMonster::eType a_MobType)
cMonster::eType cMonster::StringToMobType(const AString & a_Name)
eMonsterType cMonster::StringToMobType(const AString & a_Name)
{
AString lcName = StrToLower(a_Name);
@ -757,7 +757,7 @@ cMonster::eType cMonster::StringToMobType(const AString & a_Name)
cMonster::eFamily cMonster::FamilyFromType(eType a_Type)
cMonster::eFamily cMonster::FamilyFromType(eMonsterType a_Type)
{
// Passive-agressive mobs are counted in mob spawning code as passive
@ -822,7 +822,7 @@ int cMonster::GetSpawnDelay(cMonster::eFamily a_MobFamily)
cMonster * cMonster::NewMonsterFromType(cMonster::eType a_MobType)
cMonster * cMonster::NewMonsterFromType(eMonsterType a_MobType)
{
cFastRandom Random;
cMonster * toReturn = NULL;

View File

@ -6,6 +6,7 @@
#include "../BlockID.h"
#include "../Item.h"
#include "../Enchantments.h"
#include "MonsterTypes.h"
@ -15,50 +16,13 @@ class cClientHandle;
class cWorld;
// tolua_begin
class cMonster :
public cPawn
{
typedef cPawn super;
public:
/// This identifies individual monster type, as well as their network type-ID
enum eType
{
mtInvalidType = -1,
mtBat = E_META_SPAWN_EGG_BAT,
mtBlaze = E_META_SPAWN_EGG_BLAZE,
mtCaveSpider = E_META_SPAWN_EGG_CAVE_SPIDER,
mtChicken = E_META_SPAWN_EGG_CHICKEN,
mtCow = E_META_SPAWN_EGG_COW,
mtCreeper = E_META_SPAWN_EGG_CREEPER,
mtEnderDragon = E_META_SPAWN_EGG_ENDER_DRAGON,
mtEnderman = E_META_SPAWN_EGG_ENDERMAN,
mtGhast = E_META_SPAWN_EGG_GHAST,
mtGiant = E_META_SPAWN_EGG_GIANT,
mtHorse = E_META_SPAWN_EGG_HORSE,
mtIronGolem = E_META_SPAWN_EGG_IRON_GOLEM,
mtMagmaCube = E_META_SPAWN_EGG_MAGMA_CUBE,
mtMooshroom = E_META_SPAWN_EGG_MOOSHROOM,
mtOcelot = E_META_SPAWN_EGG_OCELOT,
mtPig = E_META_SPAWN_EGG_PIG,
mtSheep = E_META_SPAWN_EGG_SHEEP,
mtSilverfish = E_META_SPAWN_EGG_SILVERFISH,
mtSkeleton = E_META_SPAWN_EGG_SKELETON,
mtSlime = E_META_SPAWN_EGG_SLIME,
mtSnowGolem = E_META_SPAWN_EGG_SNOW_GOLEM,
mtSpider = E_META_SPAWN_EGG_SPIDER,
mtSquid = E_META_SPAWN_EGG_SQUID,
mtVillager = E_META_SPAWN_EGG_VILLAGER,
mtWitch = E_META_SPAWN_EGG_WITCH,