Make sure pirate escorts have a bounty, fix initial pirate cargo

This commit is contained in:
cim 2013-08-14 21:10:29 +01:00
parent 9d7fe2fa46
commit ce2d77557d
2 changed files with 51 additions and 28 deletions

View File

@ -1357,6 +1357,10 @@ this._addIndependentPirate = function(pos)
for (var i=0;i<pg.ships.length;i++) for (var i=0;i<pg.ships.length;i++)
{ {
pg.ships[i].setBounty(20+system.government+size+Math.floor(Math.random()*8),"setup actions"); pg.ships[i].setBounty(20+system.government+size+Math.floor(Math.random()*8),"setup actions");
if (!pos.isStation && !pos.isPlanet)
{
pg.ships[i].setCargoType("PIRATE_GOODS");
}
} }
} }
@ -1443,6 +1447,22 @@ this._addPiratePack = function(pos,leader,lf,mf,hf,thug,home,destination,returni
{ {
this._setReturnFuel(lead[0]); this._setReturnFuel(lead[0]);
} }
if (lead[0].escortGroup)
{
var eg = lead[0].escortGroup.ships;
for (var i = 0; i < eg.length; i++)
{
if (eg[i] != lead[0])
{
// ensure freighter escorts have a bounty
eg[i].bounty |= 3+Math.floor(Math.random()*12);
}
}
}
if (!pos.isStation && !pos.isPlanet)
{
lead[0].setCargoType("PIRATE_GOODS");
}
lead[0].switchAI("pirateFreighterAI.js"); lead[0].switchAI("pirateFreighterAI.js");
return lead[0]; return lead[0];
} }

View File

@ -7582,8 +7582,8 @@ NSComparisonResult ComparePlanetsBySurfaceDistance(id i1, id i2, void* context)
if (cargo_flag != flag) if (cargo_flag != flag)
{ {
cargo_flag = flag; cargo_flag = flag;
NSArray *newCargo; NSArray *newCargo = nil;
unsigned num; unsigned num = 0;
if (likely_cargo > 0) if (likely_cargo > 0)
{ {
num = likely_cargo * (0.5+randf()); 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 * thousands of pods - even if they are semi-virtual - for some
* massive OXP ship */ * massive OXP ship */
} }
switch (cargo_flag) if (num > 0)
{ {
case CARGO_FLAG_FULL_UNIFORM: switch (cargo_flag)
newCargo = [UNIVERSE getContainersOfCommodity:[shipinfoDictionary oo_stringForKey:@"cargo_carried"] :num]; {
break; case CARGO_FLAG_FULL_UNIFORM:
// TODO: PLENTIFUL AND SCARCE shouldn't contain illegal goods newCargo = [UNIVERSE getContainersOfCommodity:[shipinfoDictionary oo_stringForKey:@"cargo_carried"] :num];
case CARGO_FLAG_FULL_PLENTIFUL: break;
newCargo = [UNIVERSE getContainersOfGoods:num scarce:NO]; // TODO: PLENTIFUL AND SCARCE shouldn't contain illegal goods
break; case CARGO_FLAG_FULL_PLENTIFUL:
case CARGO_FLAG_FULL_SCARCE: newCargo = [UNIVERSE getContainersOfGoods:num scarce:NO];
newCargo = [UNIVERSE getContainersOfGoods:num scarce:YES]; break;
break; case CARGO_FLAG_FULL_SCARCE:
case CARGO_FLAG_FULL_MEDICAL: newCargo = [UNIVERSE getContainersOfGoods:num scarce:YES];
newCargo = [UNIVERSE getContainersOfCommodity:@"Narcotics" :num]; break;
break; case CARGO_FLAG_FULL_MEDICAL:
case CARGO_FLAG_FULL_CONTRABAND: newCargo = [UNIVERSE getContainersOfCommodity:@"Narcotics" :num];
// TODO: mixed contraband break;
newCargo = [UNIVERSE getContainersOfCommodity:@"Firearms" :num]; case CARGO_FLAG_FULL_CONTRABAND:
break; // TODO: mixed contraband
case CARGO_FLAG_PIRATE: newCargo = [UNIVERSE getContainersOfCommodity:@"Firearms" :num];
newCargo = [UNIVERSE getContainersOfGoods:(Ranrot() % num) scarce:YES]; break;
break; case CARGO_FLAG_PIRATE:
case CARGO_FLAG_FULL_PASSENGERS: newCargo = [UNIVERSE getContainersOfGoods:(Ranrot() % num) scarce:YES];
// TODO: allow passengers to survive break;
case CARGO_FLAG_NONE: case CARGO_FLAG_FULL_PASSENGERS:
default: // TODO: allow passengers to survive
break; case CARGO_FLAG_NONE:
default:
break;
}
} }
[self setCargo:newCargo]; [self setCargo:newCargo];
} }