Back to Index Page generated: Nov 12, 2024, 11:02:04 PM

Expansion Masslock Compensator

Content

Warnings

  1. Information URL mismatch between OXP Manifest and Expansion Manager string length at character position 0

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description Script to increase max ship speed during passive masslocks (yellow alert) Script to increase max ship speed during passive masslocks (yellow alert)
Identifier oolite.oxp.redspear.masslock_compensator oolite.oxp.redspear.masslock_compensator
Title Masslock Compensator Masslock Compensator
Category Mechanics Mechanics
Author Redspear Redspear
Version 1.4 1.4
Tags
Required Oolite Version
Maximum Oolite Version
Required Expansions
Optional Expansions
Conflict Expansions
Information URL n/a
Download URL https://wiki.alioth.net/img_auth.php/d/d2/Oolite.oxp.redspear.masslock_compensator.oxz n/a
License CC-BY-NC-SA 4.0 CC-BY-NC-SA 4.0
File Size n/a
Upload date 1610873478

Documentation

Also read http://wiki.alioth.net/index.php/Masslock%20Compensator

Equipment

Name Visible Cost [deci-credits] Tech-Level
Masslock Compensators active no 1 101+

Ships

This expansion declares no ships. This may be related to warnings.

Models

This expansion declares no models. This may be related to warnings.

Scripts

Path
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);
}