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++)
{
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]);
}
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");
return lead[0];
}

View File

@ -7582,8 +7582,8 @@ NSComparisonResult ComparePlanetsBySurfaceDistance(id i1, id i2, void* context)
if (cargo_flag != flag)
{
cargo_flag = flag;
NSArray *newCargo;
unsigned num;
NSArray *newCargo = nil;
unsigned num = 0;
if (likely_cargo > 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];
}