summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--VC2008/MCServer.vcproj16
-rw-r--r--source/Mobs/AggressiveMonster.cpp5
-rw-r--r--source/Mobs/AggressiveMonster.h2
-rw-r--r--source/Mobs/Bat.cpp20
-rw-r--r--source/Mobs/Bat.h5
-rw-r--r--source/Mobs/Blaze.cpp7
-rw-r--r--source/Mobs/Cavespider.cpp7
-rw-r--r--source/Mobs/Chicken.cpp7
-rw-r--r--source/Mobs/Cow.cpp7
-rw-r--r--source/Mobs/Creeper.cpp7
-rw-r--r--source/Mobs/Enderman.cpp7
-rw-r--r--source/Mobs/Ghast.cpp7
-rw-r--r--source/Mobs/Magmacube.cpp7
-rw-r--r--source/Mobs/Monster.cpp29
-rw-r--r--source/Mobs/Monster.h12
-rw-r--r--source/Mobs/Mooshroom.cpp7
-rw-r--r--source/Mobs/Ocelot.cpp20
-rw-r--r--source/Mobs/Ocelot.h5
-rw-r--r--source/Mobs/PassiveAggressiveMonster.cpp3
-rw-r--r--source/Mobs/PassiveAggressiveMonster.h2
-rw-r--r--source/Mobs/PassiveMonster.cpp5
-rw-r--r--source/Mobs/PassiveMonster.h2
-rw-r--r--source/Mobs/Pig.cpp7
-rw-r--r--source/Mobs/Sheep.cpp5
-rw-r--r--source/Mobs/Silverfish.cpp20
-rw-r--r--source/Mobs/Silverfish.h5
-rw-r--r--source/Mobs/Skeleton.cpp7
-rw-r--r--source/Mobs/Slime.cpp7
-rw-r--r--source/Mobs/Spider.cpp7
-rw-r--r--source/Mobs/Squid.cpp5
-rw-r--r--source/Mobs/Villager.cpp5
-rw-r--r--source/Mobs/Witch.cpp5
-rw-r--r--source/Mobs/Wolf.cpp20
-rw-r--r--source/Mobs/Wolf.h5
-rw-r--r--source/Mobs/Zombie.cpp7
-rw-r--r--source/Mobs/Zombiepigman.cpp7
-rw-r--r--source/MonsterConfig.cpp38
-rw-r--r--source/MonsterConfig.h19
38 files changed, 122 insertions, 236 deletions
diff --git a/VC2008/MCServer.vcproj b/VC2008/MCServer.vcproj
index 0ec8a7cff..0c29a5fc8 100644
--- a/VC2008/MCServer.vcproj
+++ b/VC2008/MCServer.vcproj
@@ -727,10 +727,6 @@
>
</File>
<File
- RelativePath="..\source\Mobs\Bat.cpp"
- >
- </File>
- <File
RelativePath="..\source\Mobs\Bat.h"
>
</File>
@@ -815,10 +811,6 @@
>
</File>
<File
- RelativePath="..\source\Mobs\Ocelot.cpp"
- >
- </File>
- <File
RelativePath="..\source\Mobs\Ocelot.h"
>
</File>
@@ -855,10 +847,6 @@
>
</File>
<File
- RelativePath="..\source\Mobs\Silverfish.cpp"
- >
- </File>
- <File
RelativePath="..\source\Mobs\Silverfish.h"
>
</File>
@@ -911,10 +899,6 @@
>
</File>
<File
- RelativePath="..\source\Mobs\Wolf.cpp"
- >
- </File>
- <File
RelativePath="..\source\Mobs\Wolf.h"
>
</File>
diff --git a/source/Mobs/AggressiveMonster.cpp b/source/Mobs/AggressiveMonster.cpp
index eabfb6669..f2e53ce00 100644
--- a/source/Mobs/AggressiveMonster.cpp
+++ b/source/Mobs/AggressiveMonster.cpp
@@ -11,8 +11,9 @@
-cAggressiveMonster::cAggressiveMonster()
- : m_ChaseTime(999999)
+cAggressiveMonster::cAggressiveMonster(const AString & a_ConfigName, char a_ProtocolMobType, const AString & a_SoundHurt, const AString & a_SoundDeath) :
+ super(a_ConfigName, a_ProtocolMobType, a_SoundHurt, a_SoundDeath),
+ m_ChaseTime(999999)
{
m_EMPersonality = AGGRESSIVE;
}
diff --git a/source/Mobs/AggressiveMonster.h b/source/Mobs/AggressiveMonster.h
index f71da7b3c..f364d535d 100644
--- a/source/Mobs/AggressiveMonster.h
+++ b/source/Mobs/AggressiveMonster.h
@@ -13,7 +13,7 @@ class cAggressiveMonster :
typedef cMonster super;
public:
- cAggressiveMonster(void);
+ cAggressiveMonster(const AString & a_ConfigName, char a_ProtocolMobType, const AString & a_SoundHurt, const AString & a_SoundDeath);
virtual void Tick(float a_Dt) override;
virtual void InStateChasing(float a_Dt) override;
diff --git a/source/Mobs/Bat.cpp b/source/Mobs/Bat.cpp
deleted file mode 100644
index 952b0d899..000000000
--- a/source/Mobs/Bat.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-
-#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
-
-#include "Bat.h"
-
-
-
-
-
-cBat::cBat(void)
-{
- m_MobType = 65;
- m_SoundHurt = "mob.bat.hurt";
- m_SoundDeath = "mob.bat.death";
- GetMonsterConfig("Bat");
-}
-
-
-
-
diff --git a/source/Mobs/Bat.h b/source/Mobs/Bat.h
index 91279889f..35c0f99a6 100644
--- a/source/Mobs/Bat.h
+++ b/source/Mobs/Bat.h
@@ -13,7 +13,10 @@ class cBat :
typedef cPassiveMonster super;
public:
- cBat(void);
+ cBat(void) :
+ super("Bat", 65, "mob.bat.hurt", "mob.bat.death")
+ {
+ }
CLASS_PROTODEF(cBat);
} ;
diff --git a/source/Mobs/Blaze.cpp b/source/Mobs/Blaze.cpp
index bab0ea13a..e6e2d7ec2 100644
--- a/source/Mobs/Blaze.cpp
+++ b/source/Mobs/Blaze.cpp
@@ -7,12 +7,9 @@
-cBlaze::cBlaze(void)
+cBlaze::cBlaze(void) :
+ super("Blaze", 61, "mob.blaze.hit", "mob.blaze.death")
{
- m_MobType = 61;
- m_SoundHurt = "mob.blaze.hit";
- m_SoundDeath = "mob.blaze.death";
- GetMonsterConfig("Blaze");
}
diff --git a/source/Mobs/Cavespider.cpp b/source/Mobs/Cavespider.cpp
index b9d4829bc..b0dcd2eae 100644
--- a/source/Mobs/Cavespider.cpp
+++ b/source/Mobs/Cavespider.cpp
@@ -7,12 +7,9 @@
-cCavespider::cCavespider(void)
+cCavespider::cCavespider(void) :
+ super("Cavespider", 59, "mob.spider.say", "mob.spider.death")
{
- m_MobType = 59;
- m_SoundHurt = "mob.spider.say";
- m_SoundDeath = "mob.spider.death";
- GetMonsterConfig("Cavespider");
}
diff --git a/source/Mobs/Chicken.cpp b/source/Mobs/Chicken.cpp
index 55bf73584..e506bb7a8 100644
--- a/source/Mobs/Chicken.cpp
+++ b/source/Mobs/Chicken.cpp
@@ -13,12 +13,9 @@
-cChicken::cChicken(void)
+cChicken::cChicken(void) :
+ super("Chicken", 93, "mob.chicken.hurt", "mob.chicken.hurt")
{
- m_MobType = 93;
- m_SoundHurt = "mob.chicken.hurt";
- m_SoundDeath = "mob.chicken.hurt";
- GetMonsterConfig("Chicken");
}
diff --git a/source/Mobs/Cow.cpp b/source/Mobs/Cow.cpp
index b0dab1e0f..31a431af4 100644
--- a/source/Mobs/Cow.cpp
+++ b/source/Mobs/Cow.cpp
@@ -13,12 +13,9 @@
-cCow::cCow(void)
+cCow::cCow(void) :
+ super("Cow", 92, "mob.cow.hurt", "mob.cow.hurt")
{
- m_MobType = 92;
- m_SoundHurt = "mob.cow.hurt";
- m_SoundDeath = "mob.cow.hurt";
- GetMonsterConfig("Cow");
}
diff --git a/source/Mobs/Creeper.cpp b/source/Mobs/Creeper.cpp
index b3133d7c9..44b5e76cd 100644
--- a/source/Mobs/Creeper.cpp
+++ b/source/Mobs/Creeper.cpp
@@ -7,12 +7,9 @@
-cCreeper::cCreeper(void)
+cCreeper::cCreeper(void) :
+ super("Creeper", 50, "mob.creeper.say", "mob.creeper.say")
{
- m_MobType = 50;
- m_SoundHurt = "mob.creeper.say";
- m_SoundDeath = "mob.creeper.say";
- GetMonsterConfig("Creeper");
}
diff --git a/source/Mobs/Enderman.cpp b/source/Mobs/Enderman.cpp
index 2814ab71b..33aecc61d 100644
--- a/source/Mobs/Enderman.cpp
+++ b/source/Mobs/Enderman.cpp
@@ -7,12 +7,9 @@
-cEnderman::cEnderman(void)
+cEnderman::cEnderman(void) :
+ super("Enderman", 58, "mob.endermen.hit", "mob.endermen.death")
{
- m_MobType = 58;
- m_SoundHurt = "mob.endermen.hit";
- m_SoundDeath = "mob.endermen.death";
- GetMonsterConfig("Enderman");
}
diff --git a/source/Mobs/Ghast.cpp b/source/Mobs/Ghast.cpp
index 38f6af582..1d0e074b8 100644
--- a/source/Mobs/Ghast.cpp
+++ b/source/Mobs/Ghast.cpp
@@ -7,12 +7,9 @@
-cGhast::cGhast(void)
+cGhast::cGhast(void) :
+ super("Ghast", 56, "mob.ghast.scream", "mob.ghast.death")
{
- m_MobType = 56;
- m_SoundHurt = "mob.ghast.scream";
- m_SoundDeath = "mob.ghast.death";
- GetMonsterConfig("Ghast");
}
diff --git a/source/Mobs/Magmacube.cpp b/source/Mobs/Magmacube.cpp
index f514d6177..fb9228c08 100644
--- a/source/Mobs/Magmacube.cpp
+++ b/source/Mobs/Magmacube.cpp
@@ -7,12 +7,9 @@
-cMagmacube::cMagmacube()
+cMagmacube::cMagmacube(void) :
+ super("Magmacube", 62, "mob.magmacube.big", "mob.magmacube.big")
{
- m_MobType = 62;
- m_SoundHurt = "mob.magmacube.big";
- m_SoundDeath = "mob.magmacube.big";
- GetMonsterConfig("Magmacube");
}
diff --git a/source/Mobs/Monster.cpp b/source/Mobs/Monster.cpp
index 04989caac..49f11ebfd 100644
--- a/source/Mobs/Monster.cpp
+++ b/source/Mobs/Monster.cpp
@@ -16,19 +16,13 @@
#include "../Vector3d.h"
#include "../Tracer.h"
-#include "../../iniFile/iniFile.h"
+// #include "../../iniFile/iniFile.h"
-/*
-#ifndef _WIN32
- #include <unistd.h>
-#endif
-*/
-
-cMonster::cMonster(void)
+cMonster::cMonster(const AString & a_ConfigName, char a_ProtocolMobType, const AString & a_SoundHurt, const AString & a_SoundDeath)
: super(etMob)
, m_Target(NULL)
, m_bMovingToDestination(false)
@@ -37,9 +31,9 @@ cMonster::cMonster(void)
, m_bOnGround( false )
, m_DestroyTimer( 0 )
, m_Jump(0)
- , m_MobType( 0 )
- , m_SoundHurt( "" )
- , m_SoundDeath( "" )
+ , m_MobType(a_ProtocolMobType)
+ , m_SoundHurt(a_SoundHurt)
+ , m_SoundDeath(a_SoundDeath)
, m_EMState(IDLE)
, m_SightDistance(25)
, m_SeePlayerInterval (0)
@@ -50,11 +44,10 @@ cMonster::cMonster(void)
, m_AttackRate(3)
, idle_interval(0)
{
- LOGD("cMonster::cMonster()");
- LOGD("In state: %s", GetState());
-
- m_bBurnable = true;
- m_MetaData = NORMAL;
+ if (!a_ConfigName.empty())
+ {
+ GetMonsterConfig(a_ConfigName);
+ }
}
@@ -520,9 +513,9 @@ cPlayer * cMonster::FindClosestPlayer(void)
-void cMonster::GetMonsterConfig(const char* pm_name)
+void cMonster::GetMonsterConfig(const AString & a_Name)
{
- cRoot::Get()->GetMonsterConfig()->AssignAttributes(this, pm_name);
+ cRoot::Get()->GetMonsterConfig()->AssignAttributes(this, a_Name);
}
diff --git a/source/Mobs/Monster.h b/source/Mobs/Monster.h
index 2c26045ff..066f17495 100644
--- a/source/Mobs/Monster.h
+++ b/source/Mobs/Monster.h
@@ -25,7 +25,12 @@ class cMonster :
public:
// tolua_end
- cMonster(void);
+ /** Creates the mob object.
+ * If a_ConfigName is not empty, the configuration is loaded using GetMonsterConfig()
+ * a_ProtocolMobType is the ID of the mob 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, char a_ProtocolMobType, const AString & a_SoundHurt, const AString & a_SoundDeath);
CLASS_PROTODEF(cMonster);
@@ -52,7 +57,10 @@ public:
virtual void EventSeePlayer(cEntity *);
float m_SightDistance;
virtual cPlayer * FindClosestPlayer(); // non static is easier. also virtual so other mobs can implement their own searching algo
- virtual void GetMonsterConfig(const char* pm_name);
+
+ /// Reads the monster configuration for the specified monster name and assigns it to this object.
+ void GetMonsterConfig(const AString & a_Name);
+
virtual void EventLosePlayer();
virtual void CheckEventLostPlayer();
diff --git a/source/Mobs/Mooshroom.cpp b/source/Mobs/Mooshroom.cpp
index 148b0c068..1ef1d600d 100644
--- a/source/Mobs/Mooshroom.cpp
+++ b/source/Mobs/Mooshroom.cpp
@@ -13,12 +13,9 @@
-cMooshroom::cMooshroom(void)
+cMooshroom::cMooshroom(void) :
+ super("Mooshroom", 96, "mob.cow.hurt", "mob.cow.hurt")
{
- m_MobType = 96;
- m_SoundHurt = "mob.cow.hurt";
- m_SoundDeath = "mob.cow.hurt";
- GetMonsterConfig("Mooshroom");
}
diff --git a/source/Mobs/Ocelot.cpp b/source/Mobs/Ocelot.cpp
deleted file mode 100644
index df2eb5c04..000000000
--- a/source/Mobs/Ocelot.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-
-#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
-
-#include "Ocelot.h"
-
-
-
-
-
-cOcelot::cOcelot()
-{
- m_MobType = 98;
- m_SoundHurt = "mob.cat.hitt";
- m_SoundDeath = "mob.cat.hitt";
- GetMonsterConfig("Ocelot");
-}
-
-
-
-
diff --git a/source/Mobs/Ocelot.h b/source/Mobs/Ocelot.h
index acda6a1e6..76ee6815e 100644
--- a/source/Mobs/Ocelot.h
+++ b/source/Mobs/Ocelot.h
@@ -13,7 +13,10 @@ class cOcelot :
typedef cPassiveMonster super;
public:
- cOcelot();
+ cOcelot(void) :
+ super("Ocelot", 98, "mob.cat.hitt", "mob.cat.hitt")
+ {
+ }
CLASS_PROTODEF(cOcelot);
} ;
diff --git a/source/Mobs/PassiveAggressiveMonster.cpp b/source/Mobs/PassiveAggressiveMonster.cpp
index b5ef7aa97..41258c788 100644
--- a/source/Mobs/PassiveAggressiveMonster.cpp
+++ b/source/Mobs/PassiveAggressiveMonster.cpp
@@ -9,7 +9,8 @@
-cPassiveAggressiveMonster::cPassiveAggressiveMonster(void)
+cPassiveAggressiveMonster::cPassiveAggressiveMonster(const AString & a_ConfigName, char a_ProtocolMobType, const AString & a_SoundHurt, const AString & a_SoundDeath) :
+ super(a_ConfigName, a_ProtocolMobType, a_SoundHurt, a_SoundDeath)
{
m_EMPersonality = PASSIVE;
}
diff --git a/source/Mobs/PassiveAggressiveMonster.h b/source/Mobs/PassiveAggressiveMonster.h
index e6e50677d..abb6a7abd 100644
--- a/source/Mobs/PassiveAggressiveMonster.h
+++ b/source/Mobs/PassiveAggressiveMonster.h
@@ -13,7 +13,7 @@ class cPassiveAggressiveMonster :
typedef cAggressiveMonster super;
public:
- cPassiveAggressiveMonster(void);
+ cPassiveAggressiveMonster(const AString & a_ConfigName, char a_ProtocolMobType, const AString & a_SoundHurt, const AString & a_SoundDeath);
virtual void DoTakeDamage(TakeDamageInfo & a_TDI) override;
} ;
diff --git a/source/Mobs/PassiveMonster.cpp b/source/Mobs/PassiveMonster.cpp
index 6224b284a..b11f7305d 100644
--- a/source/Mobs/PassiveMonster.cpp
+++ b/source/Mobs/PassiveMonster.cpp
@@ -8,7 +8,8 @@
-cPassiveMonster::cPassiveMonster(void)
+cPassiveMonster::cPassiveMonster(const AString & a_ConfigName, char a_ProtocolMobType, const AString & a_SoundHurt, const AString & a_SoundDeath) :
+ super(a_ConfigName, a_ProtocolMobType, a_SoundHurt, a_SoundDeath)
{
m_EMPersonality = PASSIVE;
}
@@ -32,7 +33,7 @@ void cPassiveMonster::DoTakeDamage(TakeDamageInfo & a_TDI)
void cPassiveMonster::Tick(float a_Dt)
{
- cMonster::Tick(a_Dt);
+ super::Tick(a_Dt);
m_SeePlayerInterval += a_Dt;
diff --git a/source/Mobs/PassiveMonster.h b/source/Mobs/PassiveMonster.h
index 14a4e9d24..d31510891 100644
--- a/source/Mobs/PassiveMonster.h
+++ b/source/Mobs/PassiveMonster.h
@@ -13,7 +13,7 @@ class cPassiveMonster :
typedef cMonster super;
public:
- cPassiveMonster(void);
+ cPassiveMonster(const AString & a_ConfigName, char a_ProtocolMobType, const AString & a_SoundHurt, const AString & a_SoundDeath);
virtual void Tick(float a_Dt) override;
diff --git a/source/Mobs/Pig.cpp b/source/Mobs/Pig.cpp
index c75d0c0bf..15be0001f 100644
--- a/source/Mobs/Pig.cpp
+++ b/source/Mobs/Pig.cpp
@@ -7,12 +7,9 @@
-cPig::cPig(void)
+cPig::cPig(void) :
+ super("Pig", 90, "mob.pig.say", "mob.pig.death")
{
- m_MobType = 90;
- m_SoundHurt = "mob.pig.say";
- m_SoundDeath = "mob.pig.death";
- GetMonsterConfig("Pig");
}
diff --git a/source/Mobs/Sheep.cpp b/source/Mobs/Sheep.cpp
index c4cdba1cf..c860e25d9 100644
--- a/source/Mobs/Sheep.cpp
+++ b/source/Mobs/Sheep.cpp
@@ -9,13 +9,10 @@
cSheep::cSheep(void) :
+ super("Sheep", 91, "mob.sheep.say", "mob.sheep.say"),
m_IsSheared(false),
m_WoolColor(E_META_WOOL_WHITE)
{
- m_MobType = 91;
- m_SoundHurt = "mob.sheep.say";
- m_SoundDeath = "mob.sheep.say";
- GetMonsterConfig("Sheep");
}
diff --git a/source/Mobs/Silverfish.cpp b/source/Mobs/Silverfish.cpp
deleted file mode 100644
index d62b7cc14..000000000
--- a/source/Mobs/Silverfish.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-
-#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
-
-#include "Silverfish.h"
-
-
-
-
-
-cSilverfish::cSilverfish(void)
-{
- m_MobType = 60;
- m_SoundHurt = "mob.silverfish.hit";
- m_SoundDeath = "mob.silverfish.kill";
- GetMonsterConfig("Silverfish");
-}
-
-
-
-
diff --git a/source/Mobs/Silverfish.h b/source/Mobs/Silverfish.h
index 4e4fbd11c..24a9cf38b 100644
--- a/source/Mobs/Silverfish.h
+++ b/source/Mobs/Silverfish.h
@@ -13,7 +13,10 @@ class cSilverfish :
typedef cAggressiveMonster super;
public:
- cSilverfish(void);
+ cSilverfish(void) :
+ super("Silverfish", 60, "mob.silverfish.hit", "mob.silverfish.kill")
+ {
+ }
CLASS_PROTODEF(cSilverfish);
} ;
diff --git a/source/Mobs/Skeleton.cpp b/source/Mobs/Skeleton.cpp
index 279aa0fe3..76a7b6beb 100644
--- a/source/Mobs/Skeleton.cpp
+++ b/source/Mobs/Skeleton.cpp
@@ -7,12 +7,9 @@
-cSkeleton::cSkeleton(void)
+cSkeleton::cSkeleton(void) :
+ super("Skeleton", 51, "mob.skeleton.hurt", "mob.skeleton.death")
{
- m_MobType = 51;
- m_SoundHurt = "mob.skeleton.hurt";
- m_SoundDeath = "mob.skeleton.death";
- GetMonsterConfig("Skeleton");
}
diff --git a/source/Mobs/Slime.cpp b/source/Mobs/Slime.cpp
index c95915215..ee7093b73 100644
--- a/source/Mobs/Slime.cpp
+++ b/source/Mobs/Slime.cpp
@@ -9,12 +9,9 @@
-cSlime::cSlime(void)
+cSlime::cSlime(void) :
+ super("Slime", 55, "mob.slime.attack", "mob.slime.attack")
{
- m_MobType = 55;
- m_SoundHurt = "mob.slime.attack";
- m_SoundDeath = "mob.slime.attack";
- GetMonsterConfig("Slime");
}
diff --git a/source/Mobs/Spider.cpp b/source/Mobs/Spider.cpp
index 608858a5e..4e671e7ab 100644
--- a/source/Mobs/Spider.cpp
+++ b/source/Mobs/Spider.cpp
@@ -7,12 +7,9 @@
-cSpider::cSpider()
+cSpider::cSpider(void) :
+ super("Spider", 52, "mob.spider.say", "mob.spider.death")
{
- m_MobType = 52;
- m_SoundHurt = "mob.spider.say";
- m_SoundDeath = "mob.spider.death";
- GetMonsterConfig("Spider");
}
diff --git a/source/Mobs/Squid.cpp b/source/Mobs/Squid.cpp
index b3df8711a..e300deef0 100644
--- a/source/Mobs/Squid.cpp
+++ b/source/Mobs/Squid.cpp
@@ -8,10 +8,9 @@
-cSquid::cSquid()
+cSquid::cSquid(void) :
+ super("Squid", 94, "", "")
{
- m_MobType = 94;
- GetMonsterConfig("Squid");
}
diff --git a/source/Mobs/Villager.cpp b/source/Mobs/Villager.cpp
index c97bb714f..1bc5fb86b 100644
--- a/source/Mobs/Villager.cpp
+++ b/source/Mobs/Villager.cpp
@@ -7,10 +7,9 @@
-cVillager::cVillager()
+cVillager::cVillager(void) :
+ super("Villager", 120, "", "")
{
- m_MobType = 120;
- GetMonsterConfig("Villager");
}
diff --git a/source/Mobs/Witch.cpp b/source/Mobs/Witch.cpp
index 2bbe5b94b..ee77d066b 100644
--- a/source/Mobs/Witch.cpp
+++ b/source/Mobs/Witch.cpp
@@ -7,10 +7,9 @@
-cWitch::cWitch()
+cWitch::cWitch(void) :
+ super("Witch", 66, "", "")
{
- m_MobType = 66;
- GetMonsterConfig("Witch");
}
diff --git a/source/Mobs/Wolf.cpp b/source/Mobs/Wolf.cpp
deleted file mode 100644
index 52bfb46cb..000000000
--- a/source/Mobs/Wolf.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-
-#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
-
-#include "Wolf.h"
-
-
-
-
-
-cWolf::cWolf(void)
-{
- m_MobType = 95;
- m_SoundHurt = "mob.wolf.hurt";
- m_SoundDeath = "mob.wolf.death";
- GetMonsterConfig("Wolf");
-}
-
-
-
-
diff --git a/source/Mobs/Wolf.h b/source/Mobs/Wolf.h
index 5dd7065a7..7247f823c 100644
--- a/source/Mobs/Wolf.h
+++ b/source/Mobs/Wolf.h
@@ -13,7 +13,10 @@ class cWolf :
typedef cPassiveAggressiveMonster super;
public:
- cWolf(void);
+ cWolf(void) :
+ super("Wolf", 95, "mob.wolf.hurt", "mob.wolf.death")
+ {
+ }
CLASS_PROTODEF(cWolf);
} ;
diff --git a/source/Mobs/Zombie.cpp b/source/Mobs/Zombie.cpp
index c3e331226..bf630929a 100644
--- a/source/Mobs/Zombie.cpp
+++ b/source/Mobs/Zombie.cpp
@@ -7,12 +7,9 @@
-cZombie::cZombie()
+cZombie::cZombie(void) :
+ super("Zombie", 54, "mob.zombie.hurt", "mob.zombie.death")
{
- m_MobType = 54;
- m_SoundHurt = "mob.zombie.hurt";
- m_SoundDeath = "mob.zombie.death";
- GetMonsterConfig("Zombie");
}
diff --git a/source/Mobs/Zombiepigman.cpp b/source/Mobs/Zombiepigman.cpp
index 89e679050..0e618cbc2 100644
--- a/source/Mobs/Zombiepigman.cpp
+++ b/source/Mobs/Zombiepigman.cpp
@@ -7,12 +7,9 @@
-cZombiepigman::cZombiepigman()
+cZombiepigman::cZombiepigman(void) :
+ super("Zombiepigman", 57, "mob.zombiepig.zpighurt", "mob.zombiepig.zpigdeath")
{
- m_MobType = 57;
- m_SoundHurt = "mob.zombiepig.zpighurt";
- m_SoundDeath = "mob.zombiepig.zpigdeath";
- GetMonsterConfig("Zombiepigman");
}
diff --git a/source/MonsterConfig.cpp b/source/MonsterConfig.cpp
index f4e1d2c70..ff32c3406 100644
--- a/source/MonsterConfig.cpp
+++ b/source/MonsterConfig.cpp
@@ -44,7 +44,8 @@ cMonsterConfig::cMonsterConfig(void)
-cMonsterConfig::~cMonsterConfig() {
+cMonsterConfig::~cMonsterConfig()
+{
delete m_pState;
}
@@ -52,8 +53,8 @@ cMonsterConfig::~cMonsterConfig() {
-void cMonsterConfig::Initialize() {
-
+void cMonsterConfig::Initialize()
+{
sAttributesStruct Attributes;
cIniFile SettingsIniFile("settings.ini");
cIniFile MonstersIniFile("monsters.ini");
@@ -64,7 +65,7 @@ void cMonsterConfig::Initialize() {
return;
}
- m_pState->MonsterTypes = SettingsIniFile.GetValue("Monsters","Types","");
+ m_pState->MonsterTypes = SettingsIniFile.GetValue("Monsters", "Types", "");
if ( m_pState->MonsterTypes.empty() )
{
@@ -72,17 +73,17 @@ void cMonsterConfig::Initialize() {
return;
}
- AStringVector SplitList = StringSplit(m_pState->MonsterTypes,",");
+ AStringVector SplitList = StringSplit(m_pState->MonsterTypes, ",");
for (unsigned int i = 0; i < SplitList.size(); ++i)
{
if (!SplitList[i].empty())
{
- Attributes.m_name = SplitList[i].c_str();
- Attributes.m_AttackDamage = (float)MonstersIniFile.GetValueF(SplitList[i].c_str(), "AttackDamage", 0);
- Attributes.m_AttackRange = (float)MonstersIniFile.GetValueF(SplitList[i].c_str(), "AttackRange", 0);
- Attributes.m_SightDistance = (float)MonstersIniFile.GetValueF(SplitList[i].c_str(), "SightDistance", 0);
- Attributes.m_AttackRate = (float)MonstersIniFile.GetValueF(SplitList[i].c_str(), "AttackRate", 0);
- Attributes.m_MaxHealth = MonstersIniFile.GetValueI(SplitList[i].c_str(), "MaxHealth", 0);
+ Attributes.m_name = SplitList[i];
+ Attributes.m_AttackDamage = (float)MonstersIniFile.GetValueF(SplitList[i], "AttackDamage", 0);
+ Attributes.m_AttackRange = (float)MonstersIniFile.GetValueF(SplitList[i], "AttackRange", 0);
+ Attributes.m_SightDistance = (float)MonstersIniFile.GetValueF(SplitList[i], "SightDistance", 0);
+ Attributes.m_AttackRate = (float)MonstersIniFile.GetValueF(SplitList[i], "AttackRate", 0);
+ Attributes.m_MaxHealth = MonstersIniFile.GetValueI(SplitList[i], "MaxHealth", 0);
m_pState->AttributesList.push_front(Attributes);
}
} // for i - SplitList[]
@@ -92,18 +93,19 @@ void cMonsterConfig::Initialize() {
-void cMonsterConfig::AssignAttributes(cMonster *m, const char* n)
+void cMonsterConfig::AssignAttributes(cMonster * a_Monster, const AString & a_Name)
{
std::list<sAttributesStruct>::const_iterator itr;
for (itr = m_pState->AttributesList.begin(); itr != m_pState->AttributesList.end(); ++itr)
{
- if(itr->m_name.compare(n) == 0)
+ if (itr->m_name.compare(a_Name) == 0)
{
- m->SetAttackDamage (itr->m_AttackDamage);
- m->SetAttackRange (itr->m_AttackRange);
- m->SetSightDistance(itr->m_SightDistance);
- m->SetAttackRate ((int)itr->m_AttackRate);
- m->SetMaxHealth ((short)itr->m_MaxHealth);
+ a_Monster->SetAttackDamage (itr->m_AttackDamage);
+ a_Monster->SetAttackRange (itr->m_AttackRange);
+ a_Monster->SetSightDistance(itr->m_SightDistance);
+ a_Monster->SetAttackRate ((int)itr->m_AttackRate);
+ a_Monster->SetMaxHealth ((short)itr->m_MaxHealth);
+ return;
}
} // for itr - m_pState->AttributesList[]
}
diff --git a/source/MonsterConfig.h b/source/MonsterConfig.h
index d1a514b17..371d324c2 100644
--- a/source/MonsterConfig.h
+++ b/source/MonsterConfig.h
@@ -1,17 +1,32 @@
+
#pragma once
+
+
+
+
+// fwd:
class cMonster;
+
+
+
+
+
class cMonsterConfig
{
public:
cMonsterConfig(void);
~cMonsterConfig();
- void AssignAttributes(cMonster *m, const char* n);
+ void AssignAttributes(cMonster * a_Monster, const AString & a_Name);
private:
struct sAttributesStruct;
struct sMonsterConfigState;
sMonsterConfigState* m_pState;
void Initialize();
-}; \ No newline at end of file
+} ;
+
+
+
+