summaryrefslogtreecommitdiffstats
path: root/src/Mobs/Monster.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/Mobs/Monster.h')
-rw-r--r--src/Mobs/Monster.h81
1 files changed, 38 insertions, 43 deletions
diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h
index cdbd26c09..ba746ebc8 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"
@@ -23,41 +24,9 @@ class cMonster :
{
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,
- } ;
+
+ //Depreciated
+ typedef eMonsterType eType;
enum eFamily
{
@@ -80,7 +49,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)
@@ -92,11 +61,13 @@ public:
virtual void KilledBy(TakeDamageInfo & a_TDI) override;
+ virtual void OnRightClicked(cPlayer & a_Player) override;
+
virtual void MoveToPosition(const Vector3d & a_Position); // tolua_export
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
@@ -138,21 +109,41 @@ public:
/// Sets whether the mob burns in daylight. Only evaluated at next burn-decision tick
void SetBurnsInDaylight(bool a_BurnsInDaylight) { m_BurnsInDaylight = a_BurnsInDaylight; }
+ double GetRelativeWalkSpeed(void) const { return m_RelativeWalkSpeed; } // tolua_export
+ void SetRelativeWalkSpeed(double a_WalkSpeed) { m_RelativeWalkSpeed = a_WalkSpeed; } // tolua_export
+
// 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; }
// tolua_begin
-
+
+ /** Returns true if the monster has a custom name. */
+ bool HasCustomName(void) const { return !m_CustomName.empty(); }
+
+ /** Gets the custom name of the monster. If no custom name is set, the function returns an empty string. */
+ const AString & GetCustomName(void) const { return m_CustomName; }
+
+ /** Sets the custom name of the monster. You see the name over the monster.
+ If you want to disable the custom name, simply set an empty string. */
+ void SetCustomName(const AString & a_CustomName);
+
+ /** Is the custom name of this monster always visible? If not, you only see the name when you sight the mob. */
+ bool IsCustomNameAlwaysVisible(void) const { return m_CustomNameAlwaysVisible; }
+
+ /** Sets the custom name visiblity of this monster.
+ If it's false, you only see the name when you sight the mob. If it's true, you always see the custom name. */
+ void SetCustomNameAlwaysVisible(bool a_CustomNameAlwaysVisible);
+
/// 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 +154,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 +218,9 @@ protected:
float m_IdleInterval;
float m_DestroyTimer;
- eType m_MobType;
+ eMonsterType m_MobType;
+ AString m_CustomName;
+ bool m_CustomNameAlwaysVisible;
AString m_SoundHurt;
AString m_SoundDeath;
@@ -248,6 +241,8 @@ protected:
void HandleDaylightBurning(cChunk & a_Chunk);
bool m_BurnsInDaylight;
+ double m_RelativeWalkSpeed;
+
/** Adds a random number of a_Item between a_Min and a_Max to itemdrops a_Drops*/
void AddRandomDropItem(cItems & a_Drops, unsigned int a_Min, unsigned int a_Max, short a_Item, short a_ItemHealth = 0);