summaryrefslogtreecommitdiffstats
path: root/source/Mobs
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2013-10-09 22:02:59 +0200
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2013-10-09 22:02:59 +0200
commitfe6fa23a97421af3d02b9faf92b8df2f73abb556 (patch)
treea080fa2de23b3123dc2d13ab8ee5565c3eac9ad6 /source/Mobs
parentInitial round of fixes (diff)
downloadcuberite-fe6fa23a97421af3d02b9faf92b8df2f73abb556.tar
cuberite-fe6fa23a97421af3d02b9faf92b8df2f73abb556.tar.gz
cuberite-fe6fa23a97421af3d02b9faf92b8df2f73abb556.tar.bz2
cuberite-fe6fa23a97421af3d02b9faf92b8df2f73abb556.tar.lz
cuberite-fe6fa23a97421af3d02b9faf92b8df2f73abb556.tar.xz
cuberite-fe6fa23a97421af3d02b9faf92b8df2f73abb556.tar.zst
cuberite-fe6fa23a97421af3d02b9faf92b8df2f73abb556.zip
Diffstat (limited to 'source/Mobs')
-rw-r--r--source/Mobs/Bat.h2
-rw-r--r--source/Mobs/Creeper.cpp21
-rw-r--r--source/Mobs/Creeper.h9
-rw-r--r--source/Mobs/Enderman.cpp5
-rw-r--r--source/Mobs/Enderman.h11
-rw-r--r--source/Mobs/Ghast.h2
-rw-r--r--source/Mobs/Horse.cpp1
-rw-r--r--source/Mobs/Horse.h4
-rw-r--r--source/Mobs/Monster.h6
-rw-r--r--source/Mobs/Witch.h2
-rw-r--r--source/Mobs/Zombie.cpp6
-rw-r--r--source/Mobs/Zombie.h10
12 files changed, 73 insertions, 6 deletions
diff --git a/source/Mobs/Bat.h b/source/Mobs/Bat.h
index 8e4cde29f..7aaec361b 100644
--- a/source/Mobs/Bat.h
+++ b/source/Mobs/Bat.h
@@ -20,6 +20,8 @@ public:
}
CLASS_PROTODEF(cBat);
+
+ bool IsHanging(void) const {return false; }
} ;
diff --git a/source/Mobs/Creeper.cpp b/source/Mobs/Creeper.cpp
index 9b1b68b79..b41b05f42 100644
--- a/source/Mobs/Creeper.cpp
+++ b/source/Mobs/Creeper.cpp
@@ -2,13 +2,16 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "Creeper.h"
+#include "../World.h"
cCreeper::cCreeper(void) :
- super("Creeper", 50, "mob.creeper.say", "mob.creeper.say", 0.6, 1.8)
+ super("Creeper", 50, "mob.creeper.say", "mob.creeper.say", 0.6, 1.8),
+ m_bIsBlowing(false),
+ m_bIsCharged(false)
{
}
@@ -26,3 +29,19 @@ void cCreeper::GetDrops(cItems & a_Drops, cEntity * a_Killer)
+
+void cCreeper::DoTakeDamage(TakeDamageInfo & a_TDI)
+{
+ super::DoTakeDamage(a_TDI);
+
+ if (a_TDI.DamageType == dtLightning)
+ {
+ m_bIsCharged = true;
+ }
+
+ m_World->BroadcastEntityMetadata(*this);
+}
+
+
+
+
diff --git a/source/Mobs/Creeper.h b/source/Mobs/Creeper.h
index c1d46f462..c3d4edeae 100644
--- a/source/Mobs/Creeper.h
+++ b/source/Mobs/Creeper.h
@@ -18,6 +18,15 @@ public:
CLASS_PROTODEF(cCreeper);
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
+ virtual void DoTakeDamage(TakeDamageInfo & a_TDI) override;
+
+ bool IsBlowing(void) const {return m_bIsBlowing; }
+ bool IsCharged(void) const {return m_bIsCharged; }
+
+private:
+
+ bool m_bIsBlowing, m_bIsCharged;
+
} ;
diff --git a/source/Mobs/Enderman.cpp b/source/Mobs/Enderman.cpp
index 1dc47876f..04c1a60e1 100644
--- a/source/Mobs/Enderman.cpp
+++ b/source/Mobs/Enderman.cpp
@@ -9,7 +9,10 @@
cEnderman::cEnderman(void) :
// TODO: The size is only a guesstimate, measure in vanilla and fix the size values here
- super("Enderman", 58, "mob.endermen.hit", "mob.endermen.death", 0.5, 2.5)
+ super("Enderman", 58, "mob.endermen.hit", "mob.endermen.death", 0.5, 2.5),
+ m_bIsScreaming(false),
+ CarriedBlock(E_BLOCK_AIR),
+ CarriedMeta(0)
{
}
diff --git a/source/Mobs/Enderman.h b/source/Mobs/Enderman.h
index c4f4ee364..32e40e70b 100644
--- a/source/Mobs/Enderman.h
+++ b/source/Mobs/Enderman.h
@@ -18,6 +18,17 @@ public:
CLASS_PROTODEF(cEnderman);
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
+
+ bool IsScreaming(void) const {return m_bIsScreaming; }
+ BLOCKTYPE GetCarriedBlock(void) const {return CarriedBlock; }
+ NIBBLETYPE GetCarriedMeta(void) const {return CarriedMeta; }
+
+private:
+
+ bool m_bIsScreaming;
+ BLOCKTYPE CarriedBlock;
+ NIBBLETYPE CarriedMeta;
+
} ;
diff --git a/source/Mobs/Ghast.h b/source/Mobs/Ghast.h
index f9b60dfcf..a2adc21b9 100644
--- a/source/Mobs/Ghast.h
+++ b/source/Mobs/Ghast.h
@@ -18,6 +18,8 @@ public:
CLASS_PROTODEF(cGhast);
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
+
+ bool IsCharging(void) const {return false; }
} ;
diff --git a/source/Mobs/Horse.cpp b/source/Mobs/Horse.cpp
index ec6154d26..caa1a3deb 100644
--- a/source/Mobs/Horse.cpp
+++ b/source/Mobs/Horse.cpp
@@ -16,6 +16,7 @@ cHorse::cHorse(int Type, int Color, int Style, int TameTimes) :
m_bIsRearing(false),
m_bIsMouthOpen(false),
m_bIsTame(false),
+ m_bIsSaddled(false),
m_Type(Type),
m_Color(Color),
m_Style(Style),
diff --git a/source/Mobs/Horse.h b/source/Mobs/Horse.h
index bca2e5327..bf39c8b13 100644
--- a/source/Mobs/Horse.h
+++ b/source/Mobs/Horse.h
@@ -20,6 +20,8 @@ public:
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
virtual void OnRightClicked(cPlayer & a_Player) override;
+
+ bool IsSaddled (void) const {return m_bIsSaddled; }
bool IsChested (void) const {return m_bHasChest; }
bool IsEating (void) const {return m_bIsEating; }
bool IsRearing (void) const {return m_bIsRearing; }
@@ -32,7 +34,7 @@ public:
private:
- bool m_bHasChest, m_bIsEating, m_bIsRearing, m_bIsMouthOpen, m_bIsTame;
+ bool m_bHasChest, m_bIsEating, m_bIsRearing, m_bIsMouthOpen, m_bIsTame, m_bIsSaddled;
int m_Type, m_Color, m_Style, m_Armour, m_TimesToTame, m_TameAttemptTimes;
} ;
diff --git a/source/Mobs/Monster.h b/source/Mobs/Monster.h
index b2676f5b1..d784f2eec 100644
--- a/source/Mobs/Monster.h
+++ b/source/Mobs/Monster.h
@@ -113,6 +113,11 @@ public:
/// Sets whether the mob burns in daylight. Only evaluated at next burn-decision tick
void SetBurnsInDaylight(bool a_BurnsInDaylight) { m_BurnsInDaylight = a_BurnsInDaylight; }
+
+ // Overridables to handle ageable mobs
+ virtual bool IsBaby (void) const { return false; }
+ virtual bool IsTame (void) const { return false; }
+ virtual bool IsSitting (void) const { return false; }
enum MState{ATTACKING, IDLE, CHASING, ESCAPING} m_EMState;
enum MPersonality{PASSIVE,AGGRESSIVE,COWARDLY} m_EMPersonality;
@@ -147,6 +152,7 @@ protected:
void AddRandomDropItem(cItems & a_Drops, unsigned int a_Min, unsigned int a_Max, short a_Item, short a_ItemHealth = 0);
void HandleDaylightBurning(cChunk & a_Chunk);
+
} ; // tolua_export
diff --git a/source/Mobs/Witch.h b/source/Mobs/Witch.h
index ce0b49deb..4e637beea 100644
--- a/source/Mobs/Witch.h
+++ b/source/Mobs/Witch.h
@@ -18,6 +18,8 @@ public:
CLASS_PROTODEF(cWitch);
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
+
+ bool IsAngry(void) const {return ((m_EMState == ATTACKING) || (m_EMState == CHASING)); }
} ;
diff --git a/source/Mobs/Zombie.cpp b/source/Mobs/Zombie.cpp
index 9b238baef..f495fe5ee 100644
--- a/source/Mobs/Zombie.cpp
+++ b/source/Mobs/Zombie.cpp
@@ -8,8 +8,10 @@
-cZombie::cZombie(void) :
- super("Zombie", 54, "mob.zombie.hurt", "mob.zombie.death", 0.6, 1.8)
+cZombie::cZombie(bool IsVillagerZombie) :
+ super("Zombie", 54, "mob.zombie.hurt", "mob.zombie.death", 0.6, 1.8),
+ m_bIsConverting(false),
+ m_bIsVillagerZombie(IsVillagerZombie)
{
SetBurnsInDaylight(true);
}
diff --git a/source/Mobs/Zombie.h b/source/Mobs/Zombie.h
index 4835a53c4..148b1121e 100644
--- a/source/Mobs/Zombie.h
+++ b/source/Mobs/Zombie.h
@@ -12,11 +12,19 @@ class cZombie :
typedef cAggressiveMonster super;
public:
- cZombie(void);
+ cZombie(bool IsVillagerZombie);
CLASS_PROTODEF(cZombie);
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
+
+ bool IsVillagerZombie(void) const {return m_bIsVillagerZombie; }
+ bool IsConverting(void) const {return m_bIsConverting; }
+
+private:
+
+ bool m_bIsVillagerZombie, m_bIsConverting;
+
} ;