From 2d02ff1df8204a74c477a27b3d30f297fde2e5bf Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Thu, 10 Apr 2014 15:50:43 +0100 Subject: Update Monster.cpp --- src/Mobs/Monster.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/Mobs') diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index aa6071515..22ee6e0dd 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -1,4 +1,3 @@ - #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "IncludeAllMonsters.h" @@ -526,7 +525,10 @@ void cMonster::KilledBy(cEntity * a_Killer) break; } } - m_World->SpawnExperienceOrb(GetPosX(), GetPosY(), GetPosZ(), Reward); + if (a_Killer != NULL) + { + m_World->SpawnExperienceOrb(GetPosX(), GetPosY(), GetPosZ(), Reward); + } m_DestroyTimer = 0; } -- cgit v1.2.3 From 9ad87f670b66abd0d3cc02bec446bb93ef2b578c Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Thu, 10 Apr 2014 15:52:00 +0100 Subject: Fixed GitHuB WebEdit fail. --- src/Mobs/Monster.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/Mobs') diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index 22ee6e0dd..171097aba 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -1,3 +1,4 @@ + #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "IncludeAllMonsters.h" -- cgit v1.2.3 From c0c47d33c571bde4cfb45043b645b3d45c3223e6 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 12 Apr 2014 13:16:48 +0100 Subject: Entities handle chunks properly again * Entities properly handle chunks * Changed EntityStatus enums to be less shouty --- src/Mobs/Sheep.cpp | 2 +- src/Mobs/Villager.cpp | 2 +- src/Mobs/Wolf.cpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/Mobs') diff --git a/src/Mobs/Sheep.cpp b/src/Mobs/Sheep.cpp index c64360153..d599a4cef 100644 --- a/src/Mobs/Sheep.cpp +++ b/src/Mobs/Sheep.cpp @@ -101,7 +101,7 @@ void cSheep::Tick(float a_Dt, cChunk & a_Chunk) { if (m_World->GetBlock(PosX, PosY, PosZ) == E_BLOCK_GRASS) { - m_World->BroadcastEntityStatus(*this, ENTITY_STATUS_SHEEP_EATING); + m_World->BroadcastEntityStatus(*this, esSheepEating); m_TimeToStopEating = 40; } } diff --git a/src/Mobs/Villager.cpp b/src/Mobs/Villager.cpp index bbd8d6aaa..d049acc1e 100644 --- a/src/Mobs/Villager.cpp +++ b/src/Mobs/Villager.cpp @@ -30,7 +30,7 @@ void cVillager::DoTakeDamage(TakeDamageInfo & a_TDI) { if (m_World->GetTickRandomNumber(5) == 3) { - m_World->BroadcastEntityStatus(*this, ENTITY_STATUS_VILLAGER_ANGRY); + m_World->BroadcastEntityStatus(*this, esVillagerAngry); } } } diff --git a/src/Mobs/Wolf.cpp b/src/Mobs/Wolf.cpp index 0d3619166..f02b8a4fc 100644 --- a/src/Mobs/Wolf.cpp +++ b/src/Mobs/Wolf.cpp @@ -75,12 +75,12 @@ void cWolf::OnRightClicked(cPlayer & a_Player) SetMaxHealth(20); SetIsTame(true); SetOwner(a_Player.GetName()); - m_World->BroadcastEntityStatus(*this, ENTITY_STATUS_WOLF_TAMED); + m_World->BroadcastEntityStatus(*this, esWolfTamed); m_World->BroadcastParticleEffect("heart", (float) GetPosX(), (float) GetPosY(), (float) GetPosZ(), 0, 0, 0, 0, 5); } else { - m_World->BroadcastEntityStatus(*this, ENTITY_STATUS_WOLF_TAMING); + m_World->BroadcastEntityStatus(*this, esWolfTaming); m_World->BroadcastParticleEffect("smoke", (float) GetPosX(), (float) GetPosY(), (float) GetPosZ(), 0, 0, 0, 0, 5); } } -- cgit v1.2.3 From bdea8706d8050ba3ea00b580bba795bc468cfdbd Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 17 Apr 2014 18:50:25 +0100 Subject: Added new AI rules + Added new AI rules handling cacti and large heights * Fixed cIniFile not recognising comments in cIniFile::ReadFile() * Fixed users.ini not being properly generated * Changed all instances of (int)floor(GetPosXXX()) to POSXXX_TOINT --- src/Mobs/Monster.cpp | 38 ++++++++++++++++++++++++++------------ src/Mobs/Monster.h | 4 ++-- 2 files changed, 28 insertions(+), 14 deletions(-) (limited to 'src/Mobs') diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index 171097aba..d63758b3d 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -111,9 +111,9 @@ void cMonster::SpawnOn(cClientHandle & a_Client) void cMonster::TickPathFinding() { - const int PosX = (int)floor(GetPosX()); - const int PosY = (int)floor(GetPosY()); - const int PosZ = (int)floor(GetPosZ()); + const int PosX = POSX_TOINT; + const int PosY = POSY_TOINT; + const int PosZ = POSZ_TOINT; m_FinalDestination.y = (double)FindFirstNonAirBlockPosition(m_FinalDestination.x, m_FinalDestination.z); @@ -148,13 +148,27 @@ void cMonster::TickPathFinding() BLOCKTYPE BlockAtY = m_World->GetBlock(gCrossCoords[i].x + PosX, PosY, gCrossCoords[i].z + PosZ); BLOCKTYPE BlockAtYP = m_World->GetBlock(gCrossCoords[i].x + PosX, PosY + 1, gCrossCoords[i].z + PosZ); BLOCKTYPE BlockAtYPP = m_World->GetBlock(gCrossCoords[i].x + PosX, PosY + 2, gCrossCoords[i].z + PosZ); - BLOCKTYPE BlockAtYM = m_World->GetBlock(gCrossCoords[i].x + PosX, PosY - 1, gCrossCoords[i].z + PosZ); - - if ((!cBlockInfo::IsSolid(BlockAtY)) && (!cBlockInfo::IsSolid(BlockAtYP)) && (!IsBlockLava(BlockAtYM)) && (BlockAtY != E_BLOCK_FENCE) && (BlockAtY != E_BLOCK_FENCE_GATE)) + int LowestY = FindFirstNonAirBlockPosition(gCrossCoords[i].x + PosX, gCrossCoords[i].z + PosZ); + BLOCKTYPE BlockAtLowestY = m_World->GetBlock(gCrossCoords[i].x + PosX, LowestY, gCrossCoords[i].z + PosZ); + + if ( + (!cBlockInfo::IsSolid(BlockAtY)) && + (!cBlockInfo::IsSolid(BlockAtYP)) && + (!IsBlockLava(BlockAtLowestY)) && + (BlockAtLowestY != E_BLOCK_CACTUS) && + (PosY - LowestY < FALL_DAMAGE_HEIGHT) + ) { m_PotentialCoordinates.push_back(Vector3d((gCrossCoords[i].x + PosX), PosY, gCrossCoords[i].z + PosZ)); } - else if ((cBlockInfo::IsSolid(BlockAtY)) && (!cBlockInfo::IsSolid(BlockAtYP)) && (!cBlockInfo::IsSolid(BlockAtYPP)) && (!IsBlockLava(BlockAtYM)) && (BlockAtY != E_BLOCK_FENCE) && (BlockAtY != E_BLOCK_FENCE_GATE)) + else if ( + (cBlockInfo::IsSolid(BlockAtY)) && + (BlockAtY != E_BLOCK_CACTUS) && + (!cBlockInfo::IsSolid(BlockAtYP)) && + (!cBlockInfo::IsSolid(BlockAtYPP)) && + (BlockAtY != E_BLOCK_FENCE) && + (BlockAtY != E_BLOCK_FENCE_GATE) + ) { m_PotentialCoordinates.push_back(Vector3d((gCrossCoords[i].x + PosX), PosY + 1, gCrossCoords[i].z + PosZ)); } @@ -402,7 +416,7 @@ void cMonster::HandleFalling() GetWorld()->BroadcastSoundParticleEffect(2006, POSX_TOINT, POSY_TOINT - 1, POSZ_TOINT, Damage /* Used as particle effect speed modifier */); } - m_LastGroundHeight = (int)floor(GetPosY()); + m_LastGroundHeight = POSY_TOINT; } } @@ -411,7 +425,7 @@ void cMonster::HandleFalling() int cMonster::FindFirstNonAirBlockPosition(double a_PosX, double a_PosZ) { - int PosY = (int)floor(GetPosY()); + int PosY = POSY_TOINT; if (PosY < 0) PosY = 0; @@ -969,15 +983,15 @@ void cMonster::HandleDaylightBurning(cChunk & a_Chunk) return; } - int RelY = (int)floor(GetPosY()); + int RelY = POSY_TOINT; 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; + int RelX = POSX_TOINT - GetChunkX() * cChunkDef::Width; + int RelZ = POSZ_TOINT - GetChunkZ() * cChunkDef::Width; if (!a_Chunk.IsLightValid()) { diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h index 776426a0d..70b3783fc 100644 --- a/src/Mobs/Monster.h +++ b/src/Mobs/Monster.h @@ -185,14 +185,14 @@ protected: inline bool IsNextYPosReachable(int a_PosY) { return ( - (a_PosY <= (int)floor(GetPosY())) || + (a_PosY <= POSY_TOINT) || DoesPosYRequireJump(a_PosY) ); } /** Returns if a monster can reach a given height by jumping */ inline bool DoesPosYRequireJump(int a_PosY) { - return ((a_PosY > (int)floor(GetPosY())) && (a_PosY == (int)floor(GetPosY()) + 1)); + return ((a_PosY > POSY_TOINT) && (a_PosY == POSY_TOINT + 1)); } /** A semi-temporary list to store the traversed coordinates during active pathfinding so we don't visit them again */ -- cgit v1.2.3 From 200ea6254c28b73d419001ea1be7d2d4d1d1ee88 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 18 Apr 2014 12:54:17 +0100 Subject: Fixed #904 --- src/Mobs/Monster.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Mobs') diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index d63758b3d..27bd28045 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -540,7 +540,7 @@ void cMonster::KilledBy(cEntity * a_Killer) break; } } - if (a_Killer != NULL) + if ((a_Killer != NULL) && (!IsBaby()) { m_World->SpawnExperienceOrb(GetPosX(), GetPosY(), GetPosZ(), Reward); } -- cgit v1.2.3 From 6cb63a768dd2356d0e41aef1ef086ae972449bdd Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 18 Apr 2014 12:59:14 +0100 Subject: Fixed #906 --- src/Mobs/Monster.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/Mobs') diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index 27bd28045..9df5d5e3b 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -1003,7 +1003,8 @@ void cMonster::HandleDaylightBurning(cChunk & a_Chunk) (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 + !IsOnFire() && // Not already burning + (GetWorld()->GetWeather() != eWeather_Rain) // Not raining ) { // Burn for 100 ticks, then decide again -- cgit v1.2.3 From 013da806ec20b62a742aded9a9d2b8131193f30d Mon Sep 17 00:00:00 2001 From: jfhumann Date: Fri, 18 Apr 2014 21:09:44 +0200 Subject: Did some static analysis, fixed some bugs and optimized a lot of code --- src/Mobs/Sheep.cpp | 7 ++++--- src/Mobs/Wolf.h | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'src/Mobs') diff --git a/src/Mobs/Sheep.cpp b/src/Mobs/Sheep.cpp index c64360153..b3d4d93c1 100644 --- a/src/Mobs/Sheep.cpp +++ b/src/Mobs/Sheep.cpp @@ -36,7 +36,8 @@ 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)) + const cItem & EquippedItem = a_Player.GetEquippedItem(); + if ((EquippedItem.m_ItemType == E_ITEM_SHEARS) && (!m_IsSheared)) { m_IsSheared = true; m_World->BroadcastEntityMetadata(*this); @@ -51,9 +52,9 @@ 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) && (m_WoolColor != 15 - a_Player.GetEquippedItem().m_ItemDamage)) + else if ((EquippedItem.m_ItemType == E_ITEM_DYE) && (m_WoolColor != 15 - EquippedItem.m_ItemDamage)) { - m_WoolColor = 15 - a_Player.GetEquippedItem().m_ItemDamage; + m_WoolColor = 15 - EquippedItem.m_ItemDamage; if (!a_Player.IsGameModeCreative()) { a_Player.GetInventory().RemoveOneEquippedItem(); diff --git a/src/Mobs/Wolf.h b/src/Mobs/Wolf.h index 9e5ad03c7..5925373e1 100644 --- a/src/Mobs/Wolf.h +++ b/src/Mobs/Wolf.h @@ -37,7 +37,7 @@ public: 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 SetOwner (const AString & a_NewOwner) { m_OwnerName = a_NewOwner; } void SetCollarColor(int a_CollarColor) { m_CollarColor = a_CollarColor; } protected: -- cgit v1.2.3 From 19358fc7d5cfde19d47a910adbf8a1d67dd48f5f Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 18 Apr 2014 20:20:00 +0100 Subject: Compilation fix --- src/Mobs/Monster.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Mobs') diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index 9df5d5e3b..248e88f5d 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -540,7 +540,7 @@ void cMonster::KilledBy(cEntity * a_Killer) break; } } - if ((a_Killer != NULL) && (!IsBaby()) + if ((a_Killer != NULL) && (!IsBaby())) { m_World->SpawnExperienceOrb(GetPosX(), GetPosY(), GetPosZ(), Reward); } -- cgit v1.2.3 From c2f2ef7cb4e4232cae18aaddcc6c86253e6c859b Mon Sep 17 00:00:00 2001 From: archshift Date: Wed, 23 Apr 2014 14:56:39 -0700 Subject: Rename mob source files to fit CamelCase. Rename Cavespider.cpp to CaveSpider.cpp Rename Cavespider.h to CaveSpider.h Rename Magmacube.cpp to MagmaCube.cpp Rename Magmacube.h to MagmaCube.h Rename Zombiepigman.cpp to ZombiePigman.cpp Rename Zombiepigman.h to ZombiePigman.h --- src/Mobs/CaveSpider.cpp | 47 +++++++++++++++++++++++++++++++++++++++++ src/Mobs/CaveSpider.h | 25 ++++++++++++++++++++++ src/Mobs/Cavespider.cpp | 48 ----------------------------------------- src/Mobs/Cavespider.h | 26 ----------------------- src/Mobs/MagmaCube.cpp | 30 ++++++++++++++++++++++++++ src/Mobs/MagmaCube.h | 31 +++++++++++++++++++++++++++ src/Mobs/Magmacube.cpp | 31 --------------------------- src/Mobs/Magmacube.h | 32 ---------------------------- src/Mobs/ZombiePigman.cpp | 53 ++++++++++++++++++++++++++++++++++++++++++++++ src/Mobs/ZombiePigman.h | 25 ++++++++++++++++++++++ src/Mobs/Zombiepigman.cpp | 54 ----------------------------------------------- src/Mobs/Zombiepigman.h | 26 ----------------------- 12 files changed, 211 insertions(+), 217 deletions(-) create mode 100644 src/Mobs/CaveSpider.cpp create mode 100644 src/Mobs/CaveSpider.h delete mode 100644 src/Mobs/Cavespider.cpp delete mode 100644 src/Mobs/Cavespider.h create mode 100644 src/Mobs/MagmaCube.cpp create mode 100644 src/Mobs/MagmaCube.h delete mode 100644 src/Mobs/Magmacube.cpp delete mode 100644 src/Mobs/Magmacube.h create mode 100644 src/Mobs/ZombiePigman.cpp create mode 100644 src/Mobs/ZombiePigman.h delete mode 100644 src/Mobs/Zombiepigman.cpp delete mode 100644 src/Mobs/Zombiepigman.h (limited to 'src/Mobs') diff --git a/src/Mobs/CaveSpider.cpp b/src/Mobs/CaveSpider.cpp new file mode 100644 index 000000000..4660ae44d --- /dev/null +++ b/src/Mobs/CaveSpider.cpp @@ -0,0 +1,47 @@ +#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) +{ + int LootingLevel = 0; + if (a_Killer != NULL) + { + LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting); + } + AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_STRING); + if ((a_Killer != NULL) && (a_Killer->IsPlayer() || a_Killer->IsA("cWolf"))) + { + AddRandomUncommonDropItem(a_Drops, 33.0f, E_ITEM_SPIDER_EYE); + } +} + + + + diff --git a/src/Mobs/CaveSpider.h b/src/Mobs/CaveSpider.h new file mode 100644 index 000000000..c2aacd2c7 --- /dev/null +++ b/src/Mobs/CaveSpider.h @@ -0,0 +1,25 @@ +#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/src/Mobs/Cavespider.cpp b/src/Mobs/Cavespider.cpp deleted file mode 100644 index 94e93283d..000000000 --- a/src/Mobs/Cavespider.cpp +++ /dev/null @@ -1,48 +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) -{ - int LootingLevel = 0; - if (a_Killer != NULL) - { - LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting); - } - AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_STRING); - if ((a_Killer != NULL) && (a_Killer->IsPlayer() || a_Killer->IsA("cWolf"))) - { - AddRandomUncommonDropItem(a_Drops, 33.0f, E_ITEM_SPIDER_EYE); - } -} - - - - diff --git a/src/Mobs/Cavespider.h b/src/Mobs/Cavespider.h deleted file mode 100644 index 10ea03f7b..000000000 --- a/src/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/src/Mobs/MagmaCube.cpp b/src/Mobs/MagmaCube.cpp new file mode 100644 index 000000000..064152072 --- /dev/null +++ b/src/Mobs/MagmaCube.cpp @@ -0,0 +1,30 @@ +#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) +{ + UNUSED(a_Killer); + if (GetSize() > 1) + { + AddRandomUncommonDropItem(a_Drops, 25.0f, E_ITEM_MAGMA_CREAM); + } +} + + + + diff --git a/src/Mobs/MagmaCube.h b/src/Mobs/MagmaCube.h new file mode 100644 index 000000000..43065cae5 --- /dev/null +++ b/src/Mobs/MagmaCube.h @@ -0,0 +1,31 @@ +#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/src/Mobs/Magmacube.cpp b/src/Mobs/Magmacube.cpp deleted file mode 100644 index 05405f082..000000000 --- a/src/Mobs/Magmacube.cpp +++ /dev/null @@ -1,31 +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) -{ - UNUSED(a_Killer); - if (GetSize() > 1) - { - AddRandomUncommonDropItem(a_Drops, 25.0f, E_ITEM_MAGMA_CREAM); - } -} - - - - diff --git a/src/Mobs/Magmacube.h b/src/Mobs/Magmacube.h deleted file mode 100644 index 130952970..000000000 --- a/src/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/src/Mobs/ZombiePigman.cpp b/src/Mobs/ZombiePigman.cpp new file mode 100644 index 000000000..b6f95a3e1 --- /dev/null +++ b/src/Mobs/ZombiePigman.cpp @@ -0,0 +1,53 @@ +#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) +{ + int LootingLevel = 0; + if (a_Killer != NULL) + { + LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting); + } + AddRandomDropItem(a_Drops, 0, 1 + LootingLevel, E_ITEM_ROTTEN_FLESH); + AddRandomDropItem(a_Drops, 0, 1 + LootingLevel, E_ITEM_GOLD_NUGGET); + + cItems RareDrops; + RareDrops.Add(cItem(E_ITEM_GOLD)); + AddRandomRareDropItem(a_Drops, RareDrops, LootingLevel); + AddRandomArmorDropItem(a_Drops, LootingLevel); + AddRandomWeaponDropItem(a_Drops, LootingLevel); +} + + + + + +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/src/Mobs/ZombiePigman.h b/src/Mobs/ZombiePigman.h new file mode 100644 index 000000000..ab3cebf6d --- /dev/null +++ b/src/Mobs/ZombiePigman.h @@ -0,0 +1,25 @@ +#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; +} ; + + + + diff --git a/src/Mobs/Zombiepigman.cpp b/src/Mobs/Zombiepigman.cpp deleted file mode 100644 index a0142b566..000000000 --- a/src/Mobs/Zombiepigman.cpp +++ /dev/null @@ -1,54 +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) -{ - int LootingLevel = 0; - if (a_Killer != NULL) - { - LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting); - } - AddRandomDropItem(a_Drops, 0, 1 + LootingLevel, E_ITEM_ROTTEN_FLESH); - AddRandomDropItem(a_Drops, 0, 1 + LootingLevel, E_ITEM_GOLD_NUGGET); - - cItems RareDrops; - RareDrops.Add(cItem(E_ITEM_GOLD)); - AddRandomRareDropItem(a_Drops, RareDrops, LootingLevel); - AddRandomArmorDropItem(a_Drops, LootingLevel); - AddRandomWeaponDropItem(a_Drops, LootingLevel); -} - - - - - -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/src/Mobs/Zombiepigman.h b/src/Mobs/Zombiepigman.h deleted file mode 100644 index 67991d56a..000000000 --- a/src/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 From 06819595b0a5366711bb4aa156a2198650e5c0ff Mon Sep 17 00:00:00 2001 From: archshift Date: Wed, 23 Apr 2014 15:25:10 -0700 Subject: Fixed references to renamed files. --- src/Mobs/CaveSpider.cpp | 4 ++-- src/Mobs/IncludeAllMonsters.h | 6 +++--- src/Mobs/MagmaCube.cpp | 2 +- src/Mobs/ZombiePigman.cpp | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/Mobs') diff --git a/src/Mobs/CaveSpider.cpp b/src/Mobs/CaveSpider.cpp index 4660ae44d..8e35102a4 100644 --- a/src/Mobs/CaveSpider.cpp +++ b/src/Mobs/CaveSpider.cpp @@ -1,6 +1,6 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules -#include "Cavespider.h" +#include "CaveSpider.h" #include "../World.h" @@ -8,7 +8,7 @@ cCavespider::cCavespider(void) : - super("Cavespider", mtCaveSpider, "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/src/Mobs/IncludeAllMonsters.h b/src/Mobs/IncludeAllMonsters.h index 1b436a11f..3460db993 100644 --- a/src/Mobs/IncludeAllMonsters.h +++ b/src/Mobs/IncludeAllMonsters.h @@ -1,6 +1,6 @@ #include "Bat.h" #include "Blaze.h" -#include "Cavespider.h" +#include "CaveSpider.h" #include "Chicken.h" #include "Cow.h" #include "Creeper.h" @@ -10,7 +10,7 @@ #include "Giant.h" #include "Horse.h" #include "IronGolem.h" -#include "Magmacube.h" +#include "MagmaCube.h" #include "Mooshroom.h" #include "Ocelot.h" #include "Pig.h" @@ -26,4 +26,4 @@ #include "Wither.h" #include "Wolf.h" #include "Zombie.h" -#include "Zombiepigman.h" +#include "ZombiePigman.h" diff --git a/src/Mobs/MagmaCube.cpp b/src/Mobs/MagmaCube.cpp index 064152072..3e9abc108 100644 --- a/src/Mobs/MagmaCube.cpp +++ b/src/Mobs/MagmaCube.cpp @@ -1,6 +1,6 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules -#include "Magmacube.h" +#include "MagmaCube.h" diff --git a/src/Mobs/ZombiePigman.cpp b/src/Mobs/ZombiePigman.cpp index b6f95a3e1..c9d94face 100644 --- a/src/Mobs/ZombiePigman.cpp +++ b/src/Mobs/ZombiePigman.cpp @@ -1,6 +1,6 @@ #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 8fc45c57307203a86352bdd7a788fb20cff797ff Mon Sep 17 00:00:00 2001 From: archshift Date: Thu, 24 Apr 2014 12:00:27 -0700 Subject: Fixed class capitalization for the cave spider. --- src/Mobs/CaveSpider.cpp | 6 +++--- src/Mobs/CaveSpider.h | 4 ++-- src/Mobs/Monster.cpp | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src/Mobs') diff --git a/src/Mobs/CaveSpider.cpp b/src/Mobs/CaveSpider.cpp index 8e35102a4..56ecd2d28 100644 --- a/src/Mobs/CaveSpider.cpp +++ b/src/Mobs/CaveSpider.cpp @@ -7,7 +7,7 @@ -cCavespider::cCavespider(void) : +cCaveSpider::cCaveSpider(void) : super("CaveSpider", mtCaveSpider, "mob.spider.say", "mob.spider.death", 0.7, 0.5) { } @@ -16,7 +16,7 @@ cCavespider::cCavespider(void) : -void cCavespider::Tick(float a_Dt, cChunk & a_Chunk) +void cCaveSpider::Tick(float a_Dt, cChunk & a_Chunk) { super::Tick(a_Dt, a_Chunk); @@ -28,7 +28,7 @@ void cCavespider::Tick(float a_Dt, cChunk & a_Chunk) -void cCavespider::GetDrops(cItems & a_Drops, cEntity * a_Killer) +void cCaveSpider::GetDrops(cItems & a_Drops, cEntity * a_Killer) { int LootingLevel = 0; if (a_Killer != NULL) diff --git a/src/Mobs/CaveSpider.h b/src/Mobs/CaveSpider.h index c2aacd2c7..be9f174f9 100644 --- a/src/Mobs/CaveSpider.h +++ b/src/Mobs/CaveSpider.h @@ -6,13 +6,13 @@ -class cCavespider : +class cCaveSpider : public cAggressiveMonster { typedef cAggressiveMonster super; public: - cCavespider(void); + cCaveSpider(void); CLASS_PROTODEF(cCaveSpider); diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index 248e88f5d..eb8480268 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -859,7 +859,7 @@ cMonster * cMonster::NewMonsterFromType(cMonster::eType a_MobType) case mtBat: toReturn = new cBat(); break; case mtBlaze: toReturn = new cBlaze(); break; - case mtCaveSpider: toReturn = new cCavespider(); 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; -- cgit v1.2.3 From e47dab84f3f6606d6d6e95774b16d7d4e8d7daa6 Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 25 Apr 2014 09:56:15 -0700 Subject: Cmake generated projects for IDEs include headers in project files. --- src/Mobs/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) (limited to 'src/Mobs') diff --git a/src/Mobs/CMakeLists.txt b/src/Mobs/CMakeLists.txt index 87fbfd2fc..53c265803 100644 --- a/src/Mobs/CMakeLists.txt +++ b/src/Mobs/CMakeLists.txt @@ -6,6 +6,7 @@ include_directories ("${PROJECT_SOURCE_DIR}/../") file(GLOB SOURCE "*.cpp" + "*.h" ) add_library(Mobs ${SOURCE}) -- cgit v1.2.3