summaryrefslogtreecommitdiffstats
path: root/source/Mobs
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-12-21 12:04:08 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-12-21 12:04:08 +0100
commit912a1e7adc650d20b0302a3dfe45816b5e541bc7 (patch)
tree65e7ffbf33d8f1335a4997fc5a727739f9dcdd34 /source/Mobs
parentExtended player inventory by direct r/o access to armor slots (diff)
downloadcuberite-912a1e7adc650d20b0302a3dfe45816b5e541bc7.tar
cuberite-912a1e7adc650d20b0302a3dfe45816b5e541bc7.tar.gz
cuberite-912a1e7adc650d20b0302a3dfe45816b5e541bc7.tar.bz2
cuberite-912a1e7adc650d20b0302a3dfe45816b5e541bc7.tar.lz
cuberite-912a1e7adc650d20b0302a3dfe45816b5e541bc7.tar.xz
cuberite-912a1e7adc650d20b0302a3dfe45816b5e541bc7.tar.zst
cuberite-912a1e7adc650d20b0302a3dfe45816b5e541bc7.zip
Diffstat (limited to '')
-rw-r--r--source/Mobs/Bat.cpp23
-rw-r--r--source/Mobs/Bat.h21
-rw-r--r--source/Mobs/Blaze.cpp23
-rw-r--r--source/Mobs/Blaze.h23
-rw-r--r--source/Mobs/Cavespider.cpp27
-rw-r--r--source/Mobs/Cavespider.h25
-rw-r--r--source/Mobs/Chicken.cpp27
-rw-r--r--source/Mobs/Chicken.h23
-rw-r--r--source/Mobs/Cow.cpp25
-rw-r--r--source/Mobs/Cow.h21
-rw-r--r--source/Mobs/Creeper.cpp24
-rw-r--r--source/Mobs/Creeper.h23
-rw-r--r--source/Mobs/Enderman.cpp23
-rw-r--r--source/Mobs/Enderman.h25
-rw-r--r--source/Mobs/Ghast.cpp24
-rw-r--r--source/Mobs/Ghast.h23
-rw-r--r--source/Mobs/Magmacube.cpp21
-rw-r--r--source/Mobs/Magmacube.h21
-rw-r--r--source/Mobs/Monster.cpp21
-rw-r--r--source/Mobs/Monster.h25
-rw-r--r--source/Mobs/Mooshroom.cpp25
-rw-r--r--source/Mobs/Mooshroom.h23
-rw-r--r--source/Mobs/Ocelot.cpp21
-rw-r--r--source/Mobs/Ocelot.h19
-rw-r--r--source/Mobs/PassiveAggressiveMonster.cpp23
-rw-r--r--source/Mobs/PassiveAggressiveMonster.h22
-rw-r--r--source/Mobs/PassiveMonster.cpp35
-rw-r--r--source/Mobs/PassiveMonster.h24
-rw-r--r--source/Mobs/Pig.cpp25
-rw-r--r--source/Mobs/Pig.h23
-rw-r--r--source/Mobs/Sheep.cpp37
-rw-r--r--source/Mobs/Sheep.h23
-rw-r--r--source/Mobs/Silverfish.h2
-rw-r--r--source/Mobs/Skeleton.cpp23
-rw-r--r--source/Mobs/Skeleton.h24
-rw-r--r--source/Mobs/Slime.cpp27
-rw-r--r--source/Mobs/Slime.h17
-rw-r--r--source/Mobs/Spider.cpp23
-rw-r--r--source/Mobs/Spider.h21
-rw-r--r--source/Mobs/Squid.cpp33
-rw-r--r--source/Mobs/Squid.h26
-rw-r--r--source/Mobs/Villager.cpp22
-rw-r--r--source/Mobs/Villager.h19
-rw-r--r--source/Mobs/Witch.cpp33
-rw-r--r--source/Mobs/Witch.h21
-rw-r--r--source/Mobs/Zombie.cpp24
-rw-r--r--source/Mobs/Zombie.h22
-rw-r--r--source/Mobs/Zombiepigman.cpp39
-rw-r--r--source/Mobs/Zombiepigman.h24
49 files changed, 574 insertions, 594 deletions
diff --git a/source/Mobs/Bat.cpp b/source/Mobs/Bat.cpp
index 4cc74ec2b..24ce88184 100644
--- a/source/Mobs/Bat.cpp
+++ b/source/Mobs/Bat.cpp
@@ -7,7 +7,7 @@
-cBat::cBat()
+cBat::cBat(void)
{
m_MobType = 65;
GetMonsterConfig("Bat");
@@ -17,29 +17,12 @@ cBat::cBat()
-cBat::~cBat()
+bool cBat::IsA(const char * a_EntityType)
{
+ return ((strcmp(a_EntityType, "cBat") == 0) || super::IsA(a_EntityType));
}
-bool cBat::IsA( const char* a_EntityType )
-{
- if( strcmp( a_EntityType, "cBat" ) == 0 ) return true;
- return cMonster::IsA( a_EntityType );
-}
-
-
-
-
-
-void cBat::KilledBy( cEntity* a_Killer )
-{
- cMonster::KilledBy( a_Killer );
-}
-
-
-
-
diff --git a/source/Mobs/Bat.h b/source/Mobs/Bat.h
index 94ae595d0..7965072fc 100644
--- a/source/Mobs/Bat.h
+++ b/source/Mobs/Bat.h
@@ -1,14 +1,23 @@
+
#pragma once
#include "PassiveMonster.h"
-class cBat : public cPassiveMonster
+
+
+
+
+class cBat :
+ public cPassiveMonster
{
+ typedef cPassiveMonster super;
+
public:
- cBat();
- ~cBat();
+ cBat(void);
+
+ virtual bool IsA(const char * a_EntityType) override;
+} ;
+
+
- virtual bool IsA( const char* a_EntityType );
- virtual void KilledBy( cEntity* a_Killer );
-};
diff --git a/source/Mobs/Blaze.cpp b/source/Mobs/Blaze.cpp
index c3e68518f..e53cbb44d 100644
--- a/source/Mobs/Blaze.cpp
+++ b/source/Mobs/Blaze.cpp
@@ -7,7 +7,7 @@
-cBlaze::cBlaze()
+cBlaze::cBlaze(void)
{
m_MobType = 61;
GetMonsterConfig("Blaze");
@@ -17,31 +17,18 @@ cBlaze::cBlaze()
-cBlaze::~cBlaze()
+bool cBlaze::IsA(const char * a_EntityType)
{
+ return ((strcmp(a_EntityType, "cBlaze") == 0) || super::IsA(a_EntityType));
}
-bool cBlaze::IsA( const char* a_EntityType )
+void cBlaze::GetDrops(cItems & a_Drops, cPawn * a_Killer)
{
- if( strcmp( a_EntityType, "cBlaze" ) == 0 ) return true;
- return cMonster::IsA( a_EntityType );
-}
-
-
-
-
-
-void cBlaze::KilledBy( cEntity* a_Killer )
-{
- cItems Drops;
- AddRandomDropItem(Drops, 0, 1, E_ITEM_BLAZE_ROD);
- m_World->SpawnItemPickups(Drops, m_Pos.x, m_Pos.y, m_Pos.z);
-
- cMonster::KilledBy( a_Killer );
+ AddRandomDropItem(a_Drops, 0, 1, E_ITEM_BLAZE_ROD);
}
diff --git a/source/Mobs/Blaze.h b/source/Mobs/Blaze.h
index bd722d529..6dca7fed0 100644
--- a/source/Mobs/Blaze.h
+++ b/source/Mobs/Blaze.h
@@ -1,14 +1,25 @@
+
#pragma once
#include "AggressiveMonster.h"
-class cBlaze : public cAggressiveMonster
+
+
+
+
+class cBlaze :
+ public cAggressiveMonster
{
+ typedef cAggressiveMonster super;
+
public:
- cBlaze();
- ~cBlaze();
+ cBlaze(void);
+
+ virtual bool IsA(const char * a_EntityType) override;
+
+ virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override;
+} ;
+
+
- virtual bool IsA( const char* a_EntityType );
- virtual void KilledBy( cEntity* a_Killer );
-};
diff --git a/source/Mobs/Cavespider.cpp b/source/Mobs/Cavespider.cpp
index 6c7ed0a7a..9336f8f5b 100644
--- a/source/Mobs/Cavespider.cpp
+++ b/source/Mobs/Cavespider.cpp
@@ -7,7 +7,7 @@
-cCavespider::cCavespider()
+cCavespider::cCavespider(void)
{
m_MobType = 59;
GetMonsterConfig("Cavespider");
@@ -17,18 +17,9 @@ cCavespider::cCavespider()
-cCavespider::~cCavespider()
+bool cCavespider::IsA(const char * a_EntityType)
{
-}
-
-
-
-
-
-bool cCavespider::IsA( const char* a_EntityType )
-{
- if( strcmp( a_EntityType, "cCavespider" ) == 0 ) return true;
- return cMonster::IsA( a_EntityType );
+ return ((strcmp(a_EntityType, "cCaveSpider") == 0) || super::IsA(a_EntityType));
}
@@ -37,7 +28,8 @@ bool cCavespider::IsA( const char* a_EntityType )
void cCavespider::Tick(float a_Dt)
{
- cMonster::Tick(a_Dt);
+ super::Tick(a_Dt);
+ // TODO: Check vanilla if cavespiders really get passive during the day
m_EMPersonality = (GetWorld()->GetTimeOfDay() < (12000 + 1000)) ? PASSIVE : AGGRESSIVE;
}
@@ -45,13 +37,10 @@ void cCavespider::Tick(float a_Dt)
-void cCavespider::KilledBy( cEntity* a_Killer )
+void cCavespider::GetDrops(cItems & a_Drops, cPawn * a_Killer)
{
- cItems Drops;
- AddRandomDropItem(Drops, 0, 2, E_ITEM_STRING);
- AddRandomDropItem(Drops, 0, 1, E_ITEM_SPIDER_EYE);
-
- cMonster::KilledBy( a_Killer );
+ AddRandomDropItem(a_Drops, 0, 2, E_ITEM_STRING);
+ AddRandomDropItem(a_Drops, 0, 1, E_ITEM_SPIDER_EYE);
}
diff --git a/source/Mobs/Cavespider.h b/source/Mobs/Cavespider.h
index 163bb1f92..10b462bea 100644
--- a/source/Mobs/Cavespider.h
+++ b/source/Mobs/Cavespider.h
@@ -1,15 +1,26 @@
+
#pragma once
#include "AggressiveMonster.h"
-class cCavespider : public cAggressiveMonster
+
+
+
+
+class cCavespider :
+ public cAggressiveMonster
{
+ typedef cAggressiveMonster super;
+
public:
- cCavespider();
- ~cCavespider();
+ cCavespider(void);
+
+ virtual bool IsA(const char * a_EntityType) override;
+
+ virtual void Tick(float a_Dt) override;
+ virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override;
+} ;
+
+
- virtual bool IsA( const char* a_EntityType );
- virtual void Tick(float a_Dt);
- virtual void KilledBy( cEntity* a_Killer );
-};
diff --git a/source/Mobs/Chicken.cpp b/source/Mobs/Chicken.cpp
index 940491ad4..cd282f5ed 100644
--- a/source/Mobs/Chicken.cpp
+++ b/source/Mobs/Chicken.cpp
@@ -7,13 +7,13 @@
-// TODO Drop egg every 5-10 minutes
+// TODO: Drop egg every 5-10 minutes
-cChicken::cChicken()
+cChicken::cChicken(void)
{
m_MobType = 93;
GetMonsterConfig("Chicken");
@@ -23,32 +23,19 @@ cChicken::cChicken()
-cChicken::~cChicken()
+bool cChicken::IsA(const char * a_EntityType)
{
+ return ((strcmp(a_EntityType, "cChicken") == 0) || super::IsA(a_EntityType));
}
-bool cChicken::IsA( const char* a_EntityType )
+void cChicken::GetDrops(cItems & a_Drops, cPawn * a_Killer)
{
- if( strcmp( a_EntityType, "cChicken" ) == 0 ) return true;
- return cMonster::IsA( a_EntityType );
-}
-
-
-
-
-
-void cChicken::KilledBy( cEntity* a_Killer )
-{
- cItems Drops;
- AddRandomDropItem(Drops, 0, 2, E_ITEM_FEATHER);
- Drops.push_back(cItem((GetMetaData() == BURNING) ? E_ITEM_COOKED_CHICKEN : E_ITEM_RAW_CHICKEN, 1));
- m_World->SpawnItemPickups(Drops, m_Pos.x, m_Pos.y, m_Pos.z);
-
- cMonster::KilledBy( a_Killer );
+ AddRandomDropItem(a_Drops, 0, 2, E_ITEM_FEATHER);
+ a_Drops.push_back(cItem((GetMetaData() == BURNING) ? E_ITEM_COOKED_CHICKEN : E_ITEM_RAW_CHICKEN, 1));
}
diff --git a/source/Mobs/Chicken.h b/source/Mobs/Chicken.h
index acfb202e3..49c88a059 100644
--- a/source/Mobs/Chicken.h
+++ b/source/Mobs/Chicken.h
@@ -1,14 +1,25 @@
+
#pragma once
#include "PassiveMonster.h"
-class cChicken : public cPassiveMonster
+
+
+
+
+class cChicken :
+ public cPassiveMonster
{
+ typedef cPassiveMonster super;
+
public:
- cChicken();
- ~cChicken();
+ cChicken(void);
+
+ virtual bool IsA(const char * a_EntityType) override;
+
+ virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override;
+} ;
+
+
- virtual bool IsA( const char* a_EntityType );
- virtual void KilledBy( cEntity* a_Killer );
-};
diff --git a/source/Mobs/Cow.cpp b/source/Mobs/Cow.cpp
index 0d107e1b5..8e1837434 100644
--- a/source/Mobs/Cow.cpp
+++ b/source/Mobs/Cow.cpp
@@ -13,7 +13,7 @@
-cCow::cCow()
+cCow::cCow(void)
{
m_MobType = 92;
GetMonsterConfig("Cow");
@@ -23,32 +23,19 @@ cCow::cCow()
-cCow::~cCow()
+bool cCow::IsA(const char * a_EntityType)
{
+ return ((strcmp(a_EntityType, "cCow") == 0) || super::IsA(a_EntityType));
}
-bool cCow::IsA( const char* a_EntityType )
+void cCow::GetDrops(cItems & a_Drops, cPawn * a_Killer)
{
- if( strcmp( a_EntityType, "cCow" ) == 0 ) return true;
- return cMonster::IsA( a_EntityType );
-}
-
-
-
-
-
-void cCow::KilledBy( cEntity* a_Killer )
-{
- cItems Drops;
- AddRandomDropItem(Drops, 0, 2, E_ITEM_LEATHER);
- AddRandomDropItem(Drops, 1, 3, (GetMetaData() == BURNING) ? E_ITEM_STEAK : E_ITEM_RAW_BEEF);
- m_World->SpawnItemPickups(Drops, m_Pos.x, m_Pos.y, m_Pos.z);
-
- cMonster::KilledBy( a_Killer );
+ AddRandomDropItem(a_Drops, 0, 2, E_ITEM_LEATHER);
+ AddRandomDropItem(a_Drops, 1, 3, (GetMetaData() == BURNING) ? E_ITEM_STEAK : E_ITEM_RAW_BEEF);
}
diff --git a/source/Mobs/Cow.h b/source/Mobs/Cow.h
index bb604bad4..cc7db7af9 100644
--- a/source/Mobs/Cow.h
+++ b/source/Mobs/Cow.h
@@ -1,14 +1,25 @@
+
#pragma once
#include "PassiveMonster.h"
-class cCow : public cPassiveMonster
+
+
+
+
+class cCow :
+ public cPassiveMonster
{
+ typedef cPassiveMonster super;
+
public:
cCow();
- ~cCow();
- virtual bool IsA( const char* a_EntityType );
+ virtual bool IsA(const char * a_EntityType) override;
+
+ virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override;
+} ;
+
+
+
- virtual void KilledBy( cEntity* a_Killer );
-};
diff --git a/source/Mobs/Creeper.cpp b/source/Mobs/Creeper.cpp
index b42d5690b..d247df96c 100644
--- a/source/Mobs/Creeper.cpp
+++ b/source/Mobs/Creeper.cpp
@@ -7,7 +7,7 @@
-cCreeper::cCreeper()
+cCreeper::cCreeper(void)
{
m_MobType = 50;
GetMonsterConfig("Creeper");
@@ -17,34 +17,20 @@ cCreeper::cCreeper()
-cCreeper::~cCreeper()
+bool cCreeper::IsA(const char * a_EntityType)
{
+ return ((strcmp(a_EntityType, "cCreeper") == 0) || super::IsA(a_EntityType));
}
-bool cCreeper::IsA( const char* a_EntityType )
+void cCreeper::GetDrops(cItems & a_Drops, cPawn * a_Killer)
{
- if( strcmp( a_EntityType, "cCreeper" ) == 0 ) return true;
- return cMonster::IsA( a_EntityType );
-}
-
-
-
-
-
-void cCreeper::KilledBy( cEntity* a_Killer )
-{
- cItems Drops;
- AddRandomDropItem(Drops, 0, 2, E_ITEM_GUNPOWDER);
+ AddRandomDropItem(a_Drops, 0, 2, E_ITEM_GUNPOWDER);
// TODO Check if killed by a skeleton, then drop random music disk
-
- m_World->SpawnItemPickups(Drops, m_Pos.x, m_Pos.y, m_Pos.z);
-
- cMonster::KilledBy( a_Killer );
}
diff --git a/source/Mobs/Creeper.h b/source/Mobs/Creeper.h
index e5c755103..bd6b1e992 100644
--- a/source/Mobs/Creeper.h
+++ b/source/Mobs/Creeper.h
@@ -1,14 +1,25 @@
+
#pragma once
#include "AggressiveMonster.h"
-class cCreeper : public cAggressiveMonster
+
+
+
+
+class cCreeper :
+ public cAggressiveMonster
{
+ typedef cAggressiveMonster super;
+
public:
- cCreeper();
- ~cCreeper();
+ cCreeper(void);
+
+ virtual bool IsA(const char * a_EntityType) override;
+
+ virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override;
+} ;
+
+
- virtual bool IsA( const char* a_EntityType );
- virtual void KilledBy( cEntity* a_Killer );
-};
diff --git a/source/Mobs/Enderman.cpp b/source/Mobs/Enderman.cpp
index 216fab85f..b41f8f405 100644
--- a/source/Mobs/Enderman.cpp
+++ b/source/Mobs/Enderman.cpp
@@ -7,7 +7,7 @@
-cEnderman::cEnderman()
+cEnderman::cEnderman(void)
{
m_MobType = 58;
GetMonsterConfig("Enderman");
@@ -17,18 +17,9 @@ cEnderman::cEnderman()
-cEnderman::~cEnderman()
+bool cEnderman::IsA(const char * a_EntityType)
{
-}
-
-
-
-
-
-bool cEnderman::IsA( const char* a_EntityType )
-{
- if( strcmp( a_EntityType, "cEnderman" ) == 0 ) return true;
- return cMonster::IsA( a_EntityType );
+ return ((strcmp(a_EntityType, "cEnderman") == 0) || super::IsA(a_EntityType));
}
@@ -50,13 +41,9 @@ void cEnderman::Tick(float a_Dt)
-void cEnderman::KilledBy( cEntity* a_Killer )
+void cEnderman::GetDrops(cItems & a_Drops, cPawn * a_Killer)
{
- cItems Drops;
- AddRandomDropItem(Drops, 0, 1, E_ITEM_ENDER_PEARL);
- m_World->SpawnItemPickups(Drops, m_Pos.x, m_Pos.y, m_Pos.z);
-
- cMonster::KilledBy( a_Killer );
+ AddRandomDropItem(a_Drops, 0, 1, E_ITEM_ENDER_PEARL);
}
diff --git a/source/Mobs/Enderman.h b/source/Mobs/Enderman.h
index 788cc1314..b175e8b1b 100644
--- a/source/Mobs/Enderman.h
+++ b/source/Mobs/Enderman.h
@@ -1,15 +1,26 @@
+
#pragma once
#include "PassiveAggressiveMonster.h"
-class cEnderman : public cPassiveAggressiveMonster
+
+
+
+
+class cEnderman :
+ public cPassiveAggressiveMonster
{
+ typedef cPassiveAggressiveMonster super;
+
public:
- cEnderman();
- ~cEnderman();
+ cEnderman(void);
+
+ virtual bool IsA(const char * a_EntityType) override;
+
+ virtual void Tick(float a_Dt) override;
+ virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override;
+} ;
+
+
- virtual bool IsA( const char* a_EntityType );
- virtual void Tick(float a_Dt);
- virtual void KilledBy( cEntity* a_Killer );
-};
diff --git a/source/Mobs/Ghast.cpp b/source/Mobs/Ghast.cpp
index 4993f25c0..3bcb5e4ab 100644
--- a/source/Mobs/Ghast.cpp
+++ b/source/Mobs/Ghast.cpp
@@ -7,7 +7,7 @@
-cGhast::cGhast()
+cGhast::cGhast(void)
{
m_MobType = 56;
GetMonsterConfig("Ghast");
@@ -17,31 +17,19 @@ cGhast::cGhast()
-cGhast::~cGhast()
+bool cGhast::IsA(const char * a_EntityType)
{
+ return ((strcmp(a_EntityType, "cGhast") == 0) || super::IsA(a_EntityType));
}
-bool cGhast::IsA( const char* a_EntityType )
+void cGhast::GetDrops(cItems & a_Drops, cPawn * a_Killer)
{
- if( strcmp( a_EntityType, "cGhast" ) == 0 ) return true;
- return cMonster::IsA( a_EntityType );
-}
-
-
-
-
-
-void cGhast::KilledBy( cEntity* a_Killer )
-{
- cItems Drops;
- AddRandomDropItem(Drops, 0, 2, E_ITEM_GUNPOWDER);
- AddRandomDropItem(Drops, 0, 1, E_ITEM_GHAST_TEAR);
-
- cMonster::KilledBy( a_Killer );
+ AddRandomDropItem(a_Drops, 0, 2, E_ITEM_GUNPOWDER);
+ AddRandomDropItem(a_Drops, 0, 1, E_ITEM_GHAST_TEAR);
}
diff --git a/source/Mobs/Ghast.h b/source/Mobs/Ghast.h
index 6991419e7..e6248b656 100644
--- a/source/Mobs/Ghast.h
+++ b/source/Mobs/Ghast.h
@@ -1,14 +1,25 @@
+
#pragma once
#include "AggressiveMonster.h"
-class cGhast : public cAggressiveMonster
+
+
+
+
+class cGhast :
+ public cAggressiveMonster
{
+ typedef cAggressiveMonster super;
+
public:
- cGhast();
- ~cGhast();
+ cGhast(void);
+
+ virtual bool IsA(const char * a_EntityType) override;
+
+ virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override;
+} ;
+
+
- virtual bool IsA( const char* a_EntityType );
- virtual void KilledBy( cEntity* a_Killer );
-};
diff --git a/source/Mobs/Magmacube.cpp b/source/Mobs/Magmacube.cpp
index d73041baf..21c6f17b3 100644
--- a/source/Mobs/Magmacube.cpp
+++ b/source/Mobs/Magmacube.cpp
@@ -17,31 +17,18 @@ cMagmacube::cMagmacube()
-cMagmacube::~cMagmacube()
+bool cMagmacube::IsA(const char * a_EntityType)
{
+ return ((strcmp(a_EntityType, "cMagmacube") == 0) || super::IsA(a_EntityType));
}
-bool cMagmacube::IsA( const char* a_EntityType )
+void cMagmacube::GetDrops(cItems & a_Drops, cPawn * a_Killer)
{
- if( strcmp( a_EntityType, "cMagmacube" ) == 0 ) return true;
- return cMonster::IsA( a_EntityType );
-}
-
-
-
-
-
-void cMagmacube::KilledBy( cEntity* a_Killer )
-{
- cItems Drops;
- AddRandomDropItem(Drops, 0, 1, E_ITEM_MAGMA_CREAM);
- m_World->SpawnItemPickups(Drops, m_Pos.x, m_Pos.y, m_Pos.z);
-
- cMonster::KilledBy( a_Killer );
+ AddRandomDropItem(a_Drops, 0, 1, E_ITEM_MAGMA_CREAM);
}
diff --git a/source/Mobs/Magmacube.h b/source/Mobs/Magmacube.h
index 1a36ef2c1..8c61a7853 100644
--- a/source/Mobs/Magmacube.h
+++ b/source/Mobs/Magmacube.h
@@ -1,14 +1,25 @@
+
#pragma once
#include "AggressiveMonster.h"
-class cMagmacube : public cAggressiveMonster
+
+
+
+
+class cMagmacube :
+ public cAggressiveMonster
{
+ typedef cAggressiveMonster super;
+
public:
cMagmacube();
- ~cMagmacube();
- virtual bool IsA( const char* a_EntityType );
+ virtual bool IsA(const char * a_EntityType) override;
+
+ virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override;
+} ;
+
+
+
- virtual void KilledBy( cEntity* a_Killer );
-};
diff --git a/source/Mobs/Monster.cpp b/source/Mobs/Monster.cpp
index 82d69df57..88cfcd992 100644
--- a/source/Mobs/Monster.cpp
+++ b/source/Mobs/Monster.cpp
@@ -28,8 +28,8 @@
-cMonster::cMonster()
- : m_Target(0)
+cMonster::cMonster(void)
+ : m_Target(NULL)
, m_bMovingToDestination(false)
, m_DestinationTime( 0 )
, m_Gravity( -9.81f)
@@ -318,20 +318,23 @@ void cMonster::HandlePhysics(float a_Dt)
-void cMonster::TakeDamage(int a_Damage, cEntity* a_Instigator)
+void cMonster::DoTakeDamage(TakeDamageInfo & a_TDI)
{
- cPawn::TakeDamage( a_Damage, a_Instigator );
- m_Target = a_Instigator;
- AddReference( m_Target );
+ super::DoTakeDamage(a_TDI);
+ if (a_TDI.Attacker != NULL)
+ {
+ m_Target = a_TDI.Attacker;
+ AddReference(m_Target);
+ }
}
-void cMonster::KilledBy( cEntity* a_Killer )
+void cMonster::KilledBy(cPawn * a_Killer)
{
- cPawn::KilledBy( a_Killer );
+ super::KilledBy(a_Killer);
m_DestroyTimer = 0;
}
@@ -513,7 +516,7 @@ void cMonster::Attack(float a_Dt)
{
// Setting this higher gives us more wiggle room for attackrate
m_AttackInterval = 0.0;
- ((cPawn *)m_Target)->TakeDamage((int)m_AttackDamage, this);
+ ((cPawn *)m_Target)->TakeDamage(*this);
}
}
diff --git a/source/Mobs/Monster.h b/source/Mobs/Monster.h
index f0da23977..6d3d1d775 100644
--- a/source/Mobs/Monster.h
+++ b/source/Mobs/Monster.h
@@ -17,14 +17,18 @@ class cClientHandle;
-class cMonster : public cPawn //tolua_export
-{ //tolua_export
+// tolua_begin
+class cMonster :
+ public cPawn
+{
+ typedef cPawn super;
public:
-
- cMonster();
+ // tolua_end
+
+ cMonster(void);
virtual ~cMonster();
- virtual bool IsA( const char* a_EntityType );
+ virtual bool IsA(const char * a_EntityType);
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
@@ -33,8 +37,9 @@ public:
virtual void HandlePhysics(float a_Dt);
virtual void ReplicateMovement(void);
- virtual void TakeDamage(int a_Damage, cEntity * a_Instigator) override;
- virtual void KilledBy(cEntity * a_Killer) override;
+ virtual void DoTakeDamage(TakeDamageInfo & a_TDI) override;
+
+ virtual void KilledBy(cPawn * a_Killer) override;
virtual void MoveToPosition(const Vector3f & a_Position);
virtual bool ReachedDestination(void);
@@ -47,7 +52,7 @@ public:
virtual void CheckEventSeePlayer();
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 cPlayer * FindClosestPlayer(); // non static is easier. also virtual so other mobs can implement their own searching algo
virtual void GetMonsterConfig(const char* pm_name);
virtual void EventLosePlayer();
virtual void CheckEventLostPlayer();
@@ -69,7 +74,7 @@ public:
protected:
- cEntity* m_Target;
+ cEntity * m_Target;
float m_AttackRate;
float idle_interval;
@@ -94,7 +99,7 @@ protected:
float m_AttackInterval;
void AddRandomDropItem(cItems & a_Drops, unsigned int a_Min, unsigned int a_Max, short a_Item, short a_ItemHealth = 0);
-}; //tolua_export
+} ; // tolua_export
diff --git a/source/Mobs/Mooshroom.cpp b/source/Mobs/Mooshroom.cpp
index f70349e97..0732b3fea 100644
--- a/source/Mobs/Mooshroom.cpp
+++ b/source/Mobs/Mooshroom.cpp
@@ -13,7 +13,7 @@
-cMooshroom::cMooshroom()
+cMooshroom::cMooshroom(void)
{
m_MobType = 96;
GetMonsterConfig("Mooshroom");
@@ -23,32 +23,19 @@ cMooshroom::cMooshroom()
-cMooshroom::~cMooshroom()
+bool cMooshroom::IsA(const char * a_EntityType)
{
+ return ((strcmp(a_EntityType, "cMooshroom") == 0) || super::IsA(a_EntityType));
}
-bool cMooshroom::IsA( const char* a_EntityType )
+void cMooshroom::GetDrops(cItems & a_Drops, cPawn * a_Killer)
{
- if( strcmp( a_EntityType, "cMooshroom" ) == 0 ) return true;
- return cMonster::IsA( a_EntityType );
-}
-
-
-
-
-
-void cMooshroom::KilledBy( cEntity* a_Killer )
-{
- cItems Drops;
- AddRandomDropItem(Drops, 0, 2, E_ITEM_LEATHER);
- AddRandomDropItem(Drops, 1, 3, (GetMetaData() == BURNING) ? E_ITEM_STEAK : E_ITEM_RAW_BEEF);
- m_World->SpawnItemPickups(Drops, m_Pos.x, m_Pos.y, m_Pos.z);
-
- cMonster::KilledBy( a_Killer );
+ AddRandomDropItem(a_Drops, 0, 2, E_ITEM_LEATHER);
+ AddRandomDropItem(a_Drops, 1, 3, (GetMetaData() == BURNING) ? E_ITEM_STEAK : E_ITEM_RAW_BEEF);
}
diff --git a/source/Mobs/Mooshroom.h b/source/Mobs/Mooshroom.h
index ea8ed5b08..b15bfc76f 100644
--- a/source/Mobs/Mooshroom.h
+++ b/source/Mobs/Mooshroom.h
@@ -1,14 +1,25 @@
+
#pragma once
#include "PassiveMonster.h"
-class cMooshroom : public cPassiveMonster
+
+
+
+
+class cMooshroom :
+ public cPassiveMonster
{
+ typedef cPassiveMonster super;
+
public:
- cMooshroom();
- ~cMooshroom();
+ cMooshroom(void);
+
+ virtual bool IsA(const char * a_EntityType);
+
+ virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override;
+} ;
+
+
- virtual bool IsA( const char* a_EntityType );
- virtual void KilledBy( cEntity* a_Killer );
-};
diff --git a/source/Mobs/Ocelot.cpp b/source/Mobs/Ocelot.cpp
index ec50a9656..374161bde 100644
--- a/source/Mobs/Ocelot.cpp
+++ b/source/Mobs/Ocelot.cpp
@@ -17,29 +17,12 @@ cOcelot::cOcelot()
-cOcelot::~cOcelot()
+bool cOcelot::IsA(const char * a_EntityType)
{
+ return ((strcmp(a_EntityType, "cOcelot") == 0) || super::IsA(a_EntityType));
}
-bool cOcelot::IsA( const char* a_EntityType )
-{
- if( strcmp( a_EntityType, "cOcelot" ) == 0 ) return true;
- return cMonster::IsA( a_EntityType );
-}
-
-
-
-
-
-void cOcelot::KilledBy( cEntity* a_Killer )
-{
- cMonster::KilledBy( a_Killer );
-}
-
-
-
-
diff --git a/source/Mobs/Ocelot.h b/source/Mobs/Ocelot.h
index 87571022f..07095c660 100644
--- a/source/Mobs/Ocelot.h
+++ b/source/Mobs/Ocelot.h
@@ -1,14 +1,23 @@
+
#pragma once
#include "PassiveMonster.h"
-class cOcelot : public cPassiveMonster
+
+
+
+
+class cOcelot :
+ public cPassiveMonster
{
+ typedef cPassiveMonster super;
+
public:
cOcelot();
- ~cOcelot();
- virtual bool IsA( const char* a_EntityType );
+ virtual bool IsA(const char * a_EntityType) override;
+} ;
+
+
+
- virtual void KilledBy( cEntity* a_Killer );
-};
diff --git a/source/Mobs/PassiveAggressiveMonster.cpp b/source/Mobs/PassiveAggressiveMonster.cpp
index 9d9e156ee..465c302a1 100644
--- a/source/Mobs/PassiveAggressiveMonster.cpp
+++ b/source/Mobs/PassiveAggressiveMonster.cpp
@@ -9,30 +9,27 @@
-cPassiveAggressiveMonster::cPassiveAggressiveMonster()
+cPassiveAggressiveMonster::cPassiveAggressiveMonster(void)
{
m_EMPersonality = PASSIVE;
}
-cPassiveAggressiveMonster::~cPassiveAggressiveMonster()
-{
-}
-void cPassiveAggressiveMonster::TakeDamage(int a_Damage, cEntity* a_Instigator)
+
+
+
+void cPassiveAggressiveMonster::DoTakeDamage(TakeDamageInfo & a_TDI)
{
- cMonster::TakeDamage(a_Damage, a_Instigator);
- if(m_Target->GetEntityType() == cEntity::eEntityType_Player)
+ if ((m_Target != NULL) && (m_Target->GetEntityType() == cEntity::eEntityType_Player))
{
cPlayer * Player = (cPlayer *) m_Target;
- if(Player->GetGameMode() != 1)
+ if (Player->GetGameMode() != 1)
{
m_EMState = CHASING;
}
}
-
}
-void cPassiveAggressiveMonster::EventSeePlayer(cEntity *a_Entity)
-{
- return cMonster::EventSeePlayer(a_Entity);
-} \ No newline at end of file
+
+
+
diff --git a/source/Mobs/PassiveAggressiveMonster.h b/source/Mobs/PassiveAggressiveMonster.h
index 972d2a11d..e6e50677d 100644
--- a/source/Mobs/PassiveAggressiveMonster.h
+++ b/source/Mobs/PassiveAggressiveMonster.h
@@ -1,13 +1,23 @@
+
#pragma once
#include "AggressiveMonster.h"
-class cPassiveAggressiveMonster : public cAggressiveMonster
+
+
+
+
+class cPassiveAggressiveMonster :
+ public cAggressiveMonster
{
+ typedef cAggressiveMonster super;
+
public:
- cPassiveAggressiveMonster();
- ~cPassiveAggressiveMonster();
+ cPassiveAggressiveMonster(void);
+
+ virtual void DoTakeDamage(TakeDamageInfo & a_TDI) override;
+} ;
+
+
+
- virtual void TakeDamage(int a_Damage, cEntity* a_Instigator);
- void EventSeePlayer(cEntity *a_Entity);
-};
diff --git a/source/Mobs/PassiveMonster.cpp b/source/Mobs/PassiveMonster.cpp
index bc3f70b4b..6224b284a 100644
--- a/source/Mobs/PassiveMonster.cpp
+++ b/source/Mobs/PassiveMonster.cpp
@@ -8,39 +8,50 @@
-cPassiveMonster::cPassiveMonster()
+cPassiveMonster::cPassiveMonster(void)
{
m_EMPersonality = PASSIVE;
}
-cPassiveMonster::~cPassiveMonster()
-{
-}
-void cPassiveMonster::TakeDamage(int a_Damage, cEntity* a_Instigator)
+
+
+
+void cPassiveMonster::DoTakeDamage(TakeDamageInfo & a_TDI)
{
- cMonster::TakeDamage(a_Damage, a_Instigator);
- if(a_Instigator != this)
+ super::DoTakeDamage(a_TDI);
+ if ((a_TDI.Attacker != this) && (a_TDI.Attacker != NULL))
+ {
m_EMState = ESCAPING;
+ }
}
+
+
+
+
void cPassiveMonster::Tick(float a_Dt)
{
cMonster::Tick(a_Dt);
m_SeePlayerInterval += a_Dt;
- if(m_SeePlayerInterval > 1)
+ if (m_SeePlayerInterval > 1) // Check every second
{
MTRand r1;
- int rem = r1.randInt() % 3 + 1; //check most of the time but miss occasionally
+ int rem = r1.randInt() % 3 + 1; // Check most of the time but miss occasionally
m_SeePlayerInterval = 0.0;
- if(rem >= 2) {
- if(m_EMState == ESCAPING)
+ if (rem >= 2)
+ {
+ if (m_EMState == ESCAPING)
{
CheckEventLostPlayer();
}
}
}
-} \ No newline at end of file
+}
+
+
+
+
diff --git a/source/Mobs/PassiveMonster.h b/source/Mobs/PassiveMonster.h
index 1265dc737..14a4e9d24 100644
--- a/source/Mobs/PassiveMonster.h
+++ b/source/Mobs/PassiveMonster.h
@@ -1,14 +1,26 @@
+
#pragma once
#include "Monster.h"
-class cPassiveMonster : public cMonster
+
+
+
+
+class cPassiveMonster :
+ public cMonster
{
+ typedef cMonster super;
+
public:
- cPassiveMonster();
- ~cPassiveMonster();
+ cPassiveMonster(void);
+
+ virtual void Tick(float a_Dt) override;
+
+ /// When hit by someone, run away
+ virtual void DoTakeDamage(TakeDamageInfo & a_TDI) override;
+} ;
+
+
- virtual void Tick(float a_Dt);
- virtual void TakeDamage(int a_Damage, cEntity* a_Instigator);
-};
diff --git a/source/Mobs/Pig.cpp b/source/Mobs/Pig.cpp
index 48954dc73..8abd0a10e 100644
--- a/source/Mobs/Pig.cpp
+++ b/source/Mobs/Pig.cpp
@@ -7,7 +7,7 @@
-cPig::cPig()
+cPig::cPig(void)
{
m_MobType = 90;
GetMonsterConfig("Pig");
@@ -17,33 +17,18 @@ cPig::cPig()
-cPig::~cPig()
+bool cPig::IsA(const char * a_EntityType)
{
+ return ((strcmp(a_EntityType, "cPig") == 0) || super::IsA(a_EntityType));
}
-bool cPig::IsA( const char* a_EntityType )
+void cPig::GetDrops(cItems & a_Drops, cPawn * a_Killer)
{
- if( strcmp( a_EntityType, "cPig" ) == 0 ) return true;
- return cMonster::IsA( a_EntityType );
-}
-
-
-
-
-
-void cPig::KilledBy( cEntity* a_Killer )
-{
- cItems Drops;
- AddRandomDropItem(Drops, 0, 2, E_ITEM_RAW_MEAT);
- m_World->SpawnItemPickups(Drops, m_Pos.x, m_Pos.y, m_Pos.z);
-
- // TODO: Check for burning state
-
- cMonster::KilledBy( a_Killer );
+ AddRandomDropItem(a_Drops, 1, 3, (GetMetaData() == BURNING) ? E_ITEM_COOKED_PORKCHOP : E_ITEM_RAW_MEAT);
}
diff --git a/source/Mobs/Pig.h b/source/Mobs/Pig.h
index e701535ba..018477778 100644
--- a/source/Mobs/Pig.h
+++ b/source/Mobs/Pig.h
@@ -1,14 +1,25 @@
+
#pragma once
#include "PassiveMonster.h"
-class cPig : public cPassiveMonster
+
+
+
+
+class cPig :
+ public cPassiveMonster
{
+ typedef cPassiveMonster super;
+
public:
- cPig();
- ~cPig();
+ cPig(void);
+
+ virtual bool IsA(const char * a_EntityType) override;
+
+ virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override;
+} ;
+
+
- virtual bool IsA( const char* a_EntityType );
- virtual void KilledBy( cEntity* a_Killer );
-};
diff --git a/source/Mobs/Sheep.cpp b/source/Mobs/Sheep.cpp
index 1f5f1815f..9c67aba29 100644
--- a/source/Mobs/Sheep.cpp
+++ b/source/Mobs/Sheep.cpp
@@ -2,12 +2,7 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "Sheep.h"
-
-
-
-
-
-//Todo: Implement color
+#include "../BlockID.h"
@@ -15,7 +10,7 @@
cSheep::cSheep(void) :
m_IsSheared(false),
- m_WoolColor(0) // TODO: E_META_WOOL_WHITE
+ m_WoolColor(E_META_WOOL_WHITE)
{
m_MobType = 91;
GetMonsterConfig("Sheep");
@@ -25,41 +20,23 @@ cSheep::cSheep(void) :
-cSheep::~cSheep()
+bool cSheep::IsA(const char * a_EntityType)
{
+ return ((strcmp(a_EntityType, "cSheep") == 0) || super::IsA(a_EntityType));
}
-bool cSheep::IsA( const char* a_EntityType )
+void cSheep::GetDrops(cItems & a_Drops, cPawn * a_Killer)
{
- if (strcmp( a_EntityType, "cSheep" ) == 0)
- {
- return true;
- }
- return cMonster::IsA( a_EntityType );
-}
-
-
-
-
-
-void cSheep::KilledBy( cEntity* a_Killer )
-{
- // TODO: Check whether it is sheared
- // TODO: Check color
-
if (!m_IsSheared)
{
- cItems Drops;
- Drops.push_back(cItem(E_ITEM_WHITE_CLOTH, 1, m_WoolColor));
- m_World->SpawnItemPickups(Drops, m_Pos.x, m_Pos.y, m_Pos.z);
+ a_Drops.push_back(cItem(E_ITEM_WHITE_CLOTH, 1, m_WoolColor));
}
-
- cMonster::KilledBy( a_Killer );
}
+
diff --git a/source/Mobs/Sheep.h b/source/Mobs/Sheep.h
index 28c2b97dc..ea43537cc 100644
--- a/source/Mobs/Sheep.h
+++ b/source/Mobs/Sheep.h
@@ -1,17 +1,28 @@
+
#pragma once
#include "PassiveMonster.h"
-class cSheep : public cPassiveMonster
+
+
+
+
+class cSheep :
+ public cPassiveMonster
{
+ typedef cPassiveMonster super;
+
public:
- cSheep();
- ~cSheep();
+ cSheep(void);
bool m_IsSheared;
NIBBLETYPE m_WoolColor; // Uses E_META_WOOL_ constants for colors
- virtual bool IsA(const char * a_EntityType);
+ virtual bool IsA(const char * a_EntityType) override;
+
+ virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override;
+} ;
+
+
+
- virtual void KilledBy(cEntity * a_Killer);
-};
diff --git a/source/Mobs/Silverfish.h b/source/Mobs/Silverfish.h
index fe23a4ba1..453995ec6 100644
--- a/source/Mobs/Silverfish.h
+++ b/source/Mobs/Silverfish.h
@@ -8,5 +8,5 @@ public:
cSilverfish();
~cSilverfish();
- virtual bool IsA( const char* a_EntityType );
+ virtual bool IsA(const char * a_EntityType);
};
diff --git a/source/Mobs/Skeleton.cpp b/source/Mobs/Skeleton.cpp
index b35cdb68e..f219713e0 100644
--- a/source/Mobs/Skeleton.cpp
+++ b/source/Mobs/Skeleton.cpp
@@ -7,7 +7,7 @@
-cSkeleton::cSkeleton()
+cSkeleton::cSkeleton(void)
{
m_MobType = 51;
GetMonsterConfig("Skeleton");
@@ -17,18 +17,9 @@ cSkeleton::cSkeleton()
-cSkeleton::~cSkeleton()
-{
-}
-
-
-
-
-
bool cSkeleton::IsA( const char* a_EntityType )
{
- if( strcmp( a_EntityType, "cSkeleton" ) == 0 ) return true;
- return cMonster::IsA( a_EntityType );
+ return ((strcmp(a_EntityType, "cSkeleton") == 0) || super::IsA(a_EntityType));
}
@@ -51,14 +42,10 @@ void cSkeleton::Tick(float a_Dt)
-void cSkeleton::KilledBy( cEntity* a_Killer )
+void cSkeleton::GetDrops(cItems & a_Drops, cPawn * a_Killer)
{
- cItems Drops;
- AddRandomDropItem(Drops, 0, 2, E_ITEM_ARROW);
- AddRandomDropItem(Drops, 0, 2, E_ITEM_BONE);
- m_World->SpawnItemPickups(Drops, m_Pos.x, m_Pos.y, m_Pos.z);
-
- cMonster::KilledBy( a_Killer );
+ AddRandomDropItem(a_Drops, 0, 2, E_ITEM_ARROW);
+ AddRandomDropItem(a_Drops, 0, 2, E_ITEM_BONE);
}
diff --git a/source/Mobs/Skeleton.h b/source/Mobs/Skeleton.h
index 84a434905..101358f18 100644
--- a/source/Mobs/Skeleton.h
+++ b/source/Mobs/Skeleton.h
@@ -1,16 +1,26 @@
+
#pragma once
#include "AggressiveMonster.h"
-class cSkeleton : public cAggressiveMonster
+
+
+
+
+class cSkeleton :
+ public cAggressiveMonster
{
+ typedef cAggressiveMonster super;
+
public:
cSkeleton();
- ~cSkeleton();
- virtual bool IsA( const char* a_EntityType );
+ virtual bool IsA(const char * a_EntityType) override;
+
+ virtual void Tick(float a_Dt) override;
+ virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override;
+} ;
+
+
+
- virtual void Tick(float a_Dt);
- virtual void KilledBy( cEntity* a_Killer );
-
-};
diff --git a/source/Mobs/Slime.cpp b/source/Mobs/Slime.cpp
index b8dc52d7c..d85b97c97 100644
--- a/source/Mobs/Slime.cpp
+++ b/source/Mobs/Slime.cpp
@@ -3,13 +3,13 @@
#include "Slime.h"
-//TODO Implement sized slimes
+// TODO: Implement sized slimes
-cSlime::cSlime()
+cSlime::cSlime(void)
{
m_MobType = 55;
GetMonsterConfig("Slime");
@@ -19,32 +19,19 @@ cSlime::cSlime()
-cSlime::~cSlime()
+bool cSlime::IsA(const char * a_EntityType)
{
+ return ((strcmp(a_EntityType, "cSlime") == 0) || super::IsA(a_EntityType));
}
-bool cSlime::IsA( const char* a_EntityType )
+void cSlime::GetDrops(cItems & a_Drops, cPawn * a_Killer)
{
- if( strcmp( a_EntityType, "cSlime" ) == 0 ) return true;
- return cMonster::IsA( a_EntityType );
-}
-
-
-
-
-
-void cSlime::KilledBy( cEntity* a_Killer )
-{
- //TODO: only when tiny
- cItems Drops;
- AddRandomDropItem(Drops, 0, 2, E_ITEM_SLIMEBALL);
- m_World->SpawnItemPickups(Drops, m_Pos.x, m_Pos.y, m_Pos.z);
-
- cMonster::KilledBy( a_Killer );
+ // TODO: only when tiny
+ AddRandomDropItem(a_Drops, 0, 2, E_ITEM_SLIMEBALL);
}
diff --git a/source/Mobs/Slime.h b/source/Mobs/Slime.h
index cceac617d..1f155e6f8 100644
--- a/source/Mobs/Slime.h
+++ b/source/Mobs/Slime.h
@@ -1,14 +1,21 @@
+
#pragma once
#include "AggressiveMonster.h"
-class cSlime : public cAggressiveMonster
+class cSlime :
+ public cAggressiveMonster
{
+ typedef cAggressiveMonster super;
+
public:
cSlime();
- ~cSlime();
- virtual bool IsA( const char* a_EntityType );
+ virtual bool IsA(const char * a_EntityType) override;
+
+ virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override;
+} ;
+
+
+
- virtual void KilledBy( cEntity* a_Killer );
-};
diff --git a/source/Mobs/Spider.cpp b/source/Mobs/Spider.cpp
index dfa7a8a6a..82a24f9b3 100644
--- a/source/Mobs/Spider.cpp
+++ b/source/Mobs/Spider.cpp
@@ -17,32 +17,19 @@ cSpider::cSpider()
-cSpider::~cSpider()
+bool cSpider::IsA(const char * a_EntityType)
{
+ return ((strcmp(a_EntityType, "cSpider") == 0) || super::IsA(a_EntityType));
}
-bool cSpider::IsA( const char* a_EntityType )
+void cSpider::GetDrops(cItems & a_Drops, cPawn * a_Killer)
{
- if( strcmp( a_EntityType, "cSpider" ) == 0 ) return true;
- return cMonster::IsA( a_EntityType );
-}
-
-
-
-
-
-void cSpider::KilledBy( cEntity* a_Killer )
-{
- cItems Drops;
- AddRandomDropItem(Drops, 0, 2, E_ITEM_STRING);
- AddRandomDropItem(Drops, 0, 1, E_ITEM_SPIDER_EYE);
- m_World->SpawnItemPickups(Drops, m_Pos.x, m_Pos.y, m_Pos.z);
-
- cMonster::KilledBy( a_Killer );
+ AddRandomDropItem(a_Drops, 0, 2, E_ITEM_STRING);
+ AddRandomDropItem(a_Drops, 0, 1, E_ITEM_SPIDER_EYE);
}
diff --git a/source/Mobs/Spider.h b/source/Mobs/Spider.h
index 12133bdb8..c375df593 100644
--- a/source/Mobs/Spider.h
+++ b/source/Mobs/Spider.h
@@ -1,14 +1,25 @@
+
#pragma once
#include "AggressiveMonster.h"
-class cSpider : public cAggressiveMonster
+
+
+
+
+class cSpider :
+ public cAggressiveMonster
{
+ typedef cAggressiveMonster super;
+
public:
cSpider();
- ~cSpider();
- virtual bool IsA( const char* a_EntityType );
+ virtual bool IsA(const char * a_EntityType) override;
+
+ virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override;
+} ;
+
+
+
- virtual void KilledBy( cEntity* a_Killer );
-};
diff --git a/source/Mobs/Squid.cpp b/source/Mobs/Squid.cpp
index f88c295a4..720eb05e5 100644
--- a/source/Mobs/Squid.cpp
+++ b/source/Mobs/Squid.cpp
@@ -12,32 +12,25 @@ cSquid::cSquid()
{
m_MobType = 94;
GetMonsterConfig("Squid");
- m_NoWater = 0.f;
}
-cSquid::~cSquid()
-{
-
-}
-bool cSquid::IsA( const char* a_EntityType )
+
+
+
+bool cSquid::IsA(const char * a_EntityType)
{
- if( strcmp( a_EntityType, "cSquid" ) == 0 ) return true;
- return cMonster::IsA( a_EntityType );
+ return ((strcmp(a_EntityType, "cSquid") == 0) || super::IsA(a_EntityType));
}
-void cSquid::KilledBy( cEntity* a_Killer )
+void cSquid::GetDrops(cItems & a_Drops, cPawn * a_Killer)
{
// Drops 0-3 Ink Sacs
- cItems Drops;
- AddRandomDropItem(Drops, 0, 3, E_ITEM_DYE, E_META_DYE_BLACK);
- m_World->SpawnItemPickups(Drops, m_Pos.x, m_Pos.y, m_Pos.z);
-
- cMonster::KilledBy( a_Killer );
+ AddRandomDropItem(a_Drops, 0, 3, E_ITEM_DYE, E_META_DYE_BLACK);
}
@@ -46,15 +39,17 @@ void cSquid::KilledBy( cEntity* a_Killer )
void cSquid::Tick(float a_Dt)
{
- cPassiveMonster::Tick(a_Dt);
+ super::Tick(a_Dt);
Vector3d Pos = GetPosition();
-
- //TODO Not a real behavior, but cool :D
- if(!IsBlockWater(GetWorld()->GetBlock((int) Pos.x, (int) Pos.y, (int) Pos.z)) && GetMetaData() != BURNING)
+ // TODO: Not a real behavior, but cool :D
+ if (!IsBlockWater(GetWorld()->GetBlock((int) Pos.x, (int) Pos.y, (int) Pos.z)) && GetMetaData() != BURNING)
{
SetMetaData(BURNING);
}
+}
+
+
+
-} \ No newline at end of file
diff --git a/source/Mobs/Squid.h b/source/Mobs/Squid.h
index eaf13b5c7..6500a3fea 100644
--- a/source/Mobs/Squid.h
+++ b/source/Mobs/Squid.h
@@ -1,18 +1,26 @@
+
#pragma once
#include "PassiveMonster.h"
-class cSquid : public cPassiveMonster
+
+
+
+
+class cSquid :
+ public cPassiveMonster
{
+ typedef cPassiveMonster super;
+
public:
cSquid();
- ~cSquid();
- virtual void Tick(float a_Dt);
+ virtual void Tick(float a_Dt) override;
+
+ virtual bool IsA(const char * a_EntityType) override;
+ virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override;
+} ;
+
+
+
- virtual bool IsA( const char* a_EntityType );
- virtual void KilledBy( cEntity* a_Killer );
-
-protected:
- float m_NoWater;
-};
diff --git a/source/Mobs/Villager.cpp b/source/Mobs/Villager.cpp
index 65b2ac5b5..0e6d364d7 100644
--- a/source/Mobs/Villager.cpp
+++ b/source/Mobs/Villager.cpp
@@ -17,27 +17,9 @@ cVillager::cVillager()
-cVillager::~cVillager()
+bool cVillager::IsA(const char * a_EntityType)
{
-}
-
-
-
-
-
-bool cVillager::IsA( const char* a_EntityType )
-{
- if( strcmp( a_EntityType, "cVillager" ) == 0 ) return true;
- return cMonster::IsA( a_EntityType );
-}
-
-
-
-
-
-void cVillager::KilledBy( cEntity* a_Killer )
-{
- cMonster::KilledBy( a_Killer );
+ return ((strcmp(a_EntityType, "cVillager") == 0) || super::IsA(a_EntityType));
}
diff --git a/source/Mobs/Villager.h b/source/Mobs/Villager.h
index 02272378b..74a6af868 100644
--- a/source/Mobs/Villager.h
+++ b/source/Mobs/Villager.h
@@ -1,14 +1,23 @@
+
#pragma once
#include "PassiveMonster.h"
-class cVillager : public cPassiveMonster
+
+
+
+
+class cVillager :
+ public cPassiveMonster
{
+ typedef cPassiveMonster super;
+
public:
cVillager();
- ~cVillager();
- virtual bool IsA( const char* a_EntityType );
+ virtual bool IsA(const char * a_EntityType) override;
+} ;
+
+
+
- virtual void KilledBy( cEntity* a_Killer );
-};
diff --git a/source/Mobs/Witch.cpp b/source/Mobs/Witch.cpp
index 02d1de4fe..5077f0cdd 100644
--- a/source/Mobs/Witch.cpp
+++ b/source/Mobs/Witch.cpp
@@ -17,37 +17,24 @@ cWitch::cWitch()
-cWitch::~cWitch()
+bool cWitch::IsA(const char * a_EntityType)
{
+ return ((strcmp(a_EntityType, "cWitch") == 0) || super::IsA(a_EntityType));
}
-bool cWitch::IsA( const char* a_EntityType )
+void cWitch::GetDrops(cItems & a_Drops, cPawn * a_Killer)
{
- if( strcmp( a_EntityType, "cWitch" ) == 0 ) return true;
- return cMonster::IsA( a_EntityType );
-}
-
-
-
-
-
-void cWitch::KilledBy( cEntity* a_Killer )
-{
- cItems Drops;
- AddRandomDropItem(Drops, 0, 6, E_ITEM_GLASS_BOTTLE);
- AddRandomDropItem(Drops, 0, 6, E_ITEM_GLOWSTONE_DUST);
- AddRandomDropItem(Drops, 0, 6, E_ITEM_GUNPOWDER);
- AddRandomDropItem(Drops, 0, 6, E_ITEM_REDSTONE_DUST);
- AddRandomDropItem(Drops, 0, 6, E_ITEM_SPIDER_EYE);
- AddRandomDropItem(Drops, 0, 6, E_ITEM_STICK);
- AddRandomDropItem(Drops, 0, 6, E_ITEM_SUGAR);
- m_World->SpawnItemPickups(Drops, m_Pos.x, m_Pos.y, m_Pos.z);
-
- cMonster::KilledBy( a_Killer );
+ AddRandomDropItem(a_Drops, 0, 6, E_ITEM_GLASS_BOTTLE);
+ AddRandomDropItem(a_Drops, 0, 6, E_ITEM_GLOWSTONE_DUST);
+ AddRandomDropItem(a_Drops, 0, 6, E_ITEM_GUNPOWDER);
+ AddRandomDropItem(a_Drops, 0, 6, E_ITEM_REDSTONE_DUST);
+ AddRandomDropItem(a_Drops, 0, 6, E_ITEM_SPIDER_EYE);
+ AddRandomDropItem(a_Drops, 0, 6, E_ITEM_STICK);
+ AddRandomDropItem(a_Drops, 0, 6, E_ITEM_SUGAR);
}
diff --git a/source/Mobs/Witch.h b/source/Mobs/Witch.h
index 303aa7595..2d21037bb 100644
--- a/source/Mobs/Witch.h
+++ b/source/Mobs/Witch.h
@@ -1,14 +1,25 @@
+
#pragma once
#include "AggressiveMonster.h"
-class cWitch : public cAggressiveMonster
+
+
+
+
+class cWitch :
+ public cAggressiveMonster
{
+ typedef cAggressiveMonster super;
+
public:
cWitch();
- ~cWitch();
- virtual bool IsA( const char* a_EntityType );
+ virtual bool IsA(const char* a_EntityType) override;
+
+ virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override;
+} ;
+
+
+
- virtual void KilledBy( cEntity* a_Killer );
-};
diff --git a/source/Mobs/Zombie.cpp b/source/Mobs/Zombie.cpp
index b0a429f25..5d753c4f8 100644
--- a/source/Mobs/Zombie.cpp
+++ b/source/Mobs/Zombie.cpp
@@ -17,18 +17,9 @@ cZombie::cZombie()
-cZombie::~cZombie()
+bool cZombie::IsA(const char * a_EntityType)
{
-}
-
-
-
-
-
-bool cZombie::IsA( const char* a_EntityType )
-{
- if( strcmp( a_EntityType, "cZombie" ) == 0 ) return true;
- return cMonster::IsA( a_EntityType );
+ return ((strcmp(a_EntityType, "cZombie") == 0) || super::IsA(a_EntityType));
}
@@ -37,7 +28,7 @@ bool cZombie::IsA( const char* a_EntityType )
void cZombie::Tick(float a_Dt)
{
- cMonster::Tick(a_Dt);
+ super::Tick(a_Dt);
// TODO Same as in cSkeleton :D
if ((GetWorld()->GetTimeOfDay() < (12000 + 1000)) && (GetMetaData() != BURNING))
@@ -50,16 +41,11 @@ void cZombie::Tick(float a_Dt)
-void cZombie::KilledBy( cEntity* a_Killer )
+void cZombie::GetDrops(cItems & a_Drops, cPawn * a_Killer)
{
- cItems Drops;
- AddRandomDropItem(Drops, 0, 2, E_ITEM_ROTTEN_FLESH);
+ AddRandomDropItem(a_Drops, 0, 2, E_ITEM_ROTTEN_FLESH);
// TODO: Rare drops
-
- m_World->SpawnItemPickups(Drops, m_Pos.x, m_Pos.y, m_Pos.z);
-
- cMonster::KilledBy( a_Killer );
}
diff --git a/source/Mobs/Zombie.h b/source/Mobs/Zombie.h
index 6adaaf41f..8256c040a 100644
--- a/source/Mobs/Zombie.h
+++ b/source/Mobs/Zombie.h
@@ -2,14 +2,24 @@
#include "AggressiveMonster.h"
-class cZombie : public cAggressiveMonster
+
+
+
+
+class cZombie :
+ public cAggressiveMonster
{
+ typedef cAggressiveMonster super;
+
public:
cZombie();
- ~cZombie();
- virtual bool IsA( const char* a_EntityType );
+ virtual bool IsA(const char * a_EntityType) override;
+
+ virtual void Tick(float a_Dt) override;
+ virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override;
+} ;
+
+
+
- virtual void Tick(float a_Dt);
- virtual void KilledBy( cEntity* a_Killer );
-};
diff --git a/source/Mobs/Zombiepigman.cpp b/source/Mobs/Zombiepigman.cpp
index a33d78efa..9d3106829 100644
--- a/source/Mobs/Zombiepigman.cpp
+++ b/source/Mobs/Zombiepigman.cpp
@@ -17,18 +17,9 @@ cZombiepigman::cZombiepigman()
-cZombiepigman::~cZombiepigman()
+bool cZombiepigman::IsA(const char * a_EntityType)
{
-}
-
-
-
-
-
-bool cZombiepigman::IsA( const char* a_EntityType )
-{
- if( strcmp( a_EntityType, "cZombiepigman" ) == 0 ) return true;
- return cMonster::IsA( a_EntityType );
+ return ((strcmp(a_EntityType, "cZombiepigman") == 0) || super::IsA(a_EntityType));
}
@@ -37,7 +28,7 @@ bool cZombiepigman::IsA( const char* a_EntityType )
void cZombiepigman::Tick(float a_Dt)
{
- cMonster::Tick(a_Dt);
+ super::Tick(a_Dt);
// TODO Same as noticed in cSkeleton AND Do they really burn by sun?? :D In the neather is no sun :D
if ((GetWorld()->GetTimeOfDay() < (12000 + 1000)) && (GetMetaData() != BURNING))
@@ -50,17 +41,27 @@ void cZombiepigman::Tick(float a_Dt)
-void cZombiepigman::KilledBy(cEntity * a_Killer)
+void cZombiepigman::GetDrops(cItems & a_Drops, cPawn * a_Killer)
{
- cItems Drops;
- AddRandomDropItem(Drops, 0, 1, E_ITEM_ROTTEN_FLESH);
- AddRandomDropItem(Drops, 0, 1, E_ITEM_GOLD_NUGGET);
+ AddRandomDropItem(a_Drops, 0, 1, E_ITEM_ROTTEN_FLESH);
+ AddRandomDropItem(a_Drops, 0, 1, E_ITEM_GOLD_NUGGET);
// TODO: Rare drops
-
- m_World->SpawnItemPickups(Drops, m_Pos.x, m_Pos.y, m_Pos.z);
+}
- cMonster::KilledBy( a_Killer );
+
+
+
+
+void cZombiepigman::KilledBy(cPawn * a_Killer)
+{
+ super::KilledBy(a_Killer);
+
+ if ((a_Killer != NULL) && (a_Killer->GetEntityType() == eEntityType_Player))
+ {
+ // TODO: Anger all nearby zombie pigmen
+ // TODO: In vanilla, if one player angers ZPs, do they attack any nearby player, or only that one attacker?
+ }
}
diff --git a/source/Mobs/Zombiepigman.h b/source/Mobs/Zombiepigman.h
index 93fe2d607..02ad21562 100644
--- a/source/Mobs/Zombiepigman.h
+++ b/source/Mobs/Zombiepigman.h
@@ -1,15 +1,27 @@
+
#pragma once
#include "PassiveAggressiveMonster.h"
-class cZombiepigman : public cPassiveAggressiveMonster
+
+
+
+
+class cZombiepigman :
+ public cPassiveAggressiveMonster
{
+ typedef cPassiveAggressiveMonster super;
+
public:
cZombiepigman();
- ~cZombiepigman();
- virtual bool IsA( const char* a_EntityType );
+ virtual bool IsA(const char * a_EntityType) override;
+
+ virtual void Tick(float a_Dt) override;
+ virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override;
+ virtual void KilledBy(cPawn * a_Killer) override;
+} ;
+
+
+
- virtual void Tick(float a_Dt);
- virtual void KilledBy( cEntity* a_Killer );
-};