Back to Index Page generated: Dec 20, 2024, 7:22:09 AM

Expansion Breakable Engines

Content

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description This OXP make the ships standard engines (or system drive) into a visible equipment item which can be damaged in combat. This OXP make the ships standard engines (or system drive) into a visible equipment item which can be damaged in combat.
Identifier oolite.oxp.CaptMurphy.BreakableEngines oolite.oxp.CaptMurphy.BreakableEngines
Title Breakable Engines Breakable Engines
Category Equipment Equipment
Author Capt Murphy Capt Murphy
Version 1.1 1.1
Tags Equipment Equipment
Required Oolite Version
Maximum Oolite Version
Required Expansions
Optional Expansions
Conflict Expansions
Information URL http://wiki.alioth.net/index.php/Breakable_%27Standard%27_Equipment_OXPs n/a
Download URL https://wiki.alioth.net/img_auth.php/a/ae/Oolite.oxp.CaptMurphy.BreakableEngines.oxz n/a
License CC BY-NC-SA 3.0 CC BY-NC-SA 3.0
File Size n/a
Upload date 1610873409

Documentation

Also read http://wiki.alioth.net/index.php/Breakable%20Engines

readme.rtf

{\rtf1\ansi\ansicpg1252\deff0\deflang2057\deflangfe2057{\fonttbl{\f0\fswiss\fprq2\fcharset0 Arial;}}
{\colortbl ;\red0\green0\blue255;}
{\*\generator Msftedit 5.41.21.2510;}\viewkind4\uc1\pard\nowidctlpar\f0\fs20 Breakable Engines Version 1.1 (05/05/12)\par
By Capt Murphy 2011\par
Licence: CC BY-NC-SA 3.0 : Please visit {\field{\*\fldinst{HYPERLINK "http://creativecommons.org/licenses/by-nc-sa/3.0/"}}{\fldrslt{\ul\cf1 http://creativecommons.org/licenses/by-nc-sa/3.0/}}}\f0\fs20  for more info.\par
Requires Oolite 1.76\par
\par
Overview: \par
\par
An OXP intended for the experienced Commander who wishes to make their Oolife a little more difficult. This OXP make the ships standard engines (or system drive) into a visible equipment item which can be damaged in combat. Chances of damage is reduced when compared to other equipment items. When damaged the engines are still usable, but further equipment damage and energy loss may be incurred if the player exceeds certain speeds. The threshold varies and the player is warned via a console message if they need to slow down. The Torus Drive (if working) can still be used normally.\par
\par
Repairs can be conducted at a station of any tech level. Costs vary between 500 and 3000 credits depending on the maxiumum speed, cargo capacity and energy of your ship all of which relate to the size of the engine. The equipment can also be repaired by OXP repair technology such as Thargoid\rquote s Repair Bots.\par
\par
Technical:\par
\par
This OXP creates 1 new equipment item, the \ldblquote System Drive\rdblquote  which is listed on the equipment manifest and can be damaged in combat. It automatically fits the equipment to the current ship on first run, and it is also automatically fitted when the player purchases a new ship. If the player has Fuel Injectors fitted these must already be damaged before the System Drive can be damaged. Chance of damage is sklightly reduced compared to other equipment items.\par
\par
ChangeLog: \par
\par
Version 1  \tab 22/04/12 \endash  Initial release.\par
Version 1.1        05/5/12 - Minor update for compatibility with Ship_Storage_Helper.oxp\par
\par
Tested and built using Oolite 1.76\par
}

Equipment

Name Visible Cost [deci-credits] Tech-Level
System Drive yes 40000 1+
System Drive yes 20000 1+
System Drive yes 80000 1+
System Drive yes 10000 1+

Ships

This expansion declares no ships.

Models

This expansion declares no models.

Scripts

Path
Scripts/Breakable_Engines.js
this.name        = "Breakable_Engines"; 
this.author      = "capt murphy"; 
this.copyright   = "2012 capt murphy";
this.licence     = "CC BY-NC-SA 3.0"; // see http://creativecommons.org/licenses/by-nc-sa/3.0/ for more info.
this.description = "Script to simulate combat damage to the ships engines"; 
this.version     = "1.1";

// event handler driven function for functions at startup - awards equipment to existing ship if first run with OXP.
this.startUp = function()
{
	this.warning = new SoundSource;
	this.warning.sound = "warning.ogg";
	this.explosion = new SoundSource;
	this.explosion.sound = "hullbang.ogg";
	if (!missionVariables.beng_speedThreshold) {missionVariables.beng_speedThreshold = 0.5;}
	this.speedThreshold = missionVariables.beng_speedThreshold;
	this.getEngineSize();
	if (player.ship.equipmentStatus(this.engineEQ) === "EQUIPMENT_UNAVAILABLE"){missionVariables.beng_status = this.engineEQ; player.ship.awardEquipment(this.engineEQ); missionVariables.beng_status = "OK";}
}

this.getEngineSize = function()
{
	var sizeVar = (player.ship.maxEnergy + player.ship.cargoSpaceCapacity)*(player.ship.maxSpeed/100);
	if (sizeVar < 512){this.engineEQ = "EQ_BREAKABLE_ENGINE_SMALL";}
	else if (sizeVar < 1024){this.engineEQ = "EQ_BREAKABLE_ENGINE_MEDIUM";}
	else if (sizeVar < 2048){this.engineEQ = "EQ_BREAKABLE_ENGINE_LARGE";}
	else {this.engineEQ = "EQ_BREAKABLE_ENGINE_MONSTER";}
}
	
// event handler driven function to fit equipment to newly purchased ship.
this.playerBoughtNewShip = function()
{
	this.getEngineSize();
	missionVariables.beng_status = this.engineEQ;
	player.ship.awardEquipment(this.engineEQ);
	missionVariables.beng_status = "OK";
}

// event handler driven function to control actions if equipment damaged in combat.
this.equipmentDamaged = this.equipmentDestroyed = function(equipment)
{
	if (this.shipRestore && equipment === this.engineEQ) {missionVariables.beng_status = this.engineEQ; return;}
	if (equipment === this.engineEQ && player.ship.equipmentStatus("EQ_FUEL_INJECTION") === "EQUIPMENT_OK")
	{
		player.ship.setEquipmentStatus(equipment,"EQUIPMENT_OK");
		if (player.ship.setEquipmentStatus("EQ_FUEL_INJECTION","EQUIPMENT_DAMAGED"))
		{player.consoleMessage("Injectors are damaged!", 3);}
		return;
	}
	if (equipment === this.engineEQ)
	{
		var EQarray = player.ship.equipment;
		var EQdamaged = new Array;
		var counter;
		for(counter = 0; counter < EQarray.length; counter++)
		{
			if (player.ship.equipmentStatus(EQarray[counter])==="EQUIPMENT_DAMAGED")
			{EQdamaged.push(EQarray[counter]);EQarray.splice(counter,1);counter--;continue;}
			if (!EQarray[counter].isVisible || EQarray[counter] === equipment || !EQarray[counter].canBeDamaged)
			{EQarray.splice(counter,1);counter--;}
		}
		if (EQdamaged.length < 3 || Math.random() > 0.334) // reduced chance of equipment damage.
		{
			if (EQarray.length > 0)
			{
				var index = Math.floor(Math.random() * EQarray.length);
				player.ship.setEquipmentStatus(EQarray[index],"EQUIPMENT_DAMAGED");
				this.damagedEQ = EQarray[index];
				this.delayTimer = new Timer (this, this.delayMessage,0.25);
			}
			player.ship.setEquipmentStatus(equipment,"EQUIPMENT_OK");
			return;
		}
		missionVariables.beng_status = this.engineEQ;
		this.speedThreshold = 0.5;
		this.explosion.play(1);
		player.consoleMessage("System Drive Damaged!",3);
		this.setupTimer();
	}
}

this.delayMessage = function()
{
 if (this.damagedEQ && player.ship.equipmentStatus(this.damagedEQ) === "EQUIPMENT_DAMAGED")
 {player.consoleMessage(this.damagedEQ.name + " damaged!"); delete this.damagedEQ;}
}

this.delayMessage1 = function()
{
 if (this.damagedEQ && player.ship.equipmentStatus(this.damagedEQ) === "EQUIPMENT_DAMAGED")
 {player.consoleMessage(this.damagedEQ.name + " damaged by System Drive explosion!"); delete this.damagedEQ;}
}
		
// event handler driven function for actions on launching and exiting witchspace.
this.shipLaunchedFromStation = this.shipExitedWitchspace = function()
{
	if (player.ship.equipmentStatus(this.engineEQ) === "EQUIPMENT_OK" && missionVariables.beng_status !== "OK")
	{
		this.reset();	
	}
	if (missionVariables.beng_status !== "OK")
	{
		this.setupTimer();
	}
}

// event handler driven function to stop timers on docking or player death.
this.shipWillDockWithStation = this.shipDied = function()
{
	if (this.updateTimer && this.updateTimer.isRunning)
		{
			this.updateTimer.stop();
			delete this.updateTimer;
		}
	delete this.warned;
}

// event handler driven function for actions on save game.
this.playerWillSaveGame = function()
{
	missionVariables.beng_speedThreshold = this.speedThreshold;
}

// creates timers if not already in existance otherwise restarts existing timers.
this.setupTimer = function()
{
	if (this.updateTimer && this.updateTimer.isRunning){this.updateTimer.stop();delete this.updateTimer;}
	this.updateTimer = new Timer(this,this.updateEngine,0,5);
}
	

// called by timer every 5 seconds when player in flight to give warning noise whilst a shield is damaged.
this.updateEngine = function()
{
	if (player.ship.equipmentStatus(this.engineEQ) === "EQUIPMENT_OK" && missionVariables.beng_status !== "OK") // check to see if something has repaired the engine on the fly e.g. Thargoid's Repair Bots OXP.
	{
		this.reset();
		return;
	}
	if (!this.message){this.message = true;} else {delete this.message;}
	if (player.ship.speed > player.ship.maxSpeed)
	{if (this.message){player.consoleMessage("Warning - System Drive damaged. Disengaged whilst using Torus",3);}return;} // Torus Drive can still be used
	if ((player.ship.speed/player.ship.maxSpeed) > this.speedThreshold) // over speed threshold?
	{
		this.warning.play(1);
		player.consoleMessage("Warning - System Drive damaged and unstable, reduce speed at once!",3);
		if (!this.warned){this.warned = true;return;}
		this.explosion.play(1);
		var damage = (player.ship.speed/player.ship.maxSpeed) - this.speedThreshold;
		player.ship.energy -= (player.ship.maxEnergy * damage);
		var EQarray = player.ship.equipment;
		var counter;
		for(counter = 0; counter < EQarray.length; counter++)
		{
			if (!EQarray[counter].isVisible || player.ship.equipmentStatus(EQarray[counter])==="EQUIPMENT_DAMAGED" || !EQarray[counter].canBeDamaged){EQarray.splice(counter,1);counter--;}
		}
		if (EQarray.length > 0)
			{
				var index = Math.floor(Math.random() * EQarray.length);
				player.ship.setEquipmentStatus(EQarray[index],"EQUIPMENT_DAMAGED");
				this.damagedEQ = EQarray[index];
				this.delayTimer = new Timer (this, this.delayMessage1,0.25);
				return;
			}
		if (this.speedThreshold > 0.1){this.speedThreshold -= 0.1}
		return;
	}
	if (this.warned){delete this.warned;}
	if (this.message){this.warning.play(1);}
	if (this.message){player.consoleMessage("Warning - System Drive damaged but stable at current speed.",3);}
}

this.reset = function()
{
	if (player.ship.equipmentStatus(this.engineEQ) === "EQUIPMENT_OK" && missionVariables.beng_status !== "OK")
	{
		if (this.updateTimer && this.updateTimer.isRunning)
			{
				this.updateTimer.stop();
				delete this.updateTimer;
			}
		delete this.warned;
		this.speedThreshold = 0.5;
		missionVariables.beng_status = "OK";
	}
}