From 1e02e04d2ce528df037d1ca37314ea55e8806c52 Mon Sep 17 00:00:00 2001 From: mgueydan Date: Sat, 7 Sep 2013 20:02:50 +0200 Subject: Adding Family for monsters : Hostile/Passive/Water/Ambient --- source/Mobs/Monster.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source/Mobs/Monster.h') diff --git a/source/Mobs/Monster.h b/source/Mobs/Monster.h index 5f33d4450..357e540b3 100644 --- a/source/Mobs/Monster.h +++ b/source/Mobs/Monster.h @@ -55,6 +55,15 @@ public: mtIronGolem = E_META_SPAWN_EGG_IRON_GOLEM, mtVillager = E_META_SPAWN_EGG_VILLAGER, } ; + + enum eFamily + { + mfHostile = 0, // Spider, Zombies ... + mfPassive = 1, // Cows, Pigs + mfAmbient = 2, // Bats + mfWater = 3, // Squid + mfMaxplusone = 4, // Nothing + } ; // tolua_end @@ -81,6 +90,7 @@ public: virtual bool ReachedDestination(void); char GetMobType(void) const {return m_MobType; } + virtual eFamily GetMobFamily(void) const = 0; const char * GetState(); void SetState(const AString & str); -- cgit v1.2.3 From e844612503e0d78723c76423e93165164505f7ac Mon Sep 17 00:00:00 2001 From: mgueydan Date: Sat, 7 Sep 2013 20:51:31 +0200 Subject: Adding a getType in Monster that return an enum instead of an int or char --- source/Mobs/Monster.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/Mobs/Monster.h') diff --git a/source/Mobs/Monster.h b/source/Mobs/Monster.h index 357e540b3..594914ca0 100644 --- a/source/Mobs/Monster.h +++ b/source/Mobs/Monster.h @@ -89,7 +89,8 @@ public: virtual void MoveToPosition(const Vector3f & a_Position); virtual bool ReachedDestination(void); - char GetMobType(void) const {return m_MobType; } + char GetMobType(void) const {return m_MobType; } // MG TODO : see if we can delete this one. + eType GetMobTypeAsEnum(void) const {return (eType)m_MobType; } // MG TODO : see if we should store m_MobType as enum instead of char. virtual eFamily GetMobFamily(void) const = 0; const char * GetState(); -- cgit v1.2.3 From caa54af54640d1c94c57bc84b6b1e4eb2e7a6f3c Mon Sep 17 00:00:00 2001 From: mgueydan Date: Sun, 8 Sep 2013 01:21:43 +0200 Subject: Implementing the MobSpawner (not used yet) that contains spawning rules --- source/Mobs/Monster.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source/Mobs/Monster.h') diff --git a/source/Mobs/Monster.h b/source/Mobs/Monster.h index 594914ca0..ef7904e8e 100644 --- a/source/Mobs/Monster.h +++ b/source/Mobs/Monster.h @@ -54,6 +54,8 @@ public: mtOcelot = E_META_SPAWN_EGG_OCELOT, mtIronGolem = E_META_SPAWN_EGG_IRON_GOLEM, mtVillager = E_META_SPAWN_EGG_VILLAGER, + + mtInvalidType, // MG TODO : be sure this is the way we do in this project. (needed inside cMobSpawner::ChooscMonster for instance if nothing can be spawned) } ; enum eFamily @@ -62,7 +64,8 @@ public: mfPassive = 1, // Cows, Pigs mfAmbient = 2, // Bats mfWater = 3, // Squid - mfMaxplusone = 4, // Nothing + + mfMaxplusone, // Nothing. Be sure this is the last and the others are in order } ; // tolua_end -- cgit v1.2.3 From f12ac6b995f46acf76e61e7f83273ebfc18c090f Mon Sep 17 00:00:00 2001 From: mgueydan Date: Tue, 10 Sep 2013 15:09:45 +0200 Subject: Inside cMonster::getMobFamily() : replacing Polymorphism by Map, in order to remove redundancy --- source/Mobs/Monster.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/Mobs/Monster.h') diff --git a/source/Mobs/Monster.h b/source/Mobs/Monster.h index ef7904e8e..e08fd518a 100644 --- a/source/Mobs/Monster.h +++ b/source/Mobs/Monster.h @@ -94,7 +94,8 @@ public: char GetMobType(void) const {return m_MobType; } // MG TODO : see if we can delete this one. eType GetMobTypeAsEnum(void) const {return (eType)m_MobType; } // MG TODO : see if we should store m_MobType as enum instead of char. - virtual eFamily GetMobFamily(void) const = 0; + eFamily GetMobFamily(void) const; + const char * GetState(); void SetState(const AString & str); -- cgit v1.2.3 From 9f7b2e259d554ba3529f9faac7a0146fe9a3d6b3 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 16 Sep 2013 11:42:20 +0200 Subject: Exported cMonster:GetMobType() to the Lua API. --- source/Mobs/Monster.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source/Mobs/Monster.h') diff --git a/source/Mobs/Monster.h b/source/Mobs/Monster.h index 5f33d4450..82fc4b6fc 100644 --- a/source/Mobs/Monster.h +++ b/source/Mobs/Monster.h @@ -100,7 +100,9 @@ public: virtual void InStateEscaping(float a_Dt); virtual void Attack(float a_Dt); - int GetMobType() {return m_MobType;} + + int GetMobType() { return m_MobType; } // tolua_export + int GetAttackRate(){return (int)m_AttackRate;} void SetAttackRate(int ar); void SetAttackRange(float ar); -- cgit v1.2.3 From f2b7b220a4ed2f5aa2e87792aff99715e113eefa Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 17 Sep 2013 20:57:35 +0100 Subject: Fixed undead burning (c'mon xoft, test ya code :P) --- source/Mobs/Monster.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/Mobs/Monster.h') diff --git a/source/Mobs/Monster.h b/source/Mobs/Monster.h index 82fc4b6fc..484e32c65 100644 --- a/source/Mobs/Monster.h +++ b/source/Mobs/Monster.h @@ -110,7 +110,7 @@ public: void SetSightDistance(float sd); /// Sets whether the mob burns in daylight. Only evaluated at next burn-decision tick - void SetBurnsInDaylight(bool a_BurnsInDaylight) { a_BurnsInDaylight = a_BurnsInDaylight; } + void SetBurnsInDaylight(bool a_BurnsInDaylight) { m_BurnsInDaylight = a_BurnsInDaylight; } enum MState{ATTACKING, IDLE, CHASING, ESCAPING} m_EMState; enum MPersonality{PASSIVE,AGGRESSIVE,COWARDLY} m_EMPersonality; -- cgit v1.2.3 From 3e698d7b72ad7f58a1a2ab787f49c82e096845f6 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 18 Sep 2013 22:17:43 +0100 Subject: Added moar mobs! + Added dragons + Added golems + Added giants + Added horses + Added some missing items + Added missing spawn egg metas --- source/Mobs/Monster.h | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) (limited to 'source/Mobs/Monster.h') diff --git a/source/Mobs/Monster.h b/source/Mobs/Monster.h index 484e32c65..b2676f5b1 100644 --- a/source/Mobs/Monster.h +++ b/source/Mobs/Monster.h @@ -26,34 +26,36 @@ public: /// This identifies individual monster type, as well as their network type-ID enum eType { + 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, - mtSkeleton = E_META_SPAWN_EGG_SKELETON, - mtSpider = E_META_SPAWN_EGG_SPIDER, - mtGiant = E_META_SPAWN_EGG_GIANT, - mtZombie = E_META_SPAWN_EGG_ZOMBIE, - mtSlime = E_META_SPAWN_EGG_SLIME, - mtGhast = E_META_SPAWN_EGG_GHAST, - mtZombiePigman = E_META_SPAWN_EGG_ZOMBIE_PIGMAN, + mtEnderDragon = E_META_SPAWN_EGG_ENDER_DRAGON, mtEnderman = E_META_SPAWN_EGG_ENDERMAN, - mtCaveSpider = E_META_SPAWN_EGG_CAVE_SPIDER, - mtSilverfish = E_META_SPAWN_EGG_SILVERFISH, - mtBlaze = E_META_SPAWN_EGG_BLAZE, + 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, - mtEnderDragon = E_META_SPAWN_EGG_ENDER_DRAGON, - mtWither = E_META_SPAWN_EGG_WITHER, - mtBat = E_META_SPAWN_EGG_BAT, - mtWitch = E_META_SPAWN_EGG_WITCH, + mtMooshroom = E_META_SPAWN_EGG_MOOSHROOM, + mtOcelot = E_META_SPAWN_EGG_OCELOT, mtPig = E_META_SPAWN_EGG_PIG, mtSheep = E_META_SPAWN_EGG_SHEEP, - mtCow = E_META_SPAWN_EGG_COW, - mtChicken = E_META_SPAWN_EGG_CHICKEN, - mtSquid = E_META_SPAWN_EGG_SQUID, - mtWolf = E_META_SPAWN_EGG_WOLF, - mtMooshroom = E_META_SPAWN_EGG_MOOSHROOM, + 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, - mtOcelot = E_META_SPAWN_EGG_OCELOT, - mtIronGolem = E_META_SPAWN_EGG_IRON_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 -- cgit v1.2.3 From fe6fa23a97421af3d02b9faf92b8df2f73abb556 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 9 Oct 2013 21:02:59 +0100 Subject: Second round of fixes * Implemented suggestions --- source/Mobs/Monster.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source/Mobs/Monster.h') 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 -- cgit v1.2.3 From 34928378b8e3464326de38787bfada9adc0bfb11 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 20 Oct 2013 10:23:30 +0200 Subject: Fixed loading allowed mobs in world. --- source/Mobs/Monster.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'source/Mobs/Monster.h') diff --git a/source/Mobs/Monster.h b/source/Mobs/Monster.h index be60d9e00..c416d026c 100644 --- a/source/Mobs/Monster.h +++ b/source/Mobs/Monster.h @@ -26,6 +26,8 @@ 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, @@ -55,7 +57,6 @@ public: mtWolf = E_META_SPAWN_EGG_WOLF, mtZombie = E_META_SPAWN_EGG_ZOMBIE, mtZombiePigman = E_META_SPAWN_EGG_ZOMBIE_PIGMAN, - mtInvalidType } ; enum eFamily @@ -74,10 +75,10 @@ public: /** 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_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, char a_ProtocolMobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height); + cMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height); CLASS_PROTODEF(cMonster); @@ -92,9 +93,10 @@ public: virtual void MoveToPosition(const Vector3f & a_Position); virtual bool ReachedDestination(void); - char GetMobType(void) const {return m_MobType; } // MG TODO : see if we can delete this one. - eType GetMobTypeAsEnum(void) const {return (eType)m_MobType; } // MG TODO : see if we should store m_MobType as enum instead of char. + // tolua_begin + eType GetMobType(void) const {return m_MobType; } eFamily GetMobFamily(void) const; + // tolua_end const char * GetState(); @@ -116,8 +118,6 @@ public: virtual void Attack(float a_Dt); - int GetMobType() { return m_MobType; } // tolua_export - int GetAttackRate(){return (int)m_AttackRate;} void SetAttackRate(int ar); void SetAttackRange(float ar); @@ -150,7 +150,7 @@ protected: float m_DestroyTimer; float m_Jump; - char m_MobType; + eType m_MobType; AString m_SoundHurt; AString m_SoundDeath; -- cgit v1.2.3 From 848d061de167be9fd802cc8a6b14a934702af81a Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 20 Oct 2013 13:25:56 +0200 Subject: Moved all MobTypesManager functions to cMonster. This removes some of the memory leaks and is more logical in structure. Also the functions are exported to Lua. --- source/Mobs/Monster.h | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'source/Mobs/Monster.h') diff --git a/source/Mobs/Monster.h b/source/Mobs/Monster.h index c416d026c..3b7f40c00 100644 --- a/source/Mobs/Monster.h +++ b/source/Mobs/Monster.h @@ -71,6 +71,9 @@ public: // tolua_end + enum MState{ATTACKING, IDLE, CHASING, ESCAPING} m_EMState; + enum MPersonality{PASSIVE,AGGRESSIVE,COWARDLY} m_EMPersonality; + float m_SightDistance; /** Creates the mob object. @@ -132,9 +135,28 @@ public: 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; + // tolua_begin + + /// Translates MobType enum to a string + static AString MobTypeToString(eType a_MobType); + /// Translates MobType string to the enum + static eType StringToMobType(const AString & a_MobTypeName); + + /// Returns the mob family based on the type + static eFamily FamilyFromType(eType a_MobType); + + // tolua_end + + /** Creates a new object of the specified mob. + a_MobType is the type of the mob to be created + a_Size is the size (for mobs with size) + if a_Size is let to -1 for entities that need size, size will be random + asserts and returns null if mob type is not specified + asserts if invalid size for mobs that need size + */ + static cMonster * NewMonsterFromType(eType a_MobType, int a_Size = -1); + protected: cEntity * m_Target; -- cgit v1.2.3 From 6075f7cecd7c1a1f283c98eb0feeb746402a7c00 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 20 Oct 2013 14:00:45 +0200 Subject: Fixed memory leaks in cMobCensus, moved GetSpawnRate() to cMonster. --- source/Mobs/Monster.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source/Mobs/Monster.h') diff --git a/source/Mobs/Monster.h b/source/Mobs/Monster.h index 3b7f40c00..14c72ed73 100644 --- a/source/Mobs/Monster.h +++ b/source/Mobs/Monster.h @@ -146,6 +146,9 @@ public: /// Returns the mob family based on the type static eFamily FamilyFromType(eType a_MobType); + /// Returns the spawn rate (number of game ticks between spawn attempts) for the given mob family + static int GetSpawnRate(cMonster::eFamily a_MobFamily); + // tolua_end /** Creates a new object of the specified mob. -- cgit v1.2.3 From 5331555708ce3bfc4417b2f7c788fff98e81a858 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 24 Oct 2013 16:45:13 +0200 Subject: Renamed cMonster::GetSpawnRate() to GetSpawnDelay(). --- source/Mobs/Monster.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/Mobs/Monster.h') diff --git a/source/Mobs/Monster.h b/source/Mobs/Monster.h index 14c72ed73..39fa716ed 100644 --- a/source/Mobs/Monster.h +++ b/source/Mobs/Monster.h @@ -146,8 +146,8 @@ public: /// Returns the mob family based on the type static eFamily FamilyFromType(eType a_MobType); - /// Returns the spawn rate (number of game ticks between spawn attempts) for the given mob family - static int GetSpawnRate(cMonster::eFamily a_MobFamily); + /// Returns the spawn delay (number of game ticks between spawn attempts) for the given mob family + static int GetSpawnDelay(cMonster::eFamily a_MobFamily); // tolua_end -- cgit v1.2.3 From 86bec4c57c72bb2d58c6dd91a447987f45cc7b32 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 25 Oct 2013 10:41:19 +0200 Subject: cMonster: Improved doxycomments. --- source/Mobs/Monster.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/Mobs/Monster.h') diff --git a/source/Mobs/Monster.h b/source/Mobs/Monster.h index 39fa716ed..a0002bf4f 100644 --- a/source/Mobs/Monster.h +++ b/source/Mobs/Monster.h @@ -137,10 +137,10 @@ public: // tolua_begin - /// Translates MobType enum to a string + /// Translates MobType enum to a string, empty string if unknown static AString MobTypeToString(eType a_MobType); - /// Translates MobType string to the enum + /// Translates MobType string to the enum, mtInvalidType if not recognized static eType StringToMobType(const AString & a_MobTypeName); /// Returns the mob family based on the type -- cgit v1.2.3 From 71abbb2f56c15634cca8615343d9699d0c50724d Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 10 Nov 2013 20:48:12 +0000 Subject: Bundled fixes [SEE DESC] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fixed pickups spawning in an incorrect position from a JukeBox * Pickups make a popping sound in Prtcl1.7 * Arrows make a *what sort of sound does an arrow make anyway‽* when hitting a block, and a popping sound when fired * Mobs again have metadata * Fixed Prtcl1.7 not using valid JSON to kick a client * Minecarts and arrows again have metadata --- source/Mobs/Monster.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'source/Mobs/Monster.h') diff --git a/source/Mobs/Monster.h b/source/Mobs/Monster.h index a0002bf4f..29a705d11 100644 --- a/source/Mobs/Monster.h +++ b/source/Mobs/Monster.h @@ -153,12 +153,9 @@ public: /** Creates a new object of the specified mob. a_MobType is the type of the mob to be created - a_Size is the size (for mobs with size) - if a_Size is let to -1 for entities that need size, size will be random - asserts and returns null if mob type is not specified - asserts if invalid size for mobs that need size + Asserts and returns null if mob type is not specified */ - static cMonster * NewMonsterFromType(eType a_MobType, int a_Size = -1); + static cMonster * NewMonsterFromType(eType a_MobType); protected: -- cgit v1.2.3 From 675b4aa878f16291ce33fced48a2bc7425f635ae Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Sun, 24 Nov 2013 14:19:41 +0000 Subject: Moved source to src --- source/Mobs/Monster.h | 195 -------------------------------------------------- 1 file changed, 195 deletions(-) delete mode 100644 source/Mobs/Monster.h (limited to 'source/Mobs/Monster.h') diff --git a/source/Mobs/Monster.h b/source/Mobs/Monster.h deleted file mode 100644 index 29a705d11..000000000 --- a/source/Mobs/Monster.h +++ /dev/null @@ -1,195 +0,0 @@ - -#pragma once - -#include "../Entities/Pawn.h" -#include "../Defines.h" -#include "../BlockID.h" -#include "../Item.h" - - - - - -class Vector3f; -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 ... - mfPassive = 1, // Cows, Pigs - mfAmbient = 2, // Bats - mfWater = 3, // Squid - - mfMaxplusone, // Nothing. Be sure this is the last and the others are in order - } ; - - // tolua_end - - enum MState{ATTACKING, IDLE, CHASING, ESCAPING} m_EMState; - enum MPersonality{PASSIVE,AGGRESSIVE,COWARDLY} m_EMPersonality; - - float m_SightDistance; - - /** Creates the mob object. - * If a_ConfigName is not empty, the configuration is loaded using GetMonsterConfig() - * 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); - - CLASS_PROTODEF(cMonster); - - virtual void SpawnOn(cClientHandle & a_ClientHandle) override; - - virtual void Tick(float a_Dt, cChunk & a_Chunk) override; - - virtual void DoTakeDamage(TakeDamageInfo & a_TDI) override; - - virtual void KilledBy(cEntity * a_Killer) override; - - virtual void MoveToPosition(const Vector3f & a_Position); - virtual bool ReachedDestination(void); - - // tolua_begin - eType GetMobType(void) const {return m_MobType; } - eFamily GetMobFamily(void) const; - // tolua_end - - - const char * GetState(); - void SetState(const AString & str); - - virtual void CheckEventSeePlayer(void); - virtual void EventSeePlayer(cEntity * a_Player); - virtual cPlayer * FindClosestPlayer(); // non static is easier. also virtual so other mobs can implement their own searching algo - - /// Reads the monster configuration for the specified monster name and assigns it to this object. - void GetMonsterConfig(const AString & a_Name); - - virtual void EventLosePlayer(void); - virtual void CheckEventLostPlayer(void); - - virtual void InStateIdle (float a_Dt); - virtual void InStateChasing (float a_Dt); - virtual void InStateEscaping(float a_Dt); - - virtual void Attack(float a_Dt); - - int GetAttackRate(){return (int)m_AttackRate;} - void SetAttackRate(int ar); - void SetAttackRange(float ar); - void SetAttackDamage(float ad); - void SetSightDistance(float sd); - - /// 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; } - - // tolua_begin - - /// Translates MobType enum to a string, empty string if unknown - static AString MobTypeToString(eType a_MobType); - - /// Translates MobType string to the enum, mtInvalidType if not recognized - static eType StringToMobType(const AString & a_MobTypeName); - - /// Returns the mob family based on the type - static eFamily FamilyFromType(eType 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); - - // tolua_end - - /** Creates a new object of the specified mob. - 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); - -protected: - - cEntity * m_Target; - float m_AttackRate; - float idle_interval; - - Vector3f m_Destination; - bool m_bMovingToDestination; - bool m_bPassiveAggressive; - - float m_DestinationTime; - - float m_DestroyTimer; - float m_Jump; - - eType m_MobType; - - AString m_SoundHurt; - AString m_SoundDeath; - - float m_SeePlayerInterval; - float m_AttackDamage; - float m_AttackRange; - float m_AttackInterval; - - bool m_BurnsInDaylight; - - 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 - - - - -- cgit v1.2.3