Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2013-11-10 17:25:16 +0000
committerStijn Buys <ingar@osirion.org>2013-11-10 17:25:16 +0000
commitaaf57b8aa9cbc8287f298de2b19861eb23aec2f3 (patch)
treeff2b134c7155cc39573d94044585ca2755580d89 /src
parent5f0958c121a246d445507313984358ff8a6df3fa (diff)
Added a 10 percent chance for NPCs to drop weapons when destroyed.
Diffstat (limited to 'src')
-rw-r--r--src/game/base/ship.cc16
1 files 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;
+ }
+ }
};