From aaf57b8aa9cbc8287f298de2b19861eb23aec2f3 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 10 Nov 2013 17:25:16 +0000 Subject: Added a 10 percent chance for NPCs to drop weapons when destroyed. --- src/game/base/ship.cc | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/game/base/ship.cc b/src/game/base/ship.cc index 338bc04..9c2605d 100644 --- a/src/game/base/ship.cc +++ b/src/game/base/ship.cc @@ -441,8 +441,7 @@ void Ship::explode() } if (percentage > 0) { - core::Inventory::Items::iterator it = inventory()->items().begin(); - + core::Inventory::Items::iterator it = inventory()->items().begin(); while (it != inventory()->items().end()) { if ((*it)->info()->type() == Cargo::infotype()) { long loss = (*it)->amount() * ((long) percentage) / 100l; @@ -454,6 +453,19 @@ void Ship::explode() ++it; } } + + if (!owner()) { + core::Inventory::Items::iterator it = inventory()->items().begin(); + while (it != inventory()->items().end()) { + if ((*it)->info()->type() == Weapon::infotype()) { + if (math::randomf(100.0f) < 10.0f) { + eject((*it++), (*it)->amount(), false); + continue; + } + } + ++it; + } + } }; -- cgit v1.2.3