summaryrefslogtreecommitdiff
path: root/src/game-server/monster.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game-server/monster.cpp')
-rw-r--r--src/game-server/monster.cpp32
1 files changed, 11 insertions, 21 deletions
diff --git a/src/game-server/monster.cpp b/src/game-server/monster.cpp
index 8db0df69..d0c55073 100644
--- a/src/game-server/monster.cpp
+++ b/src/game-server/monster.cpp
@@ -34,21 +34,6 @@
#include <cmath>
-ItemClass *MonsterClass::getRandomDrop() const
-{
- int p = rand() / (RAND_MAX / 10000);
- for (MonsterDrops::const_iterator i = mDrops.begin(),
- i_end = mDrops.end(); i != i_end; ++i)
- {
- p -= i->probability;
- if (p < 0)
- {
- return i->item;
- }
- }
- return NULL;
-}
-
struct MonsterTargetEventDispatch: EventDispatch
{
MonsterTargetEventDispatch()
@@ -466,13 +451,18 @@ void Monster::died()
if (mExpReceivers.size() > 0)
{
- // If the monster was killed by players, randomly drop an item.
- if (ItemClass *drop = mSpecy->getRandomDrop())
+ // If the monster was killed by players, randomly drop items.
+ const unsigned size = mSpecy->mDrops.size();
+ for (unsigned i = 0; i < size; i++)
{
- Item *item = new Item(drop, 1);
- item->setMap(getMap());
- item->setPosition(getPosition());
- GameState::enqueueInsert(item);
+ const int p = rand() / (RAND_MAX / 10000);
+ if (p <= mSpecy->mDrops[i].probability)
+ {
+ Item *item = new Item(mSpecy->mDrops[i].item, 1);
+ item->setMap(getMap());
+ item->setPosition(getPosition());
+ GameState::enqueueInsert(item);
+ }
}
// Distribute exp reward.