Temporarily suppress certain bits of normal population during missions

(avoids giving the player potentially powerful assistance)
This commit is contained in:
cim 2014-03-02 20:15:36 +00:00
parent dbe6cb109e
commit b82db62594
4 changed files with 69 additions and 10 deletions

View File

@ -71,6 +71,8 @@ this.systemWillPopulate = function ()
if (missionVariables.cloakcounter > 6 && system.countShipsWithRole("asp-cloaked") === 0) if (missionVariables.cloakcounter > 6 && system.countShipsWithRole("asp-cloaked") === 0)
{ {
// Then trigger the ambush! // Then trigger the ambush!
// ensure all normal system population is set up first
worldScripts["oolite-populator"].systemWillPopulate();
system.setPopulator("oolite-cloaking-device-mission", system.setPopulator("oolite-cloaking-device-mission",
{ {
priority: 50, priority: 50,
@ -90,6 +92,17 @@ this.systemWillPopulate = function ()
} }
} }
}); });
/* Then remove most ships from the default populator which
* might attack the cloaked group. The repopulator will add more
* later. */
system.setPopulator("oolite-interceptors-witchpoint",null);
system.setPopulator("oolite-hunters-route1",null);
system.setPopulator("oolite-hunters-medium-route1",null);
system.setPopulator("oolite-hunters-medium-route3",null);
system.setPopulator("oolite-hunters-heavy-route1",null);
system.setPopulator("oolite-hunters-heavy-route3",null);
system.setPopulator("oolite-police-route1",null);
} }
} }
} }

View File

@ -166,10 +166,15 @@ this.missionScreenOpportunity = function ()
this.systemWillPopulate = function() this.systemWillPopulate = function()
{ {
// galaxy+system parts of this check shouldn't be necessary
if (galaxyNumber === 1 && if (galaxyNumber === 1 &&
system.ID === 193 && system.ID === 193 &&
missionVariables.conhunt === "STAGE_1") missionVariables.conhunt === "STAGE_1")
{ {
// ensure all normal system population is set up first
worldScripts["oolite-populator"].systemWillPopulate();
// then add the Constrictor
system.setPopulator("oolite-constrictor-mission", system.setPopulator("oolite-constrictor-mission",
{ {
priority: 50, priority: 50,
@ -183,5 +188,17 @@ this.systemWillPopulate = function()
constrictor[0].setScript("oolite-constrictor.js"); constrictor[0].setScript("oolite-constrictor.js");
} }
}); });
/* Then remove most ships from the default populator which
* might attack the Constrictor. The repopulator will add more
* later. */
system.setPopulator("oolite-interceptors-witchpoint",null);
system.setPopulator("oolite-hunters-route1",null);
system.setPopulator("oolite-hunters-medium-route1",null);
system.setPopulator("oolite-hunters-medium-route3",null);
system.setPopulator("oolite-hunters-heavy-route1",null);
system.setPopulator("oolite-hunters-heavy-route3",null);
system.setPopulator("oolite-police-route1",null);
} }
}; };

View File

@ -43,12 +43,26 @@ this.startUp = function()
{ {
// for translations // for translations
this.$medicalReg = new RegExp(expandDescription("[medical-word]"),"i"); this.$medicalReg = new RegExp(expandDescription("[medical-word]"),"i");
this.$populatorRun = 0;
} }
/* This allows this.systemWillPopulate to be called by scripts running
* before it, so that its entries are in place before they try to
* modify them. Generally useful if you want to modify the basic
* system population. */
this.shipWillEnterWitchspace = function()
{
this.$populatorRun = 0; // reset variable after all population complete
}
/* Basic system population */ /* Basic system population */
this.systemWillPopulate = function() this.systemWillPopulate = function()
{ {
if (this.$populatorRun)
{
return;
}
/* Priority range 0-99 used by Oolite default populator */ /* Priority range 0-99 used by Oolite default populator */
// anything added here with priority > 20 will be cancelled by the // anything added here with priority > 20 will be cancelled by the
@ -629,14 +643,6 @@ this.systemWillPopulate = function()
// hunters // hunters
// 5/6 go route 1, and back. 50% faster ships than traders, on average // 5/6 go route 1, and back. 50% faster ships than traders, on average
initial = hlight * 5/6 * (l1length*2 / 900000) * (1.0-0.1*(7-system.info.government));
system.setPopulator("oolite-hunters-route1",
{
priority: 40,
location: "LANE_WP",
groupCount: randomise(initial),
callback: this._addLightHunter.bind(this)
});
initial = hlight * 1/6 * (trilength / 900000) * (1.0-0.1*(7-system.info.government)); initial = hlight * 1/6 * (trilength / 900000) * (1.0-0.1*(7-system.info.government));
system.setPopulator("oolite-hunters-triangle", system.setPopulator("oolite-hunters-triangle",
{ {
@ -645,6 +651,14 @@ this.systemWillPopulate = function()
groupCount: randomise(initial), groupCount: randomise(initial),
callback: this._addLightHunter.bind(this) callback: this._addLightHunter.bind(this)
}); });
initial = hlight * 5/6 * (l1length*2 / 900000) * (1.0-0.1*(7-system.info.government));
system.setPopulator("oolite-hunters-route1",
{
priority: 40,
location: "LANE_WP",
groupCount: randomise(initial),
callback: this._addLightHunter.bind(this)
});
initial = hmedium * l1length/900000 * (2/3) * 2/3; initial = hmedium * l1length/900000 * (2/3) * 2/3;
system.setPopulator("oolite-hunters-medium-route1", system.setPopulator("oolite-hunters-medium-route1",
{ {
@ -949,7 +963,7 @@ this.systemWillPopulate = function()
this._debugP("Thargoid (ST)",pset["oolite-thargoid-strike"].groupCount); this._debugP("Thargoid (ST)",pset["oolite-thargoid-strike"].groupCount);
// and the initial ships are done... // and the initial ships are done...
this.$populatorRun = 1;
} }
@ -1239,6 +1253,10 @@ this.systemWillRepopulate = function()
this.interstellarSpaceWillPopulate = function() this.interstellarSpaceWillPopulate = function()
{ {
if (this.$populatorRun)
{
return;
}
system.setPopulator("oolite-interstellar-thargoids", system.setPopulator("oolite-interstellar-thargoids",
{ {
priority: 10, priority: 10,
@ -1248,6 +1266,7 @@ this.interstellarSpaceWillPopulate = function()
system.addShips("thargoid",1,pos,0); system.addShips("thargoid",1,pos,0);
} }
}); });
this.$populatorRun = 1;
} }
this.interstellarSpaceWillRepopulate = function() this.interstellarSpaceWillRepopulate = function()
@ -1270,6 +1289,10 @@ this.interstellarSpaceWillRepopulate = function()
this.novaSystemWillPopulate = function() this.novaSystemWillPopulate = function()
{ {
if (this.$populatorRun)
{
return;
}
// just burnt-out rubble // just burnt-out rubble
system.setPopulator("oolite-nova-cinders", system.setPopulator("oolite-nova-cinders",
{ {
@ -1282,7 +1305,7 @@ this.novaSystemWillPopulate = function()
system.addShips("cinder",10,pos,25600); system.addShips("cinder",10,pos,25600);
} }
}); });
this.$populatorRun = 1;
} }

View File

@ -138,6 +138,9 @@ this.systemWillPopulate = function()
{ {
if (missionVariables.thargplans === "RUNNING" && galaxyNumber === 2) if (missionVariables.thargplans === "RUNNING" && galaxyNumber === 2)
{ {
// ensure all normal system population is set up first
worldScripts["oolite-populator"].systemWillPopulate();
system.setPopulator("oolite-thargoidplans-mission-a", system.setPopulator("oolite-thargoidplans-mission-a",
{ {
priority: 50, priority: 50,
@ -179,6 +182,9 @@ this.systemWillPopulate = function()
this._waveCount++; this._waveCount++;
} }
/* Make sure the player doesn't get too much help from other ships! */
system.setPopulator("oolite-interceptors-witchpoint",null);
} }
else else
{ {