Scripts/battle_damage_conditions.js |
"use strict";
this.name = "battle_damage_conditions";
this.author = "phkb";
this.copyright = "© 2023 phkb";
this.description = "Condition script for equipment.";
this.licence = "CC BY-NC-SA 4.0";
//-------------------------------------------------------------------------------------------------------------
this.allowAwardEquipment = function (equipment, ship, context) {
if (context === "scripted") return true;
if (equipment == "EQ_HULL_REPAIR") {
if (!player.ship.hasEquipmentProviding("EQ_HULL_REPAIR") && missionVariables.BattleDamage_status != "OK") return true;
}
return false;
}
|
Scripts/battle_damage_script.js |
"use strict";
// Standard attributes
this.name = "Battle Damage";
this.author = "Smivs";
this.copyright = "Smivs";
this.license = "Creative Commons Attribution - Non-Commercial - Share Alike 4.0 license";
this.description = "Script to control hull damage and repair";
this.version = "1.4";
this.startUp = function () {
if (missionVariables.BattleDamage_status !== "DAMAGED") {
player.ship.awardEquipment("EQ_HULL_REPAIR"); //Ensures that repair does not appear on F3 screen
missionVariables.BattleDamage_status = "OK";
}
}
this.playerBoughtNewShip = function () {
player.ship.awardEquipment("EQ_HULL_REPAIR"); //Ensures that repair does not appear on F3 screen
missionVariables.BattleDamage_status = "OK";
}
this.shipWillDockWithStation = function (station) {
if (missionVariables.BattleDamage_status == "DAMAGED") {
player.addMessageToArrivalReport(expandDescription("[HULL_DAMAGE_MESSAGE]"));
}
else if (missionVariables.BattleDamage_status == "DAMAGED1") {
missionVariables.BattleDamage_status = "DAMAGED"; // set to damaged
player.addMessageToArrivalReport(expandDescription("[HULL_DAMAGE_MESSAGE_TWO]"));
player.credits -= 25;
}
}
this.guiScreenChanged = function(to, from) {
if (to == "GUI_SCREEN_STATUS" && missionVariables.BattleDamage_status != "OK") {
player.ship.awardEquipment("EQ_HULL_DISPLAY");
}
if (from == "GUI_SCREEN_STATUS") {
player.ship.removeEquipment("EQ_HULL_DISPLAY");
}
}
this.shipWillLaunchFromStation = function (station) {
if (missionVariables.BattleDamage_status == "OK") //Ensures that there are no issues when player launches after un-repaired launch/re-dock/repair/re-launch
{
player.ship.fuelLeakRate = 0;
player.ship.scriptedMisjump = false;
}
}
this.shipLaunchedFromStation = function (station) { // to handle ship launching with damage un-repaired
if (missionVariables.BattleDamage_status == "DAMAGED" && (Math.random() <= 0.50)) {
this.station = station;
this.station.commsMessage("Commander, your ship appears to be badly damaged. Take care!"), player.ship;
missionVariables.BattleDamage_status = "DAMAGED"; // set to damaged
}
else if (missionVariables.BattleDamage_status == "DAMAGED" && (Math.random() > 0.50)) {
player.ship.fuelLeakRate = 0.5;
player.consoleMessage("WARNING! FUEL LEAK.", 5);
this.station = station;
this.station.commsMessage("Commander, your ship is venting fuel due to a hull breach. You must dock for repairs immediately."), player.ship;
player.ship.scriptedMisjump = true;
missionVariables.BattleDamage_status = "DAMAGED1"; // set to damaged1
}
}
this.shipTakingDamage = function (amount) {
if (amount === 0) return;
else if (missionVariables.BattleDamage_status == "DAMAGED") {
player.consoleMessage("Hull taking further damage.", 1);
}
else {
player.ship.removeEquipment("EQ_HULL_REPAIR"); //remove 'repair' to allow 'repair' to be applied again. This should happen before any risk of damage to 'repair'
missionVariables.BattleDamage_status = "DAMAGED"; // set to damaged
player.consoleMessage("WARNING! HULL DAMAGE", 6);
}
}
this.playerBoughtEquipment = function (equipment) {
if (equipment == "EQ_HULL_REPAIR") {
clock.addSeconds("35000");
missionVariables.BattleDamage_status = "OK"; // set to OK
}
if (equipment == "EQ_RENOVATION") {
player.ship.awardEquipment("EQ_HULL_REPAIR");
missionVariables.BattleDamage_status = "OK"; // set to OK
}
}
this.shipLaunchedEscapePod = function (escapepod) {// resets everything after ejecting so new ship is undamaged
missionVariables.BattleDamage_status = "OK"; //set to OK
player.ship.awardEquipment("EQ_HULL_REPAIR"); //Ensures that repair does not appear on F3 screen
}
|