| Scripts/power_to_engines.js | this.name        = "power_to_engines"; 
this.author      = "Redspear"; 
this.copyright   = "2019 Redspear";
this.licence     = "CC BY-NC-SA 4.0"; 
this.description = "more engine power when weapons off-line"; 
this.version     = "1.4";
"use strict";
// establish speed boost according to ship speed
this.startUpComplete = this.playerBoughtNewShip = this.playerBoughtEquipment = this.equipmentDamaged = this.equipmentRepaired = function ()
{
	// base values
	this._dms = player.ship.maxSpeed;
	this._dsf = player.ship.injectorSpeedFactor;
	
	if (player.ship.weaponFacings === 1 || player.ship.weaponFacings === 2 || player.ship.weaponFacings === 4 || player.ship.weaponFacings === 8) {
	this. _db = 25;
	}
	
	if (player.ship.weaponFacings === 3 || player.ship.weaponFacings === 5 || player.ship.weaponFacings === 9 || player.ship.weaponFacings === 6 || player.ship.weaponFacings === 10 || player.ship.weaponFacings === 12) {
	this. _db = 40;
	}
	
	if (player.ship.weaponFacings === 7 || player.ship.weaponFacings === 11 || player.ship.weaponFacings === 13 || player.ship.weaponFacings === 14) {
	this. _db = 55;
	}
	
	if (player.ship.weaponFacings === 15) {
	this. _db = 70;
	}
	
	if (player.ship.weaponFacings === 0) {
	this. _db = 0;
	}
		
	// when weapons off-line
	this._nms = _dms + _db;	// boosted according to laser mounts offline
	this._nsf = _dsf;	// if you prefer injector speed to be unaffected by any bonus then 'un-comment' the next line (i.e. remove the "//") back in...
	// this._nsf = _dsf - ((_db / _nms) * _dsf); // ...if using this line then you can comment the previous line out
	
	// compatibility with masslock compensator oxp
	this._mds = _dms * 2; // 200 % base speed
	this._mdf = _dsf; // MLC injector speed unaffected
	this._mcs = _nms * 2; // 200 % PtE speed
	this._mcf = _nsf; // MLC injector speed unaffected
}
// check if weapons off-line when launching
this.shipWillLaunchFromStation = function ()
{
	if (player.ship.weaponsOnline === true) {
		player.ship.maxSpeed = _dms;
		player.ship.injectorSpeedFactor = _dsf;
		} else {
			player.ship.awardEquipment ("EQ_POWER_TO_ENGINES");
			player.ship.maxSpeed = _nms;
			player.ship.injectorSpeedFactor = _nsf;
			}
}
// when weapons brought on or off-line, adjust speed accordingly
this.weaponsSystemsToggled = function ()
{
	// weapons on-line and masslock compensators active
	if (player.ship.weaponsOnline === true && player.ship.equipmentStatus("EQ_MASSLOCK_COMPENSATOR") == "EQUIPMENT_OK") {
		player.ship.removeEquipment ("EQ_POWER_TO_ENGINES");
		player.ship.maxSpeed = _mds;
		player.ship.injectorSpeedFactor = _mdf;
		} else {
		// weapons on-line and masslock compensators inactive
		if (player.ship.weaponsOnline === true) {
			player.ship.removeEquipment ("EQ_POWER_TO_ENGINES");
			player.ship.maxSpeed = _dms;
			player.ship.injectorSpeedFactor = _dsf;
			} else {
			// weapons off-line and masslock compensators active
			if (player.ship.weaponsOnline === false && player.ship.equipmentStatus("EQ_MASSLOCK_COMPENSATOR") == "EQUIPMENT_OK") {
				player.ship.awardEquipment ("EQ_POWER_TO_ENGINES");
				player.consoleMessage ("Power redirected to engines");
				player.ship.maxSpeed = _mcs;
				player.ship.injectorSpeedFactor = _mcf;
				} else {
				// weapons off-line and masslock compensators inactive
				if (player.ship.weaponsOnline === false) {
					player.ship.awardEquipment ("EQ_POWER_TO_ENGINES");
					player.consoleMessage ("Power redirected to engines");
					player.ship.maxSpeed = _nms;
					player.ship.injectorSpeedFactor = _nsf;
					}
				}
			}
		}
}
// reset to base speed when docked
this.shipWillDockWithStation = function ()
{
	player.ship.removeEquipment ("EQ_POWER_TO_ENGINES");
	player.ship.maxSpeed = _dms;
	player.ship.injectorSpeedFactor = _dsf;
}
 |