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/AggressiveMonster.cpp | 7 +++++++ source/Mobs/AggressiveMonster.h | 2 ++ source/Mobs/Bat.cpp | 19 +++++++++++++++++++ source/Mobs/Bat.h | 8 +++----- source/Mobs/Monster.h | 10 ++++++++++ source/Mobs/PassiveMonster.cpp | 7 +++++++ source/Mobs/PassiveMonster.h | 2 ++ source/Mobs/Squid.cpp | 5 ++++- source/Mobs/Squid.h | 2 ++ 9 files changed, 56 insertions(+), 6 deletions(-) create mode 100644 source/Mobs/Bat.cpp (limited to 'source/Mobs') diff --git a/source/Mobs/AggressiveMonster.cpp b/source/Mobs/AggressiveMonster.cpp index 2eae772d7..d48523373 100644 --- a/source/Mobs/AggressiveMonster.cpp +++ b/source/Mobs/AggressiveMonster.cpp @@ -95,5 +95,12 @@ void cAggressiveMonster::Tick(float a_Dt, cChunk & a_Chunk) } +cMonster::eFamily cAggressiveMonster::GetMobFamily() const +{ + return mfHostile; +} + + + diff --git a/source/Mobs/AggressiveMonster.h b/source/Mobs/AggressiveMonster.h index 1eff1831e..c16419542 100644 --- a/source/Mobs/AggressiveMonster.h +++ b/source/Mobs/AggressiveMonster.h @@ -19,6 +19,8 @@ public: virtual void InStateChasing(float a_Dt) override; virtual void EventSeePlayer(cEntity *) override; + + virtual eFamily GetMobFamily(void) const override; protected: float m_ChaseTime; diff --git a/source/Mobs/Bat.cpp b/source/Mobs/Bat.cpp new file mode 100644 index 000000000..ec7ce7bc4 --- /dev/null +++ b/source/Mobs/Bat.cpp @@ -0,0 +1,19 @@ + +#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules + +#include "Bat.h" +#include "../Vector3d.h" +#include "../Chunk.h" + + +cBat::cBat(void) : + // TODO: The size is only a guesstimate, measure in vanilla and fix the size values here + super("Bat", 65, "mob.bat.hurt", "mob.bat.death", 0.7, 0.7) +{ +} + + +cMonster::eFamily cBat::GetMobFamily() const +{ + return mfWater; +} diff --git a/source/Mobs/Bat.h b/source/Mobs/Bat.h index 8e4cde29f..e0afb5744 100644 --- a/source/Mobs/Bat.h +++ b/source/Mobs/Bat.h @@ -13,13 +13,11 @@ class cBat : typedef cPassiveMonster super; public: - cBat(void) : - // TODO: The size is only a guesstimate, measure in vanilla and fix the size values here - super("Bat", 65, "mob.bat.hurt", "mob.bat.death", 0.7, 0.7) - { - } + cBat(void); CLASS_PROTODEF(cBat); + + virtual eFamily GetMobFamily(void) const override; } ; 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); diff --git a/source/Mobs/PassiveMonster.cpp b/source/Mobs/PassiveMonster.cpp index 7a6140c04..3d7b8c8aa 100644 --- a/source/Mobs/PassiveMonster.cpp +++ b/source/Mobs/PassiveMonster.cpp @@ -55,4 +55,11 @@ void cPassiveMonster::Tick(float a_Dt, cChunk & a_Chunk) +cMonster::eFamily cPassiveMonster::GetMobFamily() const +{ + return mfPassive; +} + + + diff --git a/source/Mobs/PassiveMonster.h b/source/Mobs/PassiveMonster.h index ae0bea3fb..9d3557727 100644 --- a/source/Mobs/PassiveMonster.h +++ b/source/Mobs/PassiveMonster.h @@ -19,6 +19,8 @@ public: /// When hit by someone, run away virtual void DoTakeDamage(TakeDamageInfo & a_TDI) override; + + virtual eFamily GetMobFamily(void) const override; } ; diff --git a/source/Mobs/Squid.cpp b/source/Mobs/Squid.cpp index cb796f5ec..50265aea4 100644 --- a/source/Mobs/Squid.cpp +++ b/source/Mobs/Squid.cpp @@ -54,4 +54,7 @@ void cSquid::Tick(float a_Dt, cChunk & a_Chunk) - +cMonster::eFamily cSquid::GetMobFamily() const +{ + return mfWater; +} diff --git a/source/Mobs/Squid.h b/source/Mobs/Squid.h index 35d7295b3..d5f3a74d7 100644 --- a/source/Mobs/Squid.h +++ b/source/Mobs/Squid.h @@ -20,6 +20,8 @@ public: CLASS_PROTODEF(cSquid); virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; + + virtual eFamily GetMobFamily(void) const override; } ; -- cgit v1.2.3 From 2361a5dc418a42092ed8040e6826b65b38e94fcb Mon Sep 17 00:00:00 2001 From: mgueydan Date: Sat, 7 Sep 2013 20:07:56 +0200 Subject: relockating mobs includes (they probably will end somewhere else in order not to recompile world each time you update a mob) --- source/Mobs/IncludeAllMonsters.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 source/Mobs/IncludeAllMonsters.h (limited to 'source/Mobs') diff --git a/source/Mobs/IncludeAllMonsters.h b/source/Mobs/IncludeAllMonsters.h new file mode 100644 index 000000000..d89a6c5b5 --- /dev/null +++ b/source/Mobs/IncludeAllMonsters.h @@ -0,0 +1,23 @@ +#include "Bat.h" +#include "Blaze.h" +#include "Cavespider.h" +#include "Chicken.h" +#include "Cow.h" +#include "Creeper.h" +#include "Enderman.h" +#include "Ghast.h" +#include "Magmacube.h" +#include "Mooshroom.h" +#include "Ocelot.h" +#include "Pig.h" +#include "Sheep.h" +#include "Silverfish.h" +#include "Skeleton.h" +#include "Slime.h" +#include "Spider.h" +#include "Squid.h" +#include "Villager.h" +#include "Witch.h" +#include "Wolf.h" +#include "Zombie.h" +#include "Zombiepigman.h" -- 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') 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') 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 bf4781d0ee04625bebac2239a336caaea41f51a3 Mon Sep 17 00:00:00 2001 From: mgueydan Date: Tue, 10 Sep 2013 14:26:27 +0200 Subject: Changing Bat to AMbiant creature --- source/Mobs/Bat.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Bat.cpp b/source/Mobs/Bat.cpp index ec7ce7bc4..ff86f4139 100644 --- a/source/Mobs/Bat.cpp +++ b/source/Mobs/Bat.cpp @@ -15,5 +15,5 @@ cBat::cBat(void) : cMonster::eFamily cBat::GetMobFamily() const { - return mfWater; + return mfAmbient; } -- 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/AggressiveMonster.cpp | 9 --------- source/Mobs/AggressiveMonster.h | 1 - source/Mobs/Bat.cpp | 4 ---- source/Mobs/Bat.h | 1 - source/Mobs/Monster.cpp | 6 ++++++ source/Mobs/Monster.h | 3 ++- source/Mobs/PassiveMonster.cpp | 6 ------ source/Mobs/PassiveMonster.h | 1 - source/Mobs/Squid.cpp | 4 ---- source/Mobs/Squid.h | 1 - 10 files changed, 8 insertions(+), 28 deletions(-) (limited to 'source/Mobs') diff --git a/source/Mobs/AggressiveMonster.cpp b/source/Mobs/AggressiveMonster.cpp index d48523373..93dba6d7b 100644 --- a/source/Mobs/AggressiveMonster.cpp +++ b/source/Mobs/AggressiveMonster.cpp @@ -95,12 +95,3 @@ void cAggressiveMonster::Tick(float a_Dt, cChunk & a_Chunk) } -cMonster::eFamily cAggressiveMonster::GetMobFamily() const -{ - return mfHostile; -} - - - - - diff --git a/source/Mobs/AggressiveMonster.h b/source/Mobs/AggressiveMonster.h index c16419542..f22ed5b89 100644 --- a/source/Mobs/AggressiveMonster.h +++ b/source/Mobs/AggressiveMonster.h @@ -20,7 +20,6 @@ public: virtual void EventSeePlayer(cEntity *) override; - virtual eFamily GetMobFamily(void) const override; protected: float m_ChaseTime; diff --git a/source/Mobs/Bat.cpp b/source/Mobs/Bat.cpp index ff86f4139..715f25483 100644 --- a/source/Mobs/Bat.cpp +++ b/source/Mobs/Bat.cpp @@ -13,7 +13,3 @@ cBat::cBat(void) : } -cMonster::eFamily cBat::GetMobFamily() const -{ - return mfAmbient; -} diff --git a/source/Mobs/Bat.h b/source/Mobs/Bat.h index e0afb5744..fd3e00a07 100644 --- a/source/Mobs/Bat.h +++ b/source/Mobs/Bat.h @@ -17,7 +17,6 @@ public: CLASS_PROTODEF(cBat); - virtual eFamily GetMobFamily(void) const override; } ; diff --git a/source/Mobs/Monster.cpp b/source/Mobs/Monster.cpp index a42ae30ee..b378b2bc6 100644 --- a/source/Mobs/Monster.cpp +++ b/source/Mobs/Monster.cpp @@ -9,6 +9,7 @@ #include "../Entities/Player.h" #include "../Defines.h" #include "../MonsterConfig.h" +#include "../MobTypesManager.h" #include "../MersenneTwister.h" #include "../Vector3f.h" @@ -17,6 +18,7 @@ #include "../Tracer.h" #include "../Chunk.h" + // #include "../../iniFile/iniFile.h" @@ -510,3 +512,7 @@ void cMonster::HandleDaylightBurning(cChunk & a_Chunk) +cMonster::eFamily cMonster::GetMobFamily(void) const +{ + return cMobTypesManager::getFamilyFromType(GetMobTypeAsEnum()); +} 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); diff --git a/source/Mobs/PassiveMonster.cpp b/source/Mobs/PassiveMonster.cpp index 3d7b8c8aa..8c69c8059 100644 --- a/source/Mobs/PassiveMonster.cpp +++ b/source/Mobs/PassiveMonster.cpp @@ -55,11 +55,5 @@ void cPassiveMonster::Tick(float a_Dt, cChunk & a_Chunk) -cMonster::eFamily cPassiveMonster::GetMobFamily() const -{ - return mfPassive; -} - - diff --git a/source/Mobs/PassiveMonster.h b/source/Mobs/PassiveMonster.h index 9d3557727..908bb0ce6 100644 --- a/source/Mobs/PassiveMonster.h +++ b/source/Mobs/PassiveMonster.h @@ -20,7 +20,6 @@ public: /// When hit by someone, run away virtual void DoTakeDamage(TakeDamageInfo & a_TDI) override; - virtual eFamily GetMobFamily(void) const override; } ; diff --git a/source/Mobs/Squid.cpp b/source/Mobs/Squid.cpp index 50265aea4..e6a44079a 100644 --- a/source/Mobs/Squid.cpp +++ b/source/Mobs/Squid.cpp @@ -54,7 +54,3 @@ void cSquid::Tick(float a_Dt, cChunk & a_Chunk) -cMonster::eFamily cSquid::GetMobFamily() const -{ - return mfWater; -} diff --git a/source/Mobs/Squid.h b/source/Mobs/Squid.h index d5f3a74d7..ad299b95c 100644 --- a/source/Mobs/Squid.h +++ b/source/Mobs/Squid.h @@ -21,7 +21,6 @@ public: virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; - virtual eFamily GetMobFamily(void) const override; } ; -- cgit v1.2.3