Config/script.js |
"use strict";
this.name = "SpyHunter";
this.author = "Selezen";
this.copyright = "2016 Dave 'Selezen' Hughes";
this.description = "Main script file for Spy Hunter mission";
//-------------------------------------------------------------------------------------------------------------
this.missionScreenOpportunity = function() {
if (galaxyNumber == 0 && player.ship.dockedStation.isMainStation && player.score > 512) {
// set up mission
if (system.ID == 158 && !missionVariables.spyhunter) {
mission.runScreen({
screenID:"spyhunter_screen_1",
titleKey: "spy_hunter_mission_title",
messageKey: "spy_hunter_Inines_orders",
exitScreen: "GUI_SCREEN_STATUS"
});
missionVariables.spyhunter = "STAGE1";
mission.markSystem({system:164, name:"spyhunter"});
mission.setInstructionsKey("em1_sh_header1", this.name);
return;
}
// stage 1 complete - setup stage 2
if (system.ID == 164 && missionVariables.spyhunter == "STAGE1") {
mission.runScreen({
screenID:"spyhunter_screen_2",
titleKey: "spy_hunter_mission_title",
messageKey: "spy_hunter_Ribilebi_briefing",
exitScreen: "GUI_SCREEN_STATUS"
});
missionVariables.spyhunter = "STAGE2";
player.credits += 1000;
mission.unmarkSystem({system:164, name:"spyhunter"});
mission.markSystem({system:51, name:"spyhunter"});
mission.setInstructionsKey("em1_sh_header2", this.name);
return;
}
// stage 2 complete - setup stage 3
if (system.ID == 51 && missionVariables.spyhunter == "STAGE2") {
mission.runScreen({
screenID:"spyhunter_screen_3",
titleKey: "spy_hunter_mission_title",
messageKey: "spy_hunter_Alaza_briefing",
exitScreen: "GUI_SCREEN_STATUS"
});
missionVariables.spyhunter = "STAGE3";
mission.unmarkSystem({system:51, name:"spyhunter"});
mission.markSystem({system:102, name:"spyhunter"});
mission.setInstructionsKey("em1_sh_header3", this.name);
return;
}
// stage 2 complete - setup stage 3
if (system.ID == 102 && missionVariables.spyhunter == "STAGE3") {
mission.runScreen({
screenID:"spyhunter_screen_4",
titleKey: "spy_hunter_mission_title",
messageKey: "spy_hunter_Beraanxe_briefing",
exitScreen: "GUI_SCREEN_STATUS"
});
missionVariables.spyhunter = "STAGE4";
mission.unmarkSystem({system:102, name:"spyhunter"});
mission.markSystem({system:126, name:"spyhunter"});
mission.setInstructionsKey("em1_sh_header4", this.name);
return;
}
// stage 4 complete - show final message
if (system.ID == 126 && missionVariables.spyhunter == "STAGE5") {
mission.runScreen({
screenID:"spyhunter_screen_6",
titleKey: "spy_hunter_mission_title",
messageKey: "spy_hunter_Anerbe_briefing",
exitScreen: "GUI_SCREEN_STATUS"
});
missionVariables.spyhunter = "MISSION_COMPLETE";
player.credits += 4000;
mission.unmarkSystem({system:126, name:"spyhunter"});
mission.setInstructionsKey(null, this.name);
return;
}
}
}
//-------------------------------------------------------------------------------------------------------------
this.systemWillPopulate = function() {
if (missionVariables.spyhunter == "STAGE4" && system.ID == 126 && galaxyNumber == 0 && system.countShipsWithRole("spyhunter_impcourier") == 0) {
var position = Vector3D(0, 0, 0.1).fromCoordinateSystem("wpu");
// add base with populator
system.setPopulator("spy hunter", {
callback: function(pos) {
var sb = system.addShips("spyhunter_impcourier", 1, pos);
if (sb.length > 0) {
// monkey patch if necessary
if (sb[0].script.shipDied) {
sb[0].script.$sh_ovr_shipDied = sb[0].script.shipDied;
}
// add our shipDied event to the spy's ship
sb[0].script.shipDied = this.$spyHunter_shipDied;
} else {
log(this.name, "!!ERROR: Spy Courier not spawned!");
}
}.bind(this),
location:"COORDINATES",
coordinates:position});
}
}
//-------------------------------------------------------------------------------------------------------------
this.$updateManifestText = function() {
mission.setInstructionsKey("em1_sh_header5", this.name);
}
//-------------------------------------------------------------------------------------------------------------
this.$spyHunter_shipDied = function(whom, why) {
if (this.ship.script.$sh_ovr_shipDied) this.ship.script.$sh_ovr_shipDied(whom, why);
if (missionVariables.spyhunter == "STAGE4") {
missionVariables.spyhunter = "STAGE5";
worldScripts.SpyHunter.$updateManifestText();
}
} |