2007-07-14 13:53:50 +00:00
|
|
|
/*
|
|
|
|
|
2008-03-10 00:01:30 +00:00
|
|
|
oolite-cloaking-device-mission.js
|
2007-07-14 13:53:50 +00:00
|
|
|
|
|
|
|
Script for cloaking device mission.
|
2008-02-03 15:44:24 +00:00
|
|
|
|
2007-07-14 13:53:50 +00:00
|
|
|
|
|
|
|
Oolite
|
2012-12-31 09:00:28 +00:00
|
|
|
Copyright © 2004-2013 Giles C Williams and contributors
|
2007-07-14 13:53:50 +00:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2010-07-30 21:54:50 +00:00
|
|
|
/*jslint white: true, undef: true, eqeqeq: true, bitwise: true, regexp: true, newcap: true, immed: true */
|
2009-05-22 22:45:02 +00:00
|
|
|
/*global galaxyNumber, missionVariables, system*/
|
|
|
|
|
|
|
|
|
2011-01-02 17:54:54 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
2009-05-22 22:45:02 +00:00
|
|
|
this.name = "oolite-cloaking-device";
|
|
|
|
this.author = "Jens Ayton";
|
2012-12-31 09:00:28 +00:00
|
|
|
this.copyright = "© 2007-2013 the Oolite team.";
|
2009-05-22 22:45:02 +00:00
|
|
|
this.description = "Cloaking device mission in galaxy 5.";
|
2013-08-27 12:51:53 +01:00
|
|
|
this.version = "1.79";
|
2007-07-14 13:53:50 +00:00
|
|
|
|
|
|
|
|
2013-07-31 21:29:29 +01:00
|
|
|
this.startUp = function ()
|
|
|
|
{
|
|
|
|
if (missionVariables.cloak !== null)
|
|
|
|
{
|
|
|
|
// save time by deleting unused handlers
|
|
|
|
delete this.systemWillPopulate;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this.systemWillPopulate = function ()
|
2007-07-14 13:53:50 +00:00
|
|
|
{
|
|
|
|
// If we're in galaxy 5...
|
2009-05-22 22:45:02 +00:00
|
|
|
if (galaxyNumber === 4)
|
2007-07-14 13:53:50 +00:00
|
|
|
{
|
|
|
|
// ...and the asp-cloaked's death_actions haven't triggered...
|
2009-05-22 22:45:02 +00:00
|
|
|
if (missionVariables.cloak === null)
|
2007-07-14 13:53:50 +00:00
|
|
|
{
|
|
|
|
// ...then we count of jumps...
|
2009-05-22 22:45:02 +00:00
|
|
|
if (!missionVariables.cloakcounter)
|
|
|
|
{
|
|
|
|
missionVariables.cloakcounter = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
missionVariables.cloakcounter++;
|
|
|
|
}
|
2007-07-14 13:53:50 +00:00
|
|
|
|
|
|
|
// ...until we reach six or more.
|
2009-05-22 22:45:02 +00:00
|
|
|
if (missionVariables.cloakcounter > 6 && system.countShipsWithRole("asp-cloaked") === 0)
|
2007-07-14 13:53:50 +00:00
|
|
|
{
|
|
|
|
// Then trigger the ambush!
|
2013-07-31 21:29:29 +01:00
|
|
|
system.setPopulator("oolite-cloaking-device-mission",
|
|
|
|
{
|
|
|
|
priority: 50,
|
|
|
|
location: "WITCHPOINT",
|
|
|
|
callback: function(pos)
|
|
|
|
{
|
2013-10-20 17:53:08 +01:00
|
|
|
var asp = system.addShips("asp-cloaked", 1, pos, 0)[0];
|
|
|
|
if (asp.escortGroup.count != 3)
|
|
|
|
{
|
|
|
|
var helpers = system.addShips("asp-pirate", 2, pos, 2E3);
|
|
|
|
asp.group = new ShipGroup("asps",asp);
|
|
|
|
for (var i = 0; i < 3; i++)
|
|
|
|
{
|
|
|
|
helpers[i].group = asp.group;
|
|
|
|
asp.group.addShip(helpers[i]);
|
|
|
|
}
|
|
|
|
}
|
2013-07-31 21:29:29 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2007-07-14 13:53:50 +00:00
|
|
|
}
|
|
|
|
}
|
2009-05-22 22:45:02 +00:00
|
|
|
};
|