Adjust nova mission to use populator
Removes normal traffic from the system when player enters, making it less likely they will escape by following a wormhole.
This commit is contained in:
parent
4dcff02718
commit
d169c64312
@ -53,6 +53,7 @@ this._cleanUp = function ()
|
||||
// this.shipExitedWitchspace is still needed after the nova mission.
|
||||
delete this.shipWillEnterWitchspace;
|
||||
delete this.shipWillExitWitchspace;
|
||||
delete this.systemWillPopulate;
|
||||
delete this.missionScreenOpportunity;
|
||||
delete this.shipLaunchedEscapePod;
|
||||
delete this.shipLaunchedFromStation;
|
||||
@ -305,9 +306,36 @@ this.shipWillEnterWitchspace = function ()
|
||||
};
|
||||
|
||||
|
||||
this.shipWillExitWitchspace = function () // call this as soon as possible so other scripts can see it will go nova.
|
||||
this.shipWillExitWitchspace = function ()
|
||||
{
|
||||
if (!missionVariables.nova && galaxyNumber === 3)
|
||||
if (missionVariables.nova === "NOVA_ESCAPE_HERO")
|
||||
{
|
||||
missionVariables.nova = "NOVA_ESCAPED_SYSTEM";
|
||||
}
|
||||
else if (missionVariables.nova === "TWO_HRS_TO_ZERO")
|
||||
{
|
||||
// the populator has started the nova mission
|
||||
player.ship.fuelLeakRate = 25;
|
||||
this.willGoNova = true;
|
||||
player.consoleMessage(expandDescription("[danger-fuel-leak]"), 4.5);
|
||||
system.info.market = "none";
|
||||
this.buoyLoaded = false; // w-bouy is not in system yet.
|
||||
if (this.novaMissionTimer)
|
||||
{
|
||||
this.novaMissionTimer.start();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.novaMissionTimer = new Timer(this, this._sendShipsAwayForMission, 5, 30);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
this.systemWillPopulate = function() // call this as soon as possible so other scripts can see it will go nova.
|
||||
{
|
||||
// make sure we don't increment the count when reloading a savegame
|
||||
if (!missionVariables.nova && galaxyNumber === 3 && player.ship.status != "STATUS_DOCKED")
|
||||
{
|
||||
if (missionVariables.novacount !== null) // " !== undefined" always returns true for missionVariables!
|
||||
{
|
||||
@ -316,29 +344,21 @@ this.shipWillExitWitchspace = function () // call this as soon as possible so o
|
||||
if (player.ship.equipmentStatus("EQ_GAL_DRIVE") === "EQUIPMENT_OK" && missionVariables.novacount > 3 && !missionVariables.nova && !system.isInterstellarSpace)
|
||||
{
|
||||
missionVariables.nova = "TWO_HRS_TO_ZERO";
|
||||
player.ship.fuelLeakRate = 25;
|
||||
system.sun.goNova(7200);
|
||||
this.willGoNova = true;
|
||||
player.consoleMessage(expandDescription("[danger-fuel-leak]"), 4.5);
|
||||
system.info.market = "none";
|
||||
this.buoyLoaded = false; // w-bouy is not in system yet.
|
||||
|
||||
if (this.novaMissionTimer)
|
||||
{
|
||||
this.novaMissionTimer.start();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.novaMissionTimer = new Timer(this, this._sendShipsAwayForMission, 5, 30);
|
||||
}
|
||||
/* the main populator script might have run first. If so, remove
|
||||
* the ships it added. If it runs after, it'll notice the
|
||||
* impending nova and not add these lines in the first place */
|
||||
system.setPopulator("oolite-route1-traders",null);
|
||||
system.setPopulator("oolite-route2-traders",null);
|
||||
system.setPopulator("oolite-route1-pirates",null);
|
||||
system.setPopulator("oolite-route2-pirates",null);
|
||||
system.setPopulator("oolite-route1-hunters",null);
|
||||
system.setPopulator("oolite-route2-hunters",null);
|
||||
system.setPopulator("oolite-route1-thargoids",null);
|
||||
system.setPopulator("oolite-offlane-hermit",null);
|
||||
}
|
||||
}
|
||||
if (missionVariables.nova === "NOVA_ESCAPE_HERO")
|
||||
{
|
||||
missionVariables.nova = "NOVA_ESCAPED_SYSTEM";
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
this.shipLaunchedFromStation = function ()
|
||||
{
|
||||
|
@ -72,6 +72,50 @@ this.systemWillPopulate = function()
|
||||
deterministic: true
|
||||
});
|
||||
|
||||
/* Add asteroids */
|
||||
var clusters = 2*(1+Math.floor(system.scrambledPseudoRandomNumber(51728)*4));
|
||||
var psclusters = 1+(clusters/2);
|
||||
clusters = clusters-psclusters;
|
||||
|
||||
var addRockCluster = function(pos)
|
||||
{
|
||||
var size = 1+Math.floor(system.scrambledPseudoRandomNumber(Math.floor(pos.x))*11);
|
||||
var hermit = (system.scrambledPseudoRandomNumber(Math.floor(pos.y))*31) <= size;
|
||||
var rocks = system.addShips("asteroid",size,pos,25E3);
|
||||
// don't add rock hermits if the sun is about to explode
|
||||
if (hermit && !system.sun.isGoingNova)
|
||||
{
|
||||
var rh = system.addShips("rockhermit",1,pos,0)[0];
|
||||
rh.scanClass = "CLASS_ROCK";
|
||||
}
|
||||
}
|
||||
|
||||
system.setPopulator("oolite-route1-asteroids",
|
||||
{
|
||||
priority: 20,
|
||||
location: "LANE_WP",
|
||||
locationSeed: 51728,
|
||||
groupCount: clusters,
|
||||
callback: addRockCluster,
|
||||
deterministic: true
|
||||
});
|
||||
system.setPopulator("oolite-route2-asteroids",
|
||||
{
|
||||
priority: 20,
|
||||
location: "LANE_PS",
|
||||
locationSeed: 82715,
|
||||
groupCount: psclusters,
|
||||
callback: addRockCluster,
|
||||
deterministic: true
|
||||
});
|
||||
|
||||
/* Mainly for nova mission. If the nova script runs first, then
|
||||
* this is set and we stop here. If this script runs first, the
|
||||
* nova mission populator removes the entries this script adds. */
|
||||
if (system.sun.isGoingNova)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* Calculate numbers of major groups */
|
||||
var gov = system.info.government; // 0=anarchy, 7=corporate
|
||||
@ -255,42 +299,8 @@ this.systemWillPopulate = function()
|
||||
}
|
||||
});
|
||||
|
||||
/* Add asteroids */
|
||||
var clusters = 2*(1+Math.floor(system.scrambledPseudoRandomNumber(51728)*4));
|
||||
var psclusters = 1+(clusters/2);
|
||||
clusters = clusters-psclusters;
|
||||
|
||||
var addRockCluster = function(pos)
|
||||
{
|
||||
var size = 1+Math.floor(system.scrambledPseudoRandomNumber(Math.floor(pos.x))*11);
|
||||
var hermit = (system.scrambledPseudoRandomNumber(Math.floor(pos.y))*31) <= size;
|
||||
var rocks = system.addShips("asteroid",size,pos,25E3);
|
||||
if (hermit)
|
||||
{
|
||||
var rh = system.addShips("rockhermit",1,pos,0)[0];
|
||||
rh.scanClass = "CLASS_ROCK";
|
||||
}
|
||||
}
|
||||
|
||||
system.setPopulator("oolite-route1-asteroids",
|
||||
{
|
||||
priority: 20,
|
||||
location: "LANE_WP",
|
||||
locationSeed: 51728,
|
||||
groupCount: clusters,
|
||||
callback: addRockCluster,
|
||||
deterministic: true
|
||||
});
|
||||
system.setPopulator("oolite-route2-asteroids",
|
||||
{
|
||||
priority: 20,
|
||||
location: "LANE_PS",
|
||||
locationSeed: 82715,
|
||||
groupCount: psclusters,
|
||||
callback: addRockCluster,
|
||||
deterministic: true
|
||||
});
|
||||
/* To ensure there's at least one hermit, for pirates to dock at */
|
||||
/* To ensure there's at least one hermit, for ships avoiding the main station to dock at */
|
||||
system.setPopulator("oolite-offlane-hermit",
|
||||
{
|
||||
priority: 99, // make sure all other core population is done
|
||||
|
@ -1209,7 +1209,7 @@ static JSBool SystemSetPopulator(JSContext *context, uintN argc, jsval *vp)
|
||||
OOJSReportBadArguments(context, @"System", @"setPopulator", MIN(argc, 0U), &OOJS_ARGV[0], nil, @"key, settings");
|
||||
return NO;
|
||||
}
|
||||
if (argc < 2)
|
||||
if (argc < 2 || JSVAL_IS_NULL(OOJS_ARGV[1]))
|
||||
{
|
||||
// clearing
|
||||
[UNIVERSE setPopulatorSetting:key to:nil];
|
||||
|
Loading…
x
Reference in New Issue
Block a user