Scripts/masslock_compensator.js |
this.name = "masslock_compensator";
this.author = "Redspear";
this.copyright = "2019 Redspear";
this.licence = "CC-BY-NC-SA 4.0";
this.description = "Script to increase max ship speed during passive masslocks (yellow alert)";
this.version = "1.4";
"use strict";
// determine compensator speed based on ship
this.startUpComplete = this.playerBoughtEquipment = this.playerBoughtNewShip = function()
{
// establish base speed
this._mlcOFF = player.ship.maxSpeed;
// this._mlcON = (_mlcOFF + 1000) /2;
// set compensator speed
if (player.ship.maxSpeed > 900) {
this._mlcON = _mlcOFF; // no bonus
} else {
if (player.ship.maxSpeed > 600) {
this._mlcON = 900; // max boosted value
} else {
if (player.ship.maxSpeed > 300) {
this._mlcON = _mlcOFF + 300; // standard bonus
} else {
this._mlcON = 600; // min boosted value
}
}
}
}
// delay activation if station has aegis
this.shipWillLaunchFromStation = function(station)
{
if (station.isMainStation === false) {
this._mlcState = _mlcON;
player.ship.awardEquipment ("EQ_MASSLOCK_COMPENSATOR");
player.consoleMessage ("Mass-Lock Compensators Online");
// log(this.name, "launched = " + player.ship.maxSpeed);
} else {
this._mlcState = _mlcOFF;
// log(this.name, "launched = " + player.ship.maxSpeed);
}
return;
}
// check if player entering station aegis
this.shipEnteredStationAegis = function()
{
this._mlcState = _mlcOFF;
player.ship.removeEquipment ("EQ_MASSLOCK_COMPENSATOR");
player.consoleMessage ("Entering Aegis: Mass-Lock Compensators Disabled");
if (player.ship.equipmentStatus("EQ_POWER_TO_ENGINES") == "EQUIPMENT_OK") {
player.ship.maxSpeed = _mlcOFF * 1.5;
} else {
player.ship.maxSpeed = _mlcOFF;
}
// log(this.name, "enter aegis = " + player.ship.maxSpeed);
}
// check if player approaching star
this.shipEnteredPlanetaryVicinity = function(entity) // entity isSun
{
if (entity.isSun === true) {
this._mlcState = _mlcOFF;
player.ship.removeEquipment ("EQ_MASSLOCK_COMPENSATOR");
player.consoleMessage ("Strong Magnetic Fields: Mass-Lock Compensators Offline");
if (player.ship.equipmentStatus("EQ_POWER_TO_ENGINES") == "EQUIPMENT_OK") {
player.ship.maxSpeed = _mlcOFF * 1.5;
} else {
player.ship.maxSpeed = _mlcOFF;
}
}
// log(this.name, "star approach = " + player.ship.maxSpeed);
}
// check if player leaving station aegis
this.shipExitedStationAegis = function()
{
this._mlcState = _mlcON;
player.ship.awardEquipment ("EQ_MASSLOCK_COMPENSATOR");
player.consoleMessage ("Mass-Lock Compensators Online");
if (player.alertCondition == 2 && player.ship.equipmentStatus("EQ_POWER_TO_ENGINES") == "EQUIPMENT_OK") { // passive masslock + PTE
player.ship.maxSpeed = _mlcState * 1.5;
} else {
if (player.alertCondition == 2 && player.ship.equipmentStatus("EQ_POWER_TO_ENGINES") != "EQUIPMENT_OK") { // passive masslock alonme
player.ship.maxSpeed = _mlcState;
// log(this.name, "exit A y = " + player.ship.maxSpeed);
} else {
if (player.alertCondition != 2 && player.ship.equipmentStatus("EQ_POWER_TO_ENGINES") == "EQUIPMENT_OK") {
player.ship.maxSpeed = _mlcOFF * 1.5; // active masslock (red alert) or no masslock (status green)
} else {
player.ship.maxSpeed = _mlcOFF;
}
} // log(this.name, "exit A = " + player.ship.maxSpeed);
}
}
// check if player leaving star aegis
this.shipExitedPlanetaryVicinity = function(planet)
{
if (planet.isSun === true) {
this._mlcState = _mlcON;
player.ship.awardEquipment ("EQ_MASSLOCK_COMPENSATOR");
player.consoleMessage ("Mass-Lock Compensators Online");
if (player.alertCondition == 2 && player.ship.equipmentStatus("EQ_POWER_TO_ENGINES") == "EQUIPMENT_OK") { // passive masslock + PTE
player.ship.maxSpeed = _mlcState * 1.5;
} else {
if (player.alertCondition == 2 && player.ship.equipmentStatus("EQ_POWER_TO_ENGINES") != "EQUIPMENT_OK") { // passive masslock alonme
player.ship.maxSpeed = _mlcState;
//log(this.name, "witchspace y = " + player.ship.maxSpeed);
} else {
if (player.alertCondition != 2 && player.ship.equipmentStatus("EQ_POWER_TO_ENGINES") == "EQUIPMENT_OK") {
player.ship.maxSpeed = _mlcOFF * 1.5; // active masslock (red alert) or no masslock (status green)
} else {
player.ship.maxSpeed = _mlcOFF;
}
} //log(this.name, "witchspace = " + player.ship.maxSpeed);
}
//log(this.name, "exit star = " + player.ship.maxSpeed);
}
}
// check for hyperspace (esp from within aegis)
this.shipWillEnterWitchspace = function()
{
this._mlcState = _mlcON;
player.ship.removeEquipment ("EQ_MASSLOCK_COMPENSATOR");
player.ship.awardEquipment ("EQ_MASSLOCK_COMPENSATOR");
if (player.alertCondition == 2 && player.ship.equipmentStatus("EQ_POWER_TO_ENGINES") == "EQUIPMENT_OK") { // passive masslock + PTE
player.ship.maxSpeed = _mlcState * 1.5;
} else {
if (player.alertCondition == 2 && player.ship.equipmentStatus("EQ_POWER_TO_ENGINES") != "EQUIPMENT_OK") { // passive masslock alonme
player.ship.maxSpeed = _mlcState;
//log(this.name, "witchspace y = " + player.ship.maxSpeed);
} else {
if (player.alertCondition != 2 && player.ship.equipmentStatus("EQ_POWER_TO_ENGINES") == "EQUIPMENT_OK") {
player.ship.maxSpeed = _mlcOFF * 1.5; // active masslock (red alert) or no masslock (status green)
} else {
player.ship.maxSpeed = _mlcOFF;
}
} //log(this.name, "witchspace = " + player.ship.maxSpeed);
}
}
// activate compensator in yellow alert and outside aegis only
this.alertConditionChanged = function()
{
if (player.alertCondition == 2 && player.ship.equipmentStatus("EQ_POWER_TO_ENGINES") == "EQUIPMENT_OK") { // passive masslock + PTE
player.ship.maxSpeed = _mlcState * 1.5;
//log(this.name, "generic y = " + player.ship.maxSpeed);
} else {
if (player.alertCondition == 2 && player.ship.equipmentStatus("EQ_POWER_TO_ENGINES") != "EQUIPMENT_OK") { // passive masslock alonme
player.ship.maxSpeed = _mlcState;
} else {
if (player.alertCondition != 2 && player.ship.equipmentStatus("EQ_POWER_TO_ENGINES") == "EQUIPMENT_OK") {
player.ship.maxSpeed = _mlcOFF * 1.5; // active masslock (red alert) or no masslock (status green)
} else {
player.ship.maxSpeed = _mlcOFF;
}
}
}
}
// reset to base speed when docked
this.shipWillDockWithStation = function ()
{
player.ship.maxSpeed = _mlcOFF;
this._mlcState = _mlcOFF;
player.ship.removeEquipment ("EQ_MASSLOCK_COMPENSATOR");
// log(this.name, "docked = " + player.ship.maxSpeed);
}
|