summaryrefslogtreecommitdiffstats
path: root/src/Mobs
diff options
context:
space:
mode:
authorTycho <work.tycho+git@gmail.com>2014-09-17 19:40:10 +0200
committerTycho <work.tycho+git@gmail.com>2014-09-17 19:40:10 +0200
commit6e7c0e33b5dd6d86d66ac2eb1a07a33652a708fd (patch)
tree69681d2a6bd1f3572305f7120d9231b394ac9c88 /src/Mobs
parentIncrementalRedstoneSimulator now has no dependencies on cChunk (diff)
downloadcuberite-6e7c0e33b5dd6d86d66ac2eb1a07a33652a708fd.tar
cuberite-6e7c0e33b5dd6d86d66ac2eb1a07a33652a708fd.tar.gz
cuberite-6e7c0e33b5dd6d86d66ac2eb1a07a33652a708fd.tar.bz2
cuberite-6e7c0e33b5dd6d86d66ac2eb1a07a33652a708fd.tar.lz
cuberite-6e7c0e33b5dd6d86d66ac2eb1a07a33652a708fd.tar.xz
cuberite-6e7c0e33b5dd6d86d66ac2eb1a07a33652a708fd.tar.zst
cuberite-6e7c0e33b5dd6d86d66ac2eb1a07a33652a708fd.zip
Diffstat (limited to 'src/Mobs')
-rw-r--r--src/Mobs/AggressiveMonster.cpp2
-rw-r--r--src/Mobs/AggressiveMonster.h2
-rw-r--r--src/Mobs/Monster.cpp116
-rw-r--r--src/Mobs/Monster.h54
-rw-r--r--src/Mobs/MonsterTypes.h41
-rw-r--r--src/Mobs/Mooshroom.cpp2
-rw-r--r--src/Mobs/PassiveAggressiveMonster.cpp2
-rw-r--r--src/Mobs/PassiveAggressiveMonster.h2
-rw-r--r--src/Mobs/PassiveMonster.cpp2
-rw-r--r--src/Mobs/PassiveMonster.h2
10 files changed, 115 insertions, 110 deletions
diff --git a/src/Mobs/AggressiveMonster.cpp b/src/Mobs/AggressiveMonster.cpp
index 5f5b1853d..be2f71f7a 100644
--- a/src/Mobs/AggressiveMonster.cpp
+++ b/src/Mobs/AggressiveMonster.cpp
@@ -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;
diff --git a/src/Mobs/AggressiveMonster.h b/src/Mobs/AggressiveMonster.h
index d70ff04a3..2549ba2d3 100644
--- a/src/Mobs/AggressiveMonster.h
+++ b/src/Mobs/AggressiveMonster.h
@@ -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;
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp
index f7ee0b0c0..b6e22c0ee 100644
--- a/src/Mobs/Monster.cpp
+++ b/src/Mobs/Monster.cpp
@@ -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;
diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h
index cdbd26c09..60bf36c7a 100644
--- a/src/Mobs/Monster.h
+++ b/src/Mobs/Monster.h
@@ -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,
- mtWither = E_META_SPAWN_EGG_WITHER,
- mtWolf = E_META_SPAWN_EGG_WOLF,
- mtZombie = E_META_SPAWN_EGG_ZOMBIE,
- mtZombiePigman = E_META_SPAWN_EGG_ZOMBIE_PIGMAN,
- } ;
-
+
enum eFamily
{
mfHostile = 0, // Spider, Zombies ...
@@ -80,7 +44,7 @@ public:
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);
+ cMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
CLASS_PROTODEF(cMonster)
@@ -96,7 +60,7 @@ public:
virtual bool ReachedDestination(void);
// tolua_begin
- eType GetMobType(void) const {return m_MobType; }
+ eMonsterType GetMobType(void) const {return m_MobType; }
eFamily GetMobFamily(void) const;
// tolua_end
@@ -146,13 +110,13 @@ public:
// tolua_begin
/// Translates MobType enum to a string, empty string if unknown
- static AString MobTypeToString(eType a_MobType);
+ static AString MobTypeToString(eMonsterType a_MobType);
/// Translates MobType string to the enum, mtInvalidType if not recognized
- static eType StringToMobType(const AString & a_MobTypeName);
+ static eMonsterType StringToMobType(const AString & a_MobTypeName);
/// Returns the mob family based on the type
- static eFamily FamilyFromType(eType a_MobType);
+ static eFamily FamilyFromType(eMonsterType a_MobType);
/// Returns the spawn delay (number of game ticks between spawn attempts) for the given mob family
static int GetSpawnDelay(cMonster::eFamily a_MobFamily);
@@ -163,7 +127,7 @@ public:
a_MobType is the type of the mob to be created
Asserts and returns null if mob type is not specified
*/
- static cMonster * NewMonsterFromType(eType a_MobType);
+ static cMonster * NewMonsterFromType(eMonsterType a_MobType);
protected:
@@ -227,7 +191,7 @@ protected:
float m_IdleInterval;
float m_DestroyTimer;
- eType m_MobType;
+ eMonsterType m_MobType;
AString m_SoundHurt;
AString m_SoundDeath;
diff --git a/src/Mobs/MonsterTypes.h b/src/Mobs/MonsterTypes.h
new file mode 100644
index 000000000..7a73e99f4
--- /dev/null
+++ b/src/Mobs/MonsterTypes.h
@@ -0,0 +1,41 @@
+
+#pragma once
+
+/// This identifies individual monster type, as well as their network type-ID
+// tolua_begin
+enum eMonsterType
+{
+ 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,
+ mtWither = E_META_SPAWN_EGG_WITHER,
+ mtWolf = E_META_SPAWN_EGG_WOLF,
+ mtZombie = E_META_SPAWN_EGG_ZOMBIE,
+ mtZombiePigman = E_META_SPAWN_EGG_ZOMBIE_PIGMAN,
+} ;
+// tolua_end
+
diff --git a/src/Mobs/Mooshroom.cpp b/src/Mobs/Mooshroom.cpp
index 81bd3e3b4..99958720f 100644
--- a/src/Mobs/Mooshroom.cpp
+++ b/src/Mobs/Mooshroom.cpp
@@ -67,7 +67,7 @@ void cMooshroom::OnRightClicked(cPlayer & a_Player)
cItems Drops;
Drops.push_back(cItem(E_BLOCK_RED_MUSHROOM, 5, 0));
m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10);
- m_World->SpawnMob(GetPosX(), GetPosY(), GetPosZ(), cMonster::mtCow);
+ m_World->SpawnMob(GetPosX(), GetPosY(), GetPosZ(), mtCow);
Destroy();
} break;
}
diff --git a/src/Mobs/PassiveAggressiveMonster.cpp b/src/Mobs/PassiveAggressiveMonster.cpp
index 24501b1ba..e0cc2fd21 100644
--- a/src/Mobs/PassiveAggressiveMonster.cpp
+++ b/src/Mobs/PassiveAggressiveMonster.cpp
@@ -9,7 +9,7 @@
-cPassiveAggressiveMonster::cPassiveAggressiveMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height) :
+cPassiveAggressiveMonster::cPassiveAggressiveMonster(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 = PASSIVE;
diff --git a/src/Mobs/PassiveAggressiveMonster.h b/src/Mobs/PassiveAggressiveMonster.h
index a0da50e8e..72f472281 100644
--- a/src/Mobs/PassiveAggressiveMonster.h
+++ b/src/Mobs/PassiveAggressiveMonster.h
@@ -13,7 +13,7 @@ class cPassiveAggressiveMonster :
typedef cAggressiveMonster super;
public:
- cPassiveAggressiveMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
+ cPassiveAggressiveMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
} ;
diff --git a/src/Mobs/PassiveMonster.cpp b/src/Mobs/PassiveMonster.cpp
index 2861d7314..be3043e3d 100644
--- a/src/Mobs/PassiveMonster.cpp
+++ b/src/Mobs/PassiveMonster.cpp
@@ -8,7 +8,7 @@
-cPassiveMonster::cPassiveMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height) :
+cPassiveMonster::cPassiveMonster(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 = PASSIVE;
diff --git a/src/Mobs/PassiveMonster.h b/src/Mobs/PassiveMonster.h
index 70574585a..9221d9a6e 100644
--- a/src/Mobs/PassiveMonster.h
+++ b/src/Mobs/PassiveMonster.h
@@ -13,7 +13,7 @@ class cPassiveMonster :
typedef cMonster super;
public:
- cPassiveMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
+ cPassiveMonster(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;