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