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 From b703d9c83bff3b7e7b8b1fa2cc2163efac037cc2 Mon Sep 17 00:00:00 2001 From: tonibm19 Date: Fri, 13 Sep 2013 19:33:22 +0200 Subject: Fixed mobs attack range being too long It was set to 5, I think 2 is better because now mobs can kill you when there is a block (or 2) between you and monster. --- source/Mobs/Monster.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Monster.cpp b/source/Mobs/Monster.cpp index a42ae30ee..02e7decc7 100644 --- a/source/Mobs/Monster.cpp +++ b/source/Mobs/Monster.cpp @@ -1,4 +1,3 @@ - #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "Monster.h" @@ -40,7 +39,7 @@ cMonster::cMonster(const AString & a_ConfigName, char a_ProtocolMobType, const A , m_SeePlayerInterval (0) , m_EMPersonality(AGGRESSIVE) , m_AttackDamage(1.0f) - , m_AttackRange(5.0f) + , m_AttackRange(2.0f) , m_AttackInterval(0) , m_BurnsInDaylight(false) { -- cgit v1.2.3 From 973753774e41b78c97384893abe0871821f1cebc Mon Sep 17 00:00:00 2001 From: tonibm19 Date: Fri, 13 Sep 2013 20:06:42 +0200 Subject: Added an extra line. In first commit it says I removed first line --- source/Mobs/Monster.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'source/Mobs') diff --git a/source/Mobs/Monster.cpp b/source/Mobs/Monster.cpp index 02e7decc7..76b9414f7 100644 --- a/source/Mobs/Monster.cpp +++ b/source/Mobs/Monster.cpp @@ -1,3 +1,4 @@ + #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "Monster.h" -- 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') 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') 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/EnderDragon.cpp | 27 +++++++++++++++++++++++++++ source/Mobs/EnderDragon.h | 25 +++++++++++++++++++++++++ source/Mobs/Giant.cpp | 27 +++++++++++++++++++++++++++ source/Mobs/Giant.h | 25 +++++++++++++++++++++++++ source/Mobs/Horse.cpp | 26 ++++++++++++++++++++++++++ source/Mobs/Horse.h | 25 +++++++++++++++++++++++++ source/Mobs/IronGolem.cpp | 26 ++++++++++++++++++++++++++ source/Mobs/IronGolem.h | 25 +++++++++++++++++++++++++ source/Mobs/Magmacube.cpp | 8 ++++---- source/Mobs/Magmacube.h | 10 +++++----- source/Mobs/Monster.h | 44 +++++++++++++++++++++++--------------------- source/Mobs/SnowGolem.cpp | 26 ++++++++++++++++++++++++++ source/Mobs/SnowGolem.h | 25 +++++++++++++++++++++++++ source/Mobs/Wither.cpp | 26 ++++++++++++++++++++++++++ source/Mobs/Wither.h | 25 +++++++++++++++++++++++++ source/Mobs/Zombiepigman.cpp | 26 +++++--------------------- source/Mobs/Zombiepigman.h | 7 +++---- 17 files changed, 348 insertions(+), 55 deletions(-) create mode 100644 source/Mobs/EnderDragon.cpp create mode 100644 source/Mobs/EnderDragon.h create mode 100644 source/Mobs/Giant.cpp create mode 100644 source/Mobs/Giant.h create mode 100644 source/Mobs/Horse.cpp create mode 100644 source/Mobs/Horse.h create mode 100644 source/Mobs/IronGolem.cpp create mode 100644 source/Mobs/IronGolem.h create mode 100644 source/Mobs/SnowGolem.cpp create mode 100644 source/Mobs/SnowGolem.h create mode 100644 source/Mobs/Wither.cpp create mode 100644 source/Mobs/Wither.h (limited to 'source/Mobs') diff --git a/source/Mobs/EnderDragon.cpp b/source/Mobs/EnderDragon.cpp new file mode 100644 index 000000000..64f2bedfa --- /dev/null +++ b/source/Mobs/EnderDragon.cpp @@ -0,0 +1,27 @@ + +#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules + +#include "EnderDragon.h" + + + + + +cEnderDragon::cEnderDragon(void) : + // TODO: Vanilla source says this, but is it right? Dragons fly, they don't stand + super("EnderDragon", 63, "mob.enderdragon.hit", "mob.enderdragon.end", 16.0, 8.0) +{ +} + + + + + +void cEnderDragon::GetDrops(cItems & a_Drops, cEntity * a_Killer) +{ + return; +} + + + + diff --git a/source/Mobs/EnderDragon.h b/source/Mobs/EnderDragon.h new file mode 100644 index 000000000..77177edfe --- /dev/null +++ b/source/Mobs/EnderDragon.h @@ -0,0 +1,25 @@ + +#pragma once + +#include "AggressiveMonster.h" + + + + + +class cEnderDragon : + public cAggressiveMonster +{ + typedef cAggressiveMonster super; + +public: + cEnderDragon(void); + + CLASS_PROTODEF(cEnderDragon); + + virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; +} ; + + + + diff --git a/source/Mobs/Giant.cpp b/source/Mobs/Giant.cpp new file mode 100644 index 000000000..a02758a43 --- /dev/null +++ b/source/Mobs/Giant.cpp @@ -0,0 +1,27 @@ + +#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules + +#include "Giant.h" + + + + + +cGiant::cGiant(void) : + // TODO: The size is only a guesstimate, measure in vanilla and fix the size values here + super("Giant", 53, "mob.zombie.hurt", "mob.zombie.death", 2.0, 13.5) +{ +} + + + + + +void cGiant::GetDrops(cItems & a_Drops, cEntity * a_Killer) +{ + AddRandomDropItem(a_Drops, 10, 50, E_ITEM_ROTTEN_FLESH); +} + + + + diff --git a/source/Mobs/Giant.h b/source/Mobs/Giant.h new file mode 100644 index 000000000..356dd4352 --- /dev/null +++ b/source/Mobs/Giant.h @@ -0,0 +1,25 @@ + +#pragma once + +#include "AggressiveMonster.h" + + + + + +class cGiant : + public cAggressiveMonster +{ + typedef cAggressiveMonster super; + +public: + cGiant(void); + + CLASS_PROTODEF(cGiant); + + virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; +} ; + + + + diff --git a/source/Mobs/Horse.cpp b/source/Mobs/Horse.cpp new file mode 100644 index 000000000..05ac73c15 --- /dev/null +++ b/source/Mobs/Horse.cpp @@ -0,0 +1,26 @@ + +#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules + +#include "Horse.h" + + + + + +cHorse::cHorse(void) : + super("Horse", 100, "mob.horse.hit", "mob.horse.death", 1.4, 1.6) +{ +} + + + + + +void cHorse::GetDrops(cItems & a_Drops, cEntity * a_Killer) +{ + AddRandomDropItem(a_Drops, 0, 2, E_ITEM_LEATHER); +} + + + + diff --git a/source/Mobs/Horse.h b/source/Mobs/Horse.h new file mode 100644 index 000000000..a568fbbe3 --- /dev/null +++ b/source/Mobs/Horse.h @@ -0,0 +1,25 @@ + +#pragma once + +#include "AggressiveMonster.h" + + + + + +class cHorse : + public cAggressiveMonster +{ + typedef cAggressiveMonster super; + +public: + cHorse(void); + + CLASS_PROTODEF(cHorse); + + virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; +} ; + + + + diff --git a/source/Mobs/IronGolem.cpp b/source/Mobs/IronGolem.cpp new file mode 100644 index 000000000..42d312c23 --- /dev/null +++ b/source/Mobs/IronGolem.cpp @@ -0,0 +1,26 @@ + +#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules + +#include "IronGolem.h" + + + + + +cIronGolem::cIronGolem(void) : + super("IronGolem", 99, "mob.IronGolem.hit", "mob.IronGolem.death", 1.4, 2.9) +{ +} + + + + + +void cIronGolem::GetDrops(cItems & a_Drops, cEntity * a_Killer) +{ + AddRandomDropItem(a_Drops, 0, 5, E_ITEM_IRON); +} + + + + diff --git a/source/Mobs/IronGolem.h b/source/Mobs/IronGolem.h new file mode 100644 index 000000000..0f2298061 --- /dev/null +++ b/source/Mobs/IronGolem.h @@ -0,0 +1,25 @@ + +#pragma once + +#include "AggressiveMonster.h" + + + + + +class cIronGolem : + public cAggressiveMonster +{ + typedef cAggressiveMonster super; + +public: + cIronGolem(void); + + CLASS_PROTODEF(cIronGolem); + + virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; +} ; + + + + diff --git a/source/Mobs/Magmacube.cpp b/source/Mobs/Magmacube.cpp index 0b9b57e3c..7d553758e 100644 --- a/source/Mobs/Magmacube.cpp +++ b/source/Mobs/Magmacube.cpp @@ -1,14 +1,14 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules -#include "Magmacube.h" +#include "MagmaCube.h" -cMagmacube::cMagmacube(int a_Size) : - super("Magmacube", 62, "mob.magmacube.big", "mob.magmacube.big", 0.6 * a_Size, 0.6 * a_Size), +cMagmaCube::cMagmaCube(int a_Size) : + super("MagmaCube", 62, "mob.MagmaCube.big", "mob.MagmaCube.big", 0.6 * a_Size, 0.6 * a_Size), m_Size(a_Size) { } @@ -17,7 +17,7 @@ cMagmacube::cMagmacube(int a_Size) : -void cMagmacube::GetDrops(cItems & a_Drops, cEntity * a_Killer) +void cMagmaCube::GetDrops(cItems & a_Drops, cEntity * a_Killer) { AddRandomDropItem(a_Drops, 0, 1, E_ITEM_MAGMA_CREAM); } diff --git a/source/Mobs/Magmacube.h b/source/Mobs/Magmacube.h index e4df4f33d..80a1d0701 100644 --- a/source/Mobs/Magmacube.h +++ b/source/Mobs/Magmacube.h @@ -7,22 +7,22 @@ -class cMagmacube : +class cMagmaCube : public cAggressiveMonster { typedef cAggressiveMonster super; public: - /// Creates a magmacube of the specified size; size is 1 .. 3, with 1 being the smallest - cMagmacube(int a_Size); + /// Creates a MagmaCube of the specified size; size is 1 .. 3, with 1 being the smallest + cMagmaCube(int a_Size); - CLASS_PROTODEF(cMagmacube); + CLASS_PROTODEF(cMagmaCube); virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; protected: - /// Size of the magmacube, 1 .. 3, with 1 being the smallest + /// Size of the MagmaCube, 1 .. 3, with 1 being the smallest int m_Size; } ; 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 diff --git a/source/Mobs/SnowGolem.cpp b/source/Mobs/SnowGolem.cpp new file mode 100644 index 000000000..51125542d --- /dev/null +++ b/source/Mobs/SnowGolem.cpp @@ -0,0 +1,26 @@ + +#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules + +#include "SnowGolem.h" + + + + + +cSnowGolem::cSnowGolem(void) : + super("SnowGolem", 97, "", "", 0.4, 1.8) +{ +} + + + + + +void cSnowGolem::GetDrops(cItems & a_Drops, cEntity * a_Killer) +{ + AddRandomDropItem(a_Drops, 0, 5, E_ITEM_SNOWBALL); +} + + + + diff --git a/source/Mobs/SnowGolem.h b/source/Mobs/SnowGolem.h new file mode 100644 index 000000000..d1344adfd --- /dev/null +++ b/source/Mobs/SnowGolem.h @@ -0,0 +1,25 @@ + +#pragma once + +#include "AggressiveMonster.h" + + + + + +class cSnowGolem : + public cAggressiveMonster +{ + typedef cAggressiveMonster super; + +public: + cSnowGolem(void); + + CLASS_PROTODEF(cSnowGolem); + + virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; +} ; + + + + diff --git a/source/Mobs/Wither.cpp b/source/Mobs/Wither.cpp new file mode 100644 index 000000000..8b77284c8 --- /dev/null +++ b/source/Mobs/Wither.cpp @@ -0,0 +1,26 @@ + +#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules + +#include "Wither.h" + + + + + +cWither::cWither(void) : + super("Wither", 64, "mob.wither.hurt", "mob.wither.death", 0.9, 4.0) +{ +} + + + + + +void cWither::GetDrops(cItems & a_Drops, cEntity * a_Killer) +{ + AddRandomDropItem(a_Drops, 1, 1, E_ITEM_NETHER_STAR); +} + + + + diff --git a/source/Mobs/Wither.h b/source/Mobs/Wither.h new file mode 100644 index 000000000..56effc6bb --- /dev/null +++ b/source/Mobs/Wither.h @@ -0,0 +1,25 @@ + +#pragma once + +#include "AggressiveMonster.h" + + + + + +class cWither : + public cAggressiveMonster +{ + typedef cAggressiveMonster super; + +public: + cWither(void); + + CLASS_PROTODEF(cWither); + + virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; +} ; + + + + diff --git a/source/Mobs/Zombiepigman.cpp b/source/Mobs/Zombiepigman.cpp index 09b44816f..1aea006a6 100644 --- a/source/Mobs/Zombiepigman.cpp +++ b/source/Mobs/Zombiepigman.cpp @@ -1,15 +1,15 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules -#include "Zombiepigman.h" +#include "ZombiePigman.h" #include "../World.h" -cZombiepigman::cZombiepigman(void) : - super("Zombiepigman", 57, "mob.zombiepig.zpighurt", "mob.zombiepig.zpigdeath", 0.6, 1.8) +cZombiePigman::cZombiePigman(void) : + super("ZombiePigman", 57, "mob.zombiepig.zpighurt", "mob.zombiepig.zpigdeath", 0.6, 1.8) { } @@ -17,23 +17,7 @@ cZombiepigman::cZombiepigman(void) : -void cZombiepigman::Tick(float a_Dt, cChunk & a_Chunk) -{ - super::Tick(a_Dt, a_Chunk); - - // 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)) && !IsOnFire()) - { - // Burn for 10 ticks, then decide again - StartBurning(10); - } -} - - - - - -void cZombiepigman::GetDrops(cItems & a_Drops, cEntity * a_Killer) +void cZombiePigman::GetDrops(cItems & a_Drops, cEntity * a_Killer) { AddRandomDropItem(a_Drops, 0, 1, E_ITEM_ROTTEN_FLESH); AddRandomDropItem(a_Drops, 0, 1, E_ITEM_GOLD_NUGGET); @@ -45,7 +29,7 @@ void cZombiepigman::GetDrops(cItems & a_Drops, cEntity * a_Killer) -void cZombiepigman::KilledBy(cEntity * a_Killer) +void cZombiePigman::KilledBy(cEntity * a_Killer) { super::KilledBy(a_Killer); diff --git a/source/Mobs/Zombiepigman.h b/source/Mobs/Zombiepigman.h index fe8c6d047..67991d56a 100644 --- a/source/Mobs/Zombiepigman.h +++ b/source/Mobs/Zombiepigman.h @@ -7,17 +7,16 @@ -class cZombiepigman : +class cZombiePigman : public cPassiveAggressiveMonster { typedef cPassiveAggressiveMonster super; public: - cZombiepigman(void); + cZombiePigman(void); - CLASS_PROTODEF(cZombiepigman); + CLASS_PROTODEF(cZombiePigman); - virtual void Tick(float a_Dt, cChunk & a_Chunk) override; virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; virtual void KilledBy(cEntity * a_Killer) override; } ; -- cgit v1.2.3 From ecf40e2893b71302491af7925ebfdf04d37de5da Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 19 Sep 2013 21:20:21 +0100 Subject: Fixed new monster aggressiveness issue --- source/Mobs/Horse.h | 4 ++-- source/Mobs/IronGolem.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Horse.h b/source/Mobs/Horse.h index a568fbbe3..ea6e441bd 100644 --- a/source/Mobs/Horse.h +++ b/source/Mobs/Horse.h @@ -8,9 +8,9 @@ class cHorse : - public cAggressiveMonster + public cPassiveMonster { - typedef cAggressiveMonster super; + typedef cPassiveMonster super; public: cHorse(void); diff --git a/source/Mobs/IronGolem.h b/source/Mobs/IronGolem.h index 0f2298061..d253aefac 100644 --- a/source/Mobs/IronGolem.h +++ b/source/Mobs/IronGolem.h @@ -8,9 +8,9 @@ class cIronGolem : - public cAggressiveMonster + public cPassiveAggressiveMonster { - typedef cAggressiveMonster super; + typedef cPassiveAggressiveMonster super; public: cIronGolem(void); -- cgit v1.2.3 From f3d0cdc9bc5f6169fbfcb04d926412681155a55d Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 21 Sep 2013 11:05:44 +0200 Subject: Fixed compilation from previous commit. --- source/Mobs/Horse.h | 2 +- source/Mobs/IronGolem.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Horse.h b/source/Mobs/Horse.h index ea6e441bd..83e64308e 100644 --- a/source/Mobs/Horse.h +++ b/source/Mobs/Horse.h @@ -1,7 +1,7 @@ #pragma once -#include "AggressiveMonster.h" +#include "PassiveMonster.h" diff --git a/source/Mobs/IronGolem.h b/source/Mobs/IronGolem.h index d253aefac..d49ff4cab 100644 --- a/source/Mobs/IronGolem.h +++ b/source/Mobs/IronGolem.h @@ -1,7 +1,7 @@ #pragma once -#include "AggressiveMonster.h" +#include "PassiveAggressiveMonster.h" -- cgit v1.2.3 From ea0addc2b9eb4d9e2d44bc9cb2337ef57ccf0e05 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 21 Sep 2013 11:10:35 +0200 Subject: Fixed Linux compilation. --- source/Mobs/Zombiepigman.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Zombiepigman.cpp b/source/Mobs/Zombiepigman.cpp index 1aea006a6..1e31a72d9 100644 --- a/source/Mobs/Zombiepigman.cpp +++ b/source/Mobs/Zombiepigman.cpp @@ -1,7 +1,7 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules -#include "ZombiePigman.h" +#include "Zombiepigman.h" #include "../World.h" -- cgit v1.2.3 From c7fe42be26eb02469216eaa794adeda0f9fbecba Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 21 Sep 2013 11:15:53 +0200 Subject: Linux compilation fix #2. --- source/Mobs/Magmacube.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Magmacube.cpp b/source/Mobs/Magmacube.cpp index 7d553758e..c72b4831b 100644 --- a/source/Mobs/Magmacube.cpp +++ b/source/Mobs/Magmacube.cpp @@ -1,7 +1,7 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules -#include "MagmaCube.h" +#include "Magmacube.h" -- cgit v1.2.3 From 5db6213f34318031ece7e2a6765f69564b671891 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 8 Oct 2013 19:20:49 +0100 Subject: Initial Metadata Commit [SEE DESC] + Pigs, Minecarts, Sheep, Skeletons, Slimes, Villagers, Wolves, and Horses have metadata + Base code on taming wolves, shearing sheep, and taming horses + Sheep and horses have different colours when spawned --- source/Mobs/Horse.cpp | 95 +++++++++++++++++++++++++++++++++++++++++++++++- source/Mobs/Horse.h | 19 +++++++++- source/Mobs/Magmacube.h | 1 + source/Mobs/Pig.cpp | 49 ++++++++++++++++++++++++- source/Mobs/Pig.h | 7 ++++ source/Mobs/Sheep.cpp | 28 +++++++++++++- source/Mobs/Sheep.h | 16 +++++--- source/Mobs/Skeleton.cpp | 5 ++- source/Mobs/Skeleton.h | 8 +++- source/Mobs/Slime.cpp | 2 - source/Mobs/Slime.h | 1 + source/Mobs/Villager.cpp | 22 ++++++++++- source/Mobs/Villager.h | 10 ++++- source/Mobs/Wolf.cpp | 79 ++++++++++++++++++++++++++++++++++++++++ source/Mobs/Wolf.h | 22 ++++++++--- 15 files changed, 340 insertions(+), 24 deletions(-) create mode 100644 source/Mobs/Wolf.cpp (limited to 'source/Mobs') diff --git a/source/Mobs/Horse.cpp b/source/Mobs/Horse.cpp index 05ac73c15..50eab33cc 100644 --- a/source/Mobs/Horse.cpp +++ b/source/Mobs/Horse.cpp @@ -2,13 +2,26 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "Horse.h" +#include "../World.h" +#include "../Entities/Player.h" -cHorse::cHorse(void) : - super("Horse", 100, "mob.horse.hit", "mob.horse.death", 1.4, 1.6) +cHorse::cHorse(int Type, int Color, int Style, int TameTimes) : + super("Horse", 100, "mob.horse.hit", "mob.horse.death", 1.4, 1.6), + m_bIsChested(false), + m_bIsEating(false), + m_bIsRearing(false), + m_bIsMouthOpen(false), + m_bIsTame(false), + m_Type(Type), + m_Color(Color), + m_Style(Style), + m_Armour(0), + m_TimesToTame(TameTimes), + m_TameAttemptTimes(0) { } @@ -16,6 +29,84 @@ cHorse::cHorse(void) : +void cHorse::Tick(float a_Dt, cChunk & a_Chunk) +{ + super::Tick(a_Dt, a_Chunk); + + if (!m_bIsMouthOpen) + { + if (m_World->GetTickRandomNumber(50) == 25) + { + m_bIsMouthOpen = true; + } + } + else + { + if (m_World->GetTickRandomNumber(10) == 5) + { + m_bIsMouthOpen = false; + } + } + + if ((m_Attachee != NULL) && (!m_bIsTame)) + { + if (m_TameAttemptTimes < m_TimesToTame) + { + if (m_World->GetTickRandomNumber(50) == 25) + { + m_World->BroadcastSoundParticleEffect(2000, (int)(floor(GetPosX()) * 8), (int)(floor(GetPosY()) * 8), (int)(floor(GetPosZ()) * 8), 0); + m_World->BroadcastSoundParticleEffect(2000, (int)(floor(GetPosX()) * 8), (int)(floor(GetPosY()) * 8), (int)(floor(GetPosZ()) * 8), 2); + m_World->BroadcastSoundParticleEffect(2000, (int)(floor(GetPosX()) * 8), (int)(floor(GetPosY()) * 8), (int)(floor(GetPosZ()) * 8), 6); + m_World->BroadcastSoundParticleEffect(2000, (int)(floor(GetPosX()) * 8), (int)(floor(GetPosY()) * 8), (int)(floor(GetPosZ()) * 8), 8); + + m_Attachee->Detach(); + m_bIsRearing = true; + } + } + else + { + m_bIsTame = true; + } + } + + if ((m_bIsRearing) && (m_World->GetTickRandomNumber(15) == 6)) + { + m_bIsRearing = false; + } + + m_World->BroadcastEntityMetadata(*this); +} + + + + + +void cHorse::OnRightClicked(cPlayer & a_Player) +{ + if (m_Attachee != NULL) + { + if (m_Attachee->GetUniqueID() == a_Player.GetUniqueID()) + { + a_Player.Detach(); + return; + } + + if (m_Attachee->IsPlayer()) + { + return; + } + + m_Attachee->Detach(); + } + + m_TameAttemptTimes++; + a_Player.AttachTo(this); +} + + + + + void cHorse::GetDrops(cItems & a_Drops, cEntity * a_Killer) { AddRandomDropItem(a_Drops, 0, 2, E_ITEM_LEATHER); diff --git a/source/Mobs/Horse.h b/source/Mobs/Horse.h index ea6e441bd..d950ff1bf 100644 --- a/source/Mobs/Horse.h +++ b/source/Mobs/Horse.h @@ -13,11 +13,28 @@ class cHorse : typedef cPassiveMonster super; public: - cHorse(void); + cHorse(int Type, int Color, int Style, int TameTimes); CLASS_PROTODEF(cHorse); 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 IsChested (void) const {return m_bIsChested; } + bool IsEating (void) const {return m_bIsEating; } + bool IsRearing (void) const {return m_bIsRearing; } + bool IsMthOpen (void) const {return m_bIsMouthOpen; } + bool IsTame (void) const {return m_bIsTame; } + int GetHType (void) const {return m_Type; } + int GetHColor (void) const {return m_Color; } + int GetHStyle (void) const {return m_Style; } + int GetHArmour (void) const {return m_Armour;} + +private: + + bool m_bIsChested, m_bIsEating, m_bIsRearing, m_bIsMouthOpen, m_bIsTame; + int m_Type, m_Color, m_Style, m_Armour, m_TimesToTame, m_TameAttemptTimes; + } ; diff --git a/source/Mobs/Magmacube.h b/source/Mobs/Magmacube.h index 80a1d0701..130952970 100644 --- a/source/Mobs/Magmacube.h +++ b/source/Mobs/Magmacube.h @@ -19,6 +19,7 @@ public: CLASS_PROTODEF(cMagmaCube); virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; + int GetSize(void) const { return m_Size; } protected: diff --git a/source/Mobs/Pig.cpp b/source/Mobs/Pig.cpp index 9df2c2571..cd18c087f 100644 --- a/source/Mobs/Pig.cpp +++ b/source/Mobs/Pig.cpp @@ -2,13 +2,16 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "Pig.h" +#include "../Entities/Player.h" +#include "../World.h" cPig::cPig(void) : - super("Pig", 90, "mob.pig.say", "mob.pig.death", 0.9, 0.9) + super("Pig", 90, "mob.pig.say", "mob.pig.death", 0.9, 0.9), + m_bIsSaddled(false) { } @@ -24,3 +27,47 @@ void cPig::GetDrops(cItems & a_Drops, cEntity * a_Killer) + +void cPig::OnRightClicked(cPlayer & a_Player) +{ + if (m_bIsSaddled) + { + if (m_Attachee != NULL) + { + if (m_Attachee->GetUniqueID() == a_Player.GetUniqueID()) + { + // This player is already sitting in, they want out. + a_Player.Detach(); + return; + } + + if (m_Attachee->IsPlayer()) + { + // Another player is already sitting in here, cannot attach + return; + } + + // Detach whatever is sitting in this pig now: + m_Attachee->Detach(); + } + + // Attach the player to this pig + a_Player.AttachTo(this); + } + else if (a_Player.GetEquippedItem().m_ItemType == E_ITEM_SADDLE) + { + if (!a_Player.IsGameModeCreative()) + { + a_Player.GetInventory().RemoveOneEquippedItem(); + } + + // Set saddle state & broadcast metadata + m_bIsSaddled = true; + m_World->BroadcastEntityMetadata(*this); + } +} + + + + + diff --git a/source/Mobs/Pig.h b/source/Mobs/Pig.h index ae790ac2f..4fd0d8db8 100644 --- a/source/Mobs/Pig.h +++ b/source/Mobs/Pig.h @@ -18,6 +18,13 @@ public: CLASS_PROTODEF(cPig); virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; + virtual void OnRightClicked(cPlayer & a_Player) override; + bool IsSaddled(void) const { return m_bIsSaddled; } + +private: + + bool m_bIsSaddled; + } ; diff --git a/source/Mobs/Sheep.cpp b/source/Mobs/Sheep.cpp index 2f371f384..440c5c2b9 100644 --- a/source/Mobs/Sheep.cpp +++ b/source/Mobs/Sheep.cpp @@ -3,15 +3,17 @@ #include "Sheep.h" #include "../BlockID.h" +#include "../Entities/Player.h" +#include "../World.h" -cSheep::cSheep(void) : +cSheep::cSheep(int a_Color) : super("Sheep", 91, "mob.sheep.say", "mob.sheep.say", 0.6, 1.3), m_IsSheared(false), - m_WoolColor(E_META_WOOL_WHITE) + m_WoolColor(a_Color) { } @@ -30,3 +32,25 @@ void cSheep::GetDrops(cItems & a_Drops, cEntity * a_Killer) + +void cSheep::OnRightClicked(cPlayer & a_Player) +{ + if ((a_Player.GetEquippedItem().m_ItemType == E_ITEM_SHEARS) && (!m_IsSheared)) + { + m_IsSheared = true; + m_World->BroadcastEntityMetadata(*this); + + if (!a_Player.IsGameModeCreative()) + { + a_Player.UseEquippedItem(); + } + + cItems Drops; + Drops.push_back(cItem(E_BLOCK_WOOL, 4, m_WoolColor)); + m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10); + } +} + + + + diff --git a/source/Mobs/Sheep.h b/source/Mobs/Sheep.h index 369fc78c5..8293a2c05 100644 --- a/source/Mobs/Sheep.h +++ b/source/Mobs/Sheep.h @@ -13,14 +13,20 @@ class cSheep : typedef cPassiveMonster super; public: - cSheep(void); + cSheep(int a_Color); - bool m_IsSheared; - NIBBLETYPE m_WoolColor; // Uses E_META_WOOL_ constants for colors - CLASS_PROTODEF(cSheep); - + virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; + virtual void OnRightClicked(cPlayer & a_Player) override; + bool IsSheared(void) const { return m_IsSheared; } + int GetFurColor(void) const { return m_WoolColor; } + +private: + + bool m_IsSheared; + int m_WoolColor; + } ; diff --git a/source/Mobs/Skeleton.cpp b/source/Mobs/Skeleton.cpp index 10dad4065..6297b867c 100644 --- a/source/Mobs/Skeleton.cpp +++ b/source/Mobs/Skeleton.cpp @@ -8,8 +8,9 @@ -cSkeleton::cSkeleton(void) : - super("Skeleton", 51, "mob.skeleton.hurt", "mob.skeleton.death", 0.6, 1.8) +cSkeleton::cSkeleton(bool IsWither) : + super("Skeleton", 51, "mob.skeleton.hurt", "mob.skeleton.death", 0.6, 1.8), + m_bIsWither(IsWither) { SetBurnsInDaylight(true); } diff --git a/source/Mobs/Skeleton.h b/source/Mobs/Skeleton.h index d0a2da490..7a4af7e22 100644 --- a/source/Mobs/Skeleton.h +++ b/source/Mobs/Skeleton.h @@ -13,11 +13,17 @@ class cSkeleton : typedef cAggressiveMonster super; public: - cSkeleton(); + cSkeleton(bool IsWither); CLASS_PROTODEF(cSkeleton); virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; + bool IsWither(void) const { return m_bIsWither; }; + +private: + + bool m_bIsWither; + } ; diff --git a/source/Mobs/Slime.cpp b/source/Mobs/Slime.cpp index b209ac869..7a9487a06 100644 --- a/source/Mobs/Slime.cpp +++ b/source/Mobs/Slime.cpp @@ -3,8 +3,6 @@ #include "Slime.h" -// TODO: Implement sized slimes - diff --git a/source/Mobs/Slime.h b/source/Mobs/Slime.h index 88136ff32..782c3113f 100644 --- a/source/Mobs/Slime.h +++ b/source/Mobs/Slime.h @@ -19,6 +19,7 @@ public: CLASS_PROTODEF(cSlime); virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; + int GetSize(void) const { return m_Size; } protected: diff --git a/source/Mobs/Villager.cpp b/source/Mobs/Villager.cpp index 98e5276e1..cb50d8cfc 100644 --- a/source/Mobs/Villager.cpp +++ b/source/Mobs/Villager.cpp @@ -2,16 +2,34 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "Villager.h" +#include "../World.h" -cVillager::cVillager(void) : - super("Villager", 120, "", "", 0.6, 1.8) +cVillager::cVillager(int Type) : + super("Villager", 120, "", "", 0.6, 1.8), + m_Type(Type) { } + +void cVillager::DoTakeDamage(TakeDamageInfo & a_TDI) +{ + super::DoTakeDamage(a_TDI); + if (a_TDI.Attacker->IsPlayer()) + { + if (m_World->GetTickRandomNumber(5) == 3) + { + m_World->BroadcastEntityStatus(*this, ENTITY_STATUS_VILLAGER_ANGRY); + } + } +} + + + + diff --git a/source/Mobs/Villager.h b/source/Mobs/Villager.h index 92267a979..5fcb519dd 100644 --- a/source/Mobs/Villager.h +++ b/source/Mobs/Villager.h @@ -13,9 +13,17 @@ class cVillager : typedef cPassiveMonster super; public: - cVillager(); + cVillager(int Type); CLASS_PROTODEF(cVillager); + + virtual void DoTakeDamage(TakeDamageInfo & a_TDI) override; + int GetVilType(void) const { return m_Type; } + +private: + + int m_Type; + } ; diff --git a/source/Mobs/Wolf.cpp b/source/Mobs/Wolf.cpp new file mode 100644 index 000000000..e76f991dc --- /dev/null +++ b/source/Mobs/Wolf.cpp @@ -0,0 +1,79 @@ + +#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules + +#include "Wolf.h" +#include "../World.h" +#include "../Entities/Player.h" + + + + + +cWolf::cWolf(void) : + super("Wolf", 95, "mob.wolf.hurt", "mob.wolf.death", 0.6, 0.8), + m_bIsAngry(false), + m_bIsTame(false), + m_bIsSitting(false), + m_bIsBegging(false) +{ +} + + + + + +void cWolf::DoTakeDamage(TakeDamageInfo & a_TDI) +{ + super::DoTakeDamage(a_TDI); + if (!m_bIsTame) + { + m_bIsAngry = true; + } + m_World->BroadcastEntityMetadata(*this); // Broadcast health and possibly angry face +} + + + + + +void cWolf::OnRightClicked(cPlayer & a_Player) +{ + if ((!m_bIsTame) && (!m_bIsAngry)) + { + if (a_Player.GetEquippedItem().m_ItemType == E_ITEM_BONE) + { + if (!a_Player.IsGameModeCreative()) + { + a_Player.GetInventory().RemoveOneEquippedItem(); + } + + if (m_World->GetTickRandomNumber(10) == 5) + { + SetMaxHealth(20); + m_bIsTame = true; + m_World->BroadcastEntityStatus(*this, ENTITY_STATUS_WOLF_TAMED); + } + else + { + m_World->BroadcastEntityStatus(*this, ENTITY_STATUS_WOLF_TAMING); + } + } + } + else if (m_bIsTame) + { + if (m_bIsSitting) + { + m_bIsSitting = false; + } + else + { + m_bIsSitting = true; + } + } + + m_World->BroadcastEntityMetadata(*this); +} + + + + diff --git a/source/Mobs/Wolf.h b/source/Mobs/Wolf.h index 405df80a6..98074ba11 100644 --- a/source/Mobs/Wolf.h +++ b/source/Mobs/Wolf.h @@ -13,13 +13,25 @@ class cWolf : typedef cPassiveAggressiveMonster super; public: - cWolf(void) : - // TODO: The size is only a guesstimate, measure in vanilla and fix the size values here (wiki.vg values are suspicious) - super("Wolf", 95, "mob.wolf.hurt", "mob.wolf.death", 0.9, 0.9) - { - } + cWolf(void); CLASS_PROTODEF(cWolf); + + virtual void DoTakeDamage(TakeDamageInfo & a_TDI) override; + virtual void OnRightClicked(cPlayer & a_Player) override; + + bool IsSitting(void) const { return m_bIsSitting; } + bool IsTame(void) const { return m_bIsTame; } + bool IsBegging(void) const { return m_bIsBegging; } + bool IsAngry(void) const { return m_bIsAngry; } + +private: + + bool m_bIsSitting; + bool m_bIsTame; + bool m_bIsBegging; + bool m_bIsAngry; + } ; -- cgit v1.2.3 From 7401fc000dca2a3ff3ce61776f84e5c2d8eb1868 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 8 Oct 2013 22:21:55 +0100 Subject: Initial round of fixes * Fixed intentional misspelling of baby! :D * Better chested horse bool name * Fixed some weird continuity issues with my recent changes not being pushed up initially * Fixed derpy hexadecimal values --- source/Mobs/Horse.cpp | 2 +- source/Mobs/Horse.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Horse.cpp b/source/Mobs/Horse.cpp index 50eab33cc..ec6154d26 100644 --- a/source/Mobs/Horse.cpp +++ b/source/Mobs/Horse.cpp @@ -11,7 +11,7 @@ cHorse::cHorse(int Type, int Color, int Style, int TameTimes) : super("Horse", 100, "mob.horse.hit", "mob.horse.death", 1.4, 1.6), - m_bIsChested(false), + m_bHasChest(false), m_bIsEating(false), m_bIsRearing(false), m_bIsMouthOpen(false), diff --git a/source/Mobs/Horse.h b/source/Mobs/Horse.h index d950ff1bf..bca2e5327 100644 --- a/source/Mobs/Horse.h +++ b/source/Mobs/Horse.h @@ -1,7 +1,7 @@ #pragma once -#include "AggressiveMonster.h" +#include "PassiveMonster.h" @@ -20,7 +20,7 @@ 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 IsChested (void) const {return m_bIsChested; } + bool IsChested (void) const {return m_bHasChest; } bool IsEating (void) const {return m_bIsEating; } bool IsRearing (void) const {return m_bIsRearing; } bool IsMthOpen (void) const {return m_bIsMouthOpen; } @@ -32,7 +32,7 @@ public: private: - bool m_bIsChested, m_bIsEating, m_bIsRearing, m_bIsMouthOpen, m_bIsTame; + bool m_bHasChest, m_bIsEating, m_bIsRearing, m_bIsMouthOpen, m_bIsTame; int m_Type, m_Color, m_Style, m_Armour, m_TimesToTame, m_TameAttemptTimes; } ; -- 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/Bat.h | 2 ++ source/Mobs/Creeper.cpp | 21 ++++++++++++++++++++- source/Mobs/Creeper.h | 9 +++++++++ source/Mobs/Enderman.cpp | 5 ++++- source/Mobs/Enderman.h | 11 +++++++++++ source/Mobs/Ghast.h | 2 ++ source/Mobs/Horse.cpp | 1 + source/Mobs/Horse.h | 4 +++- source/Mobs/Monster.h | 6 ++++++ source/Mobs/Witch.h | 2 ++ source/Mobs/Zombie.cpp | 6 ++++-- source/Mobs/Zombie.h | 10 +++++++++- 12 files changed, 73 insertions(+), 6 deletions(-) (limited to 'source/Mobs') 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; + } ; -- cgit v1.2.3 From d7b2c534fd2e272c328b176432c922fd11a7cd85 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 11 Oct 2013 00:41:54 +0100 Subject: Third round of fixes * Split WriteMetadata into three functions for common, entity, and mob * Edited a few mob sizes to Vanilla values --- source/Mobs/Bat.h | 3 +-- source/Mobs/Cavespider.cpp | 3 +-- source/Mobs/Enderman.cpp | 3 +-- source/Mobs/Ocelot.h | 3 +-- source/Mobs/Silverfish.h | 3 +-- 5 files changed, 5 insertions(+), 10 deletions(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Bat.h b/source/Mobs/Bat.h index 7aaec361b..0b50e06cd 100644 --- a/source/Mobs/Bat.h +++ b/source/Mobs/Bat.h @@ -14,8 +14,7 @@ class cBat : 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) + super("Bat", 65, "mob.bat.hurt", "mob.bat.death", 0.5, 0.9) { } diff --git a/source/Mobs/Cavespider.cpp b/source/Mobs/Cavespider.cpp index 569aadcc4..2d50b391a 100644 --- a/source/Mobs/Cavespider.cpp +++ b/source/Mobs/Cavespider.cpp @@ -9,8 +9,7 @@ cCavespider::cCavespider(void) : - // TODO: The size is only a guesstimate, measure in vanilla and fix the size values here - super("Cavespider", 59, "mob.spider.say", "mob.spider.death", 0.9, 0.6) + super("Cavespider", 59, "mob.spider.say", "mob.spider.death", 0.7, 0.5) { } diff --git a/source/Mobs/Enderman.cpp b/source/Mobs/Enderman.cpp index 04c1a60e1..c0ea3d6aa 100644 --- a/source/Mobs/Enderman.cpp +++ b/source/Mobs/Enderman.cpp @@ -8,8 +8,7 @@ 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.9), m_bIsScreaming(false), CarriedBlock(E_BLOCK_AIR), CarriedMeta(0) diff --git a/source/Mobs/Ocelot.h b/source/Mobs/Ocelot.h index 98ea224e2..6d24c5672 100644 --- a/source/Mobs/Ocelot.h +++ b/source/Mobs/Ocelot.h @@ -14,8 +14,7 @@ class cOcelot : public: cOcelot(void) : - // TODO: The size is only a guesstimate, measure in vanilla and fix the size values here - super("Ocelot", 98, "mob.cat.hitt", "mob.cat.hitt", 0.9, 0.5) + super("Ocelot", 98, "mob.cat.hitt", "mob.cat.hitt", 0.6, 0.8) { } diff --git a/source/Mobs/Silverfish.h b/source/Mobs/Silverfish.h index 7d675a9c0..d632ac169 100644 --- a/source/Mobs/Silverfish.h +++ b/source/Mobs/Silverfish.h @@ -14,8 +14,7 @@ class cSilverfish : public: cSilverfish(void) : - // TODO: The size is only a guesstimate, measure in vanilla and fix the size values here - super("Silverfish", 60, "mob.silverfish.hit", "mob.silverfish.kill", 0.9, 0.3) + super("Silverfish", 60, "mob.silverfish.hit", "mob.silverfish.kill", 0.3, 0.7) { } -- cgit v1.2.3 From ee2df34d03313ecf98110384559f46f00a05978b Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 11 Oct 2013 01:00:16 +0100 Subject: Fourth round of fixes * Switchified WriteMobMetadata * Renamed Horse functions to be better --- source/Mobs/Horse.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Horse.h b/source/Mobs/Horse.h index bf39c8b13..d80678845 100644 --- a/source/Mobs/Horse.h +++ b/source/Mobs/Horse.h @@ -21,16 +21,16 @@ public: 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; } - bool IsMthOpen (void) const {return m_bIsMouthOpen; } - bool IsTame (void) const {return m_bIsTame; } - int GetHType (void) const {return m_Type; } - int GetHColor (void) const {return m_Color; } - int GetHStyle (void) const {return m_Style; } - int GetHArmour (void) const {return m_Armour;} + 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; } + bool IsMthOpen (void) const {return m_bIsMouthOpen; } + bool IsTame (void) const {return m_bIsTame; } + int GetHorseType (void) const {return m_Type; } + int GetHorseColor (void) const {return m_Color; } + int GetHorseStyle (void) const {return m_Style; } + int GetHorseArmour (void) const {return m_Armour;} private: -- cgit v1.2.3 From e2aaf202abf9d677b84efeb376f55ee976b52b8d Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 11 Oct 2013 20:57:22 +0100 Subject: Fifth round of fixes * Enumerated Villager spawning --- source/Mobs/Villager.cpp | 4 ++-- source/Mobs/Villager.h | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Villager.cpp b/source/Mobs/Villager.cpp index cb50d8cfc..97d6dc3ca 100644 --- a/source/Mobs/Villager.cpp +++ b/source/Mobs/Villager.cpp @@ -8,9 +8,9 @@ -cVillager::cVillager(int Type) : +cVillager::cVillager(eVillagerType VillagerType) : super("Villager", 120, "", "", 0.6, 1.8), - m_Type(Type) + m_Type(VillagerType) { } diff --git a/source/Mobs/Villager.h b/source/Mobs/Villager.h index 5fcb519dd..86888d9eb 100644 --- a/source/Mobs/Villager.h +++ b/source/Mobs/Villager.h @@ -13,12 +13,23 @@ class cVillager : typedef cPassiveMonster super; public: - cVillager(int Type); + + enum eVillagerType + { + VILLAGER_TYPE_FARMER = 0, + VILLAGER_TYPE_LIBRARIAN = 1, + VILLAGER_TYPE_PRIEST = 2, + VILLAGER_TYPE_BLACKSMITH = 3, + VILLAGER_TYPE_BUTCHER = 4, + VILLAGER_TYPE_GENERIC = 5 + } ; + + cVillager(eVillagerType VillagerType); CLASS_PROTODEF(cVillager); virtual void DoTakeDamage(TakeDamageInfo & a_TDI) override; - int GetVilType(void) const { return m_Type; } + int GetVilType(void) const { return m_Type; } private: -- cgit v1.2.3 From 327abdd10daad7bb49fde185f1f5aee60a98ec1c Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 11 Oct 2013 21:33:56 +0100 Subject: Sixth round of fixes * Made horse rearing time fixed instead of random --- source/Mobs/Horse.cpp | 11 ++++++++--- source/Mobs/Horse.h | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Horse.cpp b/source/Mobs/Horse.cpp index caa1a3deb..46e7969cc 100644 --- a/source/Mobs/Horse.cpp +++ b/source/Mobs/Horse.cpp @@ -22,7 +22,8 @@ cHorse::cHorse(int Type, int Color, int Style, int TameTimes) : m_Style(Style), m_Armour(0), m_TimesToTame(TameTimes), - m_TameAttemptTimes(0) + m_TameAttemptTimes(0), + m_RearTickCount(0) { } @@ -70,9 +71,13 @@ void cHorse::Tick(float a_Dt, cChunk & a_Chunk) } } - if ((m_bIsRearing) && (m_World->GetTickRandomNumber(15) == 6)) + if (m_bIsRearing) { - m_bIsRearing = false; + if (m_RearTickCount == 20) + { + m_bIsRearing = false; + } + else { m_RearTickCount++;} } m_World->BroadcastEntityMetadata(*this); diff --git a/source/Mobs/Horse.h b/source/Mobs/Horse.h index d80678845..be0c23f9b 100644 --- a/source/Mobs/Horse.h +++ b/source/Mobs/Horse.h @@ -35,7 +35,7 @@ public: private: 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; + int m_Type, m_Color, m_Style, m_Armour, m_TimesToTame, m_TameAttemptTimes, m_RearTickCount; } ; -- cgit v1.2.3 From d8d2f35e9dd354fba14f8d6512e818d18d2066c2 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 13 Oct 2013 12:47:55 +0100 Subject: Eight round of fixes * Changed IsA() to *long if statement* - Removed deprecated values in Entity.h - to blazes with the plugins! * Renamed villager type enumerations to be LESS SHOUTY and more vt-y + Use vtMax for World.cpp testificate spawning --- source/Mobs/Monster.cpp | 2 +- source/Mobs/Villager.h | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Monster.cpp b/source/Mobs/Monster.cpp index 76b9414f7..334229a42 100644 --- a/source/Mobs/Monster.cpp +++ b/source/Mobs/Monster.cpp @@ -24,7 +24,7 @@ cMonster::cMonster(const AString & a_ConfigName, char a_ProtocolMobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height) - : super(etMob, a_Width, a_Height) + : super(etMonster, a_Width, a_Height) , m_Target(NULL) , m_AttackRate(3) , idle_interval(0) diff --git a/source/Mobs/Villager.h b/source/Mobs/Villager.h index 86888d9eb..4cd9aaa8e 100644 --- a/source/Mobs/Villager.h +++ b/source/Mobs/Villager.h @@ -16,12 +16,13 @@ public: enum eVillagerType { - VILLAGER_TYPE_FARMER = 0, - VILLAGER_TYPE_LIBRARIAN = 1, - VILLAGER_TYPE_PRIEST = 2, - VILLAGER_TYPE_BLACKSMITH = 3, - VILLAGER_TYPE_BUTCHER = 4, - VILLAGER_TYPE_GENERIC = 5 + vtFarmer = 0, + vtLibrarian = 1, + vtPriest = 2, + vtBlacksmith = 3, + vtButcher = 4, + vtGeneric = 5, + vtMax } ; cVillager(eVillagerType VillagerType); -- cgit v1.2.3 From 8147ccd13be96e8d4bec2aae33b8cc8ee84c5866 Mon Sep 17 00:00:00 2001 From: tonibm19 Date: Tue, 15 Oct 2013 17:09:43 +0200 Subject: Added horse saddling It uses pig code, sorry if it don't works, i'm a noob, but it should work. --- source/Mobs/Horse.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Horse.cpp b/source/Mobs/Horse.cpp index 46e7969cc..1f2c28adf 100644 --- a/source/Mobs/Horse.cpp +++ b/source/Mobs/Horse.cpp @@ -1,4 +1,3 @@ - #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "Horse.h" @@ -107,6 +106,18 @@ void cHorse::OnRightClicked(cPlayer & a_Player) m_TameAttemptTimes++; a_Player.AttachTo(this); + + if (a_Player.GetEquippedItem().m_ItemType == E_ITEM_SADDLE) + { + if (!a_Player.IsGameModeCreative()) + { + a_Player.GetInventory().RemoveOneEquippedItem(); + } + + // Set saddle state & broadcast metadata + m_bIsSaddled = true; + m_World->BroadcastEntityMetadata(*this); + } } -- cgit v1.2.3 From 7d4c0582a8b5768c7ebe9259ac9fe77dc38870d1 Mon Sep 17 00:00:00 2001 From: tonibm19 Date: Tue, 15 Oct 2013 17:11:42 +0200 Subject: Added extra line --- source/Mobs/Horse.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'source/Mobs') diff --git a/source/Mobs/Horse.cpp b/source/Mobs/Horse.cpp index 1f2c28adf..c2a8f6ed0 100644 --- a/source/Mobs/Horse.cpp +++ b/source/Mobs/Horse.cpp @@ -1,3 +1,4 @@ + #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "Horse.h" -- cgit v1.2.3 From fbba2e79eb0ab60e5515a00944313486131c1a35 Mon Sep 17 00:00:00 2001 From: tonibm19 Date: Tue, 15 Oct 2013 17:31:26 +0200 Subject: Added basic milk code. --- source/Mobs/Cow.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Cow.cpp b/source/Mobs/Cow.cpp index 8e9b87d27..38cb30963 100644 --- a/source/Mobs/Cow.cpp +++ b/source/Mobs/Cow.cpp @@ -1,4 +1,3 @@ - #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "Cow.h" @@ -7,10 +6,6 @@ -// TODO: Milk Cow - - - cCow::cCow(void) : @@ -28,6 +23,18 @@ void cCow::GetDrops(cItems & a_Drops, cEntity * a_Killer) AddRandomDropItem(a_Drops, 1, 3, IsOnFire() ? E_ITEM_STEAK : E_ITEM_RAW_BEEF); } +void cCow::OnRightClicked(cPlayer & a_Player) +{ + if ((a_Player.GetEquippedItem().m_ItemType == E_ITEM_BUCKET)) + { + if (!a_Player.IsGameModeCreative()) + { + a_Player.GetInventory().RemoveOneEquippedItem(); + a_Player.GetInventory().AddItem(E_ITEM_MILK) + } + + } +} -- cgit v1.2.3 From 06b7e09e7099256598ada53a4cc6e17a5474fb1e Mon Sep 17 00:00:00 2001 From: tonibm19 Date: Tue, 15 Oct 2013 17:32:15 +0200 Subject: Added extra line (yes, again) --- source/Mobs/Cow.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'source/Mobs') diff --git a/source/Mobs/Cow.cpp b/source/Mobs/Cow.cpp index 38cb30963..431a6916d 100644 --- a/source/Mobs/Cow.cpp +++ b/source/Mobs/Cow.cpp @@ -1,3 +1,4 @@ + #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "Cow.h" -- cgit v1.2.3 From 400cab0b86476546b4c6a01fa4974c253e58ec8c Mon Sep 17 00:00:00 2001 From: tonibm19 Date: Tue, 15 Oct 2013 18:17:17 +0200 Subject: Fixed a big fail.I did --- source/Mobs/Cow.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source/Mobs') diff --git a/source/Mobs/Cow.h b/source/Mobs/Cow.h index b90cb170e..0391d4a31 100644 --- a/source/Mobs/Cow.h +++ b/source/Mobs/Cow.h @@ -18,6 +18,7 @@ public: CLASS_PROTODEF(cCow); virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; + virtual void OnRightClicked(cPlayer & a_Player) override; } ; -- cgit v1.2.3 From 4ee2632d4f57a5631587809b3d358bc65531b369 Mon Sep 17 00:00:00 2001 From: tonibm19 Date: Tue, 15 Oct 2013 21:25:33 +0200 Subject: Fixed saddle horse --- source/Mobs/Horse.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Horse.cpp b/source/Mobs/Horse.cpp index c2a8f6ed0..0193a88ac 100644 --- a/source/Mobs/Horse.cpp +++ b/source/Mobs/Horse.cpp @@ -1,4 +1,3 @@ - #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "Horse.h" @@ -105,9 +104,6 @@ void cHorse::OnRightClicked(cPlayer & a_Player) m_Attachee->Detach(); } - m_TameAttemptTimes++; - a_Player.AttachTo(this); - if (a_Player.GetEquippedItem().m_ItemType == E_ITEM_SADDLE) { if (!a_Player.IsGameModeCreative()) @@ -119,6 +115,11 @@ void cHorse::OnRightClicked(cPlayer & a_Player) m_bIsSaddled = true; m_World->BroadcastEntityMetadata(*this); } + else + { + m_TameAttemptTimes++; + a_Player.AttachTo(this); + } } -- cgit v1.2.3 From 2f8a0a8a3a366dc8983e0dccbe1ebd1da269236f Mon Sep 17 00:00:00 2001 From: tonibm19 Date: Tue, 15 Oct 2013 21:26:43 +0200 Subject: Added extra line --- source/Mobs/Horse.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'source/Mobs') diff --git a/source/Mobs/Horse.cpp b/source/Mobs/Horse.cpp index 0193a88ac..f1972ffc7 100644 --- a/source/Mobs/Horse.cpp +++ b/source/Mobs/Horse.cpp @@ -1,3 +1,4 @@ + #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "Horse.h" -- cgit v1.2.3 From 6a1149cf4658f5426b758de9c9951139b954dd91 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 16 Oct 2013 15:15:51 +0200 Subject: Fixed compilation errors. --- source/Mobs/Cow.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Cow.cpp b/source/Mobs/Cow.cpp index 431a6916d..dc59016e7 100644 --- a/source/Mobs/Cow.cpp +++ b/source/Mobs/Cow.cpp @@ -2,6 +2,7 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "Cow.h" +#include "../Entities/Player.h" @@ -24,6 +25,10 @@ void cCow::GetDrops(cItems & a_Drops, cEntity * a_Killer) AddRandomDropItem(a_Drops, 1, 3, IsOnFire() ? E_ITEM_STEAK : E_ITEM_RAW_BEEF); } + + + + void cCow::OnRightClicked(cPlayer & a_Player) { if ((a_Player.GetEquippedItem().m_ItemType == E_ITEM_BUCKET)) @@ -31,9 +36,8 @@ void cCow::OnRightClicked(cPlayer & a_Player) if (!a_Player.IsGameModeCreative()) { a_Player.GetInventory().RemoveOneEquippedItem(); - a_Player.GetInventory().AddItem(E_ITEM_MILK) + a_Player.GetInventory().AddItem(E_ITEM_MILK); } - } } -- cgit v1.2.3 From 137ed5a55660a9f436da972fa88e66149c5b5e49 Mon Sep 17 00:00:00 2001 From: tonibm19 Date: Wed, 16 Oct 2013 19:50:59 +0200 Subject: Improved horse saddling [SEE DESC] Now it checks if horse is already saddled, and if it's, you don't lose the saddle. Also, if the horse isn't tammed, you can't saddle it. --- source/Mobs/Horse.cpp | 64 +++++++++++++++++++++++++-------------------------- 1 file changed, 32 insertions(+), 32 deletions(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Horse.cpp b/source/Mobs/Horse.cpp index f1972ffc7..6876a5fa4 100644 --- a/source/Mobs/Horse.cpp +++ b/source/Mobs/Horse.cpp @@ -89,38 +89,38 @@ void cHorse::Tick(float a_Dt, cChunk & a_Chunk) void cHorse::OnRightClicked(cPlayer & a_Player) { - if (m_Attachee != NULL) - { - if (m_Attachee->GetUniqueID() == a_Player.GetUniqueID()) - { - a_Player.Detach(); - return; - } - - if (m_Attachee->IsPlayer()) - { - return; - } - - m_Attachee->Detach(); - } - - if (a_Player.GetEquippedItem().m_ItemType == E_ITEM_SADDLE) - { - if (!a_Player.IsGameModeCreative()) - { - a_Player.GetInventory().RemoveOneEquippedItem(); - } - - // Set saddle state & broadcast metadata - m_bIsSaddled = true; - m_World->BroadcastEntityMetadata(*this); - } - else - { - m_TameAttemptTimes++; - a_Player.AttachTo(this); - } + if (m_Attachee != NULL) + { + if (m_Attachee->GetUniqueID() == a_Player.GetUniqueID()) + { + a_Player.Detach(); + return; + } + + if (m_Attachee->IsPlayer()) + { + return; + } + + m_Attachee->Detach(); + } + + if (a_Player.GetEquippedItem().m_ItemType == E_ITEM_SADDLE && !m_bIsSaddled && m_bIsTame) + { + if (!a_Player.IsGameModeCreative()) + { + a_Player.GetInventory().RemoveOneEquippedItem(); + } + + // Set saddle state & broadcast metadata + m_bIsSaddled = true; + m_World->BroadcastEntityMetadata(*this); + } + else + { + m_TameAttemptTimes++; + a_Player.AttachTo(this); + } } -- cgit v1.2.3 From 90c39c55a97d745de4c33e3788afb75f4c3d2bc8 Mon Sep 17 00:00:00 2001 From: tonibm19 Date: Thu, 17 Oct 2013 18:41:52 +0200 Subject: More fixes - You can only tame horses with nothing at hand - Fixed rearing --- source/Mobs/Horse.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Horse.cpp b/source/Mobs/Horse.cpp index 6876a5fa4..d027e2076 100644 --- a/source/Mobs/Horse.cpp +++ b/source/Mobs/Horse.cpp @@ -1,4 +1,3 @@ - #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "Horse.h" @@ -76,6 +75,7 @@ void cHorse::Tick(float a_Dt, cChunk & a_Chunk) if (m_RearTickCount == 20) { m_bIsRearing = false; + m_RearTickCount = 0; } else { m_RearTickCount++;} } @@ -105,7 +105,7 @@ void cHorse::OnRightClicked(cPlayer & a_Player) m_Attachee->Detach(); } - if (a_Player.GetEquippedItem().m_ItemType == E_ITEM_SADDLE && !m_bIsSaddled && m_bIsTame) + if ((a_Player.GetEquippedItem().m_ItemType == E_ITEM_SADDLE) && (!m_bIsSaddled) && (m_bIsTame)) { if (!a_Player.IsGameModeCreative()) { @@ -116,7 +116,12 @@ void cHorse::OnRightClicked(cPlayer & a_Player) m_bIsSaddled = true; m_World->BroadcastEntityMetadata(*this); } - else + else if ((a_Player.GetEquippedItem().m_ItemType != E_ITEM_EMPTY) && (!m_bIsSaddled) && (!m_bIsTame)) + { + m_bIsRearing = true; + m_RearTickCount = 0; + } + else { m_TameAttemptTimes++; a_Player.AttachTo(this); -- cgit v1.2.3 From 2c187e53b73eb7104297fd2fa0a25914ff235981 Mon Sep 17 00:00:00 2001 From: tonibm19 Date: Thu, 17 Oct 2013 21:28:45 +0200 Subject: Moved lines don't know if I did well --- source/Mobs/Horse.cpp | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Horse.cpp b/source/Mobs/Horse.cpp index d027e2076..0077145dc 100644 --- a/source/Mobs/Horse.cpp +++ b/source/Mobs/Horse.cpp @@ -1,3 +1,4 @@ + #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "Horse.h" @@ -89,22 +90,6 @@ void cHorse::Tick(float a_Dt, cChunk & a_Chunk) void cHorse::OnRightClicked(cPlayer & a_Player) { - if (m_Attachee != NULL) - { - if (m_Attachee->GetUniqueID() == a_Player.GetUniqueID()) - { - a_Player.Detach(); - return; - } - - if (m_Attachee->IsPlayer()) - { - return; - } - - m_Attachee->Detach(); - } - if ((a_Player.GetEquippedItem().m_ItemType == E_ITEM_SADDLE) && (!m_bIsSaddled) && (m_bIsTame)) { if (!a_Player.IsGameModeCreative()) @@ -123,6 +108,22 @@ void cHorse::OnRightClicked(cPlayer & a_Player) } else { + if (m_Attachee != NULL) + { + if (m_Attachee->GetUniqueID() == a_Player.GetUniqueID()) + { + a_Player.Detach(); + return; + } + + if (m_Attachee->IsPlayer()) + { + return; + } + + m_Attachee->Detach(); + } + m_TameAttemptTimes++; a_Player.AttachTo(this); } -- cgit v1.2.3 From 5d4fa298d314a354558f89758ba1c237bf263afd Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 18 Oct 2013 16:34:01 +0200 Subject: Fixed indentation and re-styled conditions. --- source/Mobs/Horse.cpp | 82 +++++++++++++++++++++++++++------------------------ 1 file changed, 44 insertions(+), 38 deletions(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Horse.cpp b/source/Mobs/Horse.cpp index 0077145dc..1f791d236 100644 --- a/source/Mobs/Horse.cpp +++ b/source/Mobs/Horse.cpp @@ -78,7 +78,10 @@ void cHorse::Tick(float a_Dt, cChunk & a_Chunk) m_bIsRearing = false; m_RearTickCount = 0; } - else { m_RearTickCount++;} + else + { + m_RearTickCount++; + } } m_World->BroadcastEntityMetadata(*this); @@ -90,43 +93,46 @@ void cHorse::Tick(float a_Dt, cChunk & a_Chunk) void cHorse::OnRightClicked(cPlayer & a_Player) { - if ((a_Player.GetEquippedItem().m_ItemType == E_ITEM_SADDLE) && (!m_bIsSaddled) && (m_bIsTame)) - { - if (!a_Player.IsGameModeCreative()) - { - a_Player.GetInventory().RemoveOneEquippedItem(); - } - - // Set saddle state & broadcast metadata - m_bIsSaddled = true; - m_World->BroadcastEntityMetadata(*this); - } - else if ((a_Player.GetEquippedItem().m_ItemType != E_ITEM_EMPTY) && (!m_bIsSaddled) && (!m_bIsTame)) - { - m_bIsRearing = true; - m_RearTickCount = 0; - } - else - { - if (m_Attachee != NULL) - { - if (m_Attachee->GetUniqueID() == a_Player.GetUniqueID()) - { - a_Player.Detach(); - return; - } - - if (m_Attachee->IsPlayer()) - { - return; - } - - m_Attachee->Detach(); - } - - m_TameAttemptTimes++; - a_Player.AttachTo(this); - } + if (!m_bIsSaddled && m_bIsTame) + { + if (a_Player.GetEquippedItem().m_ItemType == E_ITEM_SADDLE) + { + // Saddle the horse: + if (!a_Player.IsGameModeCreative()) + { + a_Player.GetInventory().RemoveOneEquippedItem(); + } + m_bIsSaddled = true; + m_World->BroadcastEntityMetadata(*this); + } + else if (!a_Player.GetEquippedItem().IsEmpty()) + { + // The horse doesn't like being hit, make it rear: + m_bIsRearing = true; + m_RearTickCount = 0; + } + } + else + { + if (m_Attachee != NULL) + { + if (m_Attachee->GetUniqueID() == a_Player.GetUniqueID()) + { + a_Player.Detach(); + return; + } + + if (m_Attachee->IsPlayer()) + { + return; + } + + m_Attachee->Detach(); + } + + m_TameAttemptTimes++; + a_Player.AttachTo(this); + } } -- 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/AggressiveMonster.cpp | 4 ++-- source/Mobs/AggressiveMonster.h | 2 +- source/Mobs/Bat.cpp | 2 +- source/Mobs/Blaze.cpp | 2 +- source/Mobs/Cavespider.cpp | 2 +- source/Mobs/Chicken.cpp | 2 +- source/Mobs/Cow.cpp | 2 +- source/Mobs/Creeper.cpp | 2 +- source/Mobs/EnderDragon.cpp | 2 +- source/Mobs/Enderman.cpp | 2 +- source/Mobs/Ghast.cpp | 2 +- source/Mobs/Giant.cpp | 2 +- source/Mobs/Horse.cpp | 2 +- source/Mobs/IronGolem.cpp | 2 +- source/Mobs/Magmacube.cpp | 2 +- source/Mobs/Monster.cpp | 10 +++++++--- source/Mobs/Monster.h | 16 ++++++++-------- source/Mobs/Mooshroom.cpp | 2 +- source/Mobs/Ocelot.h | 2 +- source/Mobs/PassiveAggressiveMonster.cpp | 4 ++-- source/Mobs/PassiveAggressiveMonster.h | 2 +- source/Mobs/PassiveMonster.cpp | 4 ++-- source/Mobs/PassiveMonster.h | 2 +- source/Mobs/Pig.cpp | 2 +- source/Mobs/Sheep.cpp | 2 +- source/Mobs/Silverfish.h | 2 +- source/Mobs/Skeleton.cpp | 2 +- source/Mobs/Slime.cpp | 2 +- source/Mobs/SnowGolem.cpp | 2 +- source/Mobs/Spider.cpp | 2 +- source/Mobs/Squid.cpp | 2 +- source/Mobs/Villager.cpp | 2 +- source/Mobs/Witch.cpp | 2 +- source/Mobs/Wither.cpp | 2 +- source/Mobs/Wolf.cpp | 2 +- source/Mobs/Zombie.cpp | 2 +- source/Mobs/Zombiepigman.cpp | 2 +- 37 files changed, 53 insertions(+), 49 deletions(-) (limited to 'source/Mobs') diff --git a/source/Mobs/AggressiveMonster.cpp b/source/Mobs/AggressiveMonster.cpp index 93dba6d7b..ee6252656 100644 --- a/source/Mobs/AggressiveMonster.cpp +++ b/source/Mobs/AggressiveMonster.cpp @@ -12,8 +12,8 @@ -cAggressiveMonster::cAggressiveMonster(const AString & a_ConfigName, char a_ProtocolMobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height) : - super(a_ConfigName, a_ProtocolMobType, a_SoundHurt, a_SoundDeath, a_Width, a_Height), +cAggressiveMonster::cAggressiveMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height) : + super(a_ConfigName, a_MobType, a_SoundHurt, a_SoundDeath, a_Width, a_Height), m_ChaseTime(999999) { m_EMPersonality = AGGRESSIVE; diff --git a/source/Mobs/AggressiveMonster.h b/source/Mobs/AggressiveMonster.h index f22ed5b89..5a0d93f3d 100644 --- a/source/Mobs/AggressiveMonster.h +++ b/source/Mobs/AggressiveMonster.h @@ -13,7 +13,7 @@ class cAggressiveMonster : typedef cMonster super; public: - cAggressiveMonster(const AString & a_ConfigName, char a_ProtocolMobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height); + cAggressiveMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height); virtual void Tick (float a_Dt, cChunk & a_Chunk) override; virtual void InStateChasing(float a_Dt) override; diff --git a/source/Mobs/Bat.cpp b/source/Mobs/Bat.cpp index 715f25483..b9c82996b 100644 --- a/source/Mobs/Bat.cpp +++ b/source/Mobs/Bat.cpp @@ -8,7 +8,7 @@ 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) + super("Bat", mtBat, "mob.bat.hurt", "mob.bat.death", 0.7, 0.7) { } diff --git a/source/Mobs/Blaze.cpp b/source/Mobs/Blaze.cpp index dbbccf417..74c82c081 100644 --- a/source/Mobs/Blaze.cpp +++ b/source/Mobs/Blaze.cpp @@ -9,7 +9,7 @@ cBlaze::cBlaze(void) : // TODO: The size is only a guesstimate, measure in vanilla and fix the size values here - super("Blaze", 61, "mob.blaze.hit", "mob.blaze.death", 0.7, 1.8) + super("Blaze", mtBlaze, "mob.blaze.hit", "mob.blaze.death", 0.7, 1.8) { } diff --git a/source/Mobs/Cavespider.cpp b/source/Mobs/Cavespider.cpp index 2d50b391a..aba1ff9f5 100644 --- a/source/Mobs/Cavespider.cpp +++ b/source/Mobs/Cavespider.cpp @@ -9,7 +9,7 @@ cCavespider::cCavespider(void) : - super("Cavespider", 59, "mob.spider.say", "mob.spider.death", 0.7, 0.5) + super("Cavespider", mtCaveSpider, "mob.spider.say", "mob.spider.death", 0.7, 0.5) { } diff --git a/source/Mobs/Chicken.cpp b/source/Mobs/Chicken.cpp index 3da9781d3..434a32f94 100644 --- a/source/Mobs/Chicken.cpp +++ b/source/Mobs/Chicken.cpp @@ -14,7 +14,7 @@ cChicken::cChicken(void) : - super("Chicken", 93, "mob.chicken.hurt", "mob.chicken.hurt", 0.3, 0.4) + super("Chicken", mtChicken, "mob.chicken.hurt", "mob.chicken.hurt", 0.3, 0.4) { } diff --git a/source/Mobs/Cow.cpp b/source/Mobs/Cow.cpp index dc59016e7..9eb74dac2 100644 --- a/source/Mobs/Cow.cpp +++ b/source/Mobs/Cow.cpp @@ -11,7 +11,7 @@ cCow::cCow(void) : - super("Cow", 92, "mob.cow.hurt", "mob.cow.hurt", 0.9, 1.3) + super("Cow", mtCow, "mob.cow.hurt", "mob.cow.hurt", 0.9, 1.3) { } diff --git a/source/Mobs/Creeper.cpp b/source/Mobs/Creeper.cpp index b41b05f42..4e11ae13e 100644 --- a/source/Mobs/Creeper.cpp +++ b/source/Mobs/Creeper.cpp @@ -9,7 +9,7 @@ cCreeper::cCreeper(void) : - super("Creeper", 50, "mob.creeper.say", "mob.creeper.say", 0.6, 1.8), + super("Creeper", mtCreeper, "mob.creeper.say", "mob.creeper.say", 0.6, 1.8), m_bIsBlowing(false), m_bIsCharged(false) { diff --git a/source/Mobs/EnderDragon.cpp b/source/Mobs/EnderDragon.cpp index 64f2bedfa..acd81cde1 100644 --- a/source/Mobs/EnderDragon.cpp +++ b/source/Mobs/EnderDragon.cpp @@ -9,7 +9,7 @@ cEnderDragon::cEnderDragon(void) : // TODO: Vanilla source says this, but is it right? Dragons fly, they don't stand - super("EnderDragon", 63, "mob.enderdragon.hit", "mob.enderdragon.end", 16.0, 8.0) + super("EnderDragon", mtEnderDragon, "mob.enderdragon.hit", "mob.enderdragon.end", 16.0, 8.0) { } diff --git a/source/Mobs/Enderman.cpp b/source/Mobs/Enderman.cpp index c0ea3d6aa..a784131e4 100644 --- a/source/Mobs/Enderman.cpp +++ b/source/Mobs/Enderman.cpp @@ -8,7 +8,7 @@ cEnderman::cEnderman(void) : - super("Enderman", 58, "mob.endermen.hit", "mob.endermen.death", 0.5, 2.9), + super("Enderman", mtEnderman, "mob.endermen.hit", "mob.endermen.death", 0.5, 2.9), m_bIsScreaming(false), CarriedBlock(E_BLOCK_AIR), CarriedMeta(0) diff --git a/source/Mobs/Ghast.cpp b/source/Mobs/Ghast.cpp index 288d0c28a..419c8474d 100644 --- a/source/Mobs/Ghast.cpp +++ b/source/Mobs/Ghast.cpp @@ -8,7 +8,7 @@ cGhast::cGhast(void) : - super("Ghast", 56, "mob.ghast.scream", "mob.ghast.death", 4, 4) + super("Ghast", mtGhast, "mob.ghast.scream", "mob.ghast.death", 4, 4) { } diff --git a/source/Mobs/Giant.cpp b/source/Mobs/Giant.cpp index a02758a43..f41977535 100644 --- a/source/Mobs/Giant.cpp +++ b/source/Mobs/Giant.cpp @@ -9,7 +9,7 @@ cGiant::cGiant(void) : // TODO: The size is only a guesstimate, measure in vanilla and fix the size values here - super("Giant", 53, "mob.zombie.hurt", "mob.zombie.death", 2.0, 13.5) + super("Giant", mtGiant, "mob.zombie.hurt", "mob.zombie.death", 2.0, 13.5) { } diff --git a/source/Mobs/Horse.cpp b/source/Mobs/Horse.cpp index 1f791d236..f9705a451 100644 --- a/source/Mobs/Horse.cpp +++ b/source/Mobs/Horse.cpp @@ -10,7 +10,7 @@ cHorse::cHorse(int Type, int Color, int Style, int TameTimes) : - super("Horse", 100, "mob.horse.hit", "mob.horse.death", 1.4, 1.6), + super("Horse", mtHorse, "mob.horse.hit", "mob.horse.death", 1.4, 1.6), m_bHasChest(false), m_bIsEating(false), m_bIsRearing(false), diff --git a/source/Mobs/IronGolem.cpp b/source/Mobs/IronGolem.cpp index 42d312c23..47c961098 100644 --- a/source/Mobs/IronGolem.cpp +++ b/source/Mobs/IronGolem.cpp @@ -8,7 +8,7 @@ cIronGolem::cIronGolem(void) : - super("IronGolem", 99, "mob.IronGolem.hit", "mob.IronGolem.death", 1.4, 2.9) + super("IronGolem", mtIronGolem, "mob.IronGolem.hit", "mob.IronGolem.death", 1.4, 2.9) { } diff --git a/source/Mobs/Magmacube.cpp b/source/Mobs/Magmacube.cpp index c72b4831b..86447ff6b 100644 --- a/source/Mobs/Magmacube.cpp +++ b/source/Mobs/Magmacube.cpp @@ -8,7 +8,7 @@ cMagmaCube::cMagmaCube(int a_Size) : - super("MagmaCube", 62, "mob.MagmaCube.big", "mob.MagmaCube.big", 0.6 * a_Size, 0.6 * a_Size), + super("MagmaCube", mtMagmaCube, "mob.MagmaCube.big", "mob.MagmaCube.big", 0.6 * a_Size, 0.6 * a_Size), m_Size(a_Size) { } diff --git a/source/Mobs/Monster.cpp b/source/Mobs/Monster.cpp index 51ea644d3..591c41e22 100644 --- a/source/Mobs/Monster.cpp +++ b/source/Mobs/Monster.cpp @@ -25,7 +25,7 @@ -cMonster::cMonster(const AString & a_ConfigName, char a_ProtocolMobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height) +cMonster::cMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height) : super(etMonster, a_Width, a_Height) , m_Target(NULL) , m_AttackRate(3) @@ -34,7 +34,7 @@ cMonster::cMonster(const AString & a_ConfigName, char a_ProtocolMobType, const A , m_DestinationTime( 0 ) , m_DestroyTimer( 0 ) , m_Jump(0) - , m_MobType(a_ProtocolMobType) + , m_MobType(a_MobType) , m_SoundHurt(a_SoundHurt) , m_SoundDeath(a_SoundDeath) , m_EMState(IDLE) @@ -514,5 +514,9 @@ void cMonster::HandleDaylightBurning(cChunk & a_Chunk) cMonster::eFamily cMonster::GetMobFamily(void) const { - return cMobTypesManager::getFamilyFromType(GetMobTypeAsEnum()); + return cMobTypesManager::FamilyFromType(m_MobType); } + + + + 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; diff --git a/source/Mobs/Mooshroom.cpp b/source/Mobs/Mooshroom.cpp index 5d2c901ba..940e2db44 100644 --- a/source/Mobs/Mooshroom.cpp +++ b/source/Mobs/Mooshroom.cpp @@ -14,7 +14,7 @@ cMooshroom::cMooshroom(void) : - super("Mooshroom", 96, "mob.cow.hurt", "mob.cow.hurt", 0.9, 1.3) + super("Mooshroom", mtMooshroom, "mob.cow.hurt", "mob.cow.hurt", 0.9, 1.3) { } diff --git a/source/Mobs/Ocelot.h b/source/Mobs/Ocelot.h index 6d24c5672..adb7a1f75 100644 --- a/source/Mobs/Ocelot.h +++ b/source/Mobs/Ocelot.h @@ -14,7 +14,7 @@ class cOcelot : public: cOcelot(void) : - super("Ocelot", 98, "mob.cat.hitt", "mob.cat.hitt", 0.6, 0.8) + super("Ocelot", mtOcelot, "mob.cat.hitt", "mob.cat.hitt", 0.6, 0.8) { } diff --git a/source/Mobs/PassiveAggressiveMonster.cpp b/source/Mobs/PassiveAggressiveMonster.cpp index e473137a9..28de65905 100644 --- a/source/Mobs/PassiveAggressiveMonster.cpp +++ b/source/Mobs/PassiveAggressiveMonster.cpp @@ -9,8 +9,8 @@ -cPassiveAggressiveMonster::cPassiveAggressiveMonster(const AString & a_ConfigName, char a_ProtocolMobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height) : - super(a_ConfigName, a_ProtocolMobType, a_SoundHurt, a_SoundDeath, a_Width, a_Height) +cPassiveAggressiveMonster::cPassiveAggressiveMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height) : + super(a_ConfigName, a_MobType, a_SoundHurt, a_SoundDeath, a_Width, a_Height) { m_EMPersonality = PASSIVE; } diff --git a/source/Mobs/PassiveAggressiveMonster.h b/source/Mobs/PassiveAggressiveMonster.h index 243dfff38..2c5ef30b1 100644 --- a/source/Mobs/PassiveAggressiveMonster.h +++ b/source/Mobs/PassiveAggressiveMonster.h @@ -13,7 +13,7 @@ class cPassiveAggressiveMonster : typedef cAggressiveMonster super; public: - cPassiveAggressiveMonster(const AString & a_ConfigName, char a_ProtocolMobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height); + cPassiveAggressiveMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height); virtual void DoTakeDamage(TakeDamageInfo & a_TDI) override; } ; diff --git a/source/Mobs/PassiveMonster.cpp b/source/Mobs/PassiveMonster.cpp index 8c69c8059..91ceb5a53 100644 --- a/source/Mobs/PassiveMonster.cpp +++ b/source/Mobs/PassiveMonster.cpp @@ -9,8 +9,8 @@ -cPassiveMonster::cPassiveMonster(const AString & a_ConfigName, char a_ProtocolMobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height) : - super(a_ConfigName, a_ProtocolMobType, a_SoundHurt, a_SoundDeath, a_Width, a_Height) +cPassiveMonster::cPassiveMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height) : + super(a_ConfigName, a_MobType, a_SoundHurt, a_SoundDeath, a_Width, a_Height) { m_EMPersonality = PASSIVE; } diff --git a/source/Mobs/PassiveMonster.h b/source/Mobs/PassiveMonster.h index 908bb0ce6..14a6be6b1 100644 --- a/source/Mobs/PassiveMonster.h +++ b/source/Mobs/PassiveMonster.h @@ -13,7 +13,7 @@ class cPassiveMonster : typedef cMonster super; public: - cPassiveMonster(const AString & a_ConfigName, char a_ProtocolMobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height); + cPassiveMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height); virtual void Tick(float a_Dt, cChunk & a_Chunk) override; diff --git a/source/Mobs/Pig.cpp b/source/Mobs/Pig.cpp index cd18c087f..5427cf35f 100644 --- a/source/Mobs/Pig.cpp +++ b/source/Mobs/Pig.cpp @@ -10,7 +10,7 @@ cPig::cPig(void) : - super("Pig", 90, "mob.pig.say", "mob.pig.death", 0.9, 0.9), + super("Pig", mtPig, "mob.pig.say", "mob.pig.death", 0.9, 0.9), m_bIsSaddled(false) { } diff --git a/source/Mobs/Sheep.cpp b/source/Mobs/Sheep.cpp index 440c5c2b9..0d7d43e27 100644 --- a/source/Mobs/Sheep.cpp +++ b/source/Mobs/Sheep.cpp @@ -11,7 +11,7 @@ cSheep::cSheep(int a_Color) : - super("Sheep", 91, "mob.sheep.say", "mob.sheep.say", 0.6, 1.3), + super("Sheep", mtSheep, "mob.sheep.say", "mob.sheep.say", 0.6, 1.3), m_IsSheared(false), m_WoolColor(a_Color) { diff --git a/source/Mobs/Silverfish.h b/source/Mobs/Silverfish.h index d632ac169..a6e11c49d 100644 --- a/source/Mobs/Silverfish.h +++ b/source/Mobs/Silverfish.h @@ -14,7 +14,7 @@ class cSilverfish : public: cSilverfish(void) : - super("Silverfish", 60, "mob.silverfish.hit", "mob.silverfish.kill", 0.3, 0.7) + super("Silverfish", mtSilverfish, "mob.silverfish.hit", "mob.silverfish.kill", 0.3, 0.7) { } diff --git a/source/Mobs/Skeleton.cpp b/source/Mobs/Skeleton.cpp index 6297b867c..37a724848 100644 --- a/source/Mobs/Skeleton.cpp +++ b/source/Mobs/Skeleton.cpp @@ -9,7 +9,7 @@ cSkeleton::cSkeleton(bool IsWither) : - super("Skeleton", 51, "mob.skeleton.hurt", "mob.skeleton.death", 0.6, 1.8), + super("Skeleton", mtSkeleton, "mob.skeleton.hurt", "mob.skeleton.death", 0.6, 1.8), m_bIsWither(IsWither) { SetBurnsInDaylight(true); diff --git a/source/Mobs/Slime.cpp b/source/Mobs/Slime.cpp index 7a9487a06..19f376c21 100644 --- a/source/Mobs/Slime.cpp +++ b/source/Mobs/Slime.cpp @@ -9,7 +9,7 @@ /// Creates a slime of the specified size; size is 1 .. 3, with 1 being the smallest cSlime::cSlime(int a_Size) : - super("Slime", 55, "mob.slime.attack", "mob.slime.attack", 0.6 * a_Size, 0.6 * a_Size), + super("Slime", mtSlime, "mob.slime.attack", "mob.slime.attack", 0.6 * a_Size, 0.6 * a_Size), m_Size(a_Size) { } diff --git a/source/Mobs/SnowGolem.cpp b/source/Mobs/SnowGolem.cpp index 51125542d..9e199f87e 100644 --- a/source/Mobs/SnowGolem.cpp +++ b/source/Mobs/SnowGolem.cpp @@ -8,7 +8,7 @@ cSnowGolem::cSnowGolem(void) : - super("SnowGolem", 97, "", "", 0.4, 1.8) + super("SnowGolem", mtSnowGolem, "", "", 0.4, 1.8) { } diff --git a/source/Mobs/Spider.cpp b/source/Mobs/Spider.cpp index 2f244cdbc..b19a5dcef 100644 --- a/source/Mobs/Spider.cpp +++ b/source/Mobs/Spider.cpp @@ -8,7 +8,7 @@ cSpider::cSpider(void) : - super("Spider", 52, "mob.spider.say", "mob.spider.death", 1.4, 0.9) + super("Spider", mtSpider, "mob.spider.say", "mob.spider.death", 1.4, 0.9) { } diff --git a/source/Mobs/Squid.cpp b/source/Mobs/Squid.cpp index e6a44079a..a311108ae 100644 --- a/source/Mobs/Squid.cpp +++ b/source/Mobs/Squid.cpp @@ -10,7 +10,7 @@ cSquid::cSquid(void) : - super("Squid", 94, "", "", 0.95, 0.95) + super("Squid", mtSquid, "", "", 0.95, 0.95) { } diff --git a/source/Mobs/Villager.cpp b/source/Mobs/Villager.cpp index 97d6dc3ca..7f89fb6cc 100644 --- a/source/Mobs/Villager.cpp +++ b/source/Mobs/Villager.cpp @@ -9,7 +9,7 @@ cVillager::cVillager(eVillagerType VillagerType) : - super("Villager", 120, "", "", 0.6, 1.8), + super("Villager", mtVillager, "", "", 0.6, 1.8), m_Type(VillagerType) { } diff --git a/source/Mobs/Witch.cpp b/source/Mobs/Witch.cpp index b29783853..25d27041f 100644 --- a/source/Mobs/Witch.cpp +++ b/source/Mobs/Witch.cpp @@ -8,7 +8,7 @@ cWitch::cWitch(void) : - super("Witch", 66, "", "", 0.6, 1.8) + super("Witch", mtWitch, "", "", 0.6, 1.8) { } diff --git a/source/Mobs/Wither.cpp b/source/Mobs/Wither.cpp index 8b77284c8..c46e0beab 100644 --- a/source/Mobs/Wither.cpp +++ b/source/Mobs/Wither.cpp @@ -8,7 +8,7 @@ cWither::cWither(void) : - super("Wither", 64, "mob.wither.hurt", "mob.wither.death", 0.9, 4.0) + super("Wither", mtWither, "mob.wither.hurt", "mob.wither.death", 0.9, 4.0) { } diff --git a/source/Mobs/Wolf.cpp b/source/Mobs/Wolf.cpp index e76f991dc..2baeb4b7b 100644 --- a/source/Mobs/Wolf.cpp +++ b/source/Mobs/Wolf.cpp @@ -10,7 +10,7 @@ cWolf::cWolf(void) : - super("Wolf", 95, "mob.wolf.hurt", "mob.wolf.death", 0.6, 0.8), + super("Wolf", mtWolf, "mob.wolf.hurt", "mob.wolf.death", 0.6, 0.8), m_bIsAngry(false), m_bIsTame(false), m_bIsSitting(false), diff --git a/source/Mobs/Zombie.cpp b/source/Mobs/Zombie.cpp index f495fe5ee..1752ec390 100644 --- a/source/Mobs/Zombie.cpp +++ b/source/Mobs/Zombie.cpp @@ -9,7 +9,7 @@ cZombie::cZombie(bool IsVillagerZombie) : - super("Zombie", 54, "mob.zombie.hurt", "mob.zombie.death", 0.6, 1.8), + super("Zombie", mtZombie, "mob.zombie.hurt", "mob.zombie.death", 0.6, 1.8), m_bIsConverting(false), m_bIsVillagerZombie(IsVillagerZombie) { diff --git a/source/Mobs/Zombiepigman.cpp b/source/Mobs/Zombiepigman.cpp index 1e31a72d9..6ac89ed4c 100644 --- a/source/Mobs/Zombiepigman.cpp +++ b/source/Mobs/Zombiepigman.cpp @@ -9,7 +9,7 @@ cZombiePigman::cZombiePigman(void) : - super("ZombiePigman", 57, "mob.zombiepig.zpighurt", "mob.zombiepig.zpigdeath", 0.6, 1.8) + super("ZombiePigman", mtZombiePigman, "mob.zombiepig.zpighurt", "mob.zombiepig.zpigdeath", 0.6, 1.8) { } -- 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.cpp | 227 ++++++++++++++++++++++++++++++++++++++++++++++-- source/Mobs/Monster.h | 26 +++++- 2 files changed, 246 insertions(+), 7 deletions(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Monster.cpp b/source/Mobs/Monster.cpp index 591c41e22..73abc069d 100644 --- a/source/Mobs/Monster.cpp +++ b/source/Mobs/Monster.cpp @@ -1,7 +1,7 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules -#include "Monster.h" +#include "IncludeAllMonsters.h" #include "../Root.h" #include "../Server.h" #include "../ClientHandle.h" @@ -9,7 +9,6 @@ #include "../Entities/Player.h" #include "../Defines.h" #include "../MonsterConfig.h" -#include "../MobTypesManager.h" #include "../MersenneTwister.h" #include "../Vector3f.h" @@ -17,13 +16,54 @@ #include "../Vector3d.h" #include "../Tracer.h" #include "../Chunk.h" +#include "../FastRandom.h" -// #include "../../iniFile/iniFile.h" - +/** Map for eType <-> string +Needs to be alpha-sorted by the strings, because binary search is used in StringToMobType() +The strings need to be lowercase (for more efficient comparisons in StringToMobType()) +*/ +static const struct +{ + cMonster::eType m_Type; + const char * m_lcName; +} g_MobTypeNames[] = +{ + {cMonster::mtBat, "bat"}, + {cMonster::mtBlaze, "blaze"}, + {cMonster::mtCaveSpider, "cavespider"}, + {cMonster::mtChicken, "chicken"}, + {cMonster::mtCow, "cow"}, + {cMonster::mtCreeper, "creeper"}, + {cMonster::mtEnderman, "enderman"}, + {cMonster::mtGhast, "ghast"}, + {cMonster::mtHorse, "horse"}, + {cMonster::mtMagmaCube, "magmacube"}, + {cMonster::mtMooshroom, "mooshroom"}, + {cMonster::mtOcelot, "ocelot"}, + {cMonster::mtPig, "pig"}, + {cMonster::mtSheep, "sheep"}, + {cMonster::mtSilverfish, "silverfish"}, + {cMonster::mtSkeleton, "skeleton"}, + {cMonster::mtSlime, "slime"}, + {cMonster::mtSpider, "spider"}, + {cMonster::mtSquid, "squid"}, + {cMonster::mtVillager, "villager"}, + {cMonster::mtWitch, "witch"}, + {cMonster::mtWolf, "wolf"}, + {cMonster::mtZombie, "zombie"}, + {cMonster::mtZombiePigman, "zombiepigman"}, +} ; + + + + + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// cMonster: cMonster::cMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height) : super(etMonster, a_Width, a_Height) @@ -467,6 +507,183 @@ void cMonster::SetSightDistance(float sd) +AString cMonster::MobTypeToString(cMonster::eType a_MobType) +{ + // Mob types aren't sorted, so we need to search linearly: + for (int i = 0; i < ARRAYCOUNT(g_MobTypeNames); i++) + { + if (g_MobTypeNames[i].m_Type == a_MobType) + { + return g_MobTypeNames[i].m_lcName; + } + } + + // Not found: + return ""; +} + + + + + +cMonster::eType cMonster::StringToMobType(const AString & a_Name) +{ + AString lcName(a_Name); + StrToLower(lcName); + + // Binary-search for the lowercase name: + int lo = 0, hi = ARRAYCOUNT(g_MobTypeNames); + while (hi - lo > 1) + { + int mid = (lo + hi) / 2; + int res = strcmp(g_MobTypeNames[mid].m_lcName, lcName.c_str()); + if (res == 0) + { + return g_MobTypeNames[mid].m_Type; + } + if (res < 0) + { + hi = mid; + } + else + { + lo = mid; + } + } + // Range has collapsed to at most two elements, compare each: + if (strcmp(g_MobTypeNames[lo].m_lcName, lcName.c_str()) == 0) + { + return g_MobTypeNames[lo].m_Type; + } + if ((lo != hi) && (strcmp(g_MobTypeNames[hi].m_lcName, lcName.c_str()) == 0)) + { + return g_MobTypeNames[hi].m_Type; + } + + // Not found: + return mtInvalidType; +} + + + + + +cMonster::eFamily cMonster::FamilyFromType(eType a_Type) +{ + static const struct + { + eType m_Type; + eFamily m_Family; + } TypeMap[] = + { + {mtBat, mfAmbient}, + {mtBlaze, mfHostile}, + {mtCaveSpider, mfHostile}, + {mtChicken, mfPassive}, + {mtCow, mfPassive}, + {mtCreeper, mfHostile}, + {mtEnderman, mfHostile}, + {mtGhast, mfHostile}, + {mtHorse, mfPassive}, + {mtMagmaCube, mfHostile}, + {mtMooshroom, mfHostile}, + {mtOcelot, mfHostile}, + {mtPig, mfPassive}, + {mtSheep, mfPassive}, + {mtSilverfish, mfHostile}, + {mtSkeleton, mfHostile}, + {mtSlime, mfHostile}, + {mtSpider, mfHostile}, + {mtSquid, mfWater}, + {mtVillager, mfPassive}, + {mtWitch, mfHostile}, + {mtWolf, mfHostile}, + {mtZombie, mfHostile}, + {mtZombiePigman, mfHostile}, + } ; + + for (int i = 0; i < ARRAYCOUNT(TypeMap); i++) + { + if (TypeMap[i].m_Type == a_Type) + { + return TypeMap[i].m_Family; + } + } + return mfMaxplusone; +} + + + + + +cMonster * cMonster::NewMonsterFromType(cMonster::eType a_MobType, int a_Size) +{ + cFastRandom Random; + + cMonster * toReturn = NULL; + + // unspecified size get rand[1,3] for Monsters that need size + switch (a_MobType) + { + case mtMagmaCube: + case mtSlime: + { + if (a_Size == -1) + { + a_Size = Random.NextInt(2, a_MobType) + 1; + } + if ((a_Size <= 0) || (a_Size >= 4)) + { + ASSERT(!"Random for size was supposed to pick in [1..3] and picked outside"); + a_Size = 1; + } + break; + } + default: break; + } // switch (a_MobType) + + // Create the mob entity + switch (a_MobType) + { + case mtMagmaCube: toReturn = new cMagmaCube(a_Size); break; + case mtSlime: toReturn = new cSlime(a_Size); break; + case mtBat: toReturn = new cBat(); break; + case mtBlaze: toReturn = new cBlaze(); break; + case mtCaveSpider: toReturn = new cCavespider(); break; + case mtChicken: toReturn = new cChicken(); break; + case mtCow: toReturn = new cCow(); break; + case mtCreeper: toReturn = new cCreeper(); break; + case mtEnderman: toReturn = new cEnderman(); break; + case mtGhast: toReturn = new cGhast(); break; + // TODO: + // case cMonster::mtHorse: toReturn = new cHorse(); break; + case mtMooshroom: toReturn = new cMooshroom(); break; + case mtOcelot: toReturn = new cOcelot(); break; + case mtPig: toReturn = new cPig(); break; + // TODO: Implement sheep color + case mtSheep: toReturn = new cSheep(0); break; + case mtSilverfish: toReturn = new cSilverfish(); break; + // TODO: Implement wither skeleton geration + case mtSkeleton: toReturn = new cSkeleton(false); break; + case mtSpider: toReturn = new cSpider(); break; + case mtSquid: toReturn = new cSquid(); break; + case mtVillager: toReturn = new cVillager(cVillager::vtFarmer); break; + case mtWitch: toReturn = new cWitch(); break; + case mtWolf: toReturn = new cWolf(); break; + case mtZombie: toReturn = new cZombie(false); break; + case mtZombiePigman: toReturn = new cZombiePigman(); break; + default: + { + ASSERT(!"Unhandled Mob type"); + } + } + return toReturn; +} + + + + + void cMonster::AddRandomDropItem(cItems & a_Drops, unsigned int a_Min, unsigned int a_Max, short a_Item, short a_ItemHealth) { MTRand r1; @@ -514,7 +731,7 @@ void cMonster::HandleDaylightBurning(cChunk & a_Chunk) cMonster::eFamily cMonster::GetMobFamily(void) const { - return cMobTypesManager::FamilyFromType(m_MobType); + return FamilyFromType(m_MobType); } 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 71d06e30155eb50cdc2b5ded2ca25e136cd19654 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 20 Oct 2013 13:42:59 +0200 Subject: Fixed binary search in StringToMobType(). --- source/Mobs/Monster.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Monster.cpp b/source/Mobs/Monster.cpp index 73abc069d..ffc42cb07 100644 --- a/source/Mobs/Monster.cpp +++ b/source/Mobs/Monster.cpp @@ -532,7 +532,7 @@ cMonster::eType cMonster::StringToMobType(const AString & a_Name) StrToLower(lcName); // Binary-search for the lowercase name: - int lo = 0, hi = ARRAYCOUNT(g_MobTypeNames); + int lo = 0, hi = ARRAYCOUNT(g_MobTypeNames) - 1; while (hi - lo > 1) { int mid = (lo + hi) / 2; @@ -543,11 +543,11 @@ cMonster::eType cMonster::StringToMobType(const AString & a_Name) } if (res < 0) { - hi = mid; + lo = mid; } else { - lo = mid; + hi = mid; } } // Range has collapsed to at most two elements, compare each: -- 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.cpp | 17 +++++++++++++++++ source/Mobs/Monster.h | 3 +++ 2 files changed, 20 insertions(+) (limited to 'source/Mobs') diff --git a/source/Mobs/Monster.cpp b/source/Mobs/Monster.cpp index ffc42cb07..c5b116db4 100644 --- a/source/Mobs/Monster.cpp +++ b/source/Mobs/Monster.cpp @@ -616,6 +616,23 @@ cMonster::eFamily cMonster::FamilyFromType(eType a_Type) +int cMonster::GetSpawnRate(cMonster::eFamily a_MobFamily) +{ + switch (a_MobFamily) + { + case mfHostile: return 1; + case mfPassive: return 400; + case mfAmbient: return 400; + case mfWater: return 400; + } + ASSERT(!"Unhandled mob family"); + return -1; +} + + + + + cMonster * cMonster::NewMonsterFromType(cMonster::eType a_MobType, int a_Size) { cFastRandom Random; 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 d8576a79537029bc40ff9a125e9ada4739ce76bb Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 20 Oct 2013 14:15:55 +0200 Subject: Reimplemented cMonster::FamilyFromType() as a simple switch (duh!) --- source/Mobs/Monster.cpp | 65 ++++++++++++++++++++----------------------------- 1 file changed, 27 insertions(+), 38 deletions(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Monster.cpp b/source/Mobs/Monster.cpp index c5b116db4..599aa9cfc 100644 --- a/source/Mobs/Monster.cpp +++ b/source/Mobs/Monster.cpp @@ -570,45 +570,34 @@ cMonster::eType cMonster::StringToMobType(const AString & a_Name) cMonster::eFamily cMonster::FamilyFromType(eType a_Type) { - static const struct - { - eType m_Type; - eFamily m_Family; - } TypeMap[] = - { - {mtBat, mfAmbient}, - {mtBlaze, mfHostile}, - {mtCaveSpider, mfHostile}, - {mtChicken, mfPassive}, - {mtCow, mfPassive}, - {mtCreeper, mfHostile}, - {mtEnderman, mfHostile}, - {mtGhast, mfHostile}, - {mtHorse, mfPassive}, - {mtMagmaCube, mfHostile}, - {mtMooshroom, mfHostile}, - {mtOcelot, mfHostile}, - {mtPig, mfPassive}, - {mtSheep, mfPassive}, - {mtSilverfish, mfHostile}, - {mtSkeleton, mfHostile}, - {mtSlime, mfHostile}, - {mtSpider, mfHostile}, - {mtSquid, mfWater}, - {mtVillager, mfPassive}, - {mtWitch, mfHostile}, - {mtWolf, mfHostile}, - {mtZombie, mfHostile}, - {mtZombiePigman, mfHostile}, + switch (a_Type) + { + case mtBat: return mfAmbient; + case mtBlaze: return mfHostile; + case mtCaveSpider: return mfHostile; + case mtChicken: return mfPassive; + case mtCow: return mfPassive; + case mtCreeper: return mfHostile; + case mtEnderman: return mfHostile; + case mtGhast: return mfHostile; + case mtHorse: return mfPassive; + case mtMagmaCube: return mfHostile; + case mtMooshroom: return mfHostile; + case mtOcelot: return mfHostile; + case mtPig: return mfPassive; + case mtSheep: return mfPassive; + case mtSilverfish: return mfHostile; + case mtSkeleton: return mfHostile; + case mtSlime: return mfHostile; + case mtSpider: return mfHostile; + case mtSquid: return mfWater; + case mtVillager: return mfPassive; + case mtWitch: return mfHostile; + case mtWolf: return mfHostile; + case mtZombie: return mfHostile; + case mtZombiePigman: return mfHostile; } ; - - for (int i = 0; i < ARRAYCOUNT(TypeMap); i++) - { - if (TypeMap[i].m_Type == a_Type) - { - return TypeMap[i].m_Family; - } - } + ASSERT(!"Unhandled mob type"); return mfMaxplusone; } -- cgit v1.2.3 From 4cf0862c12346b9f3e26e86784bbd5c5d61e0590 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 22 Oct 2013 17:54:23 +0200 Subject: Fixed an assert in cMonster --- source/Mobs/Monster.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Monster.cpp b/source/Mobs/Monster.cpp index 599aa9cfc..7e35b97f1 100644 --- a/source/Mobs/Monster.cpp +++ b/source/Mobs/Monster.cpp @@ -718,8 +718,8 @@ void cMonster::HandleDaylightBurning(cChunk & a_Chunk) return; } - int RelX = (int)floor(GetPosX()) - a_Chunk.GetPosX() * cChunkDef::Width; - int RelZ = (int)floor(GetPosZ()) - a_Chunk.GetPosZ() * cChunkDef::Width; + int RelX = (int)floor(GetPosX()) - GetChunkX() * cChunkDef::Width; + int RelZ = (int)floor(GetPosZ()) - GetChunkZ() * cChunkDef::Width; if ( (a_Chunk.GetSkyLight(RelX, RelY, RelZ) == 15) && // In the daylight (a_Chunk.GetBlock(RelX, RelY, RelZ) != E_BLOCK_SOULSAND) && // Not on soulsand -- 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.cpp | 2 +- source/Mobs/Monster.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Monster.cpp b/source/Mobs/Monster.cpp index 7e35b97f1..9b1f2fc4c 100644 --- a/source/Mobs/Monster.cpp +++ b/source/Mobs/Monster.cpp @@ -605,7 +605,7 @@ cMonster::eFamily cMonster::FamilyFromType(eType a_Type) -int cMonster::GetSpawnRate(cMonster::eFamily a_MobFamily) +int cMonster::GetSpawnDelay(cMonster::eFamily a_MobFamily) { switch (a_MobFamily) { 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') 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 a42561cf5a2e8cf86848cb1925097173787de808 Mon Sep 17 00:00:00 2001 From: tonibm19 Date: Sun, 27 Oct 2013 10:41:25 +0100 Subject: Sheep fixes. Now amount of wool you get when shearing a sheep is random. Sheeps only spawn in white color (I will add sheep dying soon). --- source/Mobs/Sheep.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Sheep.cpp b/source/Mobs/Sheep.cpp index 0d7d43e27..54cce9cbe 100644 --- a/source/Mobs/Sheep.cpp +++ b/source/Mobs/Sheep.cpp @@ -1,4 +1,3 @@ - #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "Sheep.h" @@ -13,7 +12,7 @@ cSheep::cSheep(int a_Color) : super("Sheep", mtSheep, "mob.sheep.say", "mob.sheep.say", 0.6, 1.3), m_IsSheared(false), - m_WoolColor(a_Color) + m_WoolColor(0) { } @@ -33,6 +32,7 @@ void cSheep::GetDrops(cItems & a_Drops, cEntity * a_Killer) + void cSheep::OnRightClicked(cPlayer & a_Player) { if ((a_Player.GetEquippedItem().m_ItemType == E_ITEM_SHEARS) && (!m_IsSheared)) @@ -46,11 +46,26 @@ void cSheep::OnRightClicked(cPlayer & a_Player) } cItems Drops; - Drops.push_back(cItem(E_BLOCK_WOOL, 4, m_WoolColor)); - m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10); + int wooldrops = m_World->GetTickRandomNumber(2); + if (wooldrops == 0) + { + Drops.push_back(cItem(E_BLOCK_WOOL, 1, m_WoolColor)); + m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10); + } + if (wooldrops == 1) + { + Drops.push_back(cItem(E_BLOCK_WOOL, 2, m_WoolColor)); + m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10); + } + if (wooldrops == 2) + { + Drops.push_back(cItem(E_BLOCK_WOOL, 3, m_WoolColor)); + m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10); + } } } + -- cgit v1.2.3 From 144b528257140710856d6150e854b08f0e5368b9 Mon Sep 17 00:00:00 2001 From: tonibm19 Date: Sun, 27 Oct 2013 10:42:16 +0100 Subject: Extra line --- source/Mobs/Sheep.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'source/Mobs') diff --git a/source/Mobs/Sheep.cpp b/source/Mobs/Sheep.cpp index 54cce9cbe..2a92cf5b2 100644 --- a/source/Mobs/Sheep.cpp +++ b/source/Mobs/Sheep.cpp @@ -1,3 +1,4 @@ + #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "Sheep.h" -- cgit v1.2.3 From 6e554c3b5256c43feb4be66f46b08e9d6440f7b3 Mon Sep 17 00:00:00 2001 From: tonibm19 Date: Mon, 28 Oct 2013 19:42:02 +0100 Subject: Use STR_Warrior code and changed variable name --- source/Mobs/Sheep.cpp | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Sheep.cpp b/source/Mobs/Sheep.cpp index 2a92cf5b2..46749d967 100644 --- a/source/Mobs/Sheep.cpp +++ b/source/Mobs/Sheep.cpp @@ -13,7 +13,7 @@ cSheep::cSheep(int a_Color) : super("Sheep", mtSheep, "mob.sheep.say", "mob.sheep.say", 0.6, 1.3), m_IsSheared(false), - m_WoolColor(0) + m_WoolColor(a_Color) { } @@ -47,22 +47,9 @@ void cSheep::OnRightClicked(cPlayer & a_Player) } cItems Drops; - int wooldrops = m_World->GetTickRandomNumber(2); - if (wooldrops == 0) - { - Drops.push_back(cItem(E_BLOCK_WOOL, 1, m_WoolColor)); - m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10); - } - if (wooldrops == 1) - { - Drops.push_back(cItem(E_BLOCK_WOOL, 2, m_WoolColor)); - m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10); - } - if (wooldrops == 2) - { - Drops.push_back(cItem(E_BLOCK_WOOL, 3, m_WoolColor)); - m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10); - } + int NumDrops = m_World->GetTickRandomumber(2) + 1 + Drops.push_back(cItem(E_BLOCK_WOOL, NumDrops, m_WoolColor)); + m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10); } } -- cgit v1.2.3 From 984277f65e6781ffffc89b7bd382879eda8c8fe6 Mon Sep 17 00:00:00 2001 From: tonibm19 Date: Mon, 28 Oct 2013 19:47:38 +0100 Subject: Fixed compilation STR_Warrior code had an error (I copied&pasted it before) --- source/Mobs/Sheep.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Sheep.cpp b/source/Mobs/Sheep.cpp index 46749d967..5a3b2d015 100644 --- a/source/Mobs/Sheep.cpp +++ b/source/Mobs/Sheep.cpp @@ -47,7 +47,7 @@ void cSheep::OnRightClicked(cPlayer & a_Player) } cItems Drops; - int NumDrops = m_World->GetTickRandomumber(2) + 1 + int NumDrops = m_World->GetTickRandomNumber(2) + 1; Drops.push_back(cItem(E_BLOCK_WOOL, NumDrops, m_WoolColor)); m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10); } -- cgit v1.2.3 From 1eac38f3d7c70295bf986ee02c849d50b3c4f7eb Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 28 Oct 2013 19:54:03 +0100 Subject: Fixed indentation in tonibm19's code. --- source/Mobs/Sheep.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Sheep.cpp b/source/Mobs/Sheep.cpp index 5a3b2d015..703482ddb 100644 --- a/source/Mobs/Sheep.cpp +++ b/source/Mobs/Sheep.cpp @@ -47,9 +47,9 @@ void cSheep::OnRightClicked(cPlayer & a_Player) } cItems Drops; - int NumDrops = m_World->GetTickRandomNumber(2) + 1; - Drops.push_back(cItem(E_BLOCK_WOOL, NumDrops, m_WoolColor)); - m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10); + int NumDrops = m_World->GetTickRandomNumber(2) + 1; + Drops.push_back(cItem(E_BLOCK_WOOL, NumDrops, m_WoolColor)); + m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10); } } -- cgit v1.2.3 From 5a723454a97fbe00e0a83079493b887be6bd9944 Mon Sep 17 00:00:00 2001 From: tonibm19 Date: Mon, 28 Oct 2013 20:27:05 +0100 Subject: Now saddle pigs spawn a saddle pickup when killed --- source/Mobs/Pig.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source/Mobs') diff --git a/source/Mobs/Pig.cpp b/source/Mobs/Pig.cpp index 5427cf35f..0871a38a9 100644 --- a/source/Mobs/Pig.cpp +++ b/source/Mobs/Pig.cpp @@ -22,6 +22,10 @@ cPig::cPig(void) : void cPig::GetDrops(cItems & a_Drops, cEntity * a_Killer) { AddRandomDropItem(a_Drops, 1, 3, IsOnFire() ? E_ITEM_COOKED_PORKCHOP : E_ITEM_RAW_PORKCHOP); + if (m_bIsSaddled) + { + a_Drops.push_back(cItem(E_ITEM_SADDLE, 1)); + } } -- cgit v1.2.3 From 1ff051c9a31a5ebf9b8db4a5aad9361bb4299df8 Mon Sep 17 00:00:00 2001 From: tonibm19 Date: Mon, 28 Oct 2013 20:28:16 +0100 Subject: Now saddled horses spawn a saddle pickup when killed --- source/Mobs/Horse.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Horse.cpp b/source/Mobs/Horse.cpp index f9705a451..d18887ea4 100644 --- a/source/Mobs/Horse.cpp +++ b/source/Mobs/Horse.cpp @@ -1,4 +1,3 @@ - #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "Horse.h" @@ -142,6 +141,10 @@ void cHorse::OnRightClicked(cPlayer & a_Player) void cHorse::GetDrops(cItems & a_Drops, cEntity * a_Killer) { AddRandomDropItem(a_Drops, 0, 2, E_ITEM_LEATHER); + if (m_bIsSaddled) + { + a_Drops.push_back(cItem(E_ITEM_SADDLE, 1)); + } } -- cgit v1.2.3 From e1a06153b2e93473af58e1d801998ff7f388dc6d Mon Sep 17 00:00:00 2001 From: Samuel Barney Date: Tue, 29 Oct 2013 10:44:51 -0600 Subject: Update to allow the light map to remain the same, but allow alteration of sky light values based on time. --- source/Mobs/Monster.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Monster.cpp b/source/Mobs/Monster.cpp index 9b1f2fc4c..72dfb2583 100644 --- a/source/Mobs/Monster.cpp +++ b/source/Mobs/Monster.cpp @@ -609,9 +609,9 @@ int cMonster::GetSpawnDelay(cMonster::eFamily a_MobFamily) { switch (a_MobFamily) { - case mfHostile: return 1; - case mfPassive: return 400; - case mfAmbient: return 400; + case mfHostile: return 40; + case mfPassive: return 40; + case mfAmbient: return 40; case mfWater: return 400; } ASSERT(!"Unhandled mob family"); -- cgit v1.2.3 From 52d956ccf345c46a605894c4962c8171ece4dd87 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Tue, 29 Oct 2013 21:45:31 +0100 Subject: Changed GameMode() == 1 to IsGameModeCreative in AggressiveMonster.cpp and ClientHandle.cpp --- source/Mobs/AggressiveMonster.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/Mobs') diff --git a/source/Mobs/AggressiveMonster.cpp b/source/Mobs/AggressiveMonster.cpp index ee6252656..88bd2743a 100644 --- a/source/Mobs/AggressiveMonster.cpp +++ b/source/Mobs/AggressiveMonster.cpp @@ -33,7 +33,7 @@ void cAggressiveMonster::InStateChasing(float a_Dt) if (m_Target->IsPlayer()) { cPlayer * Player = (cPlayer *) m_Target; - if (Player->GetGameMode() == 1) + if (Player->IsGameModeCreative()) { m_EMState = IDLE; return; -- cgit v1.2.3 From 3dc3e5eca7358a09c7be412b6b735cd38a3eced3 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sat, 2 Nov 2013 20:45:51 +0100 Subject: Zombies and Skeletons don't walk into the sun anymore. --- source/Mobs/Skeleton.cpp | 15 +++++++++++++++ source/Mobs/Skeleton.h | 1 + source/Mobs/Zombie.cpp | 15 +++++++++++++++ source/Mobs/Zombie.h | 1 + 4 files changed, 32 insertions(+) (limited to 'source/Mobs') diff --git a/source/Mobs/Skeleton.cpp b/source/Mobs/Skeleton.cpp index 37a724848..3ca3ebbf7 100644 --- a/source/Mobs/Skeleton.cpp +++ b/source/Mobs/Skeleton.cpp @@ -3,6 +3,8 @@ #include "Skeleton.h" #include "../World.h" +#include "../Entities/ProjectileEntity.h" +#include "../Entities/Entity.h" @@ -28,3 +30,16 @@ void cSkeleton::GetDrops(cItems & a_Drops, cEntity * a_Killer) + +void cSkeleton::MoveToPosition(const Vector3f & a_Position) +{ + m_Destination = a_Position; + + // If the destination is in the sun and if it is not night AND the skeleton isn't on fire then block the movement. + if ((m_World->GetBlockSkyLight((int) a_Position.x, (int) a_Position.y, (int) a_Position.z) == 15) && (m_World->GetTimeOfDay() < 13187) && !IsOnFire()) + { + m_bMovingToDestination = false; + return; + } + m_bMovingToDestination = true; +} \ No newline at end of file diff --git a/source/Mobs/Skeleton.h b/source/Mobs/Skeleton.h index 7a4af7e22..6cede1d22 100644 --- a/source/Mobs/Skeleton.h +++ b/source/Mobs/Skeleton.h @@ -18,6 +18,7 @@ public: CLASS_PROTODEF(cSkeleton); virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; + virtual void MoveToPosition(const Vector3f & a_Position) override; bool IsWither(void) const { return m_bIsWither; }; private: diff --git a/source/Mobs/Zombie.cpp b/source/Mobs/Zombie.cpp index 1752ec390..a485d2b55 100644 --- a/source/Mobs/Zombie.cpp +++ b/source/Mobs/Zombie.cpp @@ -30,3 +30,18 @@ void cZombie::GetDrops(cItems & a_Drops, cEntity * a_Killer) + +void cZombie::MoveToPosition(const Vector3f & a_Position) +{ + m_Destination = a_Position; + + // If the destination is in the sun and if it is not night AND the skeleton isn't on fire then block the movement. + if ((m_World->GetBlockSkyLight((int) a_Position.x, (int) a_Position.y, (int) a_Position.z) == 15) && (m_World->GetTimeOfDay() < 13187) && !IsOnFire()) + { + m_bMovingToDestination = false; + return; + } + m_bMovingToDestination = true; +} + + diff --git a/source/Mobs/Zombie.h b/source/Mobs/Zombie.h index 148b1121e..7e14fe42f 100644 --- a/source/Mobs/Zombie.h +++ b/source/Mobs/Zombie.h @@ -17,6 +17,7 @@ public: CLASS_PROTODEF(cZombie); virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; + virtual void MoveToPosition(const Vector3f & a_Position) override; bool IsVillagerZombie(void) const {return m_bIsVillagerZombie; } bool IsConverting(void) const {return m_bIsConverting; } -- cgit v1.2.3 From 58ced0c12c23275112e16ff29b087f2ceb0bbd6f Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sat, 2 Nov 2013 20:47:43 +0100 Subject: Skeletons, Blazes and Ghasts now shoot their projectile to the target. --- source/Mobs/Monster.cpp | 68 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 63 insertions(+), 5 deletions(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Monster.cpp b/source/Mobs/Monster.cpp index 9b1f2fc4c..0b91df90b 100644 --- a/source/Mobs/Monster.cpp +++ b/source/Mobs/Monster.cpp @@ -441,10 +441,68 @@ void cMonster::Attack(float a_Dt) { m_AttackInterval += a_Dt * m_AttackRate; if ((m_Target != NULL) && (m_AttackInterval > 3.0)) + // Setting this higher gives us more wiggle room for attackrate { - // Setting this higher gives us more wiggle room for attackrate + switch (GetMobType()) + { + case mtSkeleton: + { + Vector3d Speed = GetLookVector() * 20; + Speed.y = Speed.y + 1; + cArrowEntity * Arrow = new cArrowEntity(this, GetPosX(), GetPosY() + 1, GetPosZ(), Speed); + if (Arrow == NULL) + { + return; + } + if (!Arrow->Initialize(m_World)) + { + delete Arrow; + return; + } + m_World->BroadcastSpawnEntity(*Arrow); + break; + } + case mtGhast: + { + Vector3d Speed = GetLookVector() * 20; + Speed.y = Speed.y + 1; + cGhastFireballEntity * GhastBall = new cGhastFireballEntity(this, GetPosX(), GetPosY() + 1, GetPosZ(), Speed); + if (GhastBall == NULL) + { + return; + } + if (!GhastBall->Initialize(m_World)) + { + delete GhastBall; + return; + } + m_World->BroadcastSpawnEntity(*GhastBall); + break; + } + case mtBlaze: + { + Vector3d Speed = GetLookVector() * 20; + Speed.y = Speed.y + 1; + cFireChargeEntity * FireCharge = new cFireChargeEntity(this, GetPosX(), GetPosY() + 1, GetPosZ(), Speed); + if (FireCharge == NULL) + { + return; + } + if (!FireCharge->Initialize(m_World)) + { + delete FireCharge; + return; + } + m_World->BroadcastSpawnEntity(*FireCharge); + break; + // ToDo: Shoot 3 fireballs instead of 1. + } + default: + { + ((cPawn *)m_Target)->TakeDamage(*this); + } + } m_AttackInterval = 0.0; - ((cPawn *)m_Target)->TakeDamage(*this); } } @@ -609,9 +667,9 @@ int cMonster::GetSpawnDelay(cMonster::eFamily a_MobFamily) { switch (a_MobFamily) { - case mfHostile: return 1; - case mfPassive: return 400; - case mfAmbient: return 400; + case mfHostile: return 40; + case mfPassive: return 40; + case mfAmbient: return 40; case mfWater: return 400; } ASSERT(!"Unhandled mob family"); -- cgit v1.2.3 From 6f0f620cf85337ee6175ab599a52cf3ff0e2d5c9 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sat, 2 Nov 2013 21:32:55 +0100 Subject: Skeleton.cpp doesn't have to load ProjectileEntity.h and Entity.h. --- source/Mobs/Skeleton.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Skeleton.cpp b/source/Mobs/Skeleton.cpp index 3ca3ebbf7..578b5eb67 100644 --- a/source/Mobs/Skeleton.cpp +++ b/source/Mobs/Skeleton.cpp @@ -3,9 +3,6 @@ #include "Skeleton.h" #include "../World.h" -#include "../Entities/ProjectileEntity.h" -#include "../Entities/Entity.h" - -- cgit v1.2.3 From 7cfcfc5f398f133f339a4dd8c87b5e02d8043fd3 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Mon, 4 Nov 2013 21:46:56 +0100 Subject: Skeleton, Ghast and Blaze's projectile code is now in their respective class. --- source/Mobs/AggressiveMonster.cpp | 2 +- source/Mobs/Blaze.cpp | 27 ++++++++++++++- source/Mobs/Blaze.h | 1 + source/Mobs/Ghast.cpp | 28 +++++++++++++++- source/Mobs/Ghast.h | 1 + source/Mobs/Monster.cpp | 70 ++++----------------------------------- source/Mobs/Skeleton.cpp | 29 +++++++++++++++- source/Mobs/Skeleton.h | 1 + 8 files changed, 91 insertions(+), 68 deletions(-) (limited to 'source/Mobs') diff --git a/source/Mobs/AggressiveMonster.cpp b/source/Mobs/AggressiveMonster.cpp index 88bd2743a..cc7e7da2b 100644 --- a/source/Mobs/AggressiveMonster.cpp +++ b/source/Mobs/AggressiveMonster.cpp @@ -44,7 +44,7 @@ void cAggressiveMonster::InStateChasing(float a_Dt) Vector3f Their = Vector3f( m_Target->GetPosition() ); if ((Their - Pos).Length() <= m_AttackRange) { - cMonster::Attack(a_Dt); + Attack(a_Dt); } MoveToPosition(Their + Vector3f(0, 0.65f, 0)); } diff --git a/source/Mobs/Blaze.cpp b/source/Mobs/Blaze.cpp index 74c82c081..f9c05b17a 100644 --- a/source/Mobs/Blaze.cpp +++ b/source/Mobs/Blaze.cpp @@ -2,7 +2,7 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "Blaze.h" - +#include "../World.h" @@ -25,3 +25,28 @@ void cBlaze::GetDrops(cItems & a_Drops, cEntity * a_Killer) + +void cBlaze::Attack(float a_Dt) +{ + m_AttackInterval += a_Dt * m_AttackRate; + + if (m_Target != NULL && m_AttackInterval > 3.0) + { + // Setting this higher gives us more wiggle room for attackrate + Vector3d Speed = GetLookVector() * 20; + Speed.y = Speed.y + 1; + cFireChargeEntity * FireCharge = new cFireChargeEntity(this, GetPosX(), GetPosY() + 1, GetPosZ(), Speed); + if (FireCharge == NULL) + { + return; + } + if (!FireCharge->Initialize(m_World)) + { + delete FireCharge; + return; + } + m_World->BroadcastSpawnEntity(*FireCharge); + m_AttackInterval = 0.0; + // ToDo: Shoot 3 fireballs instead of 1. + } +} \ No newline at end of file diff --git a/source/Mobs/Blaze.h b/source/Mobs/Blaze.h index 9df57530e..cdb3a1306 100644 --- a/source/Mobs/Blaze.h +++ b/source/Mobs/Blaze.h @@ -18,6 +18,7 @@ public: CLASS_PROTODEF(cBlaze); virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; + virtual void Attack(float a_Dt) override; } ; diff --git a/source/Mobs/Ghast.cpp b/source/Mobs/Ghast.cpp index 419c8474d..85803cb84 100644 --- a/source/Mobs/Ghast.cpp +++ b/source/Mobs/Ghast.cpp @@ -2,7 +2,7 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "Ghast.h" - +#include "../World.h" @@ -25,3 +25,29 @@ void cGhast::GetDrops(cItems & a_Drops, cEntity * a_Killer) +void cGhast::Attack(float a_Dt) +{ + m_AttackInterval += a_Dt * m_AttackRate; + + if (m_Target != NULL && m_AttackInterval > 3.0) + { + // Setting this higher gives us more wiggle room for attackrate + Vector3d Speed = GetLookVector() * 20; + Speed.y = Speed.y + 1; + cGhastFireballEntity * GhastBall = new cGhastFireballEntity(this, GetPosX(), GetPosY() + 1, GetPosZ(), Speed); + if (GhastBall == NULL) + { + return; + } + if (!GhastBall->Initialize(m_World)) + { + delete GhastBall; + return; + } + m_World->BroadcastSpawnEntity(*GhastBall); + m_AttackInterval = 0.0; + } +} + + + diff --git a/source/Mobs/Ghast.h b/source/Mobs/Ghast.h index a2adc21b9..43e8bedb6 100644 --- a/source/Mobs/Ghast.h +++ b/source/Mobs/Ghast.h @@ -18,6 +18,7 @@ public: CLASS_PROTODEF(cGhast); virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; + virtual void Attack(float a_Dt) override; bool IsCharging(void) const {return false; } } ; diff --git a/source/Mobs/Monster.cpp b/source/Mobs/Monster.cpp index 0b91df90b..9d2be1e29 100644 --- a/source/Mobs/Monster.cpp +++ b/source/Mobs/Monster.cpp @@ -440,70 +440,12 @@ void cMonster::InStateEscaping(float a_Dt) void cMonster::Attack(float a_Dt) { m_AttackInterval += a_Dt * m_AttackRate; - if ((m_Target != NULL) && (m_AttackInterval > 3.0)) - // Setting this higher gives us more wiggle room for attackrate - { - switch (GetMobType()) - { - case mtSkeleton: - { - Vector3d Speed = GetLookVector() * 20; - Speed.y = Speed.y + 1; - cArrowEntity * Arrow = new cArrowEntity(this, GetPosX(), GetPosY() + 1, GetPosZ(), Speed); - if (Arrow == NULL) - { - return; - } - if (!Arrow->Initialize(m_World)) - { - delete Arrow; - return; - } - m_World->BroadcastSpawnEntity(*Arrow); - break; - } - case mtGhast: - { - Vector3d Speed = GetLookVector() * 20; - Speed.y = Speed.y + 1; - cGhastFireballEntity * GhastBall = new cGhastFireballEntity(this, GetPosX(), GetPosY() + 1, GetPosZ(), Speed); - if (GhastBall == NULL) - { - return; - } - if (!GhastBall->Initialize(m_World)) - { - delete GhastBall; - return; - } - m_World->BroadcastSpawnEntity(*GhastBall); - break; - } - case mtBlaze: - { - Vector3d Speed = GetLookVector() * 20; - Speed.y = Speed.y + 1; - cFireChargeEntity * FireCharge = new cFireChargeEntity(this, GetPosX(), GetPosY() + 1, GetPosZ(), Speed); - if (FireCharge == NULL) - { - return; - } - if (!FireCharge->Initialize(m_World)) - { - delete FireCharge; - return; - } - m_World->BroadcastSpawnEntity(*FireCharge); - break; - // ToDo: Shoot 3 fireballs instead of 1. - } - default: - { - ((cPawn *)m_Target)->TakeDamage(*this); - } - } - m_AttackInterval = 0.0; - } + if ((m_Target != NULL) && (m_AttackInterval > 3.0)) + { + // Setting this higher gives us more wiggle room for attackrate + m_AttackInterval = 0.0; + ((cPawn *)m_Target)->TakeDamage(*this); + } } diff --git a/source/Mobs/Skeleton.cpp b/source/Mobs/Skeleton.cpp index 578b5eb67..6a1068337 100644 --- a/source/Mobs/Skeleton.cpp +++ b/source/Mobs/Skeleton.cpp @@ -33,10 +33,37 @@ void cSkeleton::MoveToPosition(const Vector3f & a_Position) m_Destination = a_Position; // If the destination is in the sun and if it is not night AND the skeleton isn't on fire then block the movement. - if ((m_World->GetBlockSkyLight((int) a_Position.x, (int) a_Position.y, (int) a_Position.z) == 15) && (m_World->GetTimeOfDay() < 13187) && !IsOnFire()) + if (!IsOnFire() && m_World->GetTimeOfDay() < 13187 && m_World->GetBlockSkyLight((int) a_Position.x, (int) a_Position.y, (int) a_Position.z) == 15) { m_bMovingToDestination = false; return; } m_bMovingToDestination = true; +} + + + + +void cSkeleton::Attack(float a_Dt) +{ + m_AttackInterval += a_Dt * m_AttackRate; + + if (m_Target != NULL && m_AttackInterval > 3.0) + { + // Setting this higher gives us more wiggle room for attackrate + Vector3d Speed = GetLookVector() * 20; + Speed.y = Speed.y + 1; + cArrowEntity * Arrow = new cArrowEntity(this, GetPosX(), GetPosY() + 1, GetPosZ(), Speed); + if (Arrow == NULL) + { + return; + } + if (!Arrow->Initialize(m_World)) + { + delete Arrow; + return; + } + m_World->BroadcastSpawnEntity(*Arrow); + m_AttackInterval = 0.0; + } } \ No newline at end of file diff --git a/source/Mobs/Skeleton.h b/source/Mobs/Skeleton.h index 6cede1d22..8f31b42e1 100644 --- a/source/Mobs/Skeleton.h +++ b/source/Mobs/Skeleton.h @@ -19,6 +19,7 @@ public: virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; virtual void MoveToPosition(const Vector3f & a_Position) override; + virtual void Attack(float a_Dt) override; bool IsWither(void) const { return m_bIsWither; }; private: -- cgit v1.2.3 From c84bd79eff56865f4754f22313c3a4c970b6aa3f Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Tue, 5 Nov 2013 16:24:54 +0100 Subject: Fixed indentation. --- source/Mobs/Ghast.cpp | 1 + source/Mobs/Skeleton.cpp | 1 + 2 files changed, 2 insertions(+) (limited to 'source/Mobs') diff --git a/source/Mobs/Ghast.cpp b/source/Mobs/Ghast.cpp index 85803cb84..96a29b2d8 100644 --- a/source/Mobs/Ghast.cpp +++ b/source/Mobs/Ghast.cpp @@ -25,6 +25,7 @@ void cGhast::GetDrops(cItems & a_Drops, cEntity * a_Killer) + void cGhast::Attack(float a_Dt) { m_AttackInterval += a_Dt * m_AttackRate; diff --git a/source/Mobs/Skeleton.cpp b/source/Mobs/Skeleton.cpp index 6a1068337..509c2191e 100644 --- a/source/Mobs/Skeleton.cpp +++ b/source/Mobs/Skeleton.cpp @@ -44,6 +44,7 @@ void cSkeleton::MoveToPosition(const Vector3f & a_Position) + void cSkeleton::Attack(float a_Dt) { m_AttackInterval += a_Dt * m_AttackRate; -- cgit v1.2.3 From 4d7695549a8f22e0f83472e6e131275dabb8f362 Mon Sep 17 00:00:00 2001 From: tonibm19 Date: Fri, 8 Nov 2013 14:04:00 +0100 Subject: Now chickens can drop eggs. They drop an egg every 5 or 10 minutes. --- source/Mobs/Chicken.cpp | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Chicken.cpp b/source/Mobs/Chicken.cpp index 434a32f94..ec9edb961 100644 --- a/source/Mobs/Chicken.cpp +++ b/source/Mobs/Chicken.cpp @@ -2,20 +2,46 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "Chicken.h" +#include "../World.h" -// TODO: Drop egg every 5-10 minutes +cChicken::cChicken(void) : + super("Chicken", mtChicken, "mob.chicken.hurt", "mob.chicken.hurt", 0.3, 0.4), + m_DropEggCount(0) +{ +} -cChicken::cChicken(void) : - super("Chicken", mtChicken, "mob.chicken.hurt", "mob.chicken.hurt", 0.3, 0.4) + + +void cChicken::Tick(float a_Dt, cChunk & a_Chunk) { + super::Tick(a_Dt, a_Chunk); + + if (m_DropEggCount == 6000 && m_World->GetTickRandomNumber(1) == 0) + { + cItems Drops; + m_DropEggCount = 0; + Drops.push_back(cItem(E_ITEM_EGG, 1)); + m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10); + } + else if (m_DropEggCount == 12000) + { + cItems Drops; + m_DropEggCount = 0; + Drops.push_back(cItem(E_ITEM_EGG, 1)); + m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10); + } + else + { + m_DropEggCount++; + } } @@ -31,3 +57,7 @@ void cChicken::GetDrops(cItems & a_Drops, cEntity * a_Killer) + + + + -- cgit v1.2.3 From 20d9886847ead593b66bbef779bb4ddda3a3abdd Mon Sep 17 00:00:00 2001 From: tonibm19 Date: Fri, 8 Nov 2013 14:04:41 +0100 Subject: Now chicken drop eggs --- source/Mobs/Chicken.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Chicken.h b/source/Mobs/Chicken.h index 2f674e908..6505a4788 100644 --- a/source/Mobs/Chicken.h +++ b/source/Mobs/Chicken.h @@ -18,8 +18,13 @@ public: CLASS_PROTODEF(cChicken); virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; -} ; + virtual void Tick(float a_Dt, cChunk & a_Chunk) override; + +private: + int m_DropEggCount; +} ; + -- cgit v1.2.3 From 2cf93b8e25c00f2fcedd691747499a6e88ca1411 Mon Sep 17 00:00:00 2001 From: tonibm19 Date: Fri, 8 Nov 2013 17:15:28 +0100 Subject: Changed variable name --- source/Mobs/Chicken.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Chicken.h b/source/Mobs/Chicken.h index 6505a4788..979c4d8a0 100644 --- a/source/Mobs/Chicken.h +++ b/source/Mobs/Chicken.h @@ -1,4 +1,3 @@ - #pragma once #include "PassiveMonster.h" @@ -23,7 +22,7 @@ public: private: - int m_DropEggCount; + int m_EggDropTimer; } ; -- cgit v1.2.3 From 705e6c13016cc00952ccba9f537dd71b7c666c74 Mon Sep 17 00:00:00 2001 From: tonibm19 Date: Fri, 8 Nov 2013 17:16:36 +0100 Subject: Changed variable name --- source/Mobs/Chicken.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Chicken.cpp b/source/Mobs/Chicken.cpp index ec9edb961..318f8a813 100644 --- a/source/Mobs/Chicken.cpp +++ b/source/Mobs/Chicken.cpp @@ -1,4 +1,3 @@ - #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "Chicken.h" @@ -13,7 +12,7 @@ cChicken::cChicken(void) : super("Chicken", mtChicken, "mob.chicken.hurt", "mob.chicken.hurt", 0.3, 0.4), - m_DropEggCount(0) + m_EggDropTimer(0) { } @@ -24,23 +23,23 @@ void cChicken::Tick(float a_Dt, cChunk & a_Chunk) { super::Tick(a_Dt, a_Chunk); - if (m_DropEggCount == 6000 && m_World->GetTickRandomNumber(1) == 0) + if (m_EggDropTimer == 6000 && m_World->GetTickRandomNumber(1) == 0) { cItems Drops; - m_DropEggCount = 0; + m_EggDropTimer = 0; Drops.push_back(cItem(E_ITEM_EGG, 1)); m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10); } - else if (m_DropEggCount == 12000) + else if (m_EggDropTimer == 12000) { cItems Drops; - m_DropEggCount = 0; + m_EggDropTimer = 0; Drops.push_back(cItem(E_ITEM_EGG, 1)); m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10); } else { - m_DropEggCount++; + m_EggDropTimer++; } } -- cgit v1.2.3 From b24bdff308e6a2c35bef1a1ae3ea497a978c84c8 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 8 Nov 2013 21:06:31 +0100 Subject: Fixed code style. --- source/Mobs/Chicken.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Chicken.cpp b/source/Mobs/Chicken.cpp index 318f8a813..087fd088a 100644 --- a/source/Mobs/Chicken.cpp +++ b/source/Mobs/Chicken.cpp @@ -23,14 +23,14 @@ void cChicken::Tick(float a_Dt, cChunk & a_Chunk) { super::Tick(a_Dt, a_Chunk); - if (m_EggDropTimer == 6000 && m_World->GetTickRandomNumber(1) == 0) + if ((m_EggDropTimer == 6000) && (m_World->GetTickRandomNumber(1) == 0)) { cItems Drops; m_EggDropTimer = 0; Drops.push_back(cItem(E_ITEM_EGG, 1)); m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10); } - else if (m_EggDropTimer == 12000) + else if (m_EggDropTimer == 12000) { cItems Drops; m_EggDropTimer = 0; -- cgit v1.2.3 From 38f6fff3fbe7c90899b319f53b08d48714a3c845 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sun, 10 Nov 2013 15:16:43 +0100 Subject: Wolves can now be owned by an entity. They only sit when right clicked by their owner. They beg if the closest player has meat or bones in his hand. They follow their owner. They teleport to their owner if they are more then 30 blocks away. They don't attack players if they are not angry anymore. They don't move if they are sitting. --- source/Mobs/Wolf.cpp | 94 ++++++++++++++++++++++++++++++++++++++++++++++------ source/Mobs/Wolf.h | 23 +++++++++---- 2 files changed, 100 insertions(+), 17 deletions(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Wolf.cpp b/source/Mobs/Wolf.cpp index 2baeb4b7b..e9d3ce394 100644 --- a/source/Mobs/Wolf.cpp +++ b/source/Mobs/Wolf.cpp @@ -14,7 +14,8 @@ cWolf::cWolf(void) : m_bIsAngry(false), m_bIsTame(false), m_bIsSitting(false), - m_bIsBegging(false) + m_bIsBegging(false), + m_bOwner(NULL) { } @@ -38,7 +39,7 @@ void cWolf::DoTakeDamage(TakeDamageInfo & a_TDI) void cWolf::OnRightClicked(cPlayer & a_Player) { - if ((!m_bIsTame) && (!m_bIsAngry)) + if ((!IsTame()) && (!IsAngry())) { if (a_Player.GetEquippedItem().m_ItemType == E_ITEM_BONE) { @@ -47,10 +48,11 @@ void cWolf::OnRightClicked(cPlayer & a_Player) a_Player.GetInventory().RemoveOneEquippedItem(); } - if (m_World->GetTickRandomNumber(10) == 5) + if (m_World->GetTickRandomNumber(7) == 0) { SetMaxHealth(20); - m_bIsTame = true; + SetIsTame(true); + SetOwner(&a_Player); m_World->BroadcastEntityStatus(*this, ENTITY_STATUS_WOLF_TAMED); } else @@ -59,15 +61,18 @@ void cWolf::OnRightClicked(cPlayer & a_Player) } } } - else if (m_bIsTame) + else if (IsTame()) { - if (m_bIsSitting) + if (m_bOwner != NULL && a_Player.GetUniqueID() == m_bOwner->GetUniqueID()) // Is the player the owner of the dog? { - m_bIsSitting = false; - } - else - { - m_bIsSitting = true; + if (IsSitting()) + { + SetIsSitting(false); + } + else + { + SetIsSitting(true); + } } } @@ -77,3 +82,70 @@ void cWolf::OnRightClicked(cPlayer & a_Player) + +void cWolf::Tick(float a_Dt, cChunk & a_Chunk) +{ + if (!IsAngry()) + { + super::cMonster::Tick(a_Dt, a_Chunk); + } else { + super::Tick(a_Dt, a_Chunk); + } + + if (IsSitting()) + { + m_bMovingToDestination = false; + } + + cPlayer * a_Closest_Player = FindClosestPlayer(); + if (a_Closest_Player != NULL) + { + switch (a_Closest_Player->GetEquippedItem().m_ItemType) + { + case E_ITEM_BONE: + case E_ITEM_RAW_BEEF: + case E_ITEM_STEAK: + case E_ITEM_RAW_CHICKEN: + case E_ITEM_COOKED_CHICKEN: + case E_ITEM_ROTTEN_FLESH: + { + if (!IsBegging()) + { + SetIsBegging(true); + m_World->BroadcastEntityMetadata(*this); + } + Vector3f a_NewDestination = a_Closest_Player->GetPosition(); + a_NewDestination.y = a_NewDestination.y + 1; // Look at the head of the player, not his feet. + m_Destination = Vector3f(a_NewDestination); + m_bMovingToDestination = false; + break; + } + default: + { + if (IsBegging()) + { + SetIsBegging(false); + m_World->BroadcastEntityMetadata(*this); + } + } + } + } + + if (IsTame()) + { + if (m_bOwner != NULL) + { + Vector3f OwnerCoords = m_bOwner->GetPosition(); + double Distance = (OwnerCoords - GetPosition()).Length(); + if (Distance < 3) + { + m_bMovingToDestination = false; + } else if((Distance > 30) && (!IsSitting())) { + TeleportToEntity(*m_bOwner); + } else { + m_Destination = OwnerCoords; + } + } + } + +} \ No newline at end of file diff --git a/source/Mobs/Wolf.h b/source/Mobs/Wolf.h index 98074ba11..e1ce25200 100644 --- a/source/Mobs/Wolf.h +++ b/source/Mobs/Wolf.h @@ -2,6 +2,7 @@ #pragma once #include "PassiveAggressiveMonster.h" +#include "../Entities/Entity.h" @@ -19,11 +20,21 @@ public: virtual void DoTakeDamage(TakeDamageInfo & a_TDI) override; virtual void OnRightClicked(cPlayer & a_Player) override; - - bool IsSitting(void) const { return m_bIsSitting; } - bool IsTame(void) const { return m_bIsTame; } - bool IsBegging(void) const { return m_bIsBegging; } - bool IsAngry(void) const { return m_bIsAngry; } + virtual void Tick(float a_Dt, cChunk & a_Chunk) override; + + // Get functions + bool IsSitting(void) const { return m_bIsSitting; } + bool IsTame(void) const { return m_bIsTame; } + bool IsBegging(void) const { return m_bIsBegging; } + bool IsAngry(void) const { return m_bIsAngry; } + cEntity * GetOwner(void) const { return m_bOwner; } + + // Set functions + void SetIsSitting(bool a_IsSitting) { m_bIsSitting = a_IsSitting; } + void SetIsTame(bool a_IsTame) { m_bIsTame = a_IsTame; } + void SetIsBegging(bool a_IsBegging) { m_bIsBegging = a_IsBegging; } + void SetIsAngry(bool a_IsAngry) { m_bIsAngry = a_IsAngry; } + void SetOwner(cEntity * a_Entity) { m_bOwner = a_Entity; } private: @@ -31,7 +42,7 @@ private: bool m_bIsTame; bool m_bIsBegging; bool m_bIsAngry; - + cEntity * m_bOwner; } ; -- cgit v1.2.3 From 09805679120dc5aa5f236664245c475a4a34d197 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sun, 10 Nov 2013 15:51:32 +0100 Subject: Using cMonster::Tick instead of super::cMonster::Tick --- source/Mobs/Wolf.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Wolf.cpp b/source/Mobs/Wolf.cpp index e9d3ce394..ad8360445 100644 --- a/source/Mobs/Wolf.cpp +++ b/source/Mobs/Wolf.cpp @@ -87,7 +87,7 @@ void cWolf::Tick(float a_Dt, cChunk & a_Chunk) { if (!IsAngry()) { - super::cMonster::Tick(a_Dt, a_Chunk); + cMonster::Tick(a_Dt, a_Chunk); } else { super::Tick(a_Dt, a_Chunk); } -- cgit v1.2.3 From e919496025bdb2dfc47e4686d767ffaa88b007af Mon Sep 17 00:00:00 2001 From: tonibm19 Date: Sun, 10 Nov 2013 16:03:00 +0100 Subject: Added sheep dyeing --- source/Mobs/Sheep.cpp | 158 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 156 insertions(+), 2 deletions(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Sheep.cpp b/source/Mobs/Sheep.cpp index 703482ddb..85081b294 100644 --- a/source/Mobs/Sheep.cpp +++ b/source/Mobs/Sheep.cpp @@ -33,7 +33,6 @@ void cSheep::GetDrops(cItems & a_Drops, cEntity * a_Killer) - void cSheep::OnRightClicked(cPlayer & a_Player) { if ((a_Player.GetEquippedItem().m_ItemType == E_ITEM_SHEARS) && (!m_IsSheared)) @@ -51,9 +50,164 @@ void cSheep::OnRightClicked(cPlayer & a_Player) Drops.push_back(cItem(E_BLOCK_WOOL, NumDrops, m_WoolColor)); m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10); } -} + if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_BLACK) + { + m_WoolColor = 15; + m_World->BroadcastEntityMetadata(*this); + + if (!a_Player.IsGameModeCreative()) + { + a_Player.GetInventory().RemoveOneEquippedItem(); + } + } + if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_RED) + { + m_WoolColor = 14; + m_World->BroadcastEntityMetadata(*this); + + if (!a_Player.IsGameModeCreative()) + { + a_Player.GetInventory().RemoveOneEquippedItem(); + } + } + if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_GREEN) + { + m_WoolColor = 13; + m_World->BroadcastEntityMetadata(*this); + + if (!a_Player.IsGameModeCreative()) + { + a_Player.GetInventory().RemoveOneEquippedItem(); + } + } + if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_BROWN) + { + m_WoolColor = 12; + m_World->BroadcastEntityMetadata(*this); + + if (!a_Player.IsGameModeCreative()) + { + a_Player.GetInventory().RemoveOneEquippedItem(); + } + } + if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_BLUE) + { + m_WoolColor = 11; + m_World->BroadcastEntityMetadata(*this); + + if (!a_Player.IsGameModeCreative()) + { + a_Player.GetInventory().RemoveOneEquippedItem(); + } + } + if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_PURPLE) + { + m_WoolColor = 10; + m_World->BroadcastEntityMetadata(*this); + + if (!a_Player.IsGameModeCreative()) + { + a_Player.GetInventory().RemoveOneEquippedItem(); + } + } + if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_CYAN) + { + m_WoolColor = 9; + m_World->BroadcastEntityMetadata(*this); + + if (!a_Player.IsGameModeCreative()) + { + a_Player.GetInventory().RemoveOneEquippedItem(); + } + } + if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_LIGHTGRAY) + { + m_WoolColor = 8; + m_World->BroadcastEntityMetadata(*this); + + if (!a_Player.IsGameModeCreative()) + { + a_Player.GetInventory().RemoveOneEquippedItem(); + } + } + if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_GRAY) + { + m_WoolColor = 7; + m_World->BroadcastEntityMetadata(*this); + if (!a_Player.IsGameModeCreative()) + { + a_Player.GetInventory().RemoveOneEquippedItem(); + } + } + if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_PINK) + { + m_WoolColor = 6; + m_World->BroadcastEntityMetadata(*this); + if (!a_Player.IsGameModeCreative()) + { + a_Player.GetInventory().RemoveOneEquippedItem(); + } + } + if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_LIGHTGREEN) + { + m_WoolColor = 5; + m_World->BroadcastEntityMetadata(*this); + if (!a_Player.IsGameModeCreative()) + { + a_Player.GetInventory().RemoveOneEquippedItem(); + } + } + if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_YELLOW) + { + m_WoolColor = 4; + m_World->BroadcastEntityMetadata(*this); + if (!a_Player.IsGameModeCreative()) + { + a_Player.GetInventory().RemoveOneEquippedItem(); + } + } + if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_LIGHTBLUE) + { + m_WoolColor = 3; + m_World->BroadcastEntityMetadata(*this); + + if (!a_Player.IsGameModeCreative()) + { + a_Player.GetInventory().RemoveOneEquippedItem(); + } + } + if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_MAGENTA) + { + m_WoolColor = 2; + m_World->BroadcastEntityMetadata(*this); + if (!a_Player.IsGameModeCreative()) + { + a_Player.GetInventory().RemoveOneEquippedItem(); + } + } + if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_ORANGE) + { + m_WoolColor = 1; + m_World->BroadcastEntityMetadata(*this); + + if (!a_Player.IsGameModeCreative()) + { + a_Player.GetInventory().RemoveOneEquippedItem(); + } + } + if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_WHITE) + { + m_WoolColor = 0; + m_World->BroadcastEntityMetadata(*this); + + if (!a_Player.IsGameModeCreative()) + { + a_Player.GetInventory().RemoveOneEquippedItem(); + } + } +} -- cgit v1.2.3 From 9da4011a7fc0f98efb2f1a9d8ad5af6e7bb0a5a9 Mon Sep 17 00:00:00 2001 From: tonibm19 Date: Sun, 10 Nov 2013 16:42:38 +0100 Subject: You can no longer color with wood --- source/Mobs/Sheep.cpp | 319 +++++++++++++++++++++++++------------------------- 1 file changed, 161 insertions(+), 158 deletions(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Sheep.cpp b/source/Mobs/Sheep.cpp index 85081b294..f9fc5a60c 100644 --- a/source/Mobs/Sheep.cpp +++ b/source/Mobs/Sheep.cpp @@ -50,164 +50,167 @@ void cSheep::OnRightClicked(cPlayer & a_Player) Drops.push_back(cItem(E_BLOCK_WOOL, NumDrops, m_WoolColor)); m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10); } - if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_BLACK) - { - m_WoolColor = 15; - m_World->BroadcastEntityMetadata(*this); - - if (!a_Player.IsGameModeCreative()) - { - a_Player.GetInventory().RemoveOneEquippedItem(); - } - } - if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_RED) - { - m_WoolColor = 14; - m_World->BroadcastEntityMetadata(*this); - - if (!a_Player.IsGameModeCreative()) - { - a_Player.GetInventory().RemoveOneEquippedItem(); - } - } - if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_GREEN) - { - m_WoolColor = 13; - m_World->BroadcastEntityMetadata(*this); - - if (!a_Player.IsGameModeCreative()) - { - a_Player.GetInventory().RemoveOneEquippedItem(); - } - } - if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_BROWN) - { - m_WoolColor = 12; - m_World->BroadcastEntityMetadata(*this); - - if (!a_Player.IsGameModeCreative()) - { - a_Player.GetInventory().RemoveOneEquippedItem(); - } - } - if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_BLUE) - { - m_WoolColor = 11; - m_World->BroadcastEntityMetadata(*this); - - if (!a_Player.IsGameModeCreative()) - { - a_Player.GetInventory().RemoveOneEquippedItem(); - } - } - if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_PURPLE) - { - m_WoolColor = 10; - m_World->BroadcastEntityMetadata(*this); - - if (!a_Player.IsGameModeCreative()) - { - a_Player.GetInventory().RemoveOneEquippedItem(); - } - } - if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_CYAN) - { - m_WoolColor = 9; - m_World->BroadcastEntityMetadata(*this); - - if (!a_Player.IsGameModeCreative()) - { - a_Player.GetInventory().RemoveOneEquippedItem(); - } - } - if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_LIGHTGRAY) - { - m_WoolColor = 8; - m_World->BroadcastEntityMetadata(*this); - - if (!a_Player.IsGameModeCreative()) - { - a_Player.GetInventory().RemoveOneEquippedItem(); - } - } - if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_GRAY) - { - m_WoolColor = 7; - m_World->BroadcastEntityMetadata(*this); - - if (!a_Player.IsGameModeCreative()) - { - a_Player.GetInventory().RemoveOneEquippedItem(); - } - } - if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_PINK) - { - m_WoolColor = 6; - m_World->BroadcastEntityMetadata(*this); - - if (!a_Player.IsGameModeCreative()) - { - a_Player.GetInventory().RemoveOneEquippedItem(); - } - } - if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_LIGHTGREEN) - { - m_WoolColor = 5; - m_World->BroadcastEntityMetadata(*this); - - if (!a_Player.IsGameModeCreative()) - { - a_Player.GetInventory().RemoveOneEquippedItem(); - } - } - if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_YELLOW) - { - m_WoolColor = 4; - m_World->BroadcastEntityMetadata(*this); - - if (!a_Player.IsGameModeCreative()) - { - a_Player.GetInventory().RemoveOneEquippedItem(); - } - } - if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_LIGHTBLUE) - { - m_WoolColor = 3; - m_World->BroadcastEntityMetadata(*this); - - if (!a_Player.IsGameModeCreative()) - { - a_Player.GetInventory().RemoveOneEquippedItem(); - } - } - if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_MAGENTA) - { - m_WoolColor = 2; - m_World->BroadcastEntityMetadata(*this); - - if (!a_Player.IsGameModeCreative()) - { - a_Player.GetInventory().RemoveOneEquippedItem(); - } - } - if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_ORANGE) - { - m_WoolColor = 1; - m_World->BroadcastEntityMetadata(*this); - - if (!a_Player.IsGameModeCreative()) - { - a_Player.GetInventory().RemoveOneEquippedItem(); - } - } - if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_WHITE) - { - m_WoolColor = 0; - m_World->BroadcastEntityMetadata(*this); - - if (!a_Player.IsGameModeCreative()) - { - a_Player.GetInventory().RemoveOneEquippedItem(); + if (a_Player.GetEquippedItem().m_ItemType == E_ITEM_DYE + ) + if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_BLACK) + { + m_WoolColor = 15; + m_World->BroadcastEntityMetadata(*this); + + if (!a_Player.IsGameModeCreative()) + { + a_Player.GetInventory().RemoveOneEquippedItem(); + } + } + if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_RED) + { + m_WoolColor = 14; + m_World->BroadcastEntityMetadata(*this); + + if (!a_Player.IsGameModeCreative()) + { + a_Player.GetInventory().RemoveOneEquippedItem(); + } + } + if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_GREEN) + { + m_WoolColor = 13; + m_World->BroadcastEntityMetadata(*this); + + if (!a_Player.IsGameModeCreative()) + { + a_Player.GetInventory().RemoveOneEquippedItem(); + } + } + if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_BROWN) + { + m_WoolColor = 12; + m_World->BroadcastEntityMetadata(*this); + + if (!a_Player.IsGameModeCreative()) + { + a_Player.GetInventory().RemoveOneEquippedItem(); + } + } + if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_BLUE) + { + m_WoolColor = 11; + m_World->BroadcastEntityMetadata(*this); + + if (!a_Player.IsGameModeCreative()) + { + a_Player.GetInventory().RemoveOneEquippedItem(); + } + } + if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_PURPLE) + { + m_WoolColor = 10; + m_World->BroadcastEntityMetadata(*this); + + if (!a_Player.IsGameModeCreative()) + { + a_Player.GetInventory().RemoveOneEquippedItem(); + } + } + if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_CYAN) + { + m_WoolColor = 9; + m_World->BroadcastEntityMetadata(*this); + + if (!a_Player.IsGameModeCreative()) + { + a_Player.GetInventory().RemoveOneEquippedItem(); + } + } + if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_LIGHTGRAY) + { + m_WoolColor = 8; + m_World->BroadcastEntityMetadata(*this); + + if (!a_Player.IsGameModeCreative()) + { + a_Player.GetInventory().RemoveOneEquippedItem(); + } + } + if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_GRAY) + { + m_WoolColor = 7; + m_World->BroadcastEntityMetadata(*this); + + if (!a_Player.IsGameModeCreative()) + { + a_Player.GetInventory().RemoveOneEquippedItem(); + } + } + if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_PINK) + { + m_WoolColor = 6; + m_World->BroadcastEntityMetadata(*this); + + if (!a_Player.IsGameModeCreative()) + { + a_Player.GetInventory().RemoveOneEquippedItem(); + } + } + if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_LIGHTGREEN) + { + m_WoolColor = 5; + m_World->BroadcastEntityMetadata(*this); + + if (!a_Player.IsGameModeCreative()) + { + a_Player.GetInventory().RemoveOneEquippedItem(); + } + } + if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_YELLOW) + { + m_WoolColor = 4; + m_World->BroadcastEntityMetadata(*this); + + if (!a_Player.IsGameModeCreative()) + { + a_Player.GetInventory().RemoveOneEquippedItem(); + } + } + if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_LIGHTBLUE) + { + m_WoolColor = 3; + m_World->BroadcastEntityMetadata(*this); + + if (!a_Player.IsGameModeCreative()) + { + a_Player.GetInventory().RemoveOneEquippedItem(); + } + } + if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_MAGENTA) + { + m_WoolColor = 2; + m_World->BroadcastEntityMetadata(*this); + + if (!a_Player.IsGameModeCreative()) + { + a_Player.GetInventory().RemoveOneEquippedItem(); + } + } + if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_ORANGE) + { + m_WoolColor = 1; + m_World->BroadcastEntityMetadata(*this); + + if (!a_Player.IsGameModeCreative()) + { + a_Player.GetInventory().RemoveOneEquippedItem(); + } + } + if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_WHITE) + { + m_WoolColor = 0; + m_World->BroadcastEntityMetadata(*this); + + if (!a_Player.IsGameModeCreative()) + { + a_Player.GetInventory().RemoveOneEquippedItem(); + } } } } -- cgit v1.2.3 From e2b4745bbf657272f13a5d70b129a7f523c46918 Mon Sep 17 00:00:00 2001 From: tonibm19 Date: Sun, 10 Nov 2013 16:43:47 +0100 Subject: Fixed compilation --- source/Mobs/Sheep.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Sheep.cpp b/source/Mobs/Sheep.cpp index f9fc5a60c..de5874132 100644 --- a/source/Mobs/Sheep.cpp +++ b/source/Mobs/Sheep.cpp @@ -1,4 +1,3 @@ - #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "Sheep.h" @@ -50,8 +49,8 @@ void cSheep::OnRightClicked(cPlayer & a_Player) Drops.push_back(cItem(E_BLOCK_WOOL, NumDrops, m_WoolColor)); m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10); } - if (a_Player.GetEquippedItem().m_ItemType == E_ITEM_DYE - ) + if (a_Player.GetEquippedItem().m_ItemType == E_ITEM_DYE) + { if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_BLACK) { m_WoolColor = 15; -- cgit v1.2.3 From da5bd81836f12588a5fcba62e1f4bc27420b5222 Mon Sep 17 00:00:00 2001 From: tonibm19 Date: Sun, 10 Nov 2013 16:48:22 +0100 Subject: STR_Warrior was right. Simplified code. --- source/Mobs/Sheep.cpp | 161 +------------------------------------------------- 1 file changed, 1 insertion(+), 160 deletions(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Sheep.cpp b/source/Mobs/Sheep.cpp index de5874132..e8d0be2ae 100644 --- a/source/Mobs/Sheep.cpp +++ b/source/Mobs/Sheep.cpp @@ -51,165 +51,6 @@ void cSheep::OnRightClicked(cPlayer & a_Player) } if (a_Player.GetEquippedItem().m_ItemType == E_ITEM_DYE) { - if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_BLACK) - { - m_WoolColor = 15; - m_World->BroadcastEntityMetadata(*this); - - if (!a_Player.IsGameModeCreative()) - { - a_Player.GetInventory().RemoveOneEquippedItem(); - } - } - if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_RED) - { - m_WoolColor = 14; - m_World->BroadcastEntityMetadata(*this); - - if (!a_Player.IsGameModeCreative()) - { - a_Player.GetInventory().RemoveOneEquippedItem(); - } - } - if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_GREEN) - { - m_WoolColor = 13; - m_World->BroadcastEntityMetadata(*this); - - if (!a_Player.IsGameModeCreative()) - { - a_Player.GetInventory().RemoveOneEquippedItem(); - } - } - if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_BROWN) - { - m_WoolColor = 12; - m_World->BroadcastEntityMetadata(*this); - - if (!a_Player.IsGameModeCreative()) - { - a_Player.GetInventory().RemoveOneEquippedItem(); - } - } - if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_BLUE) - { - m_WoolColor = 11; - m_World->BroadcastEntityMetadata(*this); - - if (!a_Player.IsGameModeCreative()) - { - a_Player.GetInventory().RemoveOneEquippedItem(); - } - } - if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_PURPLE) - { - m_WoolColor = 10; - m_World->BroadcastEntityMetadata(*this); - - if (!a_Player.IsGameModeCreative()) - { - a_Player.GetInventory().RemoveOneEquippedItem(); - } - } - if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_CYAN) - { - m_WoolColor = 9; - m_World->BroadcastEntityMetadata(*this); - - if (!a_Player.IsGameModeCreative()) - { - a_Player.GetInventory().RemoveOneEquippedItem(); - } - } - if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_LIGHTGRAY) - { - m_WoolColor = 8; - m_World->BroadcastEntityMetadata(*this); - - if (!a_Player.IsGameModeCreative()) - { - a_Player.GetInventory().RemoveOneEquippedItem(); - } - } - if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_GRAY) - { - m_WoolColor = 7; - m_World->BroadcastEntityMetadata(*this); - - if (!a_Player.IsGameModeCreative()) - { - a_Player.GetInventory().RemoveOneEquippedItem(); - } - } - if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_PINK) - { - m_WoolColor = 6; - m_World->BroadcastEntityMetadata(*this); - - if (!a_Player.IsGameModeCreative()) - { - a_Player.GetInventory().RemoveOneEquippedItem(); - } - } - if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_LIGHTGREEN) - { - m_WoolColor = 5; - m_World->BroadcastEntityMetadata(*this); - - if (!a_Player.IsGameModeCreative()) - { - a_Player.GetInventory().RemoveOneEquippedItem(); - } - } - if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_YELLOW) - { - m_WoolColor = 4; - m_World->BroadcastEntityMetadata(*this); - - if (!a_Player.IsGameModeCreative()) - { - a_Player.GetInventory().RemoveOneEquippedItem(); - } - } - if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_LIGHTBLUE) - { - m_WoolColor = 3; - m_World->BroadcastEntityMetadata(*this); - - if (!a_Player.IsGameModeCreative()) - { - a_Player.GetInventory().RemoveOneEquippedItem(); - } - } - if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_MAGENTA) - { - m_WoolColor = 2; - m_World->BroadcastEntityMetadata(*this); - - if (!a_Player.IsGameModeCreative()) - { - a_Player.GetInventory().RemoveOneEquippedItem(); - } - } - if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_ORANGE) - { - m_WoolColor = 1; - m_World->BroadcastEntityMetadata(*this); - - if (!a_Player.IsGameModeCreative()) - { - a_Player.GetInventory().RemoveOneEquippedItem(); - } - } - if (a_Player.GetEquippedItem().m_ItemDamage == E_META_DYE_WHITE) - { - m_WoolColor = 0; - m_World->BroadcastEntityMetadata(*this); - - if (!a_Player.IsGameModeCreative()) - { - a_Player.GetInventory().RemoveOneEquippedItem(); - } - } + m_WoolColor = 15 - a_Player.GetEquippedItem().m_ItemDamage; } } -- cgit v1.2.3 From 4af5868322757b892d976d9549633f40f0e7eeb4 Mon Sep 17 00:00:00 2001 From: tonibm19 Date: Sun, 10 Nov 2013 17:05:19 +0100 Subject: Fixes (SEE DESC) Entity metadata is broadcasted. If player is in survival, his equipped item is removed. If you have green dye, and sheep is green, your equipped item won't be removed. --- source/Mobs/Sheep.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Sheep.cpp b/source/Mobs/Sheep.cpp index e8d0be2ae..bda4ccff8 100644 --- a/source/Mobs/Sheep.cpp +++ b/source/Mobs/Sheep.cpp @@ -1,3 +1,4 @@ + #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "Sheep.h" @@ -49,8 +50,13 @@ void cSheep::OnRightClicked(cPlayer & a_Player) Drops.push_back(cItem(E_BLOCK_WOOL, NumDrops, m_WoolColor)); m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10); } - if (a_Player.GetEquippedItem().m_ItemType == E_ITEM_DYE) + if ((a_Player.GetEquippedItem().m_ItemType == E_ITEM_DYE) && (m_WoolColor != 15 - a_Player.GetEquippedItem().m_ItemDamage)) { m_WoolColor = 15 - a_Player.GetEquippedItem().m_ItemDamage; + if (!a_Player.IsGameModeCreative()) + { + a_Player.GetInventory().RemoveOneEquippedItem(); + } + m_World->BroadcastEntityMetadata(*this); } } -- cgit v1.2.3 From 4f11cd2f8a665dcda7f06c1b5e1c8b8cda7b38ad Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sun, 10 Nov 2013 18:03:19 +0100 Subject: The owner object isn't stored anymore. Instead we use the name of the player. This means only players can now have a wolf, but it fixes the bug where when you log out the wolf isn't your wolf anymore. --- source/Mobs/Wolf.cpp | 28 +++++++++++++++++++++------- source/Mobs/Wolf.h | 6 +++--- 2 files changed, 24 insertions(+), 10 deletions(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Wolf.cpp b/source/Mobs/Wolf.cpp index ad8360445..6d1c5565c 100644 --- a/source/Mobs/Wolf.cpp +++ b/source/Mobs/Wolf.cpp @@ -4,6 +4,7 @@ #include "Wolf.h" #include "../World.h" #include "../Entities/Player.h" +#include "../Root.h" @@ -15,7 +16,7 @@ cWolf::cWolf(void) : m_bIsTame(false), m_bIsSitting(false), m_bIsBegging(false), - m_bOwner(NULL) + m_bOwner("") { } @@ -52,7 +53,7 @@ void cWolf::OnRightClicked(cPlayer & a_Player) { SetMaxHealth(20); SetIsTame(true); - SetOwner(&a_Player); + SetOwner(a_Player.GetName()); m_World->BroadcastEntityStatus(*this, ENTITY_STATUS_WOLF_TAMED); } else @@ -63,7 +64,7 @@ void cWolf::OnRightClicked(cPlayer & a_Player) } else if (IsTame()) { - if (m_bOwner != NULL && a_Player.GetUniqueID() == m_bOwner->GetUniqueID()) // Is the player the owner of the dog? + if (a_Player.GetName() == m_bOwner) // Is the player the owner of the dog? { if (IsSitting()) { @@ -130,22 +131,35 @@ void cWolf::Tick(float a_Dt, cChunk & a_Chunk) } } } + + class cCallback : + public cPlayerListCallback + { + virtual bool Item(cPlayer * Player) override + { + OwnerCoords = Player->GetPosition(); + return false; + } + public: + Vector3f OwnerCoords; + } ; + cCallback Callback; + m_World->FindAndDoWithPlayer(m_bOwner, Callback); + Vector3f OwnerCoords = Callback.OwnerCoords; if (IsTame()) { - if (m_bOwner != NULL) + if (m_bOwner != "") { - Vector3f OwnerCoords = m_bOwner->GetPosition(); double Distance = (OwnerCoords - GetPosition()).Length(); if (Distance < 3) { m_bMovingToDestination = false; } else if((Distance > 30) && (!IsSitting())) { - TeleportToEntity(*m_bOwner); + TeleportToCoords(OwnerCoords.x, OwnerCoords.y, OwnerCoords.z); } else { m_Destination = OwnerCoords; } } } - } \ No newline at end of file diff --git a/source/Mobs/Wolf.h b/source/Mobs/Wolf.h index e1ce25200..fb6bb2355 100644 --- a/source/Mobs/Wolf.h +++ b/source/Mobs/Wolf.h @@ -27,14 +27,14 @@ public: bool IsTame(void) const { return m_bIsTame; } bool IsBegging(void) const { return m_bIsBegging; } bool IsAngry(void) const { return m_bIsAngry; } - cEntity * GetOwner(void) const { return m_bOwner; } + AString GetOwner(void) const { return m_bOwner; } // Set functions void SetIsSitting(bool a_IsSitting) { m_bIsSitting = a_IsSitting; } void SetIsTame(bool a_IsTame) { m_bIsTame = a_IsTame; } void SetIsBegging(bool a_IsBegging) { m_bIsBegging = a_IsBegging; } void SetIsAngry(bool a_IsAngry) { m_bIsAngry = a_IsAngry; } - void SetOwner(cEntity * a_Entity) { m_bOwner = a_Entity; } + void SetOwner(AString a_NewOwner) { m_bOwner = a_NewOwner; } private: @@ -42,7 +42,7 @@ private: bool m_bIsTame; bool m_bIsBegging; bool m_bIsAngry; - cEntity * m_bOwner; + AString m_bOwner; } ; -- cgit v1.2.3 From e62858ec3d027de8c5c4605913ab6261ec19d624 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sun, 10 Nov 2013 20:12:30 +0100 Subject: Using DoWithPlayer instead of FindAndDoWithPlayer for callbacks. You are able to dye the collar. --- source/Mobs/Wolf.cpp | 15 ++++++++++++--- source/Mobs/Wolf.h | 10 ++++++---- 2 files changed, 18 insertions(+), 7 deletions(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Wolf.cpp b/source/Mobs/Wolf.cpp index 6d1c5565c..9880a3442 100644 --- a/source/Mobs/Wolf.cpp +++ b/source/Mobs/Wolf.cpp @@ -16,7 +16,8 @@ cWolf::cWolf(void) : m_bIsTame(false), m_bIsSitting(false), m_bIsBegging(false), - m_bOwner("") + m_bOwner(""), + m_bCollar(14) { } @@ -66,7 +67,15 @@ void cWolf::OnRightClicked(cPlayer & a_Player) { if (a_Player.GetName() == m_bOwner) // Is the player the owner of the dog? { - if (IsSitting()) + if (a_Player.GetEquippedItem().m_ItemType == E_ITEM_DYE) + { + m_bCollar = 15 - a_Player.GetEquippedItem().m_ItemDamage; + if (!a_Player.IsGameModeCreative()) + { + a_Player.GetInventory().RemoveOneEquippedItem(); + } + } + else if (IsSitting()) { SetIsSitting(false); } @@ -144,7 +153,7 @@ void cWolf::Tick(float a_Dt, cChunk & a_Chunk) Vector3f OwnerCoords; } ; cCallback Callback; - m_World->FindAndDoWithPlayer(m_bOwner, Callback); + m_World->DoWithPlayer(m_bOwner, Callback); Vector3f OwnerCoords = Callback.OwnerCoords; if (IsTame()) diff --git a/source/Mobs/Wolf.h b/source/Mobs/Wolf.h index fb6bb2355..2afca8086 100644 --- a/source/Mobs/Wolf.h +++ b/source/Mobs/Wolf.h @@ -28,6 +28,7 @@ public: bool IsBegging(void) const { return m_bIsBegging; } bool IsAngry(void) const { return m_bIsAngry; } AString GetOwner(void) const { return m_bOwner; } + int GetCollarColor(void) const { return m_bCollar; } // Set functions void SetIsSitting(bool a_IsSitting) { m_bIsSitting = a_IsSitting; } @@ -38,11 +39,12 @@ public: private: - bool m_bIsSitting; - bool m_bIsTame; - bool m_bIsBegging; - bool m_bIsAngry; + bool m_bIsSitting; + bool m_bIsTame; + bool m_bIsBegging; + bool m_bIsAngry; AString m_bOwner; + int m_bCollar; } ; -- cgit v1.2.3 From 2ccf9b2b32cbc2b9df7bd89b5dd4077c7bc20b80 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sun, 10 Nov 2013 21:24:36 +0100 Subject: Renamed variables in cWolf. --- source/Mobs/Wolf.cpp | 24 ++++++++++++------------ source/Mobs/Wolf.h | 34 +++++++++++++++++----------------- 2 files changed, 29 insertions(+), 29 deletions(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Wolf.cpp b/source/Mobs/Wolf.cpp index 9880a3442..ac094e870 100644 --- a/source/Mobs/Wolf.cpp +++ b/source/Mobs/Wolf.cpp @@ -12,12 +12,12 @@ cWolf::cWolf(void) : super("Wolf", mtWolf, "mob.wolf.hurt", "mob.wolf.death", 0.6, 0.8), - m_bIsAngry(false), - m_bIsTame(false), - m_bIsSitting(false), - m_bIsBegging(false), - m_bOwner(""), - m_bCollar(14) + m_IsAngry(false), + m_IsTame(false), + m_IsSitting(false), + m_IsBegging(false), + m_Owner(""), + m_Collar(14) { } @@ -28,9 +28,9 @@ cWolf::cWolf(void) : void cWolf::DoTakeDamage(TakeDamageInfo & a_TDI) { super::DoTakeDamage(a_TDI); - if (!m_bIsTame) + if (!m_IsTame) { - m_bIsAngry = true; + m_IsAngry = true; } m_World->BroadcastEntityMetadata(*this); // Broadcast health and possibly angry face } @@ -65,11 +65,11 @@ void cWolf::OnRightClicked(cPlayer & a_Player) } else if (IsTame()) { - if (a_Player.GetName() == m_bOwner) // Is the player the owner of the dog? + if (a_Player.GetName() == m_Owner) // Is the player the owner of the dog? { if (a_Player.GetEquippedItem().m_ItemType == E_ITEM_DYE) { - m_bCollar = 15 - a_Player.GetEquippedItem().m_ItemDamage; + m_Collar = 15 - a_Player.GetEquippedItem().m_ItemDamage; if (!a_Player.IsGameModeCreative()) { a_Player.GetInventory().RemoveOneEquippedItem(); @@ -153,12 +153,12 @@ void cWolf::Tick(float a_Dt, cChunk & a_Chunk) Vector3f OwnerCoords; } ; cCallback Callback; - m_World->DoWithPlayer(m_bOwner, Callback); + m_World->DoWithPlayer(m_Owner, Callback); Vector3f OwnerCoords = Callback.OwnerCoords; if (IsTame()) { - if (m_bOwner != "") + if (m_Owner != "") { double Distance = (OwnerCoords - GetPosition()).Length(); if (Distance < 3) diff --git a/source/Mobs/Wolf.h b/source/Mobs/Wolf.h index 2afca8086..bc26fbf9b 100644 --- a/source/Mobs/Wolf.h +++ b/source/Mobs/Wolf.h @@ -23,28 +23,28 @@ public: virtual void Tick(float a_Dt, cChunk & a_Chunk) override; // Get functions - bool IsSitting(void) const { return m_bIsSitting; } - bool IsTame(void) const { return m_bIsTame; } - bool IsBegging(void) const { return m_bIsBegging; } - bool IsAngry(void) const { return m_bIsAngry; } - AString GetOwner(void) const { return m_bOwner; } - int GetCollarColor(void) const { return m_bCollar; } + bool IsSitting(void) const { return m_IsSitting; } + bool IsTame(void) const { return m_IsTame; } + bool IsBegging(void) const { return m_IsBegging; } + bool IsAngry(void) const { return m_IsAngry; } + AString GetOwner(void) const { return m_Owner; } + int GetCollarColor(void) const { return m_Collar; } // Set functions - void SetIsSitting(bool a_IsSitting) { m_bIsSitting = a_IsSitting; } - void SetIsTame(bool a_IsTame) { m_bIsTame = a_IsTame; } - void SetIsBegging(bool a_IsBegging) { m_bIsBegging = a_IsBegging; } - void SetIsAngry(bool a_IsAngry) { m_bIsAngry = a_IsAngry; } - void SetOwner(AString a_NewOwner) { m_bOwner = a_NewOwner; } + void SetIsSitting(bool a_IsSitting) { m_IsSitting = a_IsSitting; } + void SetIsTame(bool a_IsTame) { m_IsTame = a_IsTame; } + void SetIsBegging(bool a_IsBegging) { m_IsBegging = a_IsBegging; } + void SetIsAngry(bool a_IsAngry) { m_IsAngry = a_IsAngry; } + void SetOwner(AString a_NewOwner) { m_Owner = a_NewOwner; } private: - bool m_bIsSitting; - bool m_bIsTame; - bool m_bIsBegging; - bool m_bIsAngry; - AString m_bOwner; - int m_bCollar; + bool m_IsSitting; + bool m_IsTame; + bool m_IsBegging; + bool m_IsAngry; + AString m_Owner; + int m_Collar; } ; -- 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.cpp | 56 +++++++++++++++++++++++-------------------------- source/Mobs/Monster.h | 7 ++----- 2 files changed, 28 insertions(+), 35 deletions(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Monster.cpp b/source/Mobs/Monster.cpp index 9d2be1e29..33960ea46 100644 --- a/source/Mobs/Monster.cpp +++ b/source/Mobs/Monster.cpp @@ -622,37 +622,41 @@ int cMonster::GetSpawnDelay(cMonster::eFamily a_MobFamily) -cMonster * cMonster::NewMonsterFromType(cMonster::eType a_MobType, int a_Size) +cMonster * cMonster::NewMonsterFromType(cMonster::eType a_MobType) { - cFastRandom Random; - cMonster * toReturn = NULL; + cFastRandom RandomDerps; - // unspecified size get rand[1,3] for Monsters that need size + // Create the mob entity switch (a_MobType) { case mtMagmaCube: - case mtSlime: + case mtSlime: toReturn = new cSlime (RandomDerps.NextInt(2) + 1); break; // Size parameter + case mtSheep: toReturn = new cSheep (RandomDerps.NextInt(15)); break; // Colour parameter + case mtSkeleton: toReturn = new cSkeleton ((bool)(RandomDerps.NextInt(1))); break; // TODO: Actual detection of spawning in Nether + case mtZombie: toReturn = new cZombie (false); break; // TODO: Infected zombie parameter + case mtVillager: { - if (a_Size == -1) - { - a_Size = Random.NextInt(2, a_MobType) + 1; - } - if ((a_Size <= 0) || (a_Size >= 4)) - { - ASSERT(!"Random for size was supposed to pick in [1..3] and picked outside"); - a_Size = 1; - } + int VilType = RandomDerps.NextInt(6); + if (VilType == 6) { VilType = 0; } // Give farmers a better chance of spawning + + toReturn = new cVillager(cVillager::eVillagerType(VilType)); // Type (blacksmith, butcher, etc.) parameter + break; + } + case mtHorse: + { + // Horses take a type (species), a colour, and a style (dots, stripes, etc.) + int HseType = RandomDerps.NextInt(7); + int HseColor = RandomDerps.NextInt(6); + int HseStyle = RandomDerps.NextInt(6); + int HseTameTimes = RandomDerps.NextInt(6) + 1; + + if ((HseType == 5) || (HseType == 6) || (HseType == 7)) { HseType = 0; } // Increase chances of normal horse (zero) + + toReturn = new cHorse(HseType, HseColor, HseStyle, HseTameTimes); break; } - default: break; - } // switch (a_MobType) - // Create the mob entity - switch (a_MobType) - { - case mtMagmaCube: toReturn = new cMagmaCube(a_Size); break; - case mtSlime: toReturn = new cSlime(a_Size); break; case mtBat: toReturn = new cBat(); break; case mtBlaze: toReturn = new cBlaze(); break; case mtCaveSpider: toReturn = new cCavespider(); break; @@ -661,26 +665,18 @@ cMonster * cMonster::NewMonsterFromType(cMonster::eType a_MobType, int a_Size) case mtCreeper: toReturn = new cCreeper(); break; case mtEnderman: toReturn = new cEnderman(); break; case mtGhast: toReturn = new cGhast(); break; - // TODO: - // case cMonster::mtHorse: toReturn = new cHorse(); break; case mtMooshroom: toReturn = new cMooshroom(); break; case mtOcelot: toReturn = new cOcelot(); break; case mtPig: toReturn = new cPig(); break; - // TODO: Implement sheep color - case mtSheep: toReturn = new cSheep(0); break; case mtSilverfish: toReturn = new cSilverfish(); break; - // TODO: Implement wither skeleton geration - case mtSkeleton: toReturn = new cSkeleton(false); break; case mtSpider: toReturn = new cSpider(); break; case mtSquid: toReturn = new cSquid(); break; - case mtVillager: toReturn = new cVillager(cVillager::vtFarmer); break; case mtWitch: toReturn = new cWitch(); break; case mtWolf: toReturn = new cWolf(); break; - case mtZombie: toReturn = new cZombie(false); break; case mtZombiePigman: toReturn = new cZombiePigman(); break; default: { - ASSERT(!"Unhandled Mob type"); + ASSERT(!"Unhandled mob type whilst trying to spawn mob!"); } } return toReturn; 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 dadae874f20259e88d20e7ccbb34c8617e69bf40 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 10 Nov 2013 21:55:32 +0100 Subject: Small code-style fixes. --- source/Mobs/Wolf.cpp | 27 ++++++++++++++++++--------- source/Mobs/Wolf.h | 27 ++++++++++++++------------- 2 files changed, 32 insertions(+), 22 deletions(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Wolf.cpp b/source/Mobs/Wolf.cpp index ac094e870..02052e374 100644 --- a/source/Mobs/Wolf.cpp +++ b/source/Mobs/Wolf.cpp @@ -17,7 +17,7 @@ cWolf::cWolf(void) : m_IsSitting(false), m_IsBegging(false), m_Owner(""), - m_Collar(14) + m_CollarColor(14) { } @@ -41,7 +41,7 @@ void cWolf::DoTakeDamage(TakeDamageInfo & a_TDI) void cWolf::OnRightClicked(cPlayer & a_Player) { - if ((!IsTame()) && (!IsAngry())) + if (!IsTame() && !IsAngry()) { if (a_Player.GetEquippedItem().m_ItemType == E_ITEM_BONE) { @@ -69,7 +69,7 @@ void cWolf::OnRightClicked(cPlayer & a_Player) { if (a_Player.GetEquippedItem().m_ItemType == E_ITEM_DYE) { - m_Collar = 15 - a_Player.GetEquippedItem().m_ItemDamage; + m_CollarColor = 15 - a_Player.GetEquippedItem().m_ItemDamage; if (!a_Player.IsGameModeCreative()) { a_Player.GetInventory().RemoveOneEquippedItem(); @@ -98,7 +98,9 @@ void cWolf::Tick(float a_Dt, cChunk & a_Chunk) if (!IsAngry()) { cMonster::Tick(a_Dt, a_Chunk); - } else { + } + else + { super::Tick(a_Dt, a_Chunk); } @@ -151,8 +153,7 @@ void cWolf::Tick(float a_Dt, cChunk & a_Chunk) } public: Vector3f OwnerCoords; - } ; - cCallback Callback; + } Callback; m_World->DoWithPlayer(m_Owner, Callback); Vector3f OwnerCoords = Callback.OwnerCoords; @@ -164,11 +165,19 @@ void cWolf::Tick(float a_Dt, cChunk & a_Chunk) if (Distance < 3) { m_bMovingToDestination = false; - } else if((Distance > 30) && (!IsSitting())) { + } + else if ((Distance > 30) && (!IsSitting())) + { TeleportToCoords(OwnerCoords.x, OwnerCoords.y, OwnerCoords.z); - } else { + } + else + { m_Destination = OwnerCoords; } } } -} \ No newline at end of file +} + + + + diff --git a/source/Mobs/Wolf.h b/source/Mobs/Wolf.h index bc26fbf9b..d51d4e78a 100644 --- a/source/Mobs/Wolf.h +++ b/source/Mobs/Wolf.h @@ -23,28 +23,29 @@ public: virtual void Tick(float a_Dt, cChunk & a_Chunk) override; // Get functions - bool IsSitting(void) const { return m_IsSitting; } - bool IsTame(void) const { return m_IsTame; } - bool IsBegging(void) const { return m_IsBegging; } - bool IsAngry(void) const { return m_IsAngry; } - AString GetOwner(void) const { return m_Owner; } - int GetCollarColor(void) const { return m_Collar; } + bool IsSitting (void) const { return m_IsSitting; } + bool IsTame (void) const { return m_IsTame; } + bool IsBegging (void) const { return m_IsBegging; } + bool IsAngry (void) const { return m_IsAngry; } + AString GetOwner (void) const { return m_Owner; } + int GetCollarColor(void) const { return m_CollarColor; } // Set functions - void SetIsSitting(bool a_IsSitting) { m_IsSitting = a_IsSitting; } - void SetIsTame(bool a_IsTame) { m_IsTame = a_IsTame; } - void SetIsBegging(bool a_IsBegging) { m_IsBegging = a_IsBegging; } - void SetIsAngry(bool a_IsAngry) { m_IsAngry = a_IsAngry; } - void SetOwner(AString a_NewOwner) { m_Owner = a_NewOwner; } + void SetIsSitting (bool a_IsSitting) { m_IsSitting = a_IsSitting; } + void SetIsTame (bool a_IsTame) { m_IsTame = a_IsTame; } + void SetIsBegging (bool a_IsBegging) { m_IsBegging = a_IsBegging; } + void SetIsAngry (bool a_IsAngry) { m_IsAngry = a_IsAngry; } + void SetOwner (AString a_NewOwner) { m_Owner = a_NewOwner; } + void SetCollarColor(int a_CollarColor) { m_CollarColor = a_CollarColor; } -private: +protected: bool m_IsSitting; bool m_IsTame; bool m_IsBegging; bool m_IsAngry; AString m_Owner; - int m_Collar; + int m_CollarColor; } ; -- cgit v1.2.3 From 1682c61b596875ebb1b9ba83504e54111c030624 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sun, 10 Nov 2013 21:56:37 +0100 Subject: Removed #include "../Root.h" since it isn't needed. --- source/Mobs/Wolf.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Wolf.cpp b/source/Mobs/Wolf.cpp index ac094e870..d725e1668 100644 --- a/source/Mobs/Wolf.cpp +++ b/source/Mobs/Wolf.cpp @@ -4,7 +4,6 @@ #include "Wolf.h" #include "../World.h" #include "../Entities/Player.h" -#include "../Root.h" -- cgit v1.2.3 From 165f68b8d92975c0988cf79885f5ee5c967c8e13 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sun, 10 Nov 2013 21:56:37 +0100 Subject: Removed #include "../Root.h" since it isn't needed. --- source/Mobs/Wolf.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Wolf.cpp b/source/Mobs/Wolf.cpp index 02052e374..b9db53c7f 100644 --- a/source/Mobs/Wolf.cpp +++ b/source/Mobs/Wolf.cpp @@ -4,7 +4,6 @@ #include "Wolf.h" #include "../World.h" #include "../Entities/Player.h" -#include "../Root.h" -- cgit v1.2.3 From f713780db31e22345a1faf048ab948b1b4e03200 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 10 Nov 2013 22:20:25 +0000 Subject: Bundled fixes [SEE DESC] * Fixed compiler warning in Monster.cpp * Future proofed particle effects * Improved pickups, made less jittery --- source/Mobs/Horse.cpp | 8 ++++---- source/Mobs/Monster.cpp | 7 ++++++- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Horse.cpp b/source/Mobs/Horse.cpp index d18887ea4..bb9a4e3f6 100644 --- a/source/Mobs/Horse.cpp +++ b/source/Mobs/Horse.cpp @@ -55,10 +55,10 @@ void cHorse::Tick(float a_Dt, cChunk & a_Chunk) { if (m_World->GetTickRandomNumber(50) == 25) { - m_World->BroadcastSoundParticleEffect(2000, (int)(floor(GetPosX()) * 8), (int)(floor(GetPosY()) * 8), (int)(floor(GetPosZ()) * 8), 0); - m_World->BroadcastSoundParticleEffect(2000, (int)(floor(GetPosX()) * 8), (int)(floor(GetPosY()) * 8), (int)(floor(GetPosZ()) * 8), 2); - m_World->BroadcastSoundParticleEffect(2000, (int)(floor(GetPosX()) * 8), (int)(floor(GetPosY()) * 8), (int)(floor(GetPosZ()) * 8), 6); - m_World->BroadcastSoundParticleEffect(2000, (int)(floor(GetPosX()) * 8), (int)(floor(GetPosY()) * 8), (int)(floor(GetPosZ()) * 8), 8); + m_World->BroadcastSoundParticleEffect(2000, (int)GetPosX(), (int)GetPosY(), (int)GetPosZ(), 0); + m_World->BroadcastSoundParticleEffect(2000, (int)GetPosX(), (int)GetPosY(), (int)GetPosZ(), 2); + m_World->BroadcastSoundParticleEffect(2000, (int)GetPosX(), (int)GetPosY(), (int)GetPosZ(), 6); + m_World->BroadcastSoundParticleEffect(2000, (int)GetPosX(), (int)GetPosY(), (int)GetPosZ(), 8); m_Attachee->Detach(); m_bIsRearing = true; diff --git a/source/Mobs/Monster.cpp b/source/Mobs/Monster.cpp index 33960ea46..167a07486 100644 --- a/source/Mobs/Monster.cpp +++ b/source/Mobs/Monster.cpp @@ -633,8 +633,13 @@ cMonster * cMonster::NewMonsterFromType(cMonster::eType a_MobType) case mtMagmaCube: case mtSlime: toReturn = new cSlime (RandomDerps.NextInt(2) + 1); break; // Size parameter case mtSheep: toReturn = new cSheep (RandomDerps.NextInt(15)); break; // Colour parameter - case mtSkeleton: toReturn = new cSkeleton ((bool)(RandomDerps.NextInt(1))); break; // TODO: Actual detection of spawning in Nether case mtZombie: toReturn = new cZombie (false); break; // TODO: Infected zombie parameter + case mtSkeleton: + { + // TODO: Actual detection of spawning in Nether + toReturn = new cSkeleton(RandomDerps.NextInt(1) == 0 ? false : true); + break; + } case mtVillager: { int VilType = RandomDerps.NextInt(6); -- cgit v1.2.3 From 1eb2b7e176056392b3408a3d0399a144e9fd94d1 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Tue, 12 Nov 2013 16:39:59 +0100 Subject: Now using a TickFollowPlayer function. --- source/Mobs/Wolf.cpp | 64 +++++++++++++++++++++++++++++++--------------------- source/Mobs/Wolf.h | 42 ++++++++++++++++++---------------- 2 files changed, 60 insertions(+), 46 deletions(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Wolf.cpp b/source/Mobs/Wolf.cpp index d725e1668..c6e9736f5 100644 --- a/source/Mobs/Wolf.cpp +++ b/source/Mobs/Wolf.cpp @@ -15,8 +15,8 @@ cWolf::cWolf(void) : m_IsTame(false), m_IsSitting(false), m_IsBegging(false), - m_Owner(""), - m_Collar(14) + m_OwnerName(""), + m_CollarColor(14) { } @@ -40,7 +40,7 @@ void cWolf::DoTakeDamage(TakeDamageInfo & a_TDI) void cWolf::OnRightClicked(cPlayer & a_Player) { - if ((!IsTame()) && (!IsAngry())) + if (!IsTame() && !IsAngry()) { if (a_Player.GetEquippedItem().m_ItemType == E_ITEM_BONE) { @@ -64,11 +64,11 @@ void cWolf::OnRightClicked(cPlayer & a_Player) } else if (IsTame()) { - if (a_Player.GetName() == m_Owner) // Is the player the owner of the dog? + if (a_Player.GetName() == m_OwnerName) // Is the player the owner of the dog? { if (a_Player.GetEquippedItem().m_ItemType == E_ITEM_DYE) { - m_Collar = 15 - a_Player.GetEquippedItem().m_ItemDamage; + SetCollarColor(15 - a_Player.GetEquippedItem().m_ItemDamage); if (!a_Player.IsGameModeCreative()) { a_Player.GetInventory().RemoveOneEquippedItem(); @@ -97,7 +97,9 @@ void cWolf::Tick(float a_Dt, cChunk & a_Chunk) if (!IsAngry()) { cMonster::Tick(a_Dt, a_Chunk); - } else { + } + else + { super::Tick(a_Dt, a_Chunk); } @@ -139,35 +141,45 @@ void cWolf::Tick(float a_Dt, cChunk & a_Chunk) } } } - + + if (IsTame()) + { + TickFollowPlayer(); + } +} + + + + + +void cWolf::TickFollowPlayer() +{ class cCallback : public cPlayerListCallback { - virtual bool Item(cPlayer * Player) override + virtual bool Item(cPlayer * a_Player) override { - OwnerCoords = Player->GetPosition(); + OwnerPos = a_Player->GetPosition(); return false; } public: - Vector3f OwnerCoords; - } ; - cCallback Callback; - m_World->DoWithPlayer(m_Owner, Callback); - Vector3f OwnerCoords = Callback.OwnerCoords; - - if (IsTame()) + Vector3f OwnerPos; + } Callback; + if (m_World->DoWithPlayer(m_OwnerName, Callback)) { - if (m_Owner != "") + // The player is present in the world, follow them: + double Distance = (Callback.OwnerPos - GetPosition()).Length(); + if (Distance < 3) { - double Distance = (OwnerCoords - GetPosition()).Length(); - if (Distance < 3) - { - m_bMovingToDestination = false; - } else if((Distance > 30) && (!IsSitting())) { - TeleportToCoords(OwnerCoords.x, OwnerCoords.y, OwnerCoords.z); - } else { - m_Destination = OwnerCoords; - } + m_bMovingToDestination = false; + } + else if ((Distance > 30) && (!IsSitting())) + { + TeleportToCoords(Callback.OwnerPos.x, Callback.OwnerPos.y, Callback.OwnerPos.z); + } + else + { + m_Destination = Callback.OwnerPos; } } } \ No newline at end of file diff --git a/source/Mobs/Wolf.h b/source/Mobs/Wolf.h index bc26fbf9b..faae1d7af 100644 --- a/source/Mobs/Wolf.h +++ b/source/Mobs/Wolf.h @@ -21,30 +21,32 @@ public: virtual void DoTakeDamage(TakeDamageInfo & a_TDI) override; virtual void OnRightClicked(cPlayer & a_Player) override; virtual void Tick(float a_Dt, cChunk & a_Chunk) override; + virtual void TickFollowPlayer(); // Get functions - bool IsSitting(void) const { return m_IsSitting; } - bool IsTame(void) const { return m_IsTame; } - bool IsBegging(void) const { return m_IsBegging; } - bool IsAngry(void) const { return m_IsAngry; } - AString GetOwner(void) const { return m_Owner; } - int GetCollarColor(void) const { return m_Collar; } + bool IsSitting (void) const { return m_IsSitting; } + bool IsTame (void) const { return m_IsTame; } + bool IsBegging (void) const { return m_IsBegging; } + bool IsAngry (void) const { return m_IsAngry; } + AString GetOwner (void) const { return m_OwnerName; } + int GetCollarColor(void) const { return m_CollarColor; } // Set functions - void SetIsSitting(bool a_IsSitting) { m_IsSitting = a_IsSitting; } - void SetIsTame(bool a_IsTame) { m_IsTame = a_IsTame; } - void SetIsBegging(bool a_IsBegging) { m_IsBegging = a_IsBegging; } - void SetIsAngry(bool a_IsAngry) { m_IsAngry = a_IsAngry; } - void SetOwner(AString a_NewOwner) { m_Owner = a_NewOwner; } - -private: - - bool m_IsSitting; - bool m_IsTame; - bool m_IsBegging; - bool m_IsAngry; - AString m_Owner; - int m_Collar; + void SetIsSitting (bool a_IsSitting) { m_IsSitting = a_IsSitting; } + void SetIsTame (bool a_IsTame) { m_IsTame = a_IsTame; } + void SetIsBegging (bool a_IsBegging) { m_IsBegging = a_IsBegging; } + void SetIsAngry (bool a_IsAngry) { m_IsAngry = a_IsAngry; } + void SetOwner (AString a_NewOwner) { m_OwnerName = a_NewOwner; } + void SetCollarColor(int a_CollarColor) { m_CollarColor = a_CollarColor; } + +protected: + + bool m_IsSitting; + bool m_IsTame; + bool m_IsBegging; + bool m_IsAngry; + AString m_OwnerName; + int m_CollarColor; } ; -- 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/AggressiveMonster.cpp | 97 ---- source/Mobs/AggressiveMonster.h | 30 -- source/Mobs/Bat.cpp | 15 - source/Mobs/Bat.h | 25 - source/Mobs/Blaze.cpp | 52 --- source/Mobs/Blaze.h | 26 -- source/Mobs/Cavespider.cpp | 40 -- source/Mobs/Cavespider.h | 26 -- source/Mobs/Chicken.cpp | 62 --- source/Mobs/Chicken.h | 29 -- source/Mobs/Cow.cpp | 45 -- source/Mobs/Cow.h | 26 -- source/Mobs/Creeper.cpp | 47 -- source/Mobs/Creeper.h | 34 -- source/Mobs/EnderDragon.cpp | 27 -- source/Mobs/EnderDragon.h | 25 - source/Mobs/Enderman.cpp | 29 -- source/Mobs/Enderman.h | 36 -- source/Mobs/Ghast.cpp | 54 --- source/Mobs/Ghast.h | 28 -- source/Mobs/Giant.cpp | 27 -- source/Mobs/Giant.h | 25 - source/Mobs/Horse.cpp | 152 ------- source/Mobs/Horse.h | 44 -- source/Mobs/IncludeAllMonsters.h | 29 -- source/Mobs/IronGolem.cpp | 26 -- source/Mobs/IronGolem.h | 25 - source/Mobs/Magmacube.cpp | 27 -- source/Mobs/Magmacube.h | 32 -- source/Mobs/Monster.cpp | 758 ------------------------------- source/Mobs/Monster.h | 195 -------- source/Mobs/Mooshroom.cpp | 33 -- source/Mobs/Mooshroom.h | 25 - source/Mobs/Ocelot.h | 26 -- source/Mobs/PassiveAggressiveMonster.cpp | 38 -- source/Mobs/PassiveAggressiveMonster.h | 23 - source/Mobs/PassiveMonster.cpp | 59 --- source/Mobs/PassiveMonster.h | 27 -- source/Mobs/Pig.cpp | 77 ---- source/Mobs/Pig.h | 32 -- source/Mobs/Sheep.cpp | 62 --- source/Mobs/Sheep.h | 34 -- source/Mobs/Silverfish.h | 26 -- source/Mobs/Skeleton.cpp | 70 --- source/Mobs/Skeleton.h | 33 -- source/Mobs/Slime.cpp | 29 -- source/Mobs/Slime.h | 32 -- source/Mobs/SnowGolem.cpp | 26 -- source/Mobs/SnowGolem.h | 25 - source/Mobs/Spider.cpp | 27 -- source/Mobs/Spider.h | 25 - source/Mobs/Squid.cpp | 56 --- source/Mobs/Squid.h | 28 -- source/Mobs/Villager.cpp | 35 -- source/Mobs/Villager.h | 43 -- source/Mobs/Witch.cpp | 32 -- source/Mobs/Witch.h | 27 -- source/Mobs/Wither.cpp | 26 -- source/Mobs/Wither.h | 25 - source/Mobs/Wolf.cpp | 189 -------- source/Mobs/Wolf.h | 54 --- source/Mobs/Zombie.cpp | 47 -- source/Mobs/Zombie.h | 33 -- source/Mobs/Zombiepigman.cpp | 45 -- source/Mobs/Zombiepigman.h | 26 -- 65 files changed, 3488 deletions(-) delete mode 100644 source/Mobs/AggressiveMonster.cpp delete mode 100644 source/Mobs/AggressiveMonster.h delete mode 100644 source/Mobs/Bat.cpp delete mode 100644 source/Mobs/Bat.h delete mode 100644 source/Mobs/Blaze.cpp delete mode 100644 source/Mobs/Blaze.h delete mode 100644 source/Mobs/Cavespider.cpp delete mode 100644 source/Mobs/Cavespider.h delete mode 100644 source/Mobs/Chicken.cpp delete mode 100644 source/Mobs/Chicken.h delete mode 100644 source/Mobs/Cow.cpp delete mode 100644 source/Mobs/Cow.h delete mode 100644 source/Mobs/Creeper.cpp delete mode 100644 source/Mobs/Creeper.h delete mode 100644 source/Mobs/EnderDragon.cpp delete mode 100644 source/Mobs/EnderDragon.h delete mode 100644 source/Mobs/Enderman.cpp delete mode 100644 source/Mobs/Enderman.h delete mode 100644 source/Mobs/Ghast.cpp delete mode 100644 source/Mobs/Ghast.h delete mode 100644 source/Mobs/Giant.cpp delete mode 100644 source/Mobs/Giant.h delete mode 100644 source/Mobs/Horse.cpp delete mode 100644 source/Mobs/Horse.h delete mode 100644 source/Mobs/IncludeAllMonsters.h delete mode 100644 source/Mobs/IronGolem.cpp delete mode 100644 source/Mobs/IronGolem.h delete mode 100644 source/Mobs/Magmacube.cpp delete mode 100644 source/Mobs/Magmacube.h delete mode 100644 source/Mobs/Monster.cpp delete mode 100644 source/Mobs/Monster.h delete mode 100644 source/Mobs/Mooshroom.cpp delete mode 100644 source/Mobs/Mooshroom.h delete mode 100644 source/Mobs/Ocelot.h delete mode 100644 source/Mobs/PassiveAggressiveMonster.cpp delete mode 100644 source/Mobs/PassiveAggressiveMonster.h delete mode 100644 source/Mobs/PassiveMonster.cpp delete mode 100644 source/Mobs/PassiveMonster.h delete mode 100644 source/Mobs/Pig.cpp delete mode 100644 source/Mobs/Pig.h delete mode 100644 source/Mobs/Sheep.cpp delete mode 100644 source/Mobs/Sheep.h delete mode 100644 source/Mobs/Silverfish.h delete mode 100644 source/Mobs/Skeleton.cpp delete mode 100644 source/Mobs/Skeleton.h delete mode 100644 source/Mobs/Slime.cpp delete mode 100644 source/Mobs/Slime.h delete mode 100644 source/Mobs/SnowGolem.cpp delete mode 100644 source/Mobs/SnowGolem.h delete mode 100644 source/Mobs/Spider.cpp delete mode 100644 source/Mobs/Spider.h delete mode 100644 source/Mobs/Squid.cpp delete mode 100644 source/Mobs/Squid.h delete mode 100644 source/Mobs/Villager.cpp delete mode 100644 source/Mobs/Villager.h delete mode 100644 source/Mobs/Witch.cpp delete mode 100644 source/Mobs/Witch.h delete mode 100644 source/Mobs/Wither.cpp delete mode 100644 source/Mobs/Wither.h delete mode 100644 source/Mobs/Wolf.cpp delete mode 100644 source/Mobs/Wolf.h delete mode 100644 source/Mobs/Zombie.cpp delete mode 100644 source/Mobs/Zombie.h delete mode 100644 source/Mobs/Zombiepigman.cpp delete mode 100644 source/Mobs/Zombiepigman.h (limited to 'source/Mobs') diff --git a/source/Mobs/AggressiveMonster.cpp b/source/Mobs/AggressiveMonster.cpp deleted file mode 100644 index cc7e7da2b..000000000 --- a/source/Mobs/AggressiveMonster.cpp +++ /dev/null @@ -1,97 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "AggressiveMonster.h" - -#include "../World.h" -#include "../Vector3f.h" -#include "../Entities/Player.h" -#include "../MersenneTwister.h" - - - - - -cAggressiveMonster::cAggressiveMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height) : - super(a_ConfigName, a_MobType, a_SoundHurt, a_SoundDeath, a_Width, a_Height), - m_ChaseTime(999999) -{ - m_EMPersonality = AGGRESSIVE; -} - - - - - -// What to do if in Chasing State -void cAggressiveMonster::InStateChasing(float a_Dt) -{ - super::InStateChasing(a_Dt); - m_ChaseTime += a_Dt; - if (m_Target != NULL) - { - if (m_Target->IsPlayer()) - { - cPlayer * Player = (cPlayer *) m_Target; - if (Player->IsGameModeCreative()) - { - m_EMState = IDLE; - return; - } - } - - Vector3f Pos = Vector3f( GetPosition() ); - Vector3f Their = Vector3f( m_Target->GetPosition() ); - if ((Their - Pos).Length() <= m_AttackRange) - { - Attack(a_Dt); - } - MoveToPosition(Their + Vector3f(0, 0.65f, 0)); - } - else if (m_ChaseTime > 5.f) - { - m_ChaseTime = 0; - m_EMState = IDLE; - } -} - - - - - -void cAggressiveMonster::EventSeePlayer(cEntity * a_Entity) -{ - super::EventSeePlayer(a_Entity); - m_EMState = CHASING; -} - - - - - -void cAggressiveMonster::Tick(float a_Dt, cChunk & a_Chunk) -{ - super::Tick(a_Dt, a_Chunk); - - m_SeePlayerInterval += a_Dt; - - if (m_SeePlayerInterval > 1) - { - int rem = m_World->GetTickRandomNumber(3) + 1; // Check most of the time but miss occasionally - - m_SeePlayerInterval = 0.0; - if (rem >= 2) - { - if (m_EMState == CHASING) - { - CheckEventLostPlayer(); - } - else - { - CheckEventSeePlayer(); - } - } - } -} - - diff --git a/source/Mobs/AggressiveMonster.h b/source/Mobs/AggressiveMonster.h deleted file mode 100644 index 5a0d93f3d..000000000 --- a/source/Mobs/AggressiveMonster.h +++ /dev/null @@ -1,30 +0,0 @@ - -#pragma once - -#include "Monster.h" - - - - - -class cAggressiveMonster : - public cMonster -{ - typedef cMonster super; - -public: - cAggressiveMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height); - - virtual void Tick (float a_Dt, cChunk & a_Chunk) override; - virtual void InStateChasing(float a_Dt) override; - - virtual void EventSeePlayer(cEntity *) override; - - -protected: - float m_ChaseTime; -} ; - - - - diff --git a/source/Mobs/Bat.cpp b/source/Mobs/Bat.cpp deleted file mode 100644 index b9c82996b..000000000 --- a/source/Mobs/Bat.cpp +++ /dev/null @@ -1,15 +0,0 @@ - -#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", mtBat, "mob.bat.hurt", "mob.bat.death", 0.7, 0.7) -{ -} - - diff --git a/source/Mobs/Bat.h b/source/Mobs/Bat.h deleted file mode 100644 index e878d0ee8..000000000 --- a/source/Mobs/Bat.h +++ /dev/null @@ -1,25 +0,0 @@ - -#pragma once - -#include "PassiveMonster.h" - - - - - -class cBat : - public cPassiveMonster -{ - typedef cPassiveMonster super; - -public: - cBat(void); - - CLASS_PROTODEF(cBat); - - bool IsHanging(void) const {return false; } -} ; - - - - diff --git a/source/Mobs/Blaze.cpp b/source/Mobs/Blaze.cpp deleted file mode 100644 index f9c05b17a..000000000 --- a/source/Mobs/Blaze.cpp +++ /dev/null @@ -1,52 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "Blaze.h" -#include "../World.h" - - - - -cBlaze::cBlaze(void) : - // TODO: The size is only a guesstimate, measure in vanilla and fix the size values here - super("Blaze", mtBlaze, "mob.blaze.hit", "mob.blaze.death", 0.7, 1.8) -{ -} - - - - - -void cBlaze::GetDrops(cItems & a_Drops, cEntity * a_Killer) -{ - AddRandomDropItem(a_Drops, 0, 1, E_ITEM_BLAZE_ROD); -} - - - - - -void cBlaze::Attack(float a_Dt) -{ - m_AttackInterval += a_Dt * m_AttackRate; - - if (m_Target != NULL && m_AttackInterval > 3.0) - { - // Setting this higher gives us more wiggle room for attackrate - Vector3d Speed = GetLookVector() * 20; - Speed.y = Speed.y + 1; - cFireChargeEntity * FireCharge = new cFireChargeEntity(this, GetPosX(), GetPosY() + 1, GetPosZ(), Speed); - if (FireCharge == NULL) - { - return; - } - if (!FireCharge->Initialize(m_World)) - { - delete FireCharge; - return; - } - m_World->BroadcastSpawnEntity(*FireCharge); - m_AttackInterval = 0.0; - // ToDo: Shoot 3 fireballs instead of 1. - } -} \ No newline at end of file diff --git a/source/Mobs/Blaze.h b/source/Mobs/Blaze.h deleted file mode 100644 index cdb3a1306..000000000 --- a/source/Mobs/Blaze.h +++ /dev/null @@ -1,26 +0,0 @@ - -#pragma once - -#include "AggressiveMonster.h" - - - - - -class cBlaze : - public cAggressiveMonster -{ - typedef cAggressiveMonster super; - -public: - cBlaze(void); - - CLASS_PROTODEF(cBlaze); - - virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; - virtual void Attack(float a_Dt) override; -} ; - - - - diff --git a/source/Mobs/Cavespider.cpp b/source/Mobs/Cavespider.cpp deleted file mode 100644 index aba1ff9f5..000000000 --- a/source/Mobs/Cavespider.cpp +++ /dev/null @@ -1,40 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "Cavespider.h" -#include "../World.h" - - - - - -cCavespider::cCavespider(void) : - super("Cavespider", mtCaveSpider, "mob.spider.say", "mob.spider.death", 0.7, 0.5) -{ -} - - - - - -void cCavespider::Tick(float a_Dt, cChunk & a_Chunk) -{ - super::Tick(a_Dt, a_Chunk); - - // TODO: Check vanilla if cavespiders really get passive during the day / in daylight - m_EMPersonality = (GetWorld()->GetTimeOfDay() < (12000 + 1000)) ? PASSIVE : AGGRESSIVE; -} - - - - - -void cCavespider::GetDrops(cItems & a_Drops, cEntity * 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 deleted file mode 100644 index 10ea03f7b..000000000 --- a/source/Mobs/Cavespider.h +++ /dev/null @@ -1,26 +0,0 @@ - -#pragma once - -#include "AggressiveMonster.h" - - - - - -class cCavespider : - public cAggressiveMonster -{ - typedef cAggressiveMonster super; - -public: - cCavespider(void); - - CLASS_PROTODEF(cCaveSpider); - - virtual void Tick(float a_Dt, cChunk & a_Chunk) override; - virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; -} ; - - - - diff --git a/source/Mobs/Chicken.cpp b/source/Mobs/Chicken.cpp deleted file mode 100644 index 087fd088a..000000000 --- a/source/Mobs/Chicken.cpp +++ /dev/null @@ -1,62 +0,0 @@ -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "Chicken.h" -#include "../World.h" - - - - - - - - -cChicken::cChicken(void) : - super("Chicken", mtChicken, "mob.chicken.hurt", "mob.chicken.hurt", 0.3, 0.4), - m_EggDropTimer(0) -{ -} - - - - -void cChicken::Tick(float a_Dt, cChunk & a_Chunk) -{ - super::Tick(a_Dt, a_Chunk); - - if ((m_EggDropTimer == 6000) && (m_World->GetTickRandomNumber(1) == 0)) - { - cItems Drops; - m_EggDropTimer = 0; - Drops.push_back(cItem(E_ITEM_EGG, 1)); - m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10); - } - else if (m_EggDropTimer == 12000) - { - cItems Drops; - m_EggDropTimer = 0; - Drops.push_back(cItem(E_ITEM_EGG, 1)); - m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10); - } - else - { - m_EggDropTimer++; - } -} - - - - - -void cChicken::GetDrops(cItems & a_Drops, cEntity * a_Killer) -{ - AddRandomDropItem(a_Drops, 0, 2, E_ITEM_FEATHER); - a_Drops.push_back(cItem(IsOnFire() ? E_ITEM_COOKED_CHICKEN : E_ITEM_RAW_CHICKEN, 1)); -} - - - - - - - - diff --git a/source/Mobs/Chicken.h b/source/Mobs/Chicken.h deleted file mode 100644 index 979c4d8a0..000000000 --- a/source/Mobs/Chicken.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once - -#include "PassiveMonster.h" - - - - - -class cChicken : - public cPassiveMonster -{ - typedef cPassiveMonster super; - -public: - cChicken(void); - - CLASS_PROTODEF(cChicken); - - virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; - virtual void Tick(float a_Dt, cChunk & a_Chunk) override; - -private: - - - int m_EggDropTimer; -} ; - - - diff --git a/source/Mobs/Cow.cpp b/source/Mobs/Cow.cpp deleted file mode 100644 index 9eb74dac2..000000000 --- a/source/Mobs/Cow.cpp +++ /dev/null @@ -1,45 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "Cow.h" -#include "../Entities/Player.h" - - - - - - - -cCow::cCow(void) : - super("Cow", mtCow, "mob.cow.hurt", "mob.cow.hurt", 0.9, 1.3) -{ -} - - - - - -void cCow::GetDrops(cItems & a_Drops, cEntity * a_Killer) -{ - AddRandomDropItem(a_Drops, 0, 2, E_ITEM_LEATHER); - AddRandomDropItem(a_Drops, 1, 3, IsOnFire() ? E_ITEM_STEAK : E_ITEM_RAW_BEEF); -} - - - - - -void cCow::OnRightClicked(cPlayer & a_Player) -{ - if ((a_Player.GetEquippedItem().m_ItemType == E_ITEM_BUCKET)) - { - if (!a_Player.IsGameModeCreative()) - { - a_Player.GetInventory().RemoveOneEquippedItem(); - a_Player.GetInventory().AddItem(E_ITEM_MILK); - } - } -} - - - diff --git a/source/Mobs/Cow.h b/source/Mobs/Cow.h deleted file mode 100644 index 0391d4a31..000000000 --- a/source/Mobs/Cow.h +++ /dev/null @@ -1,26 +0,0 @@ - -#pragma once - -#include "PassiveMonster.h" - - - - - -class cCow : - public cPassiveMonster -{ - typedef cPassiveMonster super; - -public: - cCow(); - - CLASS_PROTODEF(cCow); - - virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; - virtual void OnRightClicked(cPlayer & a_Player) override; -} ; - - - - diff --git a/source/Mobs/Creeper.cpp b/source/Mobs/Creeper.cpp deleted file mode 100644 index 4e11ae13e..000000000 --- a/source/Mobs/Creeper.cpp +++ /dev/null @@ -1,47 +0,0 @@ - -#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", mtCreeper, "mob.creeper.say", "mob.creeper.say", 0.6, 1.8), - m_bIsBlowing(false), - m_bIsCharged(false) -{ -} - - - - - -void cCreeper::GetDrops(cItems & a_Drops, cEntity * a_Killer) -{ - AddRandomDropItem(a_Drops, 0, 2, E_ITEM_GUNPOWDER); - - // TODO Check if killed by a skeleton, then drop random music disk -} - - - - - -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 deleted file mode 100644 index c3d4edeae..000000000 --- a/source/Mobs/Creeper.h +++ /dev/null @@ -1,34 +0,0 @@ - -#pragma once - -#include "AggressiveMonster.h" - - - - - -class cCreeper : - public cAggressiveMonster -{ - typedef cAggressiveMonster super; - -public: - cCreeper(void); - - 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/EnderDragon.cpp b/source/Mobs/EnderDragon.cpp deleted file mode 100644 index acd81cde1..000000000 --- a/source/Mobs/EnderDragon.cpp +++ /dev/null @@ -1,27 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "EnderDragon.h" - - - - - -cEnderDragon::cEnderDragon(void) : - // TODO: Vanilla source says this, but is it right? Dragons fly, they don't stand - super("EnderDragon", mtEnderDragon, "mob.enderdragon.hit", "mob.enderdragon.end", 16.0, 8.0) -{ -} - - - - - -void cEnderDragon::GetDrops(cItems & a_Drops, cEntity * a_Killer) -{ - return; -} - - - - diff --git a/source/Mobs/EnderDragon.h b/source/Mobs/EnderDragon.h deleted file mode 100644 index 77177edfe..000000000 --- a/source/Mobs/EnderDragon.h +++ /dev/null @@ -1,25 +0,0 @@ - -#pragma once - -#include "AggressiveMonster.h" - - - - - -class cEnderDragon : - public cAggressiveMonster -{ - typedef cAggressiveMonster super; - -public: - cEnderDragon(void); - - CLASS_PROTODEF(cEnderDragon); - - virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; -} ; - - - - diff --git a/source/Mobs/Enderman.cpp b/source/Mobs/Enderman.cpp deleted file mode 100644 index a784131e4..000000000 --- a/source/Mobs/Enderman.cpp +++ /dev/null @@ -1,29 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "Enderman.h" - - - - - -cEnderman::cEnderman(void) : - super("Enderman", mtEnderman, "mob.endermen.hit", "mob.endermen.death", 0.5, 2.9), - m_bIsScreaming(false), - CarriedBlock(E_BLOCK_AIR), - CarriedMeta(0) -{ -} - - - - - -void cEnderman::GetDrops(cItems & a_Drops, cEntity * a_Killer) -{ - AddRandomDropItem(a_Drops, 0, 1, E_ITEM_ENDER_PEARL); -} - - - - diff --git a/source/Mobs/Enderman.h b/source/Mobs/Enderman.h deleted file mode 100644 index 32e40e70b..000000000 --- a/source/Mobs/Enderman.h +++ /dev/null @@ -1,36 +0,0 @@ - -#pragma once - -#include "PassiveAggressiveMonster.h" - - - - - -class cEnderman : - public cPassiveAggressiveMonster -{ - typedef cPassiveAggressiveMonster super; - -public: - cEnderman(void); - - 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.cpp b/source/Mobs/Ghast.cpp deleted file mode 100644 index 96a29b2d8..000000000 --- a/source/Mobs/Ghast.cpp +++ /dev/null @@ -1,54 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "Ghast.h" -#include "../World.h" - - - - -cGhast::cGhast(void) : - super("Ghast", mtGhast, "mob.ghast.scream", "mob.ghast.death", 4, 4) -{ -} - - - - - -void cGhast::GetDrops(cItems & a_Drops, cEntity * a_Killer) -{ - AddRandomDropItem(a_Drops, 0, 2, E_ITEM_GUNPOWDER); - AddRandomDropItem(a_Drops, 0, 1, E_ITEM_GHAST_TEAR); -} - - - - - -void cGhast::Attack(float a_Dt) -{ - m_AttackInterval += a_Dt * m_AttackRate; - - if (m_Target != NULL && m_AttackInterval > 3.0) - { - // Setting this higher gives us more wiggle room for attackrate - Vector3d Speed = GetLookVector() * 20; - Speed.y = Speed.y + 1; - cGhastFireballEntity * GhastBall = new cGhastFireballEntity(this, GetPosX(), GetPosY() + 1, GetPosZ(), Speed); - if (GhastBall == NULL) - { - return; - } - if (!GhastBall->Initialize(m_World)) - { - delete GhastBall; - return; - } - m_World->BroadcastSpawnEntity(*GhastBall); - m_AttackInterval = 0.0; - } -} - - - diff --git a/source/Mobs/Ghast.h b/source/Mobs/Ghast.h deleted file mode 100644 index 43e8bedb6..000000000 --- a/source/Mobs/Ghast.h +++ /dev/null @@ -1,28 +0,0 @@ - -#pragma once - -#include "AggressiveMonster.h" - - - - - -class cGhast : - public cAggressiveMonster -{ - typedef cAggressiveMonster super; - -public: - cGhast(void); - - CLASS_PROTODEF(cGhast); - - virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; - virtual void Attack(float a_Dt) override; - - bool IsCharging(void) const {return false; } -} ; - - - - diff --git a/source/Mobs/Giant.cpp b/source/Mobs/Giant.cpp deleted file mode 100644 index f41977535..000000000 --- a/source/Mobs/Giant.cpp +++ /dev/null @@ -1,27 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "Giant.h" - - - - - -cGiant::cGiant(void) : - // TODO: The size is only a guesstimate, measure in vanilla and fix the size values here - super("Giant", mtGiant, "mob.zombie.hurt", "mob.zombie.death", 2.0, 13.5) -{ -} - - - - - -void cGiant::GetDrops(cItems & a_Drops, cEntity * a_Killer) -{ - AddRandomDropItem(a_Drops, 10, 50, E_ITEM_ROTTEN_FLESH); -} - - - - diff --git a/source/Mobs/Giant.h b/source/Mobs/Giant.h deleted file mode 100644 index 356dd4352..000000000 --- a/source/Mobs/Giant.h +++ /dev/null @@ -1,25 +0,0 @@ - -#pragma once - -#include "AggressiveMonster.h" - - - - - -class cGiant : - public cAggressiveMonster -{ - typedef cAggressiveMonster super; - -public: - cGiant(void); - - CLASS_PROTODEF(cGiant); - - virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; -} ; - - - - diff --git a/source/Mobs/Horse.cpp b/source/Mobs/Horse.cpp deleted file mode 100644 index bb9a4e3f6..000000000 --- a/source/Mobs/Horse.cpp +++ /dev/null @@ -1,152 +0,0 @@ -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "Horse.h" -#include "../World.h" -#include "../Entities/Player.h" - - - - - -cHorse::cHorse(int Type, int Color, int Style, int TameTimes) : - super("Horse", mtHorse, "mob.horse.hit", "mob.horse.death", 1.4, 1.6), - m_bHasChest(false), - m_bIsEating(false), - m_bIsRearing(false), - m_bIsMouthOpen(false), - m_bIsTame(false), - m_bIsSaddled(false), - m_Type(Type), - m_Color(Color), - m_Style(Style), - m_Armour(0), - m_TimesToTame(TameTimes), - m_TameAttemptTimes(0), - m_RearTickCount(0) -{ -} - - - - - -void cHorse::Tick(float a_Dt, cChunk & a_Chunk) -{ - super::Tick(a_Dt, a_Chunk); - - if (!m_bIsMouthOpen) - { - if (m_World->GetTickRandomNumber(50) == 25) - { - m_bIsMouthOpen = true; - } - } - else - { - if (m_World->GetTickRandomNumber(10) == 5) - { - m_bIsMouthOpen = false; - } - } - - if ((m_Attachee != NULL) && (!m_bIsTame)) - { - if (m_TameAttemptTimes < m_TimesToTame) - { - if (m_World->GetTickRandomNumber(50) == 25) - { - m_World->BroadcastSoundParticleEffect(2000, (int)GetPosX(), (int)GetPosY(), (int)GetPosZ(), 0); - m_World->BroadcastSoundParticleEffect(2000, (int)GetPosX(), (int)GetPosY(), (int)GetPosZ(), 2); - m_World->BroadcastSoundParticleEffect(2000, (int)GetPosX(), (int)GetPosY(), (int)GetPosZ(), 6); - m_World->BroadcastSoundParticleEffect(2000, (int)GetPosX(), (int)GetPosY(), (int)GetPosZ(), 8); - - m_Attachee->Detach(); - m_bIsRearing = true; - } - } - else - { - m_bIsTame = true; - } - } - - if (m_bIsRearing) - { - if (m_RearTickCount == 20) - { - m_bIsRearing = false; - m_RearTickCount = 0; - } - else - { - m_RearTickCount++; - } - } - - m_World->BroadcastEntityMetadata(*this); -} - - - - - -void cHorse::OnRightClicked(cPlayer & a_Player) -{ - if (!m_bIsSaddled && m_bIsTame) - { - if (a_Player.GetEquippedItem().m_ItemType == E_ITEM_SADDLE) - { - // Saddle the horse: - if (!a_Player.IsGameModeCreative()) - { - a_Player.GetInventory().RemoveOneEquippedItem(); - } - m_bIsSaddled = true; - m_World->BroadcastEntityMetadata(*this); - } - else if (!a_Player.GetEquippedItem().IsEmpty()) - { - // The horse doesn't like being hit, make it rear: - m_bIsRearing = true; - m_RearTickCount = 0; - } - } - else - { - if (m_Attachee != NULL) - { - if (m_Attachee->GetUniqueID() == a_Player.GetUniqueID()) - { - a_Player.Detach(); - return; - } - - if (m_Attachee->IsPlayer()) - { - return; - } - - m_Attachee->Detach(); - } - - m_TameAttemptTimes++; - a_Player.AttachTo(this); - } -} - - - - - -void cHorse::GetDrops(cItems & a_Drops, cEntity * a_Killer) -{ - AddRandomDropItem(a_Drops, 0, 2, E_ITEM_LEATHER); - if (m_bIsSaddled) - { - a_Drops.push_back(cItem(E_ITEM_SADDLE, 1)); - } -} - - - - diff --git a/source/Mobs/Horse.h b/source/Mobs/Horse.h deleted file mode 100644 index be0c23f9b..000000000 --- a/source/Mobs/Horse.h +++ /dev/null @@ -1,44 +0,0 @@ - -#pragma once - -#include "PassiveMonster.h" - - - - - -class cHorse : - public cPassiveMonster -{ - typedef cPassiveMonster super; - -public: - cHorse(int Type, int Color, int Style, int TameTimes); - - CLASS_PROTODEF(cHorse); - - 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; } - bool IsMthOpen (void) const {return m_bIsMouthOpen; } - bool IsTame (void) const {return m_bIsTame; } - int GetHorseType (void) const {return m_Type; } - int GetHorseColor (void) const {return m_Color; } - int GetHorseStyle (void) const {return m_Style; } - int GetHorseArmour (void) const {return m_Armour;} - -private: - - 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, m_RearTickCount; - -} ; - - - - diff --git a/source/Mobs/IncludeAllMonsters.h b/source/Mobs/IncludeAllMonsters.h deleted file mode 100644 index 1b436a11f..000000000 --- a/source/Mobs/IncludeAllMonsters.h +++ /dev/null @@ -1,29 +0,0 @@ -#include "Bat.h" -#include "Blaze.h" -#include "Cavespider.h" -#include "Chicken.h" -#include "Cow.h" -#include "Creeper.h" -#include "Enderman.h" -#include "EnderDragon.h" -#include "Ghast.h" -#include "Giant.h" -#include "Horse.h" -#include "IronGolem.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 "SnowGolem.h" -#include "Spider.h" -#include "Squid.h" -#include "Villager.h" -#include "Witch.h" -#include "Wither.h" -#include "Wolf.h" -#include "Zombie.h" -#include "Zombiepigman.h" diff --git a/source/Mobs/IronGolem.cpp b/source/Mobs/IronGolem.cpp deleted file mode 100644 index 47c961098..000000000 --- a/source/Mobs/IronGolem.cpp +++ /dev/null @@ -1,26 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "IronGolem.h" - - - - - -cIronGolem::cIronGolem(void) : - super("IronGolem", mtIronGolem, "mob.IronGolem.hit", "mob.IronGolem.death", 1.4, 2.9) -{ -} - - - - - -void cIronGolem::GetDrops(cItems & a_Drops, cEntity * a_Killer) -{ - AddRandomDropItem(a_Drops, 0, 5, E_ITEM_IRON); -} - - - - diff --git a/source/Mobs/IronGolem.h b/source/Mobs/IronGolem.h deleted file mode 100644 index d49ff4cab..000000000 --- a/source/Mobs/IronGolem.h +++ /dev/null @@ -1,25 +0,0 @@ - -#pragma once - -#include "PassiveAggressiveMonster.h" - - - - - -class cIronGolem : - public cPassiveAggressiveMonster -{ - typedef cPassiveAggressiveMonster super; - -public: - cIronGolem(void); - - CLASS_PROTODEF(cIronGolem); - - virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; -} ; - - - - diff --git a/source/Mobs/Magmacube.cpp b/source/Mobs/Magmacube.cpp deleted file mode 100644 index 86447ff6b..000000000 --- a/source/Mobs/Magmacube.cpp +++ /dev/null @@ -1,27 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "Magmacube.h" - - - - - -cMagmaCube::cMagmaCube(int a_Size) : - super("MagmaCube", mtMagmaCube, "mob.MagmaCube.big", "mob.MagmaCube.big", 0.6 * a_Size, 0.6 * a_Size), - m_Size(a_Size) -{ -} - - - - - -void cMagmaCube::GetDrops(cItems & a_Drops, cEntity * a_Killer) -{ - AddRandomDropItem(a_Drops, 0, 1, E_ITEM_MAGMA_CREAM); -} - - - - diff --git a/source/Mobs/Magmacube.h b/source/Mobs/Magmacube.h deleted file mode 100644 index 130952970..000000000 --- a/source/Mobs/Magmacube.h +++ /dev/null @@ -1,32 +0,0 @@ - -#pragma once - -#include "AggressiveMonster.h" - - - - - -class cMagmaCube : - public cAggressiveMonster -{ - typedef cAggressiveMonster super; - -public: - /// Creates a MagmaCube of the specified size; size is 1 .. 3, with 1 being the smallest - cMagmaCube(int a_Size); - - CLASS_PROTODEF(cMagmaCube); - - virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; - int GetSize(void) const { return m_Size; } - -protected: - - /// Size of the MagmaCube, 1 .. 3, with 1 being the smallest - int m_Size; -} ; - - - - diff --git a/source/Mobs/Monster.cpp b/source/Mobs/Monster.cpp deleted file mode 100644 index 8a5717e27..000000000 --- a/source/Mobs/Monster.cpp +++ /dev/null @@ -1,758 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "IncludeAllMonsters.h" -#include "../Root.h" -#include "../Server.h" -#include "../ClientHandle.h" -#include "../World.h" -#include "../Entities/Player.h" -#include "../Defines.h" -#include "../MonsterConfig.h" -#include "../MersenneTwister.h" - -#include "../Vector3f.h" -#include "../Vector3i.h" -#include "../Vector3d.h" -#include "../Tracer.h" -#include "../Chunk.h" -#include "../FastRandom.h" - - - - - -/** Map for eType <-> string -Needs to be alpha-sorted by the strings, because binary search is used in StringToMobType() -The strings need to be lowercase (for more efficient comparisons in StringToMobType()) -*/ -static const struct -{ - cMonster::eType m_Type; - const char * m_lcName; -} g_MobTypeNames[] = -{ - {cMonster::mtBat, "bat"}, - {cMonster::mtBlaze, "blaze"}, - {cMonster::mtCaveSpider, "cavespider"}, - {cMonster::mtChicken, "chicken"}, - {cMonster::mtCow, "cow"}, - {cMonster::mtCreeper, "creeper"}, - {cMonster::mtEnderman, "enderman"}, - {cMonster::mtGhast, "ghast"}, - {cMonster::mtHorse, "horse"}, - {cMonster::mtMagmaCube, "magmacube"}, - {cMonster::mtMooshroom, "mooshroom"}, - {cMonster::mtOcelot, "ocelot"}, - {cMonster::mtPig, "pig"}, - {cMonster::mtSheep, "sheep"}, - {cMonster::mtSilverfish, "silverfish"}, - {cMonster::mtSkeleton, "skeleton"}, - {cMonster::mtSlime, "slime"}, - {cMonster::mtSpider, "spider"}, - {cMonster::mtSquid, "squid"}, - {cMonster::mtVillager, "villager"}, - {cMonster::mtWitch, "witch"}, - {cMonster::mtWolf, "wolf"}, - {cMonster::mtZombie, "zombie"}, - {cMonster::mtZombiePigman, "zombiepigman"}, -} ; - - - - - -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// cMonster: - -cMonster::cMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height) - : super(etMonster, a_Width, a_Height) - , m_Target(NULL) - , m_AttackRate(3) - , idle_interval(0) - , m_bMovingToDestination(false) - , m_DestinationTime( 0 ) - , m_DestroyTimer( 0 ) - , m_Jump(0) - , m_MobType(a_MobType) - , m_SoundHurt(a_SoundHurt) - , m_SoundDeath(a_SoundDeath) - , m_EMState(IDLE) - , m_SightDistance(25) - , m_SeePlayerInterval (0) - , m_EMPersonality(AGGRESSIVE) - , m_AttackDamage(1.0f) - , m_AttackRange(2.0f) - , m_AttackInterval(0) - , m_BurnsInDaylight(false) -{ - if (!a_ConfigName.empty()) - { - GetMonsterConfig(a_ConfigName); - } -} - - - - - -void cMonster::SpawnOn(cClientHandle & a_Client) -{ - a_Client.SendSpawnMob(*this); -} - - - - - -void cMonster::MoveToPosition( const Vector3f & a_Position ) -{ - m_bMovingToDestination = true; - - m_Destination = a_Position; -} - - - - - -bool cMonster::ReachedDestination() -{ - Vector3f Distance = (m_Destination) - GetPosition(); - if( Distance.SqrLength() < 2.f ) - return true; - - return false; -} - - - - - -void cMonster::Tick(float a_Dt, cChunk & a_Chunk) -{ - super::Tick(a_Dt, a_Chunk); - - if (m_Health <= 0) - { - // The mob is dead, but we're still animating the "puff" they leave when they die - m_DestroyTimer += a_Dt / 1000; - if (m_DestroyTimer > 1) - { - Destroy(true); - } - return; - } - - // Burning in daylight - HandleDaylightBurning(a_Chunk); - - HandlePhysics(a_Dt,a_Chunk); - BroadcastMovementUpdate(); - - a_Dt /= 1000; - - if (m_bMovingToDestination) - { - Vector3f Pos( GetPosition() ); - Vector3f Distance = m_Destination - Pos; - if( !ReachedDestination() ) - { - Distance.y = 0; - Distance.Normalize(); - Distance *= 3; - SetSpeedX( Distance.x ); - SetSpeedZ( Distance.z ); - - if (m_EMState == ESCAPING) - { //Runs Faster when escaping :D otherwise they just walk away - SetSpeedX (GetSpeedX() * 2.f); - SetSpeedZ (GetSpeedZ() * 2.f); - } - } - else - { - m_bMovingToDestination = false; - } - - if( GetSpeed().SqrLength() > 0.f ) - { - if( m_bOnGround ) - { - Vector3f NormSpeed = Vector3f(GetSpeed()).NormalizeCopy(); - Vector3f NextBlock = Vector3f( GetPosition() ) + NormSpeed; - int NextHeight; - if (!m_World->TryGetHeight((int)NextBlock.x, (int)NextBlock.z, NextHeight)) - { - // The chunk at NextBlock is not loaded - return; - } - if( NextHeight > (GetPosY() - 1.0) && (NextHeight - GetPosY()) < 2.5 ) - { - m_bOnGround = false; - SetSpeedY(5.f); // Jump!! - } - } - } - } - - Vector3d Distance = m_Destination - GetPosition(); - if (Distance.SqrLength() > 0.1f) - { - double Rotation, Pitch; - Distance.Normalize(); - VectorToEuler( Distance.x, Distance.y, Distance.z, Rotation, Pitch ); - SetHeadYaw (Rotation); - SetRotation( Rotation ); - SetPitch( -Pitch ); - } - - switch (m_EMState) - { - case IDLE: - { - // If enemy passive we ignore checks for player visibility - InStateIdle(a_Dt); - break; - } - - case CHASING: - { - // If we do not see a player anymore skip chasing action - InStateChasing(a_Dt); - break; - } - - case ESCAPING: - { - InStateEscaping(a_Dt); - break; - } - } // switch (m_EMState) -} - - - - - - -void cMonster::DoTakeDamage(TakeDamageInfo & a_TDI) -{ - super::DoTakeDamage(a_TDI); - if((m_SoundHurt != "") && (m_Health > 0)) m_World->BroadcastSoundEffect(m_SoundHurt, (int)(GetPosX() * 8), (int)(GetPosY() * 8), (int)(GetPosZ() * 8), 1.0f, 0.8f); - if (a_TDI.Attacker != NULL) - { - m_Target = a_TDI.Attacker; - AddReference(m_Target); - } -} - - - - - -void cMonster::KilledBy(cEntity * a_Killer) -{ - super::KilledBy(a_Killer); - if (m_SoundHurt != "") - { - m_World->BroadcastSoundEffect(m_SoundDeath, (int)(GetPosX() * 8), (int)(GetPosY() * 8), (int)(GetPosZ() * 8), 1.0f, 0.8f); - } - m_DestroyTimer = 0; -} - - - - - -//----State Logic - -const char *cMonster::GetState() -{ - switch(m_EMState) - { - case IDLE: return "Idle"; - case ATTACKING: return "Attacking"; - case CHASING: return "Chasing"; - default: return "Unknown"; - } -} - - - - - -// for debugging -void cMonster::SetState(const AString & a_State) -{ - if (a_State.compare("Idle") == 0) - { - m_EMState = IDLE; - } - else if (a_State.compare("Attacking") == 0) - { - m_EMState = ATTACKING; - } - else if (a_State.compare("Chasing") == 0) - { - m_EMState = CHASING; - } - else - { - LOGD("cMonster::SetState(): Invalid state"); - ASSERT(!"Invalid state"); - } -} - - - - - -//Checks to see if EventSeePlayer should be fired -//monster sez: Do I see the player -void cMonster::CheckEventSeePlayer(void) -{ - // TODO: Rewrite this to use cWorld's DoWithPlayers() - cPlayer * Closest = FindClosestPlayer(); - - if (Closest != NULL) - { - EventSeePlayer(Closest); - } -} - - - - - -void cMonster::CheckEventLostPlayer(void) -{ - Vector3f pos; - cTracer LineOfSight(GetWorld()); - - if (m_Target != NULL) - { - pos = m_Target->GetPosition(); - if ((pos - GetPosition()).Length() > m_SightDistance || LineOfSight.Trace(GetPosition(),(pos - GetPosition()), (int)(pos - GetPosition()).Length())) - { - EventLosePlayer(); - } - } - else - { - EventLosePlayer(); - } -} - - - - - -// What to do if player is seen -// default to change state to chasing -void cMonster::EventSeePlayer(cEntity * a_SeenPlayer) -{ - m_Target = a_SeenPlayer; - AddReference(m_Target); -} - - - - - -void cMonster::EventLosePlayer(void) -{ - Dereference(m_Target); - m_Target = NULL; - m_EMState = IDLE; -} - - - - - -// What to do if in Idle State -void cMonster::InStateIdle(float a_Dt) -{ - idle_interval += a_Dt; - if (idle_interval > 1) - { - // at this interval the results are predictable - int rem = m_World->GetTickRandomNumber(6) + 1; - // LOGD("Moving: int: %3.3f rem: %i",idle_interval,rem); - idle_interval -= 1; // So nothing gets dropped when the server hangs for a few seconds - Vector3f Dist; - Dist.x = (float)(m_World->GetTickRandomNumber(10) - 5); - Dist.z = (float)(m_World->GetTickRandomNumber(10) - 5); - if ((Dist.SqrLength() > 2) && (rem >= 3)) - { - m_Destination.x = (float)(GetPosX() + Dist.x); - m_Destination.z = (float)(GetPosZ() + Dist.z); - int PosY; - if (m_World->TryGetHeight((int)m_Destination.x, (int)m_Destination.z, PosY)) - { - m_Destination.y = (float)PosY + 1.2f; - MoveToPosition(m_Destination); - } - } - } -} - - - - - -// What to do if in Chasing State -// This state should always be defined in each child class -void cMonster::InStateChasing(float a_Dt) -{ - UNUSED(a_Dt); -} - - - - - -// What to do if in Escaping State -void cMonster::InStateEscaping(float a_Dt) -{ - UNUSED(a_Dt); - - if (m_Target != NULL) - { - Vector3d newloc = GetPosition(); - newloc.x = (m_Target->GetPosition().x < newloc.x)? (newloc.x + m_SightDistance): (newloc.x - m_SightDistance); - newloc.z = (m_Target->GetPosition().z < newloc.z)? (newloc.z + m_SightDistance): (newloc.z - m_SightDistance); - MoveToPosition(newloc); - } - else - { - m_EMState = IDLE; // This shouldnt be required but just to be safe - } -} - - - - - -// Do attack here -// a_Dt is passed so we can set attack rate -void cMonster::Attack(float a_Dt) -{ - m_AttackInterval += a_Dt * m_AttackRate; - if ((m_Target != NULL) && (m_AttackInterval > 3.0)) - { - // Setting this higher gives us more wiggle room for attackrate - m_AttackInterval = 0.0; - ((cPawn *)m_Target)->TakeDamage(*this); - } -} - - - - - -// Checks for Players close by and if they are visible return the closest -cPlayer * cMonster::FindClosestPlayer(void) -{ - return m_World->FindClosestPlayer(GetPosition(), m_SightDistance); -} - - - - - -void cMonster::GetMonsterConfig(const AString & a_Name) -{ - cRoot::Get()->GetMonsterConfig()->AssignAttributes(this, a_Name); -} - - - - - -void cMonster::SetAttackRate(int ar) -{ - m_AttackRate = (float)ar; -} - - - - - -void cMonster::SetAttackRange(float ar) -{ - m_AttackRange = ar; -} - - - - - -void cMonster::SetAttackDamage(float ad) -{ - m_AttackDamage = ad; -} - - - - - -void cMonster::SetSightDistance(float sd) -{ - m_SightDistance = sd; -} - - - - - -AString cMonster::MobTypeToString(cMonster::eType a_MobType) -{ - // Mob types aren't sorted, so we need to search linearly: - for (int i = 0; i < ARRAYCOUNT(g_MobTypeNames); i++) - { - if (g_MobTypeNames[i].m_Type == a_MobType) - { - return g_MobTypeNames[i].m_lcName; - } - } - - // Not found: - return ""; -} - - - - - -cMonster::eType cMonster::StringToMobType(const AString & a_Name) -{ - AString lcName(a_Name); - StrToLower(lcName); - - // Binary-search for the lowercase name: - int lo = 0, hi = ARRAYCOUNT(g_MobTypeNames) - 1; - while (hi - lo > 1) - { - int mid = (lo + hi) / 2; - int res = strcmp(g_MobTypeNames[mid].m_lcName, lcName.c_str()); - if (res == 0) - { - return g_MobTypeNames[mid].m_Type; - } - if (res < 0) - { - lo = mid; - } - else - { - hi = mid; - } - } - // Range has collapsed to at most two elements, compare each: - if (strcmp(g_MobTypeNames[lo].m_lcName, lcName.c_str()) == 0) - { - return g_MobTypeNames[lo].m_Type; - } - if ((lo != hi) && (strcmp(g_MobTypeNames[hi].m_lcName, lcName.c_str()) == 0)) - { - return g_MobTypeNames[hi].m_Type; - } - - // Not found: - return mtInvalidType; -} - - - - - -cMonster::eFamily cMonster::FamilyFromType(eType a_Type) -{ - switch (a_Type) - { - case mtBat: return mfAmbient; - case mtBlaze: return mfHostile; - case mtCaveSpider: return mfHostile; - case mtChicken: return mfPassive; - case mtCow: return mfPassive; - case mtCreeper: return mfHostile; - case mtEnderman: return mfHostile; - case mtGhast: return mfHostile; - case mtHorse: return mfPassive; - case mtMagmaCube: return mfHostile; - case mtMooshroom: return mfHostile; - case mtOcelot: return mfHostile; - case mtPig: return mfPassive; - case mtSheep: return mfPassive; - case mtSilverfish: return mfHostile; - case mtSkeleton: return mfHostile; - case mtSlime: return mfHostile; - case mtSpider: return mfHostile; - case mtSquid: return mfWater; - case mtVillager: return mfPassive; - case mtWitch: return mfHostile; - case mtWolf: return mfHostile; - case mtZombie: return mfHostile; - case mtZombiePigman: return mfHostile; - } ; - ASSERT(!"Unhandled mob type"); - return mfMaxplusone; -} - - - - - -int cMonster::GetSpawnDelay(cMonster::eFamily a_MobFamily) -{ - switch (a_MobFamily) - { - case mfHostile: return 40; - case mfPassive: return 40; - case mfAmbient: return 40; - case mfWater: return 400; - } - ASSERT(!"Unhandled mob family"); - return -1; -} - - - - - -cMonster * cMonster::NewMonsterFromType(cMonster::eType a_MobType) -{ - cFastRandom Random; - cMonster * toReturn = NULL; - - // Create the mob entity - switch (a_MobType) - { - case mtMagmaCube: - case mtSlime: - { - toReturn = new cSlime (Random.NextInt(2) + 1); - break; - } - case mtSkeleton: - { - // TODO: Actual detection of spawning in Nether - toReturn = new cSkeleton(Random.NextInt(1) == 0 ? false : true); - break; - } - case mtVillager: - { - int VillagerType = Random.NextInt(6); - if (VillagerType == 6) - { - // Give farmers a better chance of spawning - VillagerType = 0; - } - - toReturn = new cVillager((cVillager::eVillagerType)VillagerType); - break; - } - case mtHorse: - { - // Horses take a type (species), a colour, and a style (dots, stripes, etc.) - int HorseType = Random.NextInt(7); - int HorseColor = Random.NextInt(6); - int HorseStyle = Random.NextInt(6); - int HorseTameTimes = Random.NextInt(6) + 1; - - if ((HorseType == 5) || (HorseType == 6) || (HorseType == 7)) - { - // Increase chances of normal horse (zero) - HorseType = 0; - } - - toReturn = new cHorse(HorseType, HorseColor, HorseStyle, HorseTameTimes); - break; - } - - case mtBat: toReturn = new cBat(); break; - case mtBlaze: toReturn = new cBlaze(); break; - case mtCaveSpider: toReturn = new cCavespider(); break; - case mtChicken: toReturn = new cChicken(); break; - case mtCow: toReturn = new cCow(); break; - case mtCreeper: toReturn = new cCreeper(); break; - case mtEnderman: toReturn = new cEnderman(); break; - case mtGhast: toReturn = new cGhast(); break; - case mtMooshroom: toReturn = new cMooshroom(); break; - case mtOcelot: toReturn = new cOcelot(); break; - case mtPig: toReturn = new cPig(); break; - case mtSheep: toReturn = new cSheep (Random.NextInt(15)); break; // Colour parameter - case mtSilverfish: toReturn = new cSilverfish(); break; - case mtSpider: toReturn = new cSpider(); break; - case mtSquid: toReturn = new cSquid(); break; - case mtWitch: toReturn = new cWitch(); break; - case mtWolf: toReturn = new cWolf(); break; - case mtZombie: toReturn = new cZombie(false); break; // TODO: Infected zombie parameter - case mtZombiePigman: toReturn = new cZombiePigman(); break; - default: - { - ASSERT(!"Unhandled mob type whilst trying to spawn mob!"); - } - } - return toReturn; -} - - - - - -void cMonster::AddRandomDropItem(cItems & a_Drops, unsigned int a_Min, unsigned int a_Max, short a_Item, short a_ItemHealth) -{ - MTRand r1; - int Count = r1.randInt() % (a_Max + 1 - a_Min) + a_Min; - if (Count > 0) - { - a_Drops.push_back(cItem(a_Item, Count, a_ItemHealth)); - } -} - - - - - -void cMonster::HandleDaylightBurning(cChunk & a_Chunk) -{ - if (!m_BurnsInDaylight) - { - return; - } - - int RelY = (int)floor(GetPosY()); - if ((RelY < 0) || (RelY >= cChunkDef::Height)) - { - // Outside the world - return; - } - - int RelX = (int)floor(GetPosX()) - GetChunkX() * cChunkDef::Width; - int RelZ = (int)floor(GetPosZ()) - GetChunkZ() * cChunkDef::Width; - if ( - (a_Chunk.GetSkyLight(RelX, RelY, RelZ) == 15) && // In the daylight - (a_Chunk.GetBlock(RelX, RelY, RelZ) != E_BLOCK_SOULSAND) && // Not on soulsand - (GetWorld()->GetTimeOfDay() < (12000 + 1000)) && // It is nighttime - !IsOnFire() // Not already burning - ) - { - // Burn for 100 ticks, then decide again - StartBurning(100); - } -} - - - - -cMonster::eFamily cMonster::GetMobFamily(void) const -{ - return FamilyFromType(m_MobType); -} - - - - 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 - - - - diff --git a/source/Mobs/Mooshroom.cpp b/source/Mobs/Mooshroom.cpp deleted file mode 100644 index 940e2db44..000000000 --- a/source/Mobs/Mooshroom.cpp +++ /dev/null @@ -1,33 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "Mooshroom.h" - - - - - -// TODO: Milk Cow - - - - - -cMooshroom::cMooshroom(void) : - super("Mooshroom", mtMooshroom, "mob.cow.hurt", "mob.cow.hurt", 0.9, 1.3) -{ -} - - - - - -void cMooshroom::GetDrops(cItems & a_Drops, cEntity * a_Killer) -{ - AddRandomDropItem(a_Drops, 0, 2, E_ITEM_LEATHER); - AddRandomDropItem(a_Drops, 1, 3, IsOnFire() ? E_ITEM_STEAK : E_ITEM_RAW_BEEF); -} - - - - diff --git a/source/Mobs/Mooshroom.h b/source/Mobs/Mooshroom.h deleted file mode 100644 index 73f6348b6..000000000 --- a/source/Mobs/Mooshroom.h +++ /dev/null @@ -1,25 +0,0 @@ - -#pragma once - -#include "PassiveMonster.h" - - - - - -class cMooshroom : - public cPassiveMonster -{ - typedef cPassiveMonster super; - -public: - cMooshroom(void); - - CLASS_PROTODEF(cMooshroom); - - virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; -} ; - - - - diff --git a/source/Mobs/Ocelot.h b/source/Mobs/Ocelot.h deleted file mode 100644 index adb7a1f75..000000000 --- a/source/Mobs/Ocelot.h +++ /dev/null @@ -1,26 +0,0 @@ - -#pragma once - -#include "PassiveMonster.h" - - - - - -class cOcelot : - public cPassiveMonster -{ - typedef cPassiveMonster super; - -public: - cOcelot(void) : - super("Ocelot", mtOcelot, "mob.cat.hitt", "mob.cat.hitt", 0.6, 0.8) - { - } - - CLASS_PROTODEF(cOcelot); -} ; - - - - diff --git a/source/Mobs/PassiveAggressiveMonster.cpp b/source/Mobs/PassiveAggressiveMonster.cpp deleted file mode 100644 index 28de65905..000000000 --- a/source/Mobs/PassiveAggressiveMonster.cpp +++ /dev/null @@ -1,38 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "PassiveAggressiveMonster.h" - -#include "../Entities/Player.h" - - - - - -cPassiveAggressiveMonster::cPassiveAggressiveMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height) : - super(a_ConfigName, a_MobType, a_SoundHurt, a_SoundDeath, a_Width, a_Height) -{ - m_EMPersonality = PASSIVE; -} - - - - - -void cPassiveAggressiveMonster::DoTakeDamage(TakeDamageInfo & a_TDI) -{ - super::DoTakeDamage(a_TDI); - - if ((m_Target != NULL) && (m_Target->IsPlayer())) - { - cPlayer * Player = (cPlayer *) m_Target; - if (Player->GetGameMode() != 1) - { - m_EMState = CHASING; - } - } -} - - - - diff --git a/source/Mobs/PassiveAggressiveMonster.h b/source/Mobs/PassiveAggressiveMonster.h deleted file mode 100644 index 2c5ef30b1..000000000 --- a/source/Mobs/PassiveAggressiveMonster.h +++ /dev/null @@ -1,23 +0,0 @@ - -#pragma once - -#include "AggressiveMonster.h" - - - - - -class cPassiveAggressiveMonster : - public cAggressiveMonster -{ - typedef cAggressiveMonster super; - -public: - cPassiveAggressiveMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height); - - virtual void DoTakeDamage(TakeDamageInfo & a_TDI) override; -} ; - - - - diff --git a/source/Mobs/PassiveMonster.cpp b/source/Mobs/PassiveMonster.cpp deleted file mode 100644 index 91ceb5a53..000000000 --- a/source/Mobs/PassiveMonster.cpp +++ /dev/null @@ -1,59 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "PassiveMonster.h" -#include "../MersenneTwister.h" -#include "../World.h" - - - - - -cPassiveMonster::cPassiveMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height) : - super(a_ConfigName, a_MobType, a_SoundHurt, a_SoundDeath, a_Width, a_Height) -{ - m_EMPersonality = PASSIVE; -} - - - - - -void cPassiveMonster::DoTakeDamage(TakeDamageInfo & a_TDI) -{ - super::DoTakeDamage(a_TDI); - if ((a_TDI.Attacker != this) && (a_TDI.Attacker != NULL)) - { - m_EMState = ESCAPING; - } -} - - - - - -void cPassiveMonster::Tick(float a_Dt, cChunk & a_Chunk) -{ - super::Tick(a_Dt, a_Chunk); - - m_SeePlayerInterval += a_Dt; - - if (m_SeePlayerInterval > 1) // Check every second - { - int rem = m_World->GetTickRandomNumber(3) + 1; // Check most of the time but miss occasionally - - m_SeePlayerInterval = 0.0; - if (rem >= 2) - { - if (m_EMState == ESCAPING) - { - CheckEventLostPlayer(); - } - } - } -} - - - - - diff --git a/source/Mobs/PassiveMonster.h b/source/Mobs/PassiveMonster.h deleted file mode 100644 index 14a6be6b1..000000000 --- a/source/Mobs/PassiveMonster.h +++ /dev/null @@ -1,27 +0,0 @@ - -#pragma once - -#include "Monster.h" - - - - - -class cPassiveMonster : - public cMonster -{ - typedef cMonster super; - -public: - cPassiveMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height); - - virtual void Tick(float a_Dt, cChunk & a_Chunk) override; - - /// When hit by someone, run away - virtual void DoTakeDamage(TakeDamageInfo & a_TDI) override; - -} ; - - - - diff --git a/source/Mobs/Pig.cpp b/source/Mobs/Pig.cpp deleted file mode 100644 index 0871a38a9..000000000 --- a/source/Mobs/Pig.cpp +++ /dev/null @@ -1,77 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "Pig.h" -#include "../Entities/Player.h" -#include "../World.h" - - - - - -cPig::cPig(void) : - super("Pig", mtPig, "mob.pig.say", "mob.pig.death", 0.9, 0.9), - m_bIsSaddled(false) -{ -} - - - - - -void cPig::GetDrops(cItems & a_Drops, cEntity * a_Killer) -{ - AddRandomDropItem(a_Drops, 1, 3, IsOnFire() ? E_ITEM_COOKED_PORKCHOP : E_ITEM_RAW_PORKCHOP); - if (m_bIsSaddled) - { - a_Drops.push_back(cItem(E_ITEM_SADDLE, 1)); - } -} - - - - - -void cPig::OnRightClicked(cPlayer & a_Player) -{ - if (m_bIsSaddled) - { - if (m_Attachee != NULL) - { - if (m_Attachee->GetUniqueID() == a_Player.GetUniqueID()) - { - // This player is already sitting in, they want out. - a_Player.Detach(); - return; - } - - if (m_Attachee->IsPlayer()) - { - // Another player is already sitting in here, cannot attach - return; - } - - // Detach whatever is sitting in this pig now: - m_Attachee->Detach(); - } - - // Attach the player to this pig - a_Player.AttachTo(this); - } - else if (a_Player.GetEquippedItem().m_ItemType == E_ITEM_SADDLE) - { - if (!a_Player.IsGameModeCreative()) - { - a_Player.GetInventory().RemoveOneEquippedItem(); - } - - // Set saddle state & broadcast metadata - m_bIsSaddled = true; - m_World->BroadcastEntityMetadata(*this); - } -} - - - - - diff --git a/source/Mobs/Pig.h b/source/Mobs/Pig.h deleted file mode 100644 index 4fd0d8db8..000000000 --- a/source/Mobs/Pig.h +++ /dev/null @@ -1,32 +0,0 @@ - -#pragma once - -#include "PassiveMonster.h" - - - - - -class cPig : - public cPassiveMonster -{ - typedef cPassiveMonster super; - -public: - cPig(void); - - CLASS_PROTODEF(cPig); - - virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; - virtual void OnRightClicked(cPlayer & a_Player) override; - bool IsSaddled(void) const { return m_bIsSaddled; } - -private: - - bool m_bIsSaddled; - -} ; - - - - diff --git a/source/Mobs/Sheep.cpp b/source/Mobs/Sheep.cpp deleted file mode 100644 index bda4ccff8..000000000 --- a/source/Mobs/Sheep.cpp +++ /dev/null @@ -1,62 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "Sheep.h" -#include "../BlockID.h" -#include "../Entities/Player.h" -#include "../World.h" - - - - - -cSheep::cSheep(int a_Color) : - super("Sheep", mtSheep, "mob.sheep.say", "mob.sheep.say", 0.6, 1.3), - m_IsSheared(false), - m_WoolColor(a_Color) -{ -} - - - - - -void cSheep::GetDrops(cItems & a_Drops, cEntity * a_Killer) -{ - if (!m_IsSheared) - { - a_Drops.push_back(cItem(E_BLOCK_WOOL, 1, m_WoolColor)); - } -} - - - - - -void cSheep::OnRightClicked(cPlayer & a_Player) -{ - if ((a_Player.GetEquippedItem().m_ItemType == E_ITEM_SHEARS) && (!m_IsSheared)) - { - m_IsSheared = true; - m_World->BroadcastEntityMetadata(*this); - - if (!a_Player.IsGameModeCreative()) - { - a_Player.UseEquippedItem(); - } - - cItems Drops; - int NumDrops = m_World->GetTickRandomNumber(2) + 1; - Drops.push_back(cItem(E_BLOCK_WOOL, NumDrops, m_WoolColor)); - m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10); - } - if ((a_Player.GetEquippedItem().m_ItemType == E_ITEM_DYE) && (m_WoolColor != 15 - a_Player.GetEquippedItem().m_ItemDamage)) - { - m_WoolColor = 15 - a_Player.GetEquippedItem().m_ItemDamage; - if (!a_Player.IsGameModeCreative()) - { - a_Player.GetInventory().RemoveOneEquippedItem(); - } - m_World->BroadcastEntityMetadata(*this); - } -} diff --git a/source/Mobs/Sheep.h b/source/Mobs/Sheep.h deleted file mode 100644 index 8293a2c05..000000000 --- a/source/Mobs/Sheep.h +++ /dev/null @@ -1,34 +0,0 @@ - -#pragma once - -#include "PassiveMonster.h" - - - - - -class cSheep : - public cPassiveMonster -{ - typedef cPassiveMonster super; - -public: - cSheep(int a_Color); - - CLASS_PROTODEF(cSheep); - - virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; - virtual void OnRightClicked(cPlayer & a_Player) override; - bool IsSheared(void) const { return m_IsSheared; } - int GetFurColor(void) const { return m_WoolColor; } - -private: - - bool m_IsSheared; - int m_WoolColor; - -} ; - - - - diff --git a/source/Mobs/Silverfish.h b/source/Mobs/Silverfish.h deleted file mode 100644 index a6e11c49d..000000000 --- a/source/Mobs/Silverfish.h +++ /dev/null @@ -1,26 +0,0 @@ - -#pragma once - -#include "AggressiveMonster.h" - - - - - -class cSilverfish : - public cAggressiveMonster -{ - typedef cAggressiveMonster super; - -public: - cSilverfish(void) : - super("Silverfish", mtSilverfish, "mob.silverfish.hit", "mob.silverfish.kill", 0.3, 0.7) - { - } - - CLASS_PROTODEF(cSilverfish); -} ; - - - - diff --git a/source/Mobs/Skeleton.cpp b/source/Mobs/Skeleton.cpp deleted file mode 100644 index 509c2191e..000000000 --- a/source/Mobs/Skeleton.cpp +++ /dev/null @@ -1,70 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "Skeleton.h" -#include "../World.h" - - - - -cSkeleton::cSkeleton(bool IsWither) : - super("Skeleton", mtSkeleton, "mob.skeleton.hurt", "mob.skeleton.death", 0.6, 1.8), - m_bIsWither(IsWither) -{ - SetBurnsInDaylight(true); -} - - - - - -void cSkeleton::GetDrops(cItems & a_Drops, cEntity * a_Killer) -{ - AddRandomDropItem(a_Drops, 0, 2, E_ITEM_ARROW); - AddRandomDropItem(a_Drops, 0, 2, E_ITEM_BONE); -} - - - - - -void cSkeleton::MoveToPosition(const Vector3f & a_Position) -{ - m_Destination = a_Position; - - // If the destination is in the sun and if it is not night AND the skeleton isn't on fire then block the movement. - if (!IsOnFire() && m_World->GetTimeOfDay() < 13187 && m_World->GetBlockSkyLight((int) a_Position.x, (int) a_Position.y, (int) a_Position.z) == 15) - { - m_bMovingToDestination = false; - return; - } - m_bMovingToDestination = true; -} - - - - - -void cSkeleton::Attack(float a_Dt) -{ - m_AttackInterval += a_Dt * m_AttackRate; - - if (m_Target != NULL && m_AttackInterval > 3.0) - { - // Setting this higher gives us more wiggle room for attackrate - Vector3d Speed = GetLookVector() * 20; - Speed.y = Speed.y + 1; - cArrowEntity * Arrow = new cArrowEntity(this, GetPosX(), GetPosY() + 1, GetPosZ(), Speed); - if (Arrow == NULL) - { - return; - } - if (!Arrow->Initialize(m_World)) - { - delete Arrow; - return; - } - m_World->BroadcastSpawnEntity(*Arrow); - m_AttackInterval = 0.0; - } -} \ No newline at end of file diff --git a/source/Mobs/Skeleton.h b/source/Mobs/Skeleton.h deleted file mode 100644 index 8f31b42e1..000000000 --- a/source/Mobs/Skeleton.h +++ /dev/null @@ -1,33 +0,0 @@ - -#pragma once - -#include "AggressiveMonster.h" - - - - - -class cSkeleton : - public cAggressiveMonster -{ - typedef cAggressiveMonster super; - -public: - cSkeleton(bool IsWither); - - CLASS_PROTODEF(cSkeleton); - - virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; - virtual void MoveToPosition(const Vector3f & a_Position) override; - virtual void Attack(float a_Dt) override; - bool IsWither(void) const { return m_bIsWither; }; - -private: - - bool m_bIsWither; - -} ; - - - - diff --git a/source/Mobs/Slime.cpp b/source/Mobs/Slime.cpp deleted file mode 100644 index 19f376c21..000000000 --- a/source/Mobs/Slime.cpp +++ /dev/null @@ -1,29 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "Slime.h" - - - - - -/// Creates a slime of the specified size; size is 1 .. 3, with 1 being the smallest -cSlime::cSlime(int a_Size) : - super("Slime", mtSlime, "mob.slime.attack", "mob.slime.attack", 0.6 * a_Size, 0.6 * a_Size), - m_Size(a_Size) -{ -} - - - - - -void cSlime::GetDrops(cItems & a_Drops, cEntity * 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 deleted file mode 100644 index 782c3113f..000000000 --- a/source/Mobs/Slime.h +++ /dev/null @@ -1,32 +0,0 @@ - -#pragma once - -#include "AggressiveMonster.h" - - - - - -class cSlime : - public cAggressiveMonster -{ - typedef cAggressiveMonster super; - -public: - /// Creates a slime of the specified size; size is 1 .. 3, with 1 being the smallest - cSlime(int a_Size); - - CLASS_PROTODEF(cSlime); - - virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; - int GetSize(void) const { return m_Size; } - -protected: - - /// Size of the slime, 1 .. 3, with 1 being the smallest - int m_Size; -} ; - - - - diff --git a/source/Mobs/SnowGolem.cpp b/source/Mobs/SnowGolem.cpp deleted file mode 100644 index 9e199f87e..000000000 --- a/source/Mobs/SnowGolem.cpp +++ /dev/null @@ -1,26 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "SnowGolem.h" - - - - - -cSnowGolem::cSnowGolem(void) : - super("SnowGolem", mtSnowGolem, "", "", 0.4, 1.8) -{ -} - - - - - -void cSnowGolem::GetDrops(cItems & a_Drops, cEntity * a_Killer) -{ - AddRandomDropItem(a_Drops, 0, 5, E_ITEM_SNOWBALL); -} - - - - diff --git a/source/Mobs/SnowGolem.h b/source/Mobs/SnowGolem.h deleted file mode 100644 index d1344adfd..000000000 --- a/source/Mobs/SnowGolem.h +++ /dev/null @@ -1,25 +0,0 @@ - -#pragma once - -#include "AggressiveMonster.h" - - - - - -class cSnowGolem : - public cAggressiveMonster -{ - typedef cAggressiveMonster super; - -public: - cSnowGolem(void); - - CLASS_PROTODEF(cSnowGolem); - - virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; -} ; - - - - diff --git a/source/Mobs/Spider.cpp b/source/Mobs/Spider.cpp deleted file mode 100644 index b19a5dcef..000000000 --- a/source/Mobs/Spider.cpp +++ /dev/null @@ -1,27 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "Spider.h" - - - - - -cSpider::cSpider(void) : - super("Spider", mtSpider, "mob.spider.say", "mob.spider.death", 1.4, 0.9) -{ -} - - - - - -void cSpider::GetDrops(cItems & a_Drops, cEntity * 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 deleted file mode 100644 index 51e65d028..000000000 --- a/source/Mobs/Spider.h +++ /dev/null @@ -1,25 +0,0 @@ - -#pragma once - -#include "AggressiveMonster.h" - - - - - -class cSpider : - public cAggressiveMonster -{ - typedef cAggressiveMonster super; - -public: - cSpider(void); - - CLASS_PROTODEF(cSpider); - - virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; -} ; - - - - diff --git a/source/Mobs/Squid.cpp b/source/Mobs/Squid.cpp deleted file mode 100644 index a311108ae..000000000 --- a/source/Mobs/Squid.cpp +++ /dev/null @@ -1,56 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "Squid.h" -#include "../Vector3d.h" -#include "../Chunk.h" - - - - - -cSquid::cSquid(void) : - super("Squid", mtSquid, "", "", 0.95, 0.95) -{ -} - - - - - -void cSquid::GetDrops(cItems & a_Drops, cEntity * a_Killer) -{ - // Drops 0-3 Ink Sacs - AddRandomDropItem(a_Drops, 0, 3, E_ITEM_DYE, E_META_DYE_BLACK); -} - - - - - -void cSquid::Tick(float a_Dt, cChunk & a_Chunk) -{ - // We must first process current location, and only then tick, otherwise we risk processing a location in a chunk - // that is not where the entity currently resides (FS #411) - - Vector3d Pos = GetPosition(); - - // TODO: Not a real behavior, but cool :D - int RelY = (int)floor(Pos.y); - if ((RelY < 0) || (RelY >= cChunkDef::Height)) - { - return; - } - int RelX = (int)floor(Pos.x) - a_Chunk.GetPosX() * cChunkDef::Width; - int RelZ = (int)floor(Pos.z) - a_Chunk.GetPosZ() * cChunkDef::Width; - if (!IsBlockWater(a_Chunk.GetBlock(RelX, RelY, RelZ)) && !IsOnFire()) - { - // Burn for 10 ticks, then decide again - StartBurning(10); - } - - super::Tick(a_Dt, a_Chunk); -} - - - diff --git a/source/Mobs/Squid.h b/source/Mobs/Squid.h deleted file mode 100644 index ad299b95c..000000000 --- a/source/Mobs/Squid.h +++ /dev/null @@ -1,28 +0,0 @@ - -#pragma once - -#include "PassiveMonster.h" - - - - - -class cSquid : - public cPassiveMonster -{ - typedef cPassiveMonster super; - -public: - cSquid(); - - virtual void Tick(float a_Dt, cChunk & a_Chunk) override; - - CLASS_PROTODEF(cSquid); - - virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; - -} ; - - - - diff --git a/source/Mobs/Villager.cpp b/source/Mobs/Villager.cpp deleted file mode 100644 index 7f89fb6cc..000000000 --- a/source/Mobs/Villager.cpp +++ /dev/null @@ -1,35 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "Villager.h" -#include "../World.h" - - - - - -cVillager::cVillager(eVillagerType VillagerType) : - super("Villager", mtVillager, "", "", 0.6, 1.8), - m_Type(VillagerType) -{ -} - - - - - -void cVillager::DoTakeDamage(TakeDamageInfo & a_TDI) -{ - super::DoTakeDamage(a_TDI); - if (a_TDI.Attacker->IsPlayer()) - { - if (m_World->GetTickRandomNumber(5) == 3) - { - m_World->BroadcastEntityStatus(*this, ENTITY_STATUS_VILLAGER_ANGRY); - } - } -} - - - - diff --git a/source/Mobs/Villager.h b/source/Mobs/Villager.h deleted file mode 100644 index 4cd9aaa8e..000000000 --- a/source/Mobs/Villager.h +++ /dev/null @@ -1,43 +0,0 @@ - -#pragma once - -#include "PassiveMonster.h" - - - - - -class cVillager : - public cPassiveMonster -{ - typedef cPassiveMonster super; - -public: - - enum eVillagerType - { - vtFarmer = 0, - vtLibrarian = 1, - vtPriest = 2, - vtBlacksmith = 3, - vtButcher = 4, - vtGeneric = 5, - vtMax - } ; - - cVillager(eVillagerType VillagerType); - - CLASS_PROTODEF(cVillager); - - virtual void DoTakeDamage(TakeDamageInfo & a_TDI) override; - int GetVilType(void) const { return m_Type; } - -private: - - int m_Type; - -} ; - - - - diff --git a/source/Mobs/Witch.cpp b/source/Mobs/Witch.cpp deleted file mode 100644 index 25d27041f..000000000 --- a/source/Mobs/Witch.cpp +++ /dev/null @@ -1,32 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "Witch.h" - - - - - -cWitch::cWitch(void) : - super("Witch", mtWitch, "", "", 0.6, 1.8) -{ -} - - - - - -void cWitch::GetDrops(cItems & a_Drops, cEntity * 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 deleted file mode 100644 index 4e637beea..000000000 --- a/source/Mobs/Witch.h +++ /dev/null @@ -1,27 +0,0 @@ - -#pragma once - -#include "AggressiveMonster.h" - - - - - -class cWitch : - public cAggressiveMonster -{ - typedef cAggressiveMonster super; - -public: - cWitch(); - - 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/Wither.cpp b/source/Mobs/Wither.cpp deleted file mode 100644 index c46e0beab..000000000 --- a/source/Mobs/Wither.cpp +++ /dev/null @@ -1,26 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "Wither.h" - - - - - -cWither::cWither(void) : - super("Wither", mtWither, "mob.wither.hurt", "mob.wither.death", 0.9, 4.0) -{ -} - - - - - -void cWither::GetDrops(cItems & a_Drops, cEntity * a_Killer) -{ - AddRandomDropItem(a_Drops, 1, 1, E_ITEM_NETHER_STAR); -} - - - - diff --git a/source/Mobs/Wither.h b/source/Mobs/Wither.h deleted file mode 100644 index 56effc6bb..000000000 --- a/source/Mobs/Wither.h +++ /dev/null @@ -1,25 +0,0 @@ - -#pragma once - -#include "AggressiveMonster.h" - - - - - -class cWither : - public cAggressiveMonster -{ - typedef cAggressiveMonster super; - -public: - cWither(void); - - CLASS_PROTODEF(cWither); - - virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; -} ; - - - - diff --git a/source/Mobs/Wolf.cpp b/source/Mobs/Wolf.cpp deleted file mode 100644 index c86250142..000000000 --- a/source/Mobs/Wolf.cpp +++ /dev/null @@ -1,189 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "Wolf.h" -#include "../World.h" -#include "../Entities/Player.h" - - - - - -cWolf::cWolf(void) : - super("Wolf", mtWolf, "mob.wolf.hurt", "mob.wolf.death", 0.6, 0.8), - m_IsAngry(false), - m_IsTame(false), - m_IsSitting(false), - m_IsBegging(false), - m_OwnerName(""), - m_CollarColor(14) -{ -} - - - - - -void cWolf::DoTakeDamage(TakeDamageInfo & a_TDI) -{ - super::DoTakeDamage(a_TDI); - if (!m_IsTame) - { - m_IsAngry = true; - } - m_World->BroadcastEntityMetadata(*this); // Broadcast health and possibly angry face -} - - - - - -void cWolf::OnRightClicked(cPlayer & a_Player) -{ - if (!IsTame() && !IsAngry()) - { - if (a_Player.GetEquippedItem().m_ItemType == E_ITEM_BONE) - { - if (!a_Player.IsGameModeCreative()) - { - a_Player.GetInventory().RemoveOneEquippedItem(); - } - - if (m_World->GetTickRandomNumber(7) == 0) - { - SetMaxHealth(20); - SetIsTame(true); - SetOwner(a_Player.GetName()); - m_World->BroadcastEntityStatus(*this, ENTITY_STATUS_WOLF_TAMED); - } - else - { - m_World->BroadcastEntityStatus(*this, ENTITY_STATUS_WOLF_TAMING); - } - } - } - else if (IsTame()) - { - if (a_Player.GetName() == m_OwnerName) // Is the player the owner of the dog? - { - if (a_Player.GetEquippedItem().m_ItemType == E_ITEM_DYE) - { - SetCollarColor(15 - a_Player.GetEquippedItem().m_ItemDamage); - if (!a_Player.IsGameModeCreative()) - { - a_Player.GetInventory().RemoveOneEquippedItem(); - } - } - else if (IsSitting()) - { - SetIsSitting(false); - } - else - { - SetIsSitting(true); - } - } - } - - m_World->BroadcastEntityMetadata(*this); -} - - - - - -void cWolf::Tick(float a_Dt, cChunk & a_Chunk) -{ - if (!IsAngry()) - { - cMonster::Tick(a_Dt, a_Chunk); - } - else - { - super::Tick(a_Dt, a_Chunk); - } - - if (IsSitting()) - { - m_bMovingToDestination = false; - } - - cPlayer * a_Closest_Player = FindClosestPlayer(); - if (a_Closest_Player != NULL) - { - switch (a_Closest_Player->GetEquippedItem().m_ItemType) - { - case E_ITEM_BONE: - case E_ITEM_RAW_BEEF: - case E_ITEM_STEAK: - case E_ITEM_RAW_CHICKEN: - case E_ITEM_COOKED_CHICKEN: - case E_ITEM_ROTTEN_FLESH: - { - if (!IsBegging()) - { - SetIsBegging(true); - m_World->BroadcastEntityMetadata(*this); - } - Vector3f a_NewDestination = a_Closest_Player->GetPosition(); - a_NewDestination.y = a_NewDestination.y + 1; // Look at the head of the player, not his feet. - m_Destination = Vector3f(a_NewDestination); - m_bMovingToDestination = false; - break; - } - default: - { - if (IsBegging()) - { - SetIsBegging(false); - m_World->BroadcastEntityMetadata(*this); - } - } - } - } - - if (IsTame()) - { - TickFollowPlayer(); - } -} - - - - - -void cWolf::TickFollowPlayer() -{ - class cCallback : - public cPlayerListCallback - { - virtual bool Item(cPlayer * a_Player) override - { - OwnerPos = a_Player->GetPosition(); - return false; - } - public: - Vector3f OwnerPos; - } Callback; - if (m_World->DoWithPlayer(m_OwnerName, Callback)) - { - // The player is present in the world, follow them: - double Distance = (Callback.OwnerPos - GetPosition()).Length(); - if (Distance < 3) - { - m_bMovingToDestination = false; - } - else if ((Distance > 30) && (!IsSitting())) - { - TeleportToCoords(Callback.OwnerPos.x, Callback.OwnerPos.y, Callback.OwnerPos.z); - } - else - { - m_Destination = Callback.OwnerPos; - } - } -} - - - - diff --git a/source/Mobs/Wolf.h b/source/Mobs/Wolf.h deleted file mode 100644 index 040e2cf7a..000000000 --- a/source/Mobs/Wolf.h +++ /dev/null @@ -1,54 +0,0 @@ - -#pragma once - -#include "PassiveAggressiveMonster.h" -#include "../Entities/Entity.h" - - - - - -class cWolf : - public cPassiveAggressiveMonster -{ - typedef cPassiveAggressiveMonster super; - -public: - cWolf(void); - - CLASS_PROTODEF(cWolf); - - virtual void DoTakeDamage(TakeDamageInfo & a_TDI) override; - virtual void OnRightClicked(cPlayer & a_Player) override; - virtual void Tick(float a_Dt, cChunk & a_Chunk) override; - virtual void TickFollowPlayer(); - - // Get functions - bool IsSitting (void) const { return m_IsSitting; } - bool IsTame (void) const { return m_IsTame; } - bool IsBegging (void) const { return m_IsBegging; } - bool IsAngry (void) const { return m_IsAngry; } - AString GetOwner (void) const { return m_OwnerName; } - int GetCollarColor(void) const { return m_CollarColor; } - - // Set functions - void SetIsSitting (bool a_IsSitting) { m_IsSitting = a_IsSitting; } - void SetIsTame (bool a_IsTame) { m_IsTame = a_IsTame; } - void SetIsBegging (bool a_IsBegging) { m_IsBegging = a_IsBegging; } - void SetIsAngry (bool a_IsAngry) { m_IsAngry = a_IsAngry; } - void SetOwner (AString a_NewOwner) { m_OwnerName = a_NewOwner; } - void SetCollarColor(int a_CollarColor) { m_CollarColor = a_CollarColor; } - -protected: - - bool m_IsSitting; - bool m_IsTame; - bool m_IsBegging; - bool m_IsAngry; - AString m_OwnerName; - int m_CollarColor; -} ; - - - - diff --git a/source/Mobs/Zombie.cpp b/source/Mobs/Zombie.cpp deleted file mode 100644 index a485d2b55..000000000 --- a/source/Mobs/Zombie.cpp +++ /dev/null @@ -1,47 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "Zombie.h" -#include "../World.h" -#include "../LineBlockTracer.h" - - - - -cZombie::cZombie(bool IsVillagerZombie) : - super("Zombie", mtZombie, "mob.zombie.hurt", "mob.zombie.death", 0.6, 1.8), - m_bIsConverting(false), - m_bIsVillagerZombie(IsVillagerZombie) -{ - SetBurnsInDaylight(true); -} - - - - - -void cZombie::GetDrops(cItems & a_Drops, cEntity * a_Killer) -{ - AddRandomDropItem(a_Drops, 0, 2, E_ITEM_ROTTEN_FLESH); - - // TODO: Rare drops -} - - - - - -void cZombie::MoveToPosition(const Vector3f & a_Position) -{ - m_Destination = a_Position; - - // If the destination is in the sun and if it is not night AND the skeleton isn't on fire then block the movement. - if ((m_World->GetBlockSkyLight((int) a_Position.x, (int) a_Position.y, (int) a_Position.z) == 15) && (m_World->GetTimeOfDay() < 13187) && !IsOnFire()) - { - m_bMovingToDestination = false; - return; - } - m_bMovingToDestination = true; -} - - diff --git a/source/Mobs/Zombie.h b/source/Mobs/Zombie.h deleted file mode 100644 index 7e14fe42f..000000000 --- a/source/Mobs/Zombie.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once - -#include "AggressiveMonster.h" - - - - - -class cZombie : - public cAggressiveMonster -{ - typedef cAggressiveMonster super; - -public: - cZombie(bool IsVillagerZombie); - - CLASS_PROTODEF(cZombie); - - virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; - virtual void MoveToPosition(const Vector3f & a_Position) override; - - bool IsVillagerZombie(void) const {return m_bIsVillagerZombie; } - bool IsConverting(void) const {return m_bIsConverting; } - -private: - - bool m_bIsVillagerZombie, m_bIsConverting; - -} ; - - - - diff --git a/source/Mobs/Zombiepigman.cpp b/source/Mobs/Zombiepigman.cpp deleted file mode 100644 index 6ac89ed4c..000000000 --- a/source/Mobs/Zombiepigman.cpp +++ /dev/null @@ -1,45 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "Zombiepigman.h" -#include "../World.h" - - - - - -cZombiePigman::cZombiePigman(void) : - super("ZombiePigman", mtZombiePigman, "mob.zombiepig.zpighurt", "mob.zombiepig.zpigdeath", 0.6, 1.8) -{ -} - - - - - -void cZombiePigman::GetDrops(cItems & a_Drops, cEntity * a_Killer) -{ - AddRandomDropItem(a_Drops, 0, 1, E_ITEM_ROTTEN_FLESH); - AddRandomDropItem(a_Drops, 0, 1, E_ITEM_GOLD_NUGGET); - - // TODO: Rare drops -} - - - - - -void cZombiePigman::KilledBy(cEntity * a_Killer) -{ - super::KilledBy(a_Killer); - - if ((a_Killer != NULL) && (a_Killer->IsPlayer())) - { - // 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 deleted file mode 100644 index 67991d56a..000000000 --- a/source/Mobs/Zombiepigman.h +++ /dev/null @@ -1,26 +0,0 @@ - -#pragma once - -#include "PassiveAggressiveMonster.h" - - - - - -class cZombiePigman : - public cPassiveAggressiveMonster -{ - typedef cPassiveAggressiveMonster super; - -public: - cZombiePigman(void); - - CLASS_PROTODEF(cZombiePigman); - - virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; - virtual void KilledBy(cEntity * a_Killer) override; -} ; - - - - -- cgit v1.2.3