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

Expansion Single-Use Witchdrive

Content

Warnings

  1. Information URL mismatch between OXP Manifest and Expansion Manager string length at character position 0

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description Adds the option to buy a Single-Use Witchdrive for ships without a Witchdrive, that will break after one use. The drive is repairable, weights 2 tons and a second set of coils (weighting another ton) can be added, to allow a second use before repairs become necessary. Adds the option to buy a Single-Use Witchdrive for ships without a Witchdrive, that will break after one use. The drive is repairable, weights 2 tons and a second set of coils (weighting another ton) can be added, to allow a second use before repairs become necessary.
Identifier oolite.oxp.ocz.SUWitchdrive oolite.oxp.ocz.SUWitchdrive
Title Single-Use Witchdrive Single-Use Witchdrive
Category Equipment Equipment
Author ocz ocz
Version 0.9.2 0.9.2
Tags Equipment, Witchdrive, SUWitchdrive, SU-Witchdrive Equipment, Witchdrive, SUWitchdrive, SU-Witchdrive
Required Oolite Version
Maximum Oolite Version
Required Expansions
Optional Expansions
Conflict Expansions
Information URL n/a
Download URL https://wiki.alioth.net/img_auth.php/c/c5/Singel-Use_Witchdrive-0.9.2.oxz n/a
License CC BY-NC-SA 4.0 CC BY-NC-SA 4.0
File Size n/a
Upload date 1610873465

Documentation

Also read http://wiki.alioth.net/index.php/Single-Use%20Witchdrive

readme.txt

Single-Use Witchdrive
By ocz

About:
This OXP add the option to buy a Single-use Witchdrive for ships without a Witchdrive. It can only be fitted into ships without a standard Witchdrive and will break after one use. The drive is repairable, weights 2 tons and a second set of coils (weighting another ton) can be added, to allow a second use before repairs become necessary. 

Installation:
Put the *.oxz file into the AddOns folder of your Oolite directory.

Licence:
This work is licensed under CC BY-NC-SA 4.0
To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/ or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA. 

Sidenote:
If it breaks and isn't repaired by me within quite some time, feel free the recreate a repaired version. (Please check beforehand, if somebody else already did this and his/her version isn't working at this point either. Give them credit too, when due!)

Version History:

version 0.9.2 11/27/2015
- Hardening (Bugfix kinda): Replaced "player.ship.hasHyperspaceMotor" condition with Ship.shipDataForKey(player.ship.dataKey)["hyperspace_motor"] to prevent some of the possible tinkering with the drive ingame by other OXPs.

Version 0.9.1 11/20/2015
- Bugfix: All ships could buy a SU-Witchdrive. This has been corrected. Only ships, that don't have got a standard Witchdrive are allowed to buy the SU-Witchdrive now.

Version 0.9.0 11/18/2015
- Initial beta release

Equipment

Name Visible Cost [deci-credits] Tech-Level
Singel-Use Witchdrive yes 4000 4+
Remove Single-Use Witchdrive and Spare Coils yes 1500 1+
Singel-Use Witchdrive yes 4000 10+
Single-Use Witchdrive Spare Coils yes 2000 3+
Remove Single-Use Witchdrive Spare Coils yes 500 1+
Remove Single-Use Witchdrive yes 1000 1+
Repair: Singel-Use Witchdrive yes 2000 3+

Ships

This expansion declares no ships. This may be related to warnings.

Models

This expansion declares no models. This may be related to warnings.

Scripts

Path
Scripts/SUWitchdriveConditions.js
"use strict";
this.name			= "Single-Use Witchdrive Conditions Script";
this.author			= "ocz";
this.copyright		= "2015 ocz";
this.licence		= "CC BY-NC-SA 4.0";

var versionLowerThan183 = function(_version) {
	if ((_version[0] < 1) || (_version[0] == 1 && _version[1] < 83)) {
		return true;
	}
	return false;
}

this.allowAwardEquipment = function(eqKey, ship, context) {
	if (context === "purchase" && eqKey === "EQ_SUWITCHDRIVE") {
		if (player.ship.equipmentStatus("EQ_SUWITCHDRIVE") === "EQUIPMENT_DAMAGED" && !versionLowerThan183(oolite.version)) {return true;}
		return false;
	}
	if (context === "purchase" && eqKey === "EQ_SUWITCHDRIVE_REP") {  // An Oolite pre v1.83 fix to offer a repair option, even when no additional 2t free cargo space, which is needed before v1.83, is available.
		if (player.ship.equipmentStatus("EQ_SUWITCHDRIVE") === "EQUIPMENT_DAMAGED" && versionLowerThan183(oolite.version)) {
			return true;
		}
		return false;
	}
	if (context === "purchase" && eqKey === "EQ_SUWITCHDRIVEBUY" &&  !(Ship.shipDataForKey(player.ship.dataKey)["hyperspace_motor"] === "no") ) {
		return false;
	}
	return true; // In any other case, it's fine. (All other stuff is available, too.)
}
Scripts/SUWitchdriveScripts.js
"use strict";
this.name			= "Single-Use Witchdrive Script";
this.author			= "ocz";
this.copyright		= "2015 ocz";
this.licence		= "CC BY-NC-SA 4.0";

this.playerBoughtEquipment = function(equipment) {
	if (equipment == "EQ_SUWITCHDRIVEBUY") {
		player.ship.removeEquipment("EQ_SUWITCHDRIVEBUY");
		player.ship.awardEquipment("EQ_SUWITCHDRIVE");
		player.ship.hyperspaceSpinTime = 15;		//This line gives both the ship the ability to make Witchjumps and sets the countdown length to 15s.
		return;
	}
	if (equipment == "EQ_SUWITCHDRIVE_REP") {
		player.ship.removeEquipment("EQ_SUWITCHDRIVE_REP");
		player.ship.setEquipmentStatus("EQ_SUWITCHDRIVE", "EQUIPMENT_OK");
		player.ship.hyperspaceSpinTime = 15;
		return;
	}
	if (equipment == "EQ_SUWITCHDRIVE_REMOVE") {
		player.ship.removeEquipment("EQ_SUWITCHDRIVE_REMOVE");
		if (player.ship.equipmentStatus("EQ_SUWITCHDRIVE") === "EQUIPMENT_DAMAGED") {
			player.credits += 200; // If damaged, refund only half the price.
		}
		else player.credits += 400; // Refund the price.
		player.ship.hyperspaceSpinTime = -1; // Take away the Witchdrive for good. SU-Witchdrive shouldn't be available for ships with standard Witchdrive anyway.
		player.ship.removeEquipment("EQ_SUWITCHDRIVE");
		return;
	}
	if (equipment == "EQ_SUWITCHDRIVEANDSPARECOILS_REMOVE") {
		player.ship.removeEquipment("EQ_SUWITCHDRIVEANDSPARECOILS_REMOVE");
		player.ship.removeEquipment("EQ_SUWITCHDRIVESPARECOILS");
		if (player.ship.equipmentStatus("EQ_SUWITCHDRIVE") === "EQUIPMENT_DAMAGED") {
			player.credits += 400;
		}
		else player.credits += 600;
		player.ship.hyperspaceSpinTime = -1;
		player.ship.removeEquipment("EQ_SUWITCHDRIVE");
		return;
	}
	if (equipment == "EQ_SUWITCHDRIVESPARECOILS_REMOVE") {
		player.ship.removeEquipment("EQ_SUWITCHDRIVESPARECOILS_REMOVE");
		player.ship.removeEquipment("EQ_SUWITCHDRIVESPARECOILS");
		player.credits += 200;
	}
}

this.shipWillEnterWitchspace = function(cause, destination) {
	if (player.ship.equipmentStatus("EQ_SUWITCHDRIVE") === "EQUIPMENT_OK" && cause === "standard jump") {
		if (player.ship.equipmentStatus("EQ_SUWITCHDRIVESPARECOILS") === "EQUIPMENT_OK") {
			player.ship.removeEquipment("EQ_SUWITCHDRIVESPARECOILS"); //The spare coils get ejected after use. 
		}
		else player.ship.setEquipmentStatus("EQ_SUWITCHDRIVE", "EQUIPMENT_DAMAGED");
	}
}

this.equipmentDamaged = function(equipment) {
    if (equipment === "EQ_SUWITCHDRIVE") {
		player.ship.hyperspaceSpinTime = -1;	//If the Single-Use Witchdrive gets damaged in a fight or by using it without spare coils, the ship loses its witchjump ability.
		player.ship.cancelHyperspaceCountdown(); //Just in case the player was about to jump out of a fight for example.
	}
	else if (equipment === "EQ_SUWITCHDRIVESPARECOILS") {
		player.ship.removeEquipment("EQ_SUWITCHDRIVESPARECOILS"); //If the spare coils get somehow damaged they get ejected.
	}
}

this.equipmentRepaired = function(equipment) {
    if (equipment === "EQ_SUWITCHDRIVE") {
		player.ship.hyperspaceSpinTime = 15;	//If the Single-Use Witchdrive gets repaired, the ship regains its witchjump ability.
	}
}

this.startUpComplete = function() {
	if (player.ship.equipmentStatus("EQ_SUWITCHDRIVE") === "EQUIPMENT_OK") {
		player.ship.hyperspaceSpinTime = 15;
	}	
}