| Config/script.js | "use strict";
this.name = "MissileSummary";
this.author = "phkb";
this.copyright = "(C) 2023 phkb.";
this.license = "CC-NC-by-SA 4.0";
this.description = "Controls the equipment items to summarise missiles on the F5 Status screen";
this._knownKeys = {};
this._summaryKeys = [];
//-------------------------------------------------------------------------------------------------------------
this.startUpComplete = function () {
    var idx = 1;
    var found = true;
    var sc = worldScripts.ShipConfiguration_Core;
    do {
        found = false;
        var k = "EQ_MISSILESUMMARY_" + (idx < 10 ? "00" : (idx < 100 ? "0" : "")) + idx.toString();
        var ke = EquipmentInfo.infoForKey(k);
        if (ke) {
            this._knownKeys[ke.scriptInfo.missileKey] = k;
            this._summaryKeys.push(k);
            found = true;
            if (sc) sc._ignoreEquip.push(k);
        }
        idx += 1;
    } while (found == true);
    if (sc) sc._ignoreEquip.push("EQ_AMSDART_SUMMARY");
}
//-------------------------------------------------------------------------------------------------------------
this.shipWillLaunchFromStation = function() {
    this.$clearDummyEquipment();
}
//-------------------------------------------------------------------------------------------------------------
this.guiScreenChanged = function (to, from) {
    var p = player.ship;
    if (to == "GUI_SCREEN_STATUS") {
        if (p.missileCapacity > 0) {
            var flag = false;
            var miss = null;
            try {
                miss = p.missiles;
                flag = true;
            } catch (err) {
                if (this._debug) log(this.name, "!!ERROR: " + err);
            }
            if (flag === true) {
                for (var i = 0; i < miss.length; i++) {
                    //if (this._debug) log(this.name, p.missileCapacity + " - " + i + ": " + miss[i].equipmentKey);
                    var mk = miss[i].equipmentKey;
                    if (this._knownKeys[mk]) {
                        p.awardEquipment(this._knownKeys[mk]);
                    }
                }
            }
            // show the number of ams darts remaining
            if (missionVariables.amCount > 0 && p.hasEquipmentProviding("EQ_AMS")) {
                var amc = missionVariables.amCount;
                for (var i = 0; i < amc; i++) {
                    p.awardEquipment("EQ_AMSDART_SUMMARY");
                }
            }
        }
    }
    if (from == "GUI_SCREEN_STATUS") {
        this.$clearDummyEquipment();
    }
}
//-------------------------------------------------------------------------------------------------------------
this.playerWillSaveGame = function() {
    this.$clearDummyEquipment();
}
//-------------------------------------------------------------------------------------------------------------
this.$clearDummyEquipment = function() {
    var p = player.ship;
    var sk = this._summaryKeys;
    var i = sk.length;
    while (i--) {
        do {
            p.removeEquipment(sk[i]);
        } while (p.hasEquipmentProviding(sk[i]));
    }
} | 
                
                    | Scripts/missilesummary_conditions.js | "use strict";
this.name = "MissileSummary_Conditions";
this.author = "phkb";
this.copyright = "2023 phkb";
this.description = "Condition script for equipment.";
this.license = "CC BY-NC-SA 3.0";
//-------------------------------------------------------------------------------------------------------------
this.allowAwardEquipment = function (equipment, ship, context) {
    // we will only award this item via script
    if (context != "scripted") return false;
    return true;
} |