From 1cca9b13b3d320ff767cfc552413265b2ef6e0d6 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Wed, 6 Jun 2012 20:18:50 +0000 Subject: Item-dropping code rewritten and centralized - now there's only one place to modify if we want to split or merge same-item drops: cWorld:SpawnItemPickups(). Also, mined blocks can now drop more items, and they recognize if they're being mined by the correct tool. git-svn-id: http://mc-server.googlecode.com/svn/trunk@561 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/cMonster.cpp | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'source/cMonster.cpp') diff --git a/source/cMonster.cpp b/source/cMonster.cpp index 1820bae4d..7834b855a 100644 --- a/source/cMonster.cpp +++ b/source/cMonster.cpp @@ -7,10 +7,7 @@ #include "cClientHandle.h" #include "cWorld.h" #include "cPlayer.h" -#include "BlockID.h" #include "Defines.h" -#include "cPickup.h" -#include "cItem.h" #include "cMonsterConfig.h" #include "MersenneTwister.h" @@ -548,21 +545,16 @@ void cMonster::SetSightDistance(float sd) -void cMonster::DropItem(ENUM_ITEM_ID a_Item, unsigned int a_Count) +void cMonster::AddRandomDropItem(cItems & a_Drops, unsigned int a_Min, unsigned int a_Max, ENUM_ITEM_ID a_Item, short a_ItemHealth) { - if (a_Count > 0) + MTRand r1; + int Count = r1.randInt() % (a_Max + 1 - a_Min) + a_Min; + if (Count > 0) { - cPickup * Pickup = new cPickup( (int)(m_Pos.x * 32), (int)(m_Pos.y * 32), (int)(m_Pos.z * 32), cItem( a_Item, (char) a_Count ) ); - Pickup->Initialize( GetWorld() ); + a_Drops.push_back(cItem(a_Item, Count, a_ItemHealth)); } } - -void cMonster::RandomDropItem(ENUM_ITEM_ID a_Item, unsigned int a_Min, unsigned int a_Max) -{ - MTRand r1; - return cMonster::DropItem(a_Item, r1.randInt() % (a_Max + 1 - a_Min) + a_Min); -} \ No newline at end of file -- cgit v1.2.3