From ce2d77557ddbebecf4decb4c20c039dc45f206cc Mon Sep 17 00:00:00 2001 From: cim Date: Wed, 14 Aug 2013 21:10:29 +0100 Subject: [PATCH] Make sure pirate escorts have a bounty, fix initial pirate cargo --- Resources/Scripts/oolite-populator.js | 20 +++++++++ src/Core/Entities/ShipEntity.m | 59 ++++++++++++++------------- 2 files changed, 51 insertions(+), 28 deletions(-) diff --git a/Resources/Scripts/oolite-populator.js b/Resources/Scripts/oolite-populator.js index d0f9b0b4..4efc3425 100644 --- a/Resources/Scripts/oolite-populator.js +++ b/Resources/Scripts/oolite-populator.js @@ -1357,6 +1357,10 @@ this._addIndependentPirate = function(pos) for (var i=0;i 0) { num = likely_cargo * (0.5+randf()); @@ -7604,33 +7604,36 @@ NSComparisonResult ComparePlanetsBySurfaceDistance(id i1, id i2, void* context) * thousands of pods - even if they are semi-virtual - for some * massive OXP ship */ } - switch (cargo_flag) + if (num > 0) { - case CARGO_FLAG_FULL_UNIFORM: - newCargo = [UNIVERSE getContainersOfCommodity:[shipinfoDictionary oo_stringForKey:@"cargo_carried"] :num]; - break; - // TODO: PLENTIFUL AND SCARCE shouldn't contain illegal goods - case CARGO_FLAG_FULL_PLENTIFUL: - newCargo = [UNIVERSE getContainersOfGoods:num scarce:NO]; - break; - case CARGO_FLAG_FULL_SCARCE: - newCargo = [UNIVERSE getContainersOfGoods:num scarce:YES]; - break; - case CARGO_FLAG_FULL_MEDICAL: - newCargo = [UNIVERSE getContainersOfCommodity:@"Narcotics" :num]; - break; - case CARGO_FLAG_FULL_CONTRABAND: - // TODO: mixed contraband - newCargo = [UNIVERSE getContainersOfCommodity:@"Firearms" :num]; - break; - case CARGO_FLAG_PIRATE: - newCargo = [UNIVERSE getContainersOfGoods:(Ranrot() % num) scarce:YES]; - break; - case CARGO_FLAG_FULL_PASSENGERS: - // TODO: allow passengers to survive - case CARGO_FLAG_NONE: - default: - break; + switch (cargo_flag) + { + case CARGO_FLAG_FULL_UNIFORM: + newCargo = [UNIVERSE getContainersOfCommodity:[shipinfoDictionary oo_stringForKey:@"cargo_carried"] :num]; + break; + // TODO: PLENTIFUL AND SCARCE shouldn't contain illegal goods + case CARGO_FLAG_FULL_PLENTIFUL: + newCargo = [UNIVERSE getContainersOfGoods:num scarce:NO]; + break; + case CARGO_FLAG_FULL_SCARCE: + newCargo = [UNIVERSE getContainersOfGoods:num scarce:YES]; + break; + case CARGO_FLAG_FULL_MEDICAL: + newCargo = [UNIVERSE getContainersOfCommodity:@"Narcotics" :num]; + break; + case CARGO_FLAG_FULL_CONTRABAND: + // TODO: mixed contraband + newCargo = [UNIVERSE getContainersOfCommodity:@"Firearms" :num]; + break; + case CARGO_FLAG_PIRATE: + newCargo = [UNIVERSE getContainersOfGoods:(Ranrot() % num) scarce:YES]; + break; + case CARGO_FLAG_FULL_PASSENGERS: + // TODO: allow passengers to survive + case CARGO_FLAG_NONE: + default: + break; + } } [self setCargo:newCargo]; }