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

Expansion IronHide

Content

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description Enhanced armour for the ship's hull to better protect against combat damage and general bumps and knocks. Enhanced armour for the ship's hull to better protect against combat damage and general bumps and knocks.
Identifier oolite.oxp.Thargoid.IronHide oolite.oxp.Thargoid.IronHide
Title IronHide IronHide
Category Equipment Equipment
Author Thargoid, Milo Thargoid, Milo
Version 3.06 3.06
Tags equipment equipment
Required Oolite Version
Maximum Oolite Version
Required Expansions
Optional Expansions
Conflict Expansions
Information URL http://wiki.alioth.net/index.php/IronHide_OXP n/a
Download URL https://wiki.alioth.net/img_auth.php/a/a0/Oolite.oxp.Thargoid.IronHide.3.06.oxz n/a
License Creative Commons Attribution - Non-Commercial - Share Alike 3.0 license with clauses - see readme file Creative Commons Attribution - Non-Commercial - Share Alike 3.0 license with clauses - see readme file
File Size n/a
Upload date 1610873396

Documentation

Also read http://wiki.alioth.net/index.php/IronHide

IronHide ReadMe & License.txt

IronHide OXP by Thargoid, now maintained by Milo.

The Ships Systems Department of the Aquarian Shipbuilding Corporation introduce their latest development - IronHide armour. This is a simple but effective technology which applies a special treatment to the hull of the customer ship which helps to strengthen it against combat and physical damage in collaboration with the ship's shielding.

In practice the armour helps to absorb damage that gets passed (or takes down) the shields, although if a truly concentrated attack occurs then localised penetration and energy damage may still occur. This is especially true of missile attacks, which can still cause internal damage and equipment failure due to concussion effects. The current strength of the armour can be viewed on the ship's manifest (F5-F5) screen, and any damage can be repaired at a suitably high-tech station.

The armour itself is available from all good tech 5 locations, for a recommended retail price of just 750 credits. These stations should also be able to quote for repairs to damaged installations. It should also be noted that insurers class armour as a combat consumable, and so its replacement is not included as part of the insurance for equipment such as escape pods and lifeboats.

A special enhanced upgrade for military uses has also been developed, and may be available to customers at tech 10 systems (the upgrade requires an undamaged civilian-grade installation). The upgrade doubles the effectiveness of the regular armour.

Requires v1.82 or later of Oolite. It will not run on older versions.

--------------------------------------------------------------

License:

This OXP is released under the Creative Commons Attribution - Non-Commercial - Share Alike 3.0 license with the following clauses:

* Whilst you are free (and encouraged) to re-use any of the scripting, models or texturing in this OXP, the usage must be distinct from that within this OXP. Unique identifiers such as (but not limited to) unique shipdata.plist entity keys, mission variables, script names (this.name), equipment identity strings (EQ_), description list arrays and entity roles must not be re-used without prior agreement. Basically if it's unique or would identify or overwrite anything in the original OXP, then you may not re-use it (for obvious compatibility reasons).
* rebundling of this OXP within another distribution is permitted as long as it is unchanged. The following derivates however are permitted and except from the above:
	* the conversion of files between XML and openStep.
	* the merging of files with other files of the same type from other OXPs.
* The license information (either as this file or merged into a larger one) must be included in the OXP.
* Even though it is not compulsory, if you are re-using any sizable or recognisable piece of this OXP, please let me know :)

--------------------------------------------------------------

Instructions:

Look for IronHide in the Equipment category of the in-game expansions manager, or download the OXZ file manually and put it in your AddOns folder.

--------------------------------------------------------------

Version history:

31/07/2010 - Version 1.00, initial release.

01/08/2010 - Version 1.01, changed shield strength from this. to mission variables to maintain across save games.

19/02/2011 - Version 2.00, upgrade for 1.75 trunk - and operating properly now after shields are gone!

19/06/2020 - Version 3.00, updated by Milo; IronHide OXP now requires Oolite 1.79+; armour durability increased but energy restoration is now proportional to damage absorbed (previously the ship's energy was fully restored after every hit, which could conflict with other OXPs' attempts to regulate energy levels); damage below 5 (10 for military grade) will not degrade IronHide armour; further improved compatibility with other OXPs by checking damage type instead of energy level to decide which damage the armour can absorb.

20/06/2020 - Version 3.01, updated by Milo; IronHide OXP now requires Oolite 1.82+; introduced a new script_info property in equipment.plist (ironHide_percentArmourLostPerDamagePointTaken), which functionally replaces the ironHide_strength mission variable (now unused by IronHide, but kept and returned to its pre-3.00 values because CombatMFD uses it for its SEE indicator); eliminated the "damage below X will not degrade armour" threshold (any damage that gets through shields now will consume armour); set damage_probability to zero so IronHide cannot be made "inoperable" (appear broken on the F5 screen) before it is fully consumed; introduced price variance for installation and repairs proportional to ship surface area (cobra3-player is the baseline); added installation_time of 12 hours for both civilian and military grades and a proportional time advance when repairing (repairing X percent is 25% faster than installing X percent, a small incentive to repair before the armour is destroyed; note that if military grade armour is fully consumed, you must first reinstall civilian grade [12 hrs] and then upgrade to military grade [12 hrs], so it saves even more time if you repair military grade before it breaks; also, while not a change from previous versions, military grade armour costs less to repair than it costs to install).

21/06/2020 - Version 3.02, updated by Milo; doubled price variance for larger ships and applied proportional adjustment to repair costs (they were still using the baseline price); improved compatibility with ShipVersion OXP by not offering IronHide for purchase on ships that ShipVersion does not allow to use it (when ShipVersion OXP is detected, civilian IronHide is only for ships with mass 30t or higher and military IronHide is only for ships with mass 130t or higher).

21/06/2020 - Version 3.04, updated by Milo; improved handling of invalid ironHide_milFlag missionVariable (not zero or one) from old saved game; modified allowAwardEquipment handler to allow other OXPs to add IronHide to player ships (e.g., Ship Storage Helper).

21/06/2020 - Version 3.05, updated by Milo; re-assess damage-to-armour multiplier each time the ship launches, in case another OXP replaced the player ship, awarded IronHide, or changed the grade of the armour.

21/06/2020 - Version 3.06, updated by Milo; if armour percentage is above zero but EQ_IRONHIDE is missing at startUp or at launch, set percentage to zero (in case another OXP removed IronHide without changing percentage); allow other OXPs to awardEquipment("EQ_IRONHIDE") to NPC ships (e.g., Ship Storage Helper using it as a placeholder for player->npc->player transitions), but IronHide does nothing for NPC ships, so outside of scripted additions, do not allow NPC ships to spawn with IronHide armour, and do not allow awardEquipment("EQ_IRONHIDE_MIL" or "EQ_IRONHIDE_REPAIRS") on NPCs because those are used only as script triggers from the F3 purchase screen.

--------------------------------------------------------------

Acknowledgements:

With thanks to ClymAngus for a discussion long ago over a pint about the possibilities of armour for ships.

And to Ahruman for implementing the damage event allowing this OXP to be written as it should be, rather than as surrogate shields :)

Equipment

Name Visible Cost [deci-credits] Tech-Level
IronHide Armour yes 7500 5+
IronHide Armour Military Upgrade yes 7500 10+
Quotation for repair of IronHide armour yes 0 5+

Ships

This expansion declares no ships.

Models

This expansion declares no models.

Scripts

Path
Scripts/thargoid-ironhide.js
"use strict";
this.name			= "IronHide Armour Script";
this.author			= "Thargoid";
this.copyright		= "Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description	= "Script for IronHide armour, for player ship only";
this.version		= "3.06";

this.startUp = function()
{
	if(!missionVariables.ironHide_percentage)
		missionVariables.ironHide_percentage = 0; // float from 0 to 100 representing percentage of armour remaining
	else if (player.ship.equipmentStatus("EQ_IRONHIDE") !== "EQUIPMENT_OK")
		missionVariables.ironHide_percentage = 0; // 3.06: resolve inconsistency caused by other OXPs removing IronHide without setting percentage to zero

	missionVariables.ironHide_milFlag = missionVariables.ironHide_milFlag ? 1 : 0; // boolean 0 or 1 representing whether the armour is military-grade

	// strength represents total damage the armour can absorb (does not regenerate unless repaired), and is configurable in equipment.plist, so always reload it
	missionVariables.ironHide_strength = parseInt(EquipmentInfo.infoForKey(missionVariables.ironHide_milFlag ? "EQ_IRONHIDE_MIL" : "EQ_IRONHIDE").scriptInfo.ironHideStrength);
	// as of IronHide 3.01, ironHide_strength is no longer used, so it is only here for compatibility with other OXPs that look at the value

	// below is how much to charge per percentage of armour to be repaired, proportional to the price of a new set of civilian grade armour
	this.ironHideFactor = this.updateEquipmentPrice("EQ_IRONHIDE", parseInt(EquipmentInfo.infoForKey("EQ_IRONHIDE").price)) / 1000;
}

this.updateEquipmentPrice = function(equipmentKey, currentPrice)
{
	if (equipmentKey === "EQ_IRONHIDE" || equipmentKey === "EQ_IRONHIDE_MIL")
	{
		// calculate price proportional to ship surface area
		var adjust = player.ship.boundingBox.magnitude() / 157.30239913964633; // baseline is from a stock cobra3-player
		return (adjust > 1) ? Math.ceil(adjust * 2 * currentPrice) : currentPrice; // only adjust price upwards, don't discount for smaller ships
	}
	return currentPrice;
}

this.shipDockedWithStation = function(station)
{
	// below is how much to charge per percentage of armour to be repaired; necessary to recalculate after startUp because player may have changed ships
	this.ironHideFactor = this.updateEquipmentPrice("EQ_IRONHIDE", parseInt(EquipmentInfo.infoForKey("EQ_IRONHIDE").price)) / 1000;
}

// this.equipmentDamaged = function(equipment) // unnecessary since 3.01 because damage_probability is set to zero in equipment.plist
// {
	// if(equipment === "EQ_IRONHIDE")
	// {
		// player.ship.setEquipmentStatus("EQ_IRONHIDE","EQUIPMENT_OK"); // as it doesn't make sense for the armour to be inoperable-damaged
	// }
// }

this.shipLaunchedFromStation = function() // 3.05: moved from startUp to every launch in case another OXP used replaceShip and awardEquipment("EQ_IRONHIDE") and set milFlag to a different value
{
	// below is the multiplier for damage taken to determine how much armour percentage is lost (e.g., if dmgMult is 0.2 and 10 damage is taken, ironHide_percentage drops by 10 * 0.2 = 2)
	this.ironHideDamageMult = parseFloat(EquipmentInfo.infoForKey(missionVariables.ironHide_milFlag ? "EQ_IRONHIDE_MIL" : "EQ_IRONHIDE").scriptInfo.ironHide_percentArmourLostPerDamagePointTaken);
	
	if (missionVariables.ironHide_percentage > 0 && player.ship.equipmentStatus("EQ_IRONHIDE") !== "EQUIPMENT_OK")
		missionVariables.ironHide_percentage = 0; // 3.06: resolve inconsistency caused by other OXPs removing IronHide without setting percentage to zero
}

this.shipTakingDamage = function(amount, fromEntity, damageType)
{
	if(amount < 1) return; // all damage was absorbed by shields

	var ps = player.ship, percLeft = missionVariables.ironHide_percentage, dmgMult = this.ironHideDamageMult; // cache for performance
	if(percLeft > 0 && damageType === "energy damage") // have armour, check damageType instead of energy level to improve compatibility with other OXPs
	{
		if(percLeft > amount * dmgMult) // armour is sufficient to absorb all the damage
		{
			ps.energy += amount; // formula change: restore the amount absorbed by armour instead of ps.energy = ps.maxEnergy
			missionVariables.ironHide_percentage = percLeft - amount * dmgMult;
		}
		else // damage fully consumes remaining armour
		{
			ps.energy += percLeft / dmgMult; // whatever armour was left absorbed as much as it could
			player.consoleMessage("IronHide armour has been destroyed!", 8);
			ps.removeEquipment("EQ_IRONHIDE");
			missionVariables.ironHide_percentage = 0;
			missionVariables.ironHide_milFlag = 0;
			mission.setInstructionsKey(null);
		}
	}
}

this.guiScreenWillChange = function(newScreen, oldScreen)
{
	if(newScreen === "GUI_SCREEN_MANIFEST")
	{
		//if (equipmentStatus("EQ_IRONHIDE") === "EQUIPMENT_OK")
		if(missionVariables.ironHide_percentage > 0) // 3.06 replaced condition above to ensure armour visibility even if EQ_IRONHIDE is missing (e.g., removed by other OXPs without adjusting missionVariables)
			mission.setInstructions([expandMissionText(missionVariables.ironHide_milFlag ? "ironHideMil_short" : "ironHideCiv_short")]);
		else
			mission.setInstructionsKey(null);
	}
}

this.allowAwardEquipment = function(eqKey, ship, context)
{
	// if (context === "newShip" || context === "purchase") // equipment pre-installed on a ship in a station shipyard (F3 F3), or equipment for purchase on the F3 screen
	if (ship === player.ship) // 3.04: replaced conditions above, to allow scripted awardEquipment but still restrict to player-only (e.g., by Ship Storage Helper)
	{
		if (eqKey === "EQ_IRONHIDE") {
			if (player.ship.mass < 30000 && worldScripts["shipversion"]) return false; // ShipVersion OXP does not allow IronHide for ships with mass below 30t
			if (missionVariables.ironHide_percentage > 0) return false; // have armour, but missing equipment (can be caused by other OXPs removing equipment or changing IronHide mission variables)
			return true; // no restrictions on civilian grade armour
		} else if (eqKey === "EQ_IRONHIDE_MIL" && missionVariables.ironHide_percentage === 100 && missionVariables.ironHide_milFlag === 0) {
			if (player.ship.mass < 130000 && worldScripts["shipversion"]) return false; // ShipVersion OXP does not allow military IronHide for ships with mass below 130t
			return true; // only if your civilian armour is fully repaired and you don't already have military grade armour
		} else if (eqKey === "EQ_IRONHIDE_REPAIR" && missionVariables.ironHide_percentage < 100) {
			return true; // only if your armour is damaged
		}
	} else if (context === "scripted" && eqKey === "EQ_IRONHIDE") { // equipment added to NPC ships by scripts from other OXPs
		return true; // allow this for NPC ships assuming that another OXP has a good reason to do this (e.g., Ship Storage Helper using it as a placeholder for player->npc->player transitions)
	}
	// default is no in all other cases (IronHide does nothing for NPC ships, so don't allow the game to spawn NPCs with IronHide, and don't allow awarding the military or repair equipment to non-player ships because they are placeholders for triggering playerBoughtEquipment and are removed immediately after)
	return false;
}

this.playerBoughtEquipment = function(equipment)
{
	switch(equipment)
	{
		case("EQ_IRONHIDE"): // always available
			missionVariables.ironHide_milFlag = 0;
			missionVariables.ironHide_percentage = 100;
			this.dmgMult = parseFloat(EquipmentInfo.infoForKey(equipment).scriptInfo.ironHide_percentArmourLostPerDamagePointTaken);
			break;

		case("EQ_IRONHIDE_MIL"): // only available when armour is fully repaired (therefore ironHide_percentage is already 100 and does not need to be set here)
			missionVariables.ironHide_milFlag = 1;
			this.dmgMult = parseFloat(EquipmentInfo.infoForKey(equipment).scriptInfo.ironHide_percentArmourLostPerDamagePointTaken);
			player.ship.removeEquipment("EQ_IRONHIDE_MIL"); // only used as a placeholder for purchase
			break;

		case("EQ_IRONHIDE_REPAIR"): // only available when armour is damaged
			missionVariables.ironHide_cost = (100 - missionVariables.ironHide_percentage) * this.ironHideFactor;
			if(missionVariables.ironHide_mil === 1)
				missionVariables.ironHide_cost *= 1.5; // cheaper to repair than buying armour new (price * 2 vs. price * 1.5)
			player.ship.removeEquipment("EQ_IRONHIDE_REPAIR");
			if(player.credits < missionVariables.ironHide_cost)
				mission.runScreen({title: "Too Expensive", messageKey:"ironHide_tooExpensive"});
			else
				mission.runScreen({title: "Armour Repair", messageKey:"ironHide_repair", choicesKey:"ironHide_choices"}, this.choice);
			break;

		case("EQ_RENOVATION"):
			if(missionVariables.ironHide_percentage === 100 || player.ship.equipmentStatus("EQ_IRONHIDE") === "EQUIPMENT_UNAVAILABLE")
				break; // don't have armour or it's full-strength, so no repair needed during renovations
			else if(player.ship.equipmentStatus("EQ_IRONHIDE") === "EQUIPMENT_OK")
			{
				missionVariables.ironHide_cost = (100 - missionVariables.ironHide_percentage) * this.ironHideFactor;
				if(missionVariables.ironHide_milFlag === 1)
					missionVariables.ironHide_cost *= 1.5; // cheaper to repair than buying armour new (price * 2 vs. price * 1.5)
				if(missionVariables.ironHide_cost > 0 && missionVariables.ironHide_cost < player.credits)
					mission.runScreen({title: "Armour Repair", messageKey:"ironHide_renovationRepair", choicesKey:"ironHide_renovationChoices"}, this.choice);
			}
			break;
	}
}

this.choice = function(choice)
{
	switch(choice)
	{
		case "IRONHIDE_1_ACCEPT":
			// repair time is proportional to installation time of 12 hours but 25% faster (0.75 * 12 * 60 * 60 = 32400 seconds)
			clock.addSeconds(32400 * (100 - missionVariables.ironHide_percentage) / 100);
			player.credits -= missionVariables.ironHide_cost;
			missionVariables.ironHide_percentage = 100;
			break;
		case "IRONHIDE_1_RENOVATION_ACCEPT":
			// repair time is included in renovation time (convenient) even though cost is not
			player.credits -= missionVariables.ironHide_cost;
			missionVariables.ironHide_percentage = 100;
			break;
		case "IRONHIDE_2_REJECT":
			break;
	}
}

this.playerBoughtNewShip = this.shipLaunchedEscapePod = function()
{ // reset everything for a new ship, as armour isn't transferable or covered by insurance
	player.ship.removeEquipment("EQ_IRONHIDE");
	missionVariables.ironHide_percentage = 0;
	missionVariables.ironHide_milFlag = 0;
	mission.setInstructionsKey(null);
}