From b698286e86b56cd43f340129a570b24d2a011949 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Sat, 21 Mar 2015 15:52:49 +0100 Subject: Creeper: Fixed skeleton check. --- src/Mobs/Creeper.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/Mobs/Creeper.cpp b/src/Mobs/Creeper.cpp index c4ae47f2f..41796402f 100644 --- a/src/Mobs/Creeper.cpp +++ b/src/Mobs/Creeper.cpp @@ -67,30 +67,29 @@ void cCreeper::GetDrops(cItems & a_Drops, cEntity * a_Killer) } AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_GUNPOWDER); - if ((a_Killer != nullptr) && a_Killer->IsProjectile() && (((cProjectileEntity *)a_Killer)->GetCreatorUniqueID() >= 0)) + // If the creeper was killed by a skeleton, add a random music disc drop: + if ( + (a_Killer != nullptr) && + a_Killer->IsProjectile() && + ((reinterpret_cast(a_Killer))->GetCreatorUniqueID() != cEntity::INVALID_ID)) { class cProjectileCreatorCallback : public cEntityCallback { public: - cProjectileCreatorCallback(void) - { - } + cProjectileCreatorCallback(void) {} virtual bool Item(cEntity * a_Entity) override { - if (a_Entity->IsMob() && ((cMonster *)a_Entity)->GetMobType() == mtSkeleton) + if (a_Entity->IsMob() && ((reinterpret_cast(a_Entity))->GetMobType() == mtSkeleton)) { return true; } return false; } - }; - - cProjectileCreatorCallback PCC; - if (GetWorld()->DoWithEntityByID(((cProjectileEntity *)a_Killer)->GetCreatorUniqueID(), PCC)) + } PCC; + if (GetWorld()->DoWithEntityByID((reinterpret_cast(a_Killer))->GetCreatorUniqueID(), PCC)) { - // 12 music discs. TickRand starts from 0 to 11. Disk IDs start at 2256, so add that. There. - AddRandomDropItem(a_Drops, 1, 1, (short)m_World->GetTickRandomNumber(11) + 2256); + AddRandomDropItem(a_Drops, 1, 1, static_cast(m_World->GetTickRandomNumber(11) + E_ITEM_FIRST_DISC)); } } } -- cgit v1.2.3