2008-03-10 00:01:30 +00:00
|
|
|
/*
|
|
|
|
|
2010-06-27 17:38:31 +00:00
|
|
|
oolite-constrictor.js
|
2008-03-10 00:01:30 +00:00
|
|
|
|
2010-06-27 17:38:31 +00:00
|
|
|
Ship script for Constrictor Hunt mission.
|
2008-03-10 00:01:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
Oolite
|
2012-12-31 09:00:28 +00:00
|
|
|
Copyright © 2004-2013 Giles C Williams and contributors
|
2008-03-10 00:01:30 +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 missionVariables, player*/
|
|
|
|
|
|
|
|
|
2011-01-02 17:54:54 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
2008-11-15 01:10:01 +00:00
|
|
|
this.name = "oolite-constrictor";
|
2009-05-22 22:45:02 +00:00
|
|
|
this.author = "Eric Walch";
|
2012-12-31 09:00:28 +00:00
|
|
|
this.copyright = "© 2008-2013 the Oolite team.";
|
2008-03-10 00:01:30 +00:00
|
|
|
|
|
|
|
|
2010-07-30 21:54:50 +00:00
|
|
|
/*
|
|
|
|
To avoid being attacked by other ships, the Constrictor goes legal when
|
|
|
|
the player is well out of range. When this happens, the "real" bounty
|
|
|
|
is stored in _legalPoints.
|
|
|
|
*/
|
|
|
|
this._legalPoints = 0;
|
|
|
|
|
2008-03-10 00:01:30 +00:00
|
|
|
|
|
|
|
this.shipSpawned = function ()
|
|
|
|
{
|
2010-07-30 21:54:50 +00:00
|
|
|
this._legalPoints = this.ship.bounty;
|
2008-03-10 00:01:30 +00:00
|
|
|
this.ship.bounty = 0;
|
2012-06-06 10:02:31 +00:00
|
|
|
if (this.ship.accuracy < 0)
|
|
|
|
{ // make sure it is always reasonably good AI
|
|
|
|
this.ship.accuracy = -this.ship.accuracy;
|
|
|
|
}
|
2010-07-30 21:54:50 +00:00
|
|
|
if (player.score > 512)
|
|
|
|
{
|
|
|
|
this.ship.awardEquipment("EQ_SHIELD_BOOSTER"); // Player is Dangerous
|
|
|
|
}
|
|
|
|
if (player.score > 2560)
|
|
|
|
{
|
|
|
|
this.ship.awardEquipment("EQ_SHIELD_ENHANCER"); // Player is Deadly
|
|
|
|
}
|
2010-04-24 08:32:23 +00:00
|
|
|
this.ship.energy = this.ship.maxEnergy; // start with all energy banks full.
|
2009-05-22 22:45:02 +00:00
|
|
|
};
|
2008-03-10 00:01:30 +00:00
|
|
|
|
|
|
|
|
2008-04-26 14:21:34 +00:00
|
|
|
this.shipDied = function (killer)
|
|
|
|
{
|
2014-07-26 20:10:17 +01:00
|
|
|
// check mission variable, just in case
|
|
|
|
if (killer && killer.isPlayer && missionVariables.conhunt === "STAGE_1")
|
2009-05-22 22:45:02 +00:00
|
|
|
{
|
|
|
|
missionVariables.conhunt = "CONSTRICTOR_DESTROYED";
|
|
|
|
}
|
|
|
|
};
|
2008-03-10 00:01:30 +00:00
|
|
|
|
|
|
|
|
2010-07-30 21:54:50 +00:00
|
|
|
this._checkDistance = function ()
|
2008-03-10 00:01:30 +00:00
|
|
|
{
|
2008-08-07 08:06:08 +00:00
|
|
|
if (player.ship.position.distanceTo(this.ship) < 50000)
|
2008-03-10 00:01:30 +00:00
|
|
|
{
|
2010-07-30 21:54:50 +00:00
|
|
|
if (this._legalPoints > 0)
|
2008-03-10 00:01:30 +00:00
|
|
|
{
|
2010-07-30 21:54:50 +00:00
|
|
|
this.ship.bounty = this._legalPoints;
|
|
|
|
this._legalPoints = 0;
|
2008-03-10 00:01:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-07-30 21:54:50 +00:00
|
|
|
if (this._legalPoints === 0)
|
2008-03-10 00:01:30 +00:00
|
|
|
{
|
2010-07-30 21:54:50 +00:00
|
|
|
this._legalPoints = this.ship.bounty;
|
2008-03-10 00:01:30 +00:00
|
|
|
this.ship.bounty = 0;
|
|
|
|
}
|
|
|
|
}
|
2009-05-22 22:45:02 +00:00
|
|
|
};
|