2008-03-10 00:01:30 +00:00
|
|
|
|
/*
|
|
|
|
|
|
|
|
|
|
oolite-thargoid-plans-mission.js
|
|
|
|
|
|
|
|
|
|
Script for Thargoid plans mission.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Oolite
|
|
|
|
|
Copyright © 2004-2008 Giles C Williams and contributors
|
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
|
|
|
MA 02110-1301, USA.
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
2009-05-22 22:45:02 +00:00
|
|
|
|
/*jslint bitwise: true, undef: true, eqeqeq: true, immed: true, newcap: true*/
|
|
|
|
|
/*global EquipmentInfo, Timer, galaxyNumber, guiScreen, mission, missionVariables, player, system*/
|
|
|
|
|
|
|
|
|
|
|
2008-11-15 01:10:01 +00:00
|
|
|
|
this.name = "oolite-thargoid-plans";
|
2009-05-22 22:45:02 +00:00
|
|
|
|
this.author = "Eric Walch";
|
|
|
|
|
this.copyright = "© 2008–2009 the Oolite team.";
|
2009-08-30 14:49:03 +00:00
|
|
|
|
this.version = "1.74";
|
2008-03-10 00:01:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.missionOffers = function ()
|
|
|
|
|
{
|
2009-08-06 20:24:25 +00:00
|
|
|
|
if (guiScreen === "GUI_SCREEN_MISSION" || guiScreen === "GUI_SCREEN_REPORT" || (mission.choice && mission.choice !== "") || !player.ship.docked) { return; }
|
2008-03-10 00:01:30 +00:00
|
|
|
|
// there will be a "missionScreenEnded" or a "missionChoiceWasReset" in future to react to.
|
2008-08-02 20:16:22 +00:00
|
|
|
|
if (player.ship.dockedStation.isMainStation)
|
2008-03-10 00:01:30 +00:00
|
|
|
|
{
|
2009-05-22 22:45:02 +00:00
|
|
|
|
if (galaxyNumber === 2)
|
2008-03-10 00:01:30 +00:00
|
|
|
|
{
|
|
|
|
|
if (!missionVariables.thargplans &&
|
2009-05-22 22:45:02 +00:00
|
|
|
|
missionVariables.conhunt === "MISSION_COMPLETE" &&
|
2008-03-10 00:01:30 +00:00
|
|
|
|
player.score > 1280 &&
|
2009-05-22 22:45:02 +00:00
|
|
|
|
system.ID !== 83)
|
2008-03-10 00:01:30 +00:00
|
|
|
|
{
|
|
|
|
|
mission.runMissionScreen("thargoid_plans_intro_brief");
|
|
|
|
|
missionVariables.thargplans = "PRELUDE";
|
|
|
|
|
mission.setInstructionsKey("thargplans_short_desc1");
|
|
|
|
|
mission.markSystem(83);
|
|
|
|
|
}
|
2009-05-22 22:45:02 +00:00
|
|
|
|
else if (missionVariables.thargplans === "PRELUDE" &&
|
|
|
|
|
system.ID === 83)
|
2008-03-10 00:01:30 +00:00
|
|
|
|
{
|
|
|
|
|
mission.unmarkSystem(83);
|
|
|
|
|
mission.runMissionScreen("thargoid_plans_main_brief", null, null, "thargoid");
|
|
|
|
|
missionVariables.thargplans = "RUNNING";
|
|
|
|
|
mission.setInstructionsKey("thargplans_short_desc2");
|
|
|
|
|
mission.markSystem(36);
|
|
|
|
|
}
|
2009-05-22 22:45:02 +00:00
|
|
|
|
else if (missionVariables.thargplans === "RUNNING" &&
|
|
|
|
|
system.ID === 36)
|
2008-03-10 00:01:30 +00:00
|
|
|
|
{
|
|
|
|
|
mission.runMissionScreen("thargoid_plans_debrief", null, null, "thargoid");
|
|
|
|
|
player.score += 256; // ship kills
|
2008-09-01 18:21:21 +00:00
|
|
|
|
mission.setInstructionsKey(null); // reset the missionbriefing
|
2008-03-10 00:01:30 +00:00
|
|
|
|
missionVariables.thargplans = "MISSION_COMPLETE";
|
2008-08-07 08:06:08 +00:00
|
|
|
|
if (player.ship.hasEquipment("EQ_ENERGY_UNIT"))
|
2008-06-19 15:47:12 +00:00
|
|
|
|
{
|
2008-08-07 08:06:08 +00:00
|
|
|
|
player.ship.removeEquipment("EQ_ENERGY_UNIT");
|
2008-06-19 15:47:12 +00:00
|
|
|
|
}
|
2008-08-07 08:06:08 +00:00
|
|
|
|
else if (player.ship.hasEquipment("EQ_ENERGY_UNIT_DAMAGED"))
|
2008-06-19 15:47:12 +00:00
|
|
|
|
{
|
2008-08-07 08:06:08 +00:00
|
|
|
|
player.ship.removeEquipment("EQ_ENERGY_UNIT_DAMAGED");
|
2008-06-19 15:47:12 +00:00
|
|
|
|
}
|
2008-08-07 08:06:08 +00:00
|
|
|
|
player.ship.awardEquipment("EQ_NAVAL_ENERGY_UNIT");
|
2008-10-17 23:09:12 +00:00
|
|
|
|
EquipmentInfo.infoForKey("EQ_NAVAL_ENERGY_UNIT").effectiveTechLevel = 13;
|
2008-03-10 00:01:30 +00:00
|
|
|
|
mission.unmarkSystem(36);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-05-22 22:45:02 +00:00
|
|
|
|
};
|
2008-03-10 00:01:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.addTargoids = function ()
|
|
|
|
|
{
|
|
|
|
|
this.loopcount++; // 5 loops of adding in the legacy script with a script timer.
|
|
|
|
|
if (this.loopcount > 5)
|
|
|
|
|
{
|
2009-05-22 22:45:02 +00:00
|
|
|
|
this.targoidTimer.stop();
|
2008-03-10 00:01:30 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (system.countShipsWithRole("thargoid") < 2)
|
|
|
|
|
{
|
|
|
|
|
system.legacy_addSystemShips("thargoid", 1, 0.33);
|
|
|
|
|
system.legacy_addSystemShips("thargoid", 1, 0.66);
|
|
|
|
|
}
|
|
|
|
|
if (system.countShipsWithRole("thargoid") < 5 && Math.random() < 0.5)
|
|
|
|
|
{
|
|
|
|
|
system.legacy_addShips("thargoid", 1);
|
|
|
|
|
}
|
2009-05-22 22:45:02 +00:00
|
|
|
|
};
|
2008-03-10 00:01:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.setUpShips = function ()
|
|
|
|
|
{
|
2009-05-22 22:45:02 +00:00
|
|
|
|
if (missionVariables.thargplans === "RUNNING" && galaxyNumber === 2)
|
2008-03-10 00:01:30 +00:00
|
|
|
|
{
|
2009-05-22 22:45:02 +00:00
|
|
|
|
if (this.targoidTimer)
|
|
|
|
|
{
|
|
|
|
|
this.targoidTimer.start();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
this.targoidTimer = new Timer(this, this.addTargoids, 10, 10);
|
|
|
|
|
}
|
2008-03-10 00:01:30 +00:00
|
|
|
|
}
|
2009-05-22 22:45:02 +00:00
|
|
|
|
};
|
2008-03-10 00:01:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**** Event handlers ****/
|
|
|
|
|
this.startUp = this.reset = function ()
|
|
|
|
|
{
|
|
|
|
|
this.loopcount = 0; // should be zero on the first launch after a reset.
|
2009-05-22 22:45:02 +00:00
|
|
|
|
};
|
2008-03-10 00:01:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.shipDockedWithStation = function ()
|
|
|
|
|
{
|
|
|
|
|
this.missionOffers();
|
2009-05-22 22:45:02 +00:00
|
|
|
|
};
|
2008-03-10 00:01:30 +00:00
|
|
|
|
|
|
|
|
|
|
2009-08-06 20:24:25 +00:00
|
|
|
|
this.missionScreenEnded = this.reportScreenEnded = this.missionChoiceWasReset = function ()
|
2008-03-10 00:01:30 +00:00
|
|
|
|
{
|
2009-05-22 22:45:02 +00:00
|
|
|
|
if (!player.ship.docked) { return; }
|
2008-03-10 00:01:30 +00:00
|
|
|
|
this.missionOffers();
|
2009-05-22 22:45:02 +00:00
|
|
|
|
};
|
2008-03-10 00:01:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.shipLaunchedFromStation = function ()
|
|
|
|
|
{
|
|
|
|
|
this.setUpShips();
|
2009-05-22 22:45:02 +00:00
|
|
|
|
};
|
2008-03-10 00:01:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.shipExitedWitchspace = function ()
|
|
|
|
|
{
|
|
|
|
|
this.loopcount = 0;
|
|
|
|
|
this.setUpShips();
|
2009-05-22 22:45:02 +00:00
|
|
|
|
};
|