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

Expansion Breakable Torus Drive

Content

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description This OXP make the Torus or Jump Drive into an equipment item that can be damaged in combat. This OXP make the Torus or Jump Drive into an equipment item that can be damaged in combat.
Identifier oolite.oxp.CaptMurphy.BreakableTorusDrive oolite.oxp.CaptMurphy.BreakableTorusDrive
Title Breakable Torus Drive Breakable Torus Drive
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/4/4e/Oolite.oxp.CaptMurphy.BreakableTorusDrive.oxz n/a
License CC BY-NC-SA 3.0 CC BY-NC-SA 3.0
File Size n/a
Upload date 1631494626

Documentation

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

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 Torus Drive v 1.1 (05/05/11)\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 Torus or Jump Drive into an equipment item that can be damaged in combat. If damaged players can still attempt to use the drive but will be plagued with random drive malfunction manifesting as mystery mass locking events until it is repaired.  Repairs can be conducted at a station of any tech level and given the ubiquitous nature of this technology are relatively cheap at 125 credits. 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 a new equipment item, the \ldblquote Torus Drive\rdblquote  which is listed on the equipment manifest and can be damaged in combat. It is automatically fitted to the current ship on first run, and it is also automatically fitted when the player purchases a new ship. \par
\par
Version 1  \tab 10/7/11 \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
Torus Jump Drive yes 2500 1+

Ships

Name
Malfunction...Malfunction

Models

This expansion declares no models.

Scripts

Path
Scripts/Breakable_TorusDrive.js
this.name        = "Breakable_TorusDrive"; 
this.author      = "capt murphy"; 
this.copyright   = "2011 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 Torus Drive."; 
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()
{
	if (!missionVariables.btd_status)
	{
		missionVariables.btd_status = "OK";
	}
	this.btd_status = missionVariables.btd_status;
	if (player.ship.equipmentStatus("EQ_BREAKABLE_TORUSDRIVE") != "EQUIPMENT_OK" && this.btd_status == "OK")
	{
		player.ship.awardEquipment("EQ_BREAKABLE_TORUSDRIVE");	
	}
		
}

// event handler driven function to fit equipment to newly purchased ship.
this.playerBoughtNewShip = function()
{
		player.ship.awardEquipment("EQ_BREAKABLE_TORUSDRIVE");
		this.btd_status = "OK";
}

// event handler driven function to control actions if equipment damaged in combat.
this.equipmentDamaged = this.equipmentDestroyed = function(equipment)
{
	if (this.shipRestore && equipment === "EQ_BREAKABLE_TORUSDRIVE") {this.btd_status = "DAMAGED"; return;}
	if (equipment == "EQ_BREAKABLE_TORUSDRIVE")
	{
		this.btd_status = "DAMAGED";
		player.consoleMessage("Torus Drive Damaged!",3);
		this.btd_setupTimer();
	}
}

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


// event handler driven function for actions on launching.
this.shipLaunchedFromStation = this.shipExitedWitchspace = function()
{
	if (player.ship.equipmentStatus("EQ_BREAKABLE_TORUSDRIVE") == "EQUIPMENT_OK" && this.btd_status != "OK")
	{
		this.btd_status = "OK";
		this.btd_stopTimer();
		return;
	}
	if (this.btd_status != "OK")
	{
		this.btd_setupTimer();
	}
}
// creates timers if not already in existance otherwise restarts existing timers.
this.btd_setupTimer = function()
{
	if (!this.btd_updateTimer)
		{
			this.btd_updateTimer = new Timer(this, this.btd_speedcheck, 0, 3);
		}
		else
		{
			this.btd_updateTimer.start();
		}
}

// called by timer every 3 seconds.
this.btd_speedcheck = function()
{	
	if (player.ship.equipmentStatus("EQ_BREAKABLE_TORUSDRIVE") == "EQUIPMENT_OK" && this.btd_status != "OK") // check to see if something has repaired the witch drive on the fly e.g. Thargoid's Repair Bots OXP.
	{
		this.btd_status = "OK";
		this.btd_stopTimer();
		return;
	}
	if (player.ship.speed > (player.ship.maxSpeed * 10) && Math.random () < 0.5)
	{
		system.addShips("btd_dummy_entity", 1, player.ship.position);
		var delay = (Math.random()*10)+5;
		this.btd_removedummyTimer = new Timer(this,this.btd_removedummy,delay);
		player.consoleMessage("Torus Drive Malfunction - Repairs needed!",4);
	}
}
// called by timer to remove dummy masslocking entity after random delay.
this.btd_removedummy = function ()
{
		function btd_finddummy(entity)
	{
		return (entity.primaryRole == "btd_dummy_entity");
	}
	var targets = system.filteredEntities(this, btd_finddummy);
	if (targets.length > 0)
	{
		let counter = 0;
		for (counter = 0; counter < targets.length;counter++)
			{
				targets[counter].remove(true);
			}
	}
}
 
// event handler driven function to stop Timers on player's death or on docking.
this.shipDied = this.shipWillDockWithStation = this.btd_stopTimer = function()
{
	if (this.btd_updateTimer && this.btd_updateTimer.isRunning)
		{
			this.btd_updateTimer.stop();
			delete this.btd_updateTimer;
		}
}
Scripts/btd_dummy_entity.js
this.name        = "btd_dummy_entity"; 
this.author      = "capt murphy"; 
this.copyright   = "2011 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 = "Breakable Torus Drive Dummy Entity Shipscript"; 
this.version     = "1.0";

this.shipSpawned = function()
{
	 this.ship.bounty = 0;
     this.ship.scannerDisplayColor1 = "clearColor";
	 this.ship.scannerDisplayColor2 = "clearColor";
	 this.btd_dummyentitycontrolTimer = new Timer (this, this.btd_dummyentitycontrol,0,1);
}

this.btd_dummyentitycontrol = function()
{
	this.ship.position = player.ship.position.add(player.ship.vectorUp.multiply(300));
}

this.playerWillEnterWitchspace = this.shipRemoved = this.entityDestroyed = function()
{
  if (this.btd_dummyentitycontrolTimer && this.btd_dummyentitycontrolTimer.isRunning)
  {
	this.btd_dummyentitycontrolTimer.stop();
	delete this.btd_dummyentitycontrolTimer;
  }
}