Scripts/kchud_conditions.js |
"use strict";
this.name = "kchud_Equipment";
this.author = "gsagostinho, based on work by phkb";
this.copyright = "2015 phkb, 2017 gsagostinho";
this.description = "Condition script for KingCobra HUD equipment";
this.licence = "CC BY-NC-SA 4.0";
this.allowAwardEquipment = function(equipment, ship, context) {
if (context != "scripted") return false;
return true;
}
|
Scripts/kw-kchud.js |
/*
kw-kchud.js
Script for the animation of numeric gauges on your ship.
Oolite
Copyright � 2003-2010 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.
kingcobrahud.oxp
Copyright � 2011 "CommonSenseOTB" modified by Killer Wolf
This work is licensed under the Creative Commons
Attribution-Noncommercial-Share Alike 3.0 Unported License.
To view a copy of this license, visit
http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter
to Creative Commons, 171 Second Street, Suite 300, San Francisco,
California, 94105, USA.
*/
this.name = "kw-kchud.js";
this.author = "CommonSenseOTB";
this.copyright = "Copyright 2011 by CommonSenseOTB, modified by KW CC-by-nc-sa-3.0";
this.description = "kingcobrahud Animation Script";
this.version = "1.0";
this.kctradhud = 1;
this.alertConditionChanged = function (newCondition, oldCondition) {
switch (newCondition) {
case 0: // we're docked
{
kctradhud = 1;
player.ship.hud = "kw-kctrad.plist"; // set the docked HUD
break;
}
case 1: // we're at green alert
case 2: // or we're at yellow alert
case 3: // we're at red alert
{
kctradhud = 0;
}
break;
}
}
this.shipWillLaunchFromStation = function () //overides for the shield equalizer and capacitors oxp countdown timer, alarm and messages are below
{
if (this.kingcobrastartupflag !== 1.0) { //overides for the shield equalizer and capacitors oxp countdown timer, alarm and messages are farther below
this.kingcobragaugevalue = 0.0; // number to be displayed on current gauge
this.kingcobragaugeselector = "NONE"; // current gauge to be displayed
this.kingcobragaugecolor = "NONE"; // current gauge color to be used
this.kingcobragaugechanged = "FALSE"; // current gauge state decides whether to draw
this.kingcobragaugecolorchanged = "FALSE"; // current gauge state decides whether to erase previous color
this.kingcobragaugeflashcounter = 1.0; // counter to flash the between colors
this.kingcobragaugelastflashcounter = 1.0; // last value of flash counter
this.kingcobragaugeframecounter = 1.0; // frame counter for gauge control
this.kingcobragaugelastframecounter = 1.0; // last value of frame counter for gauge control
this.kingcobragaugelastforwardshieldvalue = 0.0; // last value of forward shield
this.kingcobragaugelastforwardshieldcolor = "NONE"; // last color of forward shield
this.kingcobragaugelastaftshieldvalue = 0.0; // last value of aft shield
this.kingcobragaugelastaftshieldcolor = "NONE"; // last color of aft shield
this.kingcobrastartupflag = 1.0; // prevent setting variables more than once
}
player.ship.hud = "kw-kcHUD.plist";
this.refresh();
this.pfsr = addFrameCallback(this.prepareForwardShieldReadout.bind(this)); //----------
this.pfsrdg = addFrameCallback(this.displayGauge.bind(this));
this.pasr = addFrameCallback(this.prepareAftShieldReadout.bind(this)); //----------
this.pasrdg = addFrameCallback(this.displayGauge.bind(this));
if (this.kingcobragaugeCheckTimer) {
this.kingcobragaugeCheckTimer.start();
} else {
this.kingcobragaugeCheckTimer = new Timer(this, this.kingcobragaugeCheck, 0, 0.25); // use a timer to update the numeric gauge flash counter
}
}
this.kingcobragaugeCheck = function ()
{
if (player.ship.docked) {
removeFrameCallback(this.pfsr); //----------
removeFrameCallback(this.pfsrdg);
removeFrameCallback(this.pasr); //----------
removeFrameCallback(this.pasrdg);
this.kingcobragaugeCheckTimer.stop();
} else {
this.kingcobragaugeflashcounter += 1.0;
if (this.kingcobragaugeflashcounter > 8.0) {
this.kingcobragaugeflashcounter = 1.0;
return;
}
return;
}
return;
}
this.shipWillEnterWitchspace = function ()
{
player.ship.hud = "kw-kcHUD.plist";
removeFrameCallback(this.pfsr); //----------
removeFrameCallback(this.pfsrdg);
removeFrameCallback(this.pasr); //----------
removeFrameCallback(this.pasrdg);
this.kingcobragaugeCheckTimer.stop();
}
this.shipExitedWitchspace = function ()
{
this.pfsr = addFrameCallback(this.prepareForwardShieldReadout.bind(this)); //----------
this.pfsrdg = addFrameCallback(this.displayGauge.bind(this));
this.pasr = addFrameCallback(this.prepareAftShieldReadout.bind(this)); //----------
this.pasrdg = addFrameCallback(this.displayGauge.bind(this));
if (this.kingcobragaugeCheckTimer) {
this.kingcobragaugeCheckTimer.start();
} else {
this.kingcobragaugeCheckTimer = new Timer(this, this.kingcobragaugeCheck, 0, 0.25); // use a timer to update the numeric gauge flash counter
}
}
this.prepareForwardShieldReadout = function ()
{
this.kingcobragaugeframecounter += 1.0;
if (this.kingcobragaugeframecounter >= 3.0) {
this.kingcobragaugeframecounter = 1.0;
}
if (this.kingcobragaugeframecounter !== 2.0) {
this.kingcobragaugechanged = "FALSE";
return;
}
this.kingcobragaugevalue = ((player.ship.forwardShield / player.ship.maxForwardShield) * 40);
mfs = 40;
this.kingcobragaugeselector = "FORWARDSHIELD";
if (this.kingcobragaugevalue < (mfs * 0.25)) {
if ((this.kingcobragaugeflashcounter === 1.0) || (this.kingcobragaugeflashcounter === 3.0) || (this.kingcobragaugeflashcounter === 5.0) || (this.kingcobragaugeflashcounter === 7.0)) // flash fast
{
this.kingcobragaugecolor = "GREEN";
if (this.kingcobragaugelastforwardshieldcolor === this.kingcobragaugecolor) {
this.kingcobragaugecolorchanged = "FALSE";
} else {
this.kingcobragaugecolorchanged = "TRUE";
}
if ((this.kingcobragaugelastforwardshieldvalue === this.kingcobragaugevalue) && (this.kingcobragaugelastforwardshieldcolor === this.kingcobragaugecolor)) {
this.kingcobragaugechanged = "FALSE";
this.kingcobragaugecolorchanged = "FALSE";
this.kingcobragaugelastforwardshieldvalue = this.kingcobragaugevalue;
this.kingcobragaugelastforwardshieldcolor = this.kingcobragaugecolor;
return;
} else {
this.kingcobragaugechanged = "TRUE";
this.kingcobragaugelastforwardshieldvalue = this.kingcobragaugevalue;
this.kingcobragaugelastforwardshieldcolor = this.kingcobragaugecolor;
return;
}
} else {
this.kingcobragaugecolor = "YELLOW";
if (this.kingcobragaugelastforwardshieldcolor === this.kingcobragaugecolor) {
this.kingcobragaugecolorchanged = "FALSE";
} else {
this.kingcobragaugecolorchanged = "TRUE";
}
if ((this.kingcobragaugelastforwardshieldvalue === this.kingcobragaugevalue) && (this.kingcobragaugelastforwardshieldcolor === this.kingcobragaugecolor)) {
this.kingcobragaugechanged = "FALSE";
this.kingcobragaugelastforwardshieldvalue = this.kingcobragaugevalue;
this.kingcobragaugelastforwardshieldcolor = this.kingcobragaugecolor;
return;
} else {
this.kingcobragaugechanged = "TRUE";
this.kingcobragaugelastforwardshieldvalue = this.kingcobragaugevalue;
this.kingcobragaugelastforwardshieldcolor = this.kingcobragaugecolor;
return;
}
}
}
if (this.kingcobragaugevalue > (mfs * 0.8)) {
this.kingcobragaugecolor = "GREEN";
if (this.kingcobragaugelastforwardshieldcolor === this.kingcobragaugecolor) {
this.kingcobragaugecolorchanged = "FALSE";
} else {
this.kingcobragaugecolorchanged = "TRUE";
}
if ((this.kingcobragaugelastforwardshieldvalue === this.kingcobragaugevalue) && (this.kingcobragaugelastforwardshieldcolor === this.kingcobragaugecolor)) {
this.kingcobragaugechanged = "FALSE";
this.kingcobragaugelastforwardshieldvalue = this.kingcobragaugevalue;
this.kingcobragaugelastforwardshieldcolor = this.kingcobragaugecolor;
return;
} else {
this.kingcobragaugechanged = "TRUE";
this.kingcobragaugelastforwardshieldvalue = this.kingcobragaugevalue;
this.kingcobragaugelastforwardshieldcolor = this.kingcobragaugecolor;
return;
}
} else {
this.kingcobragaugecolor = "YELLOW";
if (this.kingcobragaugelastforwardshieldcolor === this.kingcobragaugecolor) {
this.kingcobragaugecolorchanged = "FALSE";
} else {
this.kingcobragaugecolorchanged = "TRUE";
}
if ((this.kingcobragaugelastforwardshieldvalue === this.kingcobragaugevalue) && (this.kingcobragaugelastforwardshieldcolor === this.kingcobragaugecolor)) {
this.kingcobragaugechanged = "FALSE";
this.kingcobragaugelastforwardshieldvalue = this.kingcobragaugevalue;
this.kingcobragaugelastforwardshieldcolor = this.kingcobragaugecolor;
return;
} else {
this.kingcobragaugechanged = "TRUE";
this.kingcobragaugelastforwardshieldvalue = this.kingcobragaugevalue;
this.kingcobragaugelastforwardshieldcolor = this.kingcobragaugecolor;
return;
}
return;
}
return;
}
this.prepareAftShieldReadout = function ()
{
if (this.kingcobragaugeframecounter !== 2.0) {
this.kingcobragaugechanged = "FALSE";
return;
}
this.kingcobragaugevalue = ((player.ship.aftShield / player.ship.maxAftShield) * 40);
mas = 40;
this.kingcobragaugeselector = "AFTSHIELD";
if (this.kingcobragaugevalue < (mas * 0.25)) {
if ((this.kingcobragaugeflashcounter === 1.0) || (this.kingcobragaugeflashcounter === 3.0) || (this.kingcobragaugeflashcounter === 5.0) || (this.kingcobragaugeflashcounter === 7.0)) // flash fast
{
this.kingcobragaugecolor = "GREEN";
if (this.kingcobragaugelastaftshieldcolor === this.kingcobragaugecolor) {
this.kingcobragaugecolorchanged = "FALSE";
} else {
this.kingcobragaugecolorchanged = "TRUE";
}
if ((this.kingcobragaugelastaftshieldvalue === this.kingcobragaugevalue) && (this.kingcobragaugelastaftshieldcolor === this.kingcobragaugecolor)) {
this.kingcobragaugechanged = "FALSE";
this.kingcobragaugelastaftshieldvalue = this.kingcobragaugevalue;
this.kingcobragaugelastaftshieldcolor = this.kingcobragaugecolor;
return;
} else {
this.kingcobragaugechanged = "TRUE";
this.kingcobragaugelastaftshieldvalue = this.kingcobragaugevalue;
this.kingcobragaugelastaftshieldcolor = this.kingcobragaugecolor;
return;
}
} else {
this.kingcobragaugecolor = "YELLOW";
if (this.kingcobragaugelastaftshieldcolor === this.kingcobragaugecolor) {
this.kingcobragaugecolorchanged = "FALSE";
} else {
this.kingcobragaugecolorchanged = "TRUE";
}
if ((this.kingcobragaugelastaftshieldvalue === this.kingcobragaugevalue) && (this.kingcobragaugelastaftshieldcolor === this.kingcobragaugecolor)) {
this.kingcobragaugechanged = "FALSE";
this.kingcobragaugelastaftshieldvalue = this.kingcobragaugevalue;
this.kingcobragaugelastaftshieldcolor = this.kingcobragaugecolor;
return;
} else {
this.kingcobragaugechanged = "TRUE";
this.kingcobragaugelastaftshieldvalue = this.kingcobragaugevalue;
this.kingcobragaugelastaftshieldcolor = this.kingcobragaugecolor;
return;
}
}
}
if (this.kingcobragaugevalue > (mas * 0.8)) {
this.kingcobragaugecolor = "GREEN";
if (this.kingcobragaugelastaftshieldcolor === this.kingcobragaugecolor) {
this.kingcobragaugecolorchanged = "FALSE";
} else {
this.kingcobragaugecolorchanged = "TRUE";
}
if ((this.kingcobragaugelastaftshieldvalue === this.kingcobragaugevalue) && (this.kingcobragaugelastaftshieldcolor === this.kingcobragaugecolor)) {
this.kingcobragaugechanged = "FALSE";
this.kingcobragaugelastaftshieldvalue = this.kingcobragaugevalue;
this.kingcobragaugelastaftshieldcolor = this.kingcobragaugecolor;
return;
} else {
this.kingcobragaugechanged = "TRUE";
this.kingcobragaugelastaftshieldvalue = this.kingcobragaugevalue;
this.kingcobragaugelastaftshieldcolor = this.kingcobragaugecolor;
return;
}
} else {
this.kingcobragaugecolor = "YELLOW";
if (this.kingcobragaugelastaftshieldcolor === this.kingcobragaugecolor) {
this.kingcobragaugecolorchanged = "FALSE";
} else {
this.kingcobragaugecolorchanged = "TRUE";
}
if ((this.kingcobragaugelastaftshieldvalue === this.kingcobragaugevalue) && (this.kingcobragaugelastaftshieldcolor === this.kingcobragaugecolor)) {
this.kingcobragaugechanged = "FALSE";
this.kingcobragaugelastaftshieldvalue = this.kingcobragaugevalue;
this.kingcobragaugelastaftshieldcolor = this.kingcobragaugecolor;
return;
} else {
this.kingcobragaugechanged = "TRUE";
this.kingcobragaugelastaftshieldvalue = this.kingcobragaugevalue;
this.kingcobragaugelastaftshieldcolor = this.kingcobragaugecolor;
return;
}
return;
}
return;
}
this.displayGauge = function ()
{
if (this.kingcobragaugechanged === "FALSE") {
return;
}
let g1 = this.kingcobragaugevalue;
let g2 = this.kingcobragaugeselector;
let c1 = this.kingcobragaugecolor;
if ((c1 === "YELLOW") && (this.kingcobragaugecolorchanged === "TRUE")) {
player.ship.removeEquipment("EQ_KINGCOBRA_GREEN_1_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_GREEN_2_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_GREEN_3_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_GREEN_4_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_GREEN_5_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_GREEN_6_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_GREEN_7_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_GREEN_8_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_GREEN_9_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_GREEN_10_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_GREEN_11_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_GREEN_12_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_GREEN_13_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_GREEN_14_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_GREEN_15_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_GREEN_16_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_GREEN_17_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_GREEN_18_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_GREEN_19_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_GREEN_20_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_GREEN_21_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_GREEN_22_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_GREEN_23_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_GREEN_24_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_GREEN_25_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_GREEN_26_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_GREEN_27_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_GREEN_28_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_GREEN_29_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_GREEN_30_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_GREEN_31_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_GREEN_32_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_GREEN_33_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_GREEN_34_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_GREEN_35_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_GREEN_36_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_GREEN_37_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_GREEN_38_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_GREEN_39_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_GREEN_40_" + g2);
}
if ((c1 === "GREEN") && (this.kingcobragaugecolorchanged === "TRUE")) {
player.ship.removeEquipment("EQ_KINGCOBRA_YELLOW_1_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_YELLOW_2_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_YELLOW_3_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_YELLOW_4_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_YELLOW_5_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_YELLOW_6_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_YELLOW_7_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_YELLOW_8_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_YELLOW_9_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_YELLOW_10_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_YELLOW_11_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_YELLOW_12_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_YELLOW_13_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_YELLOW_14_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_YELLOW_15_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_YELLOW_16_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_YELLOW_17_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_YELLOW_18_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_YELLOW_19_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_YELLOW_20_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_YELLOW_21_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_YELLOW_22_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_YELLOW_23_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_YELLOW_24_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_YELLOW_25_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_YELLOW_26_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_YELLOW_27_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_YELLOW_28_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_YELLOW_29_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_YELLOW_30_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_YELLOW_31_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_YELLOW_32_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_YELLOW_33_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_YELLOW_34_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_YELLOW_35_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_YELLOW_36_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_YELLOW_37_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_YELLOW_38_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_YELLOW_39_" + g2);
player.ship.removeEquipment("EQ_KINGCOBRA_YELLOW_40_" + g2);
}
if ((g1 > 1) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_1_" + g2) !== "EQUIPMENT_OK")) {
player.ship.awardEquipment("EQ_KINGCOBRA_" + c1 + "_1_" + g2);
}
if ((g1 <= 1) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_1_" + g2) === "EQUIPMENT_OK")) {
player.ship.removeEquipment("EQ_KINGCOBRA_" + c1 + "_1_" + g2);
}
if ((g1 > 2) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_2_" + g2) !== "EQUIPMENT_OK")) {
player.ship.awardEquipment("EQ_KINGCOBRA_" + c1 + "_2_" + g2);
}
if ((g1 <= 2) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_2_" + g2) === "EQUIPMENT_OK")) {
player.ship.removeEquipment("EQ_KINGCOBRA_" + c1 + "_2_" + g2);
}
if ((g1 > 3) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_3_" + g2) !== "EQUIPMENT_OK")) {
player.ship.awardEquipment("EQ_KINGCOBRA_" + c1 + "_3_" + g2);
}
if ((g1 <= 3) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_3_" + g2) === "EQUIPMENT_OK")) {
player.ship.removeEquipment("EQ_KINGCOBRA_" + c1 + "_3_" + g2);
}
if ((g1 > 4) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_4_" + g2) !== "EQUIPMENT_OK")) {
player.ship.awardEquipment("EQ_KINGCOBRA_" + c1 + "_4_" + g2);
}
if ((g1 <= 4) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_4_" + g2) === "EQUIPMENT_OK")) {
player.ship.removeEquipment("EQ_KINGCOBRA_" + c1 + "_4_" + g2);
}
if ((g1 > 5) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_5_" + g2) !== "EQUIPMENT_OK")) {
player.ship.awardEquipment("EQ_KINGCOBRA_" + c1 + "_5_" + g2);
}
if ((g1 <= 5) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_5_" + g2) === "EQUIPMENT_OK")) {
player.ship.removeEquipment("EQ_KINGCOBRA_" + c1 + "_5_" + g2);
}
if ((g1 > 6) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_6_" + g2) !== "EQUIPMENT_OK")) {
player.ship.awardEquipment("EQ_KINGCOBRA_" + c1 + "_6_" + g2);
}
if ((g1 <= 6) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_6_" + g2) === "EQUIPMENT_OK")) {
player.ship.removeEquipment("EQ_KINGCOBRA_" + c1 + "_6_" + g2);
}
if ((g1 > 7) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_7_" + g2) !== "EQUIPMENT_OK")) {
player.ship.awardEquipment("EQ_KINGCOBRA_" + c1 + "_7_" + g2);
}
if ((g1 <= 7) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_7_" + g2) === "EQUIPMENT_OK")) {
player.ship.removeEquipment("EQ_KINGCOBRA_" + c1 + "_7_" + g2);
}
if ((g1 > 8) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_8_" + g2) !== "EQUIPMENT_OK")) {
player.ship.awardEquipment("EQ_KINGCOBRA_" + c1 + "_8_" + g2);
}
if ((g1 <= 8) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_8_" + g2) === "EQUIPMENT_OK")) {
player.ship.removeEquipment("EQ_KINGCOBRA_" + c1 + "_8_" + g2);
}
if ((g1 > 9) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_9_" + g2) !== "EQUIPMENT_OK")) {
player.ship.awardEquipment("EQ_KINGCOBRA_" + c1 + "_9_" + g2);
}
if ((g1 <= 9) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_9_" + g2) === "EQUIPMENT_OK")) {
player.ship.removeEquipment("EQ_KINGCOBRA_" + c1 + "_9_" + g2);
}
if ((g1 > 10) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_10_" + g2) !== "EQUIPMENT_OK")) {
player.ship.awardEquipment("EQ_KINGCOBRA_" + c1 + "_10_" + g2);
}
if ((g1 <= 10) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_10_" + g2) === "EQUIPMENT_OK")) {
player.ship.removeEquipment("EQ_KINGCOBRA_" + c1 + "_10_" + g2);
}
if ((g1 > 11) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_11_" + g2) !== "EQUIPMENT_OK")) {
player.ship.awardEquipment("EQ_KINGCOBRA_" + c1 + "_11_" + g2);
}
if ((g1 <= 11) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_11_" + g2) === "EQUIPMENT_OK")) {
player.ship.removeEquipment("EQ_KINGCOBRA_" + c1 + "_11_" + g2);
}
if ((g1 > 12) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_12_" + g2) !== "EQUIPMENT_OK")) {
player.ship.awardEquipment("EQ_KINGCOBRA_" + c1 + "_12_" + g2);
}
if ((g1 <= 12) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_12_" + g2) === "EQUIPMENT_OK")) {
player.ship.removeEquipment("EQ_KINGCOBRA_" + c1 + "_12_" + g2);
}
if ((g1 > 13) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_13_" + g2) !== "EQUIPMENT_OK")) {
player.ship.awardEquipment("EQ_KINGCOBRA_" + c1 + "_13_" + g2);
}
if ((g1 <= 13) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_13_" + g2) === "EQUIPMENT_OK")) {
player.ship.removeEquipment("EQ_KINGCOBRA_" + c1 + "_13_" + g2);
}
if ((g1 > 14) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_14_" + g2) !== "EQUIPMENT_OK")) {
player.ship.awardEquipment("EQ_KINGCOBRA_" + c1 + "_14_" + g2);
}
if ((g1 <= 14) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_14_" + g2) === "EQUIPMENT_OK")) {
player.ship.removeEquipment("EQ_KINGCOBRA_" + c1 + "_14_" + g2);
}
if ((g1 > 15) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_15_" + g2) !== "EQUIPMENT_OK")) {
player.ship.awardEquipment("EQ_KINGCOBRA_" + c1 + "_15_" + g2);
}
if ((g1 <= 15) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_15_" + g2) === "EQUIPMENT_OK")) {
player.ship.removeEquipment("EQ_KINGCOBRA_" + c1 + "_15_" + g2);
}
if ((g1 > 16) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_16_" + g2) !== "EQUIPMENT_OK")) {
player.ship.awardEquipment("EQ_KINGCOBRA_" + c1 + "_16_" + g2);
}
if ((g1 <= 16) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_16_" + g2) === "EQUIPMENT_OK")) {
player.ship.removeEquipment("EQ_KINGCOBRA_" + c1 + "_16_" + g2);
}
if ((g1 > 17) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_17_" + g2) !== "EQUIPMENT_OK")) {
player.ship.awardEquipment("EQ_KINGCOBRA_" + c1 + "_17_" + g2);
}
if ((g1 <= 17) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_17_" + g2) === "EQUIPMENT_OK")) {
player.ship.removeEquipment("EQ_KINGCOBRA_" + c1 + "_17_" + g2);
}
if ((g1 > 18) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_18_" + g2) !== "EQUIPMENT_OK")) {
player.ship.awardEquipment("EQ_KINGCOBRA_" + c1 + "_18_" + g2);
}
if ((g1 <= 18) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_18_" + g2) === "EQUIPMENT_OK")) {
player.ship.removeEquipment("EQ_KINGCOBRA_" + c1 + "_18_" + g2);
}
if ((g1 > 19) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_19_" + g2) !== "EQUIPMENT_OK")) {
player.ship.awardEquipment("EQ_KINGCOBRA_" + c1 + "_19_" + g2);
}
if ((g1 <= 19) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_19_" + g2) === "EQUIPMENT_OK")) {
player.ship.removeEquipment("EQ_KINGCOBRA_" + c1 + "_19_" + g2);
}
if ((g1 > 20) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_20_" + g2) !== "EQUIPMENT_OK")) {
player.ship.awardEquipment("EQ_KINGCOBRA_" + c1 + "_20_" + g2);
}
if ((g1 <= 20) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_20_" + g2) === "EQUIPMENT_OK")) {
player.ship.removeEquipment("EQ_KINGCOBRA_" + c1 + "_20_" + g2);
}
if ((g1 > 21) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_21_" + g2) !== "EQUIPMENT_OK")) {
player.ship.awardEquipment("EQ_KINGCOBRA_" + c1 + "_21_" + g2);
}
if ((g1 <= 21) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_21_" + g2) === "EQUIPMENT_OK")) {
player.ship.removeEquipment("EQ_KINGCOBRA_" + c1 + "_21_" + g2);
}
if ((g1 > 22) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_22_" + g2) !== "EQUIPMENT_OK")) {
player.ship.awardEquipment("EQ_KINGCOBRA_" + c1 + "_22_" + g2);
}
if ((g1 <= 22) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_22_" + g2) === "EQUIPMENT_OK")) {
player.ship.removeEquipment("EQ_KINGCOBRA_" + c1 + "_22_" + g2);
}
if ((g1 > 23) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_23_" + g2) !== "EQUIPMENT_OK")) {
player.ship.awardEquipment("EQ_KINGCOBRA_" + c1 + "_23_" + g2);
}
if ((g1 <= 23) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_23_" + g2) === "EQUIPMENT_OK")) {
player.ship.removeEquipment("EQ_KINGCOBRA_" + c1 + "_23_" + g2);
}
if ((g1 > 24) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_24_" + g2) !== "EQUIPMENT_OK")) {
player.ship.awardEquipment("EQ_KINGCOBRA_" + c1 + "_24_" + g2);
}
if ((g1 <= 24) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_24_" + g2) === "EQUIPMENT_OK")) {
player.ship.removeEquipment("EQ_KINGCOBRA_" + c1 + "_24_" + g2);
}
if ((g1 > 25) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_25_" + g2) !== "EQUIPMENT_OK")) {
player.ship.awardEquipment("EQ_KINGCOBRA_" + c1 + "_25_" + g2);
}
if ((g1 <= 25) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_25_" + g2) === "EQUIPMENT_OK")) {
player.ship.removeEquipment("EQ_KINGCOBRA_" + c1 + "_25_" + g2);
}
if ((g1 > 26) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_26_" + g2) !== "EQUIPMENT_OK")) {
player.ship.awardEquipment("EQ_KINGCOBRA_" + c1 + "_26_" + g2);
}
if ((g1 <= 26) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_26_" + g2) === "EQUIPMENT_OK")) {
player.ship.removeEquipment("EQ_KINGCOBRA_" + c1 + "_26_" + g2);
}
if ((g1 > 27) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_27_" + g2) !== "EQUIPMENT_OK")) {
player.ship.awardEquipment("EQ_KINGCOBRA_" + c1 + "_27_" + g2);
}
if ((g1 <= 27) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_27_" + g2) === "EQUIPMENT_OK")) {
player.ship.removeEquipment("EQ_KINGCOBRA_" + c1 + "_27_" + g2);
}
if ((g1 > 28) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_28_" + g2) !== "EQUIPMENT_OK")) {
player.ship.awardEquipment("EQ_KINGCOBRA_" + c1 + "_28_" + g2);
}
if ((g1 <= 28) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_28_" + g2) === "EQUIPMENT_OK")) {
player.ship.removeEquipment("EQ_KINGCOBRA_" + c1 + "_28_" + g2);
}
if ((g1 > 29) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_29_" + g2) !== "EQUIPMENT_OK")) {
player.ship.awardEquipment("EQ_KINGCOBRA_" + c1 + "_29_" + g2);
}
if ((g1 <= 29) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_29_" + g2) === "EQUIPMENT_OK")) {
player.ship.removeEquipment("EQ_KINGCOBRA_" + c1 + "_29_" + g2);
}
if ((g1 > 30) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_30_" + g2) !== "EQUIPMENT_OK")) {
player.ship.awardEquipment("EQ_KINGCOBRA_" + c1 + "_30_" + g2);
}
if ((g1 <= 30) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_30_" + g2) === "EQUIPMENT_OK")) {
player.ship.removeEquipment("EQ_KINGCOBRA_" + c1 + "_30_" + g2);
}
if ((g1 > 31) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_31_" + g2) !== "EQUIPMENT_OK")) {
player.ship.awardEquipment("EQ_KINGCOBRA_" + c1 + "_31_" + g2);
}
if ((g1 <= 31) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_31_" + g2) === "EQUIPMENT_OK")) {
player.ship.removeEquipment("EQ_KINGCOBRA_" + c1 + "_31_" + g2);
}
if ((g1 > 32) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_32_" + g2) !== "EQUIPMENT_OK")) {
player.ship.awardEquipment("EQ_KINGCOBRA_" + c1 + "_32_" + g2);
}
if ((g1 <= 32) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_32_" + g2) === "EQUIPMENT_OK")) {
player.ship.removeEquipment("EQ_KINGCOBRA_" + c1 + "_32_" + g2);
}
if ((g1 > 33) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_33_" + g2) !== "EQUIPMENT_OK")) {
player.ship.awardEquipment("EQ_KINGCOBRA_" + c1 + "_33_" + g2);
}
if ((g1 <= 33) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_33_" + g2) === "EQUIPMENT_OK")) {
player.ship.removeEquipment("EQ_KINGCOBRA_" + c1 + "_33_" + g2);
}
if ((g1 > 34) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_34_" + g2) !== "EQUIPMENT_OK")) {
player.ship.awardEquipment("EQ_KINGCOBRA_" + c1 + "_34_" + g2);
}
if ((g1 <= 34) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_34_" + g2) === "EQUIPMENT_OK")) {
player.ship.removeEquipment("EQ_KINGCOBRA_" + c1 + "_34_" + g2);
}
if ((g1 > 35) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_35_" + g2) !== "EQUIPMENT_OK")) {
player.ship.awardEquipment("EQ_KINGCOBRA_" + c1 + "_35_" + g2);
}
if ((g1 <= 35) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_35_" + g2) === "EQUIPMENT_OK")) {
player.ship.removeEquipment("EQ_KINGCOBRA_" + c1 + "_35_" + g2);
}
if ((g1 > 36) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_36_" + g2) !== "EQUIPMENT_OK")) {
player.ship.awardEquipment("EQ_KINGCOBRA_" + c1 + "_36_" + g2);
}
if ((g1 <= 36) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_36_" + g2) === "EQUIPMENT_OK")) {
player.ship.removeEquipment("EQ_KINGCOBRA_" + c1 + "_36_" + g2);
}
if ((g1 > 37) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_37_" + g2) !== "EQUIPMENT_OK")) {
player.ship.awardEquipment("EQ_KINGCOBRA_" + c1 + "_37_" + g2);
}
if ((g1 <= 37) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_37_" + g2) === "EQUIPMENT_OK")) {
player.ship.removeEquipment("EQ_KINGCOBRA_" + c1 + "_37_" + g2);
}
if ((g1 > 38) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_38_" + g2) !== "EQUIPMENT_OK")) {
player.ship.awardEquipment("EQ_KINGCOBRA_" + c1 + "_38_" + g2);
}
if ((g1 <= 38) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_38_" + g2) === "EQUIPMENT_OK")) {
player.ship.removeEquipment("EQ_KINGCOBRA_" + c1 + "_38_" + g2);
}
if ((g1 > 39) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_39_" + g2) !== "EQUIPMENT_OK")) {
player.ship.awardEquipment("EQ_KINGCOBRA_" + c1 + "_39_" + g2);
}
if ((g1 <= 39) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_39_" + g2) === "EQUIPMENT_OK")) {
player.ship.removeEquipment("EQ_KINGCOBRA_" + c1 + "_39_" + g2);
}
if ((g1 >= 40) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_40_" + g2) !== "EQUIPMENT_OK")) {
player.ship.awardEquipment("EQ_KINGCOBRA_" + c1 + "_40_" + g2);
}
if ((g1 < 40) && (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_40_" + g2) === "EQUIPMENT_OK")) {
player.ship.removeEquipment("EQ_KINGCOBRA_" + c1 + "_40_" + g2);
}
}
this.refresh = function ()
{
this.kingcobragaugelastframecounter = this.kingcobragaugeframecounter;
this.kingcobragaugeframecounter = 1.0; //normally should be 2 but the counter will add 1 when it goes to prepareForwardShield function, remark just to avoid confusion
this.prepareForwardShieldReadout();
this.kingcobragaugechanged = "TRUE";
this.displayGauge();
this.kingcobragaugeframecounter = 2.0;
this.prepareAftShieldReadout();
this.kingcobragaugechanged = "TRUE";
this.displayGauge();
this.kingcobragaugeframecounter = this.kingcobragaugelastframecounter;
}
this.viewDirectionChanged = function (to, from)
{
if (from === "VIEW_GUI_DISPLAY" && to !== "VIEW_GUI_DISPLAY") {
player.ship.hud = "kw-kcHUD.plist"; // set the standard HUD
}
}
this.guiScreenChanged = function (to, from)
{
if (to === "GUI_SCREEN_STATUS") {
if (kctradhud == 0) {
player.ship.hud = "kw-kcGUI.plist";
} else {
player.ship.hud = "kw-kctrad.plist";
}
} else if (to === "GUI_SCREEN_SHORT_RANGE_CHART" || "GUI_SCREEN_LONG_RANGE_CHART") {
if (kctradhud == 0) {
player.ship.hud = "kw-kcGUI.plist";
} else {
player.ship.hud = "kw-kctrad.plist";
}
} else if (to === "GUI_SCREEN_MANIFEST") {
if (kctradhud == 0) {
player.ship.hud = "kw-kcGUI.plist";
} else {
player.ship.hud = "kw-kctrad.plist";
}
} else if (to === "GUI_SCREEN_SYSTEM_DATA") {
if (kctradhud == 0) {
player.ship.hud = "kw-kcGUI.plist";
} else {
player.ship.hud = "kw-kctrad.plist";
}
} else if (to === "GUI_SCREEN_MARKET") {
if (kctradhud == 0) {
player.ship.hud = "kw-kcGUI.plist";
} else {
player.ship.hud = "kw-kctrad.plist";
}
}
}
this.playerWillSaveGame = function ()
{
this.cleanUp();
}
this.cleanUp = function ()
{
this.kingcobragaugeselector = "FORWARDSHIELD";
this.kingcobragaugecolor = "GREEN";
this.removeLeftovers();
this.kingcobragaugecolor = "YELLOW";
this.removeLeftovers();
this.kingcobragaugeselector = "AFTSHIELD";
this.kingcobragaugecolor = "GREEN";
this.removeLeftovers();
this.kingcobragaugecolor = "YELLOW";
this.removeLeftovers();
}
this.removeLeftovers = function ()
{
let c1 = this.kingcobragaugecolor;
let g2 = this.kingcobragaugeselector;
for (counter = 0; counter < 41; counter++) {
if (player.ship.equipmentStatus("EQ_KINGCOBRA_" + c1 + "_" + counter + "_" + g2) === "EQUIPMENT_OK") {
player.ship.removeEquipment("EQ_KINGCOBRA_" + c1 + "_" + counter + "_" + g2);
}
}
}
this.shipDied = function ()
{
removeFrameCallback(this.pfsr); //----------
removeFrameCallback(this.pfsrdg);
removeFrameCallback(this.pasr); //----------
removeFrameCallback(this.pasrdg);
if (this.kingcobragaugeCheckTimer) {
this.kingcobragaugeCheckTimer.stop();
}
} |