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

Expansion Breakable Shield Generators

Content

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description This OXP make the generators for the fore and aft shields into equipment items than can be damaged in combat. This OXP make the generators for the fore and aft shields into equipment items than can be damaged in combat.
Identifier oolite.oxp.CaptMurphy.BreakableShieldGenerators oolite.oxp.CaptMurphy.BreakableShieldGenerators
Title Breakable Shield Generators Breakable Shield Generators
Category Equipment Equipment
Author Capt Murphy Capt Murphy
Version 1.2 1.2
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/8/84/Oolite.oxp.CaptMurphy.BreakableShieldGenerators.oxz n/a
License CC BY-NC-SA 3.0 CC BY-NC-SA 3.0
File Size n/a
Upload date 1610873351

Documentation

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

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 Shield Generators Version 1.2 (05/05/12)\par
By Capt Murphy 2012\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 generators for the fore and aft shields into equipment items than can be damaged in combat. When damaged the relevant shield will remain at zero strength until the generator is repaired.  Repairs can be conducted at a station of any tech level. Repair costs vary between 250 credits and 1000 credits depending on the cargo capacity and maximum energy of your ship. 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 2 new equipment items \ldblquote Forward Shield Generator\rdblquote  and \ldblquote Aft Shield Generator\rdblquote , which are 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 Shield Boosters or Military Shield Enhancement fitted these must already be damaged before the Shield Generators themselves can be damaged.\par
\par
This OXP is compatible with both CommonsenseOTB\rquote s \ldblquote Shield Equaliser and Capacitors\rdblquote  OXP (version 1.3+ only), and Lone_Wolf\rquote s \ldblquote Shield Cycler\rdblquote  OXP (beta version 0.30.1+ only). In both cases this OXP temporarily disables the activity if these equipment items whilst a shield generator is damaged.\par
\par
ChangeLog: \par
\par
Version 1  \tab 10/7/11 \endash  Initial release.\par
Version 1.1       22/04/12 \endash  adds variable repair cost depending on ship size. \par
Version 1.2       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
Primary Shield Generator - Aft yes 20000 1+
Primary Shield Generator - Aft yes 10000 1+
Primary Shield Generator - Aft yes 5000 1+
Primary Shield Generator - Fore yes 20000 1+
Primary Shield Generator - Fore yes 10000 1+
Primary Shield Generator - Fore yes 5000 1+

Ships

This expansion declares no ships.

Models

This expansion declares no models.

Scripts

Path
Scripts/Breakable_Shield_Generators.js
this.name        = "Breakable_Shield_Generators"; 
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 Shield Generators"; 
this.version     = "1.2";

// 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.getShieldSize();
	if (player.ship.equipmentStatus(this.foreShieldEQ) === "EQUIPMENT_UNAVAILABLE"){missionVariables.bsg_foreshieldstatus = this.foreShieldEQ; player.ship.awardEquipment(this.foreShieldEQ); missionVariables.bsg_foreshieldstatus = "OK";}
	if (player.ship.equipmentStatus(this.aftShieldEQ) === "EQUIPMENT_UNAVAILABLE"){missionVariables.bsg_aftshieldstatus = this.aftShieldEQ; player.ship.awardEquipment(this.aftShieldEQ); missionVariables.bsg_aftshieldstatus = "OK";}	
}

this.getShieldSize = function()
{
	var sizeVar = (player.ship.maxEnergy + player.ship.cargoSpaceCapacity);
	if (player.ship.equipmentStatus("EQ_CARGO_BAY")==="EQUIPMENT_OK"){sizeVar -= 15;}
	if (sizeVar < 256){this.foreShieldEQ = "EQ_BREAKABLE_SHIELD_FORE_SMALL";this.aftShieldEQ = "EQ_BREAKABLE_SHIELD_AFT_SMALL";}
	else if (sizeVar < 512){this.foreShieldEQ = "EQ_BREAKABLE_SHIELD_FORE_MEDIUM";this.aftShieldEQ = "EQ_BREAKABLE_SHIELD_AFT_MEDIUM";}
	else {this.foreShieldEQ = "EQ_BREAKABLE_SHIELD_FORE_LARGE";this.aftShieldEQ = "EQ_BREAKABLE_SHIELD_AFT_LARGE";}
}
	
// event handler driven function to fit equipment to newly purchased ship.
this.playerBoughtNewShip = function()
{
	this.getShieldSize();
	missionVariables.bsg_foreshieldstatus = this.foreShieldEQ;
	missionVariables.bsg_aftshieldstatus = this.aftShieldEQ;
	player.ship.awardEquipment(this.foreShieldEQ);
	player.ship.awardEquipment(this.aftShieldEQ);
	missionVariables.bsg_foreshieldstatus = "OK";
	missionVariables.bsg_aftshieldstatus = "OK";
}

// event handler driven function to control actions if equipment damaged in combat.
this.equipmentDamaged = this.equipmentDestroyed = function(equipment)
{
    if (this.shipRestore && (equipment === this.foreShieldEQ || equipment === this.aftShieldEQ))
	{
		if (equipment === this.foreShieldEQ)
		{	 
			missionVariables.bsg_foreshieldstatus = this.foreShieldEQ;
		}
		if (equipment === this.aftShieldEQ)
		{
			missionVariables.bsg_aftshieldstatus = this.aftShieldEQ;
		}
		return;
	}
	if ((equipment === this.foreShieldEQ || equipment === this.aftShieldEQ) && (player.ship.equipmentStatus("EQ_NAVAL_SHIELD_BOOSTER") === "EQUIPMENT_OK" || player.ship.equipmentStatus("EQ_SHIELD_BOOSTER") === "EQUIPMENT_OK"))//if Military Shield Enhancement or Shield Boosters fitted these will be damaged first.
	{
	player.ship.setEquipmentStatus(equipment,"EQUIPMENT_OK");
	if (player.ship.equipmentStatus("EQ_NAVAL_SHIELD_BOOSTER") === "EQUIPMENT_OK")
		{
			player.ship.setEquipmentStatus("EQ_NAVAL_SHIELD_BOOSTER","EQUIPMENT_DAMAGED");
		    this.consoleMessageTimer = new Timer(this, this.consoleMessage1, 0.25);//delayed message in case other OXP (Shield Equaliser) prevents damage.
			return;
		}
	else
		{ 
			player.ship.setEquipmentStatus("EQ_SHIELD_BOOSTER","EQUIPMENT_DAMAGED");
			this.consoleMessageTimer = new Timer(this, this.consoleMessage2, 0.25);//delayed message in case other OXP (Shield Equaliser) prevents damage.
			return;
		}
	}
	if (equipment === this.foreShieldEQ || equipment === this.aftShieldEQ)
	{
		if (player.ship.equipmentStatus("EQ_SC_SHIELD_CYCLER_INTERNAL") === "EQUIPMENT_OK" && !worldScripts["Shield Cycler"].deactivated)// disables Shield Cycler if fitted and active to prevent catastrophic shield/energy loss.
		{
			if (worldScripts["Shield Cycler"].sc_stop())
			{
			 this.stoppedSC = true;
			 player.consoleMessage("All Shield Cycler functionality disabled pending Primary Shield Generator repair.",4);
			}
		}
	if (player.ship.equipmentStatus("EQ_SHIELD_EQUALIZER") === "EQUIPMENT_OK" && worldScripts["shieldequalizercapacitors"].shieldCheckTimer.isRunning)// disables Shield Equaliser (and Capacitors) if fitted to prevent catastrophic Shield Loss.
		{
			worldScripts["shieldequalizercapacitors"].shieldCheckTimer.stop();
			this.stoppedSEC = true;
			player.consoleMessage("All Shield Equalizer functionality disabled pending Primary Shield Generator repair.",4);
		}
	if (equipment === this.foreShieldEQ)
		{	 
			missionVariables.bsg_foreshieldstatus = this.foreShieldEQ;
		}
	if (equipment === this.aftShieldEQ)
		{
			missionVariables.bsg_aftshieldstatus = this.aftShieldEQ;
		}
	this.setupTimerFC();
	}
}

//delayed console messages.
this.consoleMessage1 = function()
{
 if (player.ship.equipmentStatus("EQ_NAVAL_SHIELD_BOOSTER") === "EQUIPMENT_OK")
 {return;}
 player.consoleMessage ("Military Shield Enhancement is damaged!", 2);
}

this.consoleMessage2 = function()
{
 if (player.ship.equipmentStatus("EQ_SHIELD_BOOSTER") === "EQUIPMENT_OK")
 {return;}
 player.consoleMessage ("Shield Booster is damaged!", 2);
}
	
// event handler driven function for actions on launching and exiting witchspace.
this.shipLaunchedFromStation = this.shipExitedWitchspace = function()
{
	if ((player.ship.equipmentStatus(this.foreShieldEQ) === "EQUIPMENT_OK" && missionVariables.bsg_foreshieldstatus !== "OK") || (player.ship.equipmentStatus(this.aftShieldEQ) === "EQUIPMENT_OK" && missionVariables.bsg_aftshieldstatus !== "OK")){this.reset();}
	if (missionVariables.bsg_foreshieldstatus !== "OK" || missionVariables.bsg_aftshieldstatus !== "OK"){this.setupTimerFC();}
}

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

// creates timers if not already in existance otherwise restarts existing timers.
this.setupTimerFC = function()
{
	if (this.updateTimer && this.updateTimer.isRunning){this.updateTimer.stop();delete this.updateTimer;}
	this.updateTimer = new Timer (this,this.updateShield,0,0.25);
	if (this.warningTimer && this.warningTimer.isRunning){this.warningTimer.stop();delete this.warningTimer;}
	this.warningTimer = new Timer(this,this.warningSound,0,10);
}

// called by timer every 0.25 seconds when player is in flight to set damaged shield to 0.
this.updateShield = function()
{	
	if ((player.ship.equipmentStatus(this.foreShieldEQ) === "EQUIPMENT_OK" && missionVariables.bsg_foreshieldstatus !== "OK")||(player.ship.equipmentStatus(this.aftShieldEQ) === "EQUIPMENT_OK" && missionVariables.bsg_aftshieldstatus !== "OK")) // check to see if something has repaired the shields on the fly e.g. Thargoid's Repair Bots OXP.
	{
		this.reset();
		return;
	}
	if (missionVariables.bsg_aftshieldstatus !== "OK")
	{
		player.ship.aftShield = 0;
	}
	if (missionVariables.bsg_foreshieldstatus !== "OK")
	{
		player.ship.forwardShield = 0;
	}
	if (player.ship.equipmentStatus("EQ_SHIELD_EQUALIZER") === "EQUIPMENT_OK" && worldScripts["shieldequalizercapacitors"].shieldCheckTimer.isRunning)
		{
		    worldScripts["shieldequalizercapacitors"].shieldCheckTimer.stop();
			this.stoppedSEC = true;
			player.consoleMessage("All Shield Equaliser functionality disabled pending Primary Shield Generator repair.",4);
		}
	if (player.ship.equipmentStatus("EQ_SC_SHIELD_CYCLER_INTERNAL") === "EQUIPMENT_OK" && !worldScripts["Shield Cycler"].deactivated)
		{
			if (worldScripts["Shield Cycler"].sc_stop())
			{
			 this.stoppedSC = true;
			 player.consoleMessage("All Shield Cycler functionality disabled pending Primary Shield Generator repair.",4);
			}
		}
}

// called by timer every 10 seconds when player in flight to give warning noise whilst a shield is damaged.
this.warningSound = function()
{
	this.warning.play(1);
	if (missionVariables.bsg_foreshieldstatus !== "OK")
	{
		player.consoleMessage("Forward Shield Generator Damaged!", 3);
	}
	if (missionVariables.bsg_aftshieldstatus !== "OK")
	{
		player.consoleMessage("Aft Shield Generator Damaged!", 3);
	}
}

// function to reset the shields once equipment fixed and restart Shield Cycler and Shield Equaliser functionality.
this.reset = function()
{
	if (player.ship.equipmentStatus(this.foreShieldEQ) === "EQUIPMENT_OK" && missionVariables.bsg_foreshieldstatus !== "OK"){missionVariables.bsg_foreshieldstatus = "OK";}
	if (player.ship.equipmentStatus(this.aftShieldEQ) === "EQUIPMENT_OK" && missionVariables.bsg_aftshieldstatus !== "OK"){missionVariables.bsg_aftshieldstatus = "OK";}
	if (missionVariables.bsg_foreshieldstatus === "OK" && missionVariables.bsg_aftshieldstatus === "OK")
	{
		if (this.updateTimer && this.warningTimer.isRunning){this.updateTimer.stop();delete this.updateTimer;}
		if (this.warningTimer && this.warningTimer.isRunning){this.warningTimer.stop();delete this.warningTimer;}
		if (this.stoppedSC && worldScripts["Shield Cycler"].deactivated)
			{
				if (worldScripts["Shield Cycler"].sc_start())
				{
					delete this.stoppedSC;
					if (player.ship.equipmentStatus("EQ_SC_SHIELD_CYCLER_INTERNAL") === "EQUIPMENT_OK")
					{player.consoleMessage("All Shield Cycler functionality re-enabled.",4);}
				}
			}
		if (this.stoppedSEC && worldScripts["shieldequalizercapacitors"].shieldCheckTimer)
			{
				worldScripts["shieldequalizercapacitors"].shieldCheckTimer.start();
				delete this.stoppedSEC;
				if (player.ship.equipmentStatus("EQ_SHIELD_EQUALIZER") === "EQUIPMENT_OK")
				{player.consoleMessage("All Shield Equalizer functionality re-enabled.",4);}
			}
	}
}