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

Expansion AutoDock

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 Gives players without a docking computer the ability to engage an autopilot docking sequence for a small charge. Gives players without a docking computer the ability to engage an autopilot docking sequence for a small charge.
Identifier oolite.oxp.phkb.AutoDock oolite.oxp.phkb.AutoDock
Title AutoDock AutoDock
Category Equipment Equipment
Author phkb phkb
Version 1.1.0 1.1.0
Tags
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/7/79/AutoDock.oxz n/a
License CC BY-NC-SA 4.0 CC BY-NC-SA 4.0
File Size n/a
Upload date 1610873342

Documentation

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

readme.txt

AutoDock Facility
By Nick Rogers

Overview
========
This OXP gives players who don't have a docking computer the ability to dock at Main Stations using remote guidance technology driven from the station itself, for a small charge. This is similar to facilities available in some versions of Elite (ArcElite and Elite Plus being notable examples).

No special equipment needs to be purchased. When the player approaches the main station they can press "C" to begin the automatic docking process, and 10 Cr will be deducted from their account. If the player disengages the autopilot they will be refunded half this cost. If fast docking is available at a station, the player can also press "Shift-C" to fast dock. If, in the future, the player purchases a docking computer, no further auto-docking charges will take place, unless their docking computers are damaged.

This OXP is based on work by CommonSenseOTB who released a version similar to this for Oolite 1.76/77, but new features in 1.82 allow for a much simpler implementation.

Licence
=======
This work is licensed under the Creative Commons Attribution-ShareAlike 4.0 International Public License. To view a copy of this license, visit http://http://creativecommons.org/licenses/by-sa/4.0/ or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.

Version History
===============
Version 1.1.0
- Added configuration items to Library (if installed).

Version 1.0.1
- Fixed small Javascript bug.

Version 1.0.0
- Initial release

Equipment

Name Visible Cost [deci-credits] Tech-Level
The No-Dock-Computer Autodock facility no 50 1+

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/autodock_conditions.js
"use strict";
this.name        = "Autodock_Conditions";
this.author      = "phkb";
this.copyright   = "2015 phkb";
this.description = "Condition script for the Autodock computer";
this.licence     = "CC BY-NC-SA 4.0";

//-------------------------------------------------------------------------------------------------------------
this.allowAwardEquipment = function(equipment, ship, context) {
	if (context != "scripted") return false;
	return true
}
Scripts/autodock_core.js
"use strict";
this.name        = "Autodock_Core";
this.author      = "phkb";
this.copyright   = "2015 phkb";
this.description = "Main routine for handling autodock option";
this.licence     = "CC BY-NC-SA 4.0";

this._payment = 10;				// the cost of an autodock. (should be an even number so the refund price doesn't have decimals)
this._minTechLevel = 0;			// the minimum techlevel required for an autodock (this matches main logic of being 1 less that the actual TL. ie entering 6 here means TL7)
this._mainStationOnly = true;	// flag that indicates whether autodock is provided at the main station only (true), or all stations (false)
this._abort = false;			// used if the player has the autodock, but credit went below payment amount during flight, then tries to autodock
								// docking will be cancelled, and this flag prevents the player from being refunded as no payment would have been made.


// configuration settings for use in Lib_Config
this._adConfig = {Name:this.name, Display:"Settings", Alias:"Autodock", Alive:"_adConfig", 
	Bool:{B0:{Name:"_mainStationOnly", Def:true, Desc:"Autodock at main stns"},Info:"Autodock only available at main stations."},
	SInt:{
		S0:{Name:"_payment", Def:10, Desc:"Payment Amount", Min:1, Max:100},
		S1:{Name:"_minTechLevel", Def:0, Desc:"Minimum tech level", Min:0, Max:14},
		Info:"0 - Cost of autodock, in credits\n1 - Minimum tech level for autodock"}
};
this._trueValues = ["yes", "1", 1, "true", true];

//-------------------------------------------------------------------------------------------------------------
this.startUpComplete = function() {
	// register our settings, if Lib_Config is present
	if (worldScripts.Lib_Config) worldScripts.Lib_Config._registerSet(this._adConfig);
	if (missionVariables.Autodock_Payment) this._payment = parseInt(missionVariables.Autodock_Payment);
	if (missionVariables.Autodock_TechLevel) this._minTechLevel = parseInt(missionVariables.Autodock_TechLevel);
	if (missionVariables.Autodock_MainStation) this._mainStationOnly = (this._trueValues.indexOf(missionVariables.Autodock_MainStation) >= 0 ? true : false);
}

//-------------------------------------------------------------------------------------------------------------
this.playerWillSaveGame = function() {
	missionVariables.Autodock_Payment = this._payment;
	missionVariables.Autodock_TechLevel = this._minTechLevel;
	missionVariables.Autodock_MainStation = this._mainStationOnly;
}

//-------------------------------------------------------------------------------------------------------------
this.shipWillDockWithStation = function(station) {
	// make sure the equipment is removed on docking
	var p = player.ship;
	// check for an fast-dock
	var diff = (global.clock.adjustedSeconds - global.clock.seconds);
	if (diff > 1000 && diff <= 1200) {
		if (p.equipmentStatus("EQ_NDC_AUTODOCK") == "EQUIPMENT_OK") {
			this.$notifyAndDeduct();
		}
	}
	p.removeEquipment("EQ_NDC_AUTODOCK");
}

//-------------------------------------------------------------------------------------------------------------
this.shipWillLaunchFromStation = function(station) {
	// auto install after launching (to cope with scenario where player docks at another station, or the same one even)
	if ((station.isMainStation && this._mainStationOnly == true) || this._mainStationOnly == false) {
		this.$installAutoDock();
	}
}

//-------------------------------------------------------------------------------------------------------------
this.shipEnteredStationAegis = function(station) {
	var p = player.ship;
	if (this._mainStationOnly == true) this.$installAutoDock();
	// if we have less that payment amount when we hit the aegis, remove the autodock item so the player can't fast-dock
	if (player.credits < this._payment && p.equipmentStatus("EQ_NDC_AUTODOCK") == "EQUIPMENT_OK") {
		p.removeEquipment("EQ_NDC_AUTODOCK");
	}
}

//-------------------------------------------------------------------------------------------------------------
this.shipExitedStationAegis = function(station) {
	if (this._mainStationOnly == true) {
		var p = player.ship;
		p.removeEquipment("EQ_NDC_AUTODOCK");
	}
}

//-------------------------------------------------------------------------------------------------------------
this.shipExitedWitchspace = function() {
	var p = player.ship;
	// remove the equipment, then attempt to reinstall it
	// this allows for the new system not having a high enough tech level
	p.removeEquipment("EQ_NDC_AUTODOCK");
	// only instal the autodock at this point if the mainstationonly flag is set to false (meaning all stations)
	if (this._mainStationOnly == false) this.$installAutoDock();
}

//-------------------------------------------------------------------------------------------------------------
this.playerStartedAutoPilot = function() {
	var p = player.ship;
	if (p.equipmentStatus("EQ_NDC_AUTODOCK") === "EQUIPMENT_OK"){
		if (player.credits >= this._payment) {
			this.$notifyAndDeduct();
		} else {
			// in the off chance the player has dropped below payment amount between installing the autodock and arriving in a new system
			// (eg bribing ships via the Broadcast comms MFD)
			this._abort = true;
			p.disengageAutopilot();
			player.consoleMessage("Insufficient credit available for autodock. Manual docking required.");
			p.removeEquipment("EQ_NDC_AUTODOCK");

		}
	}
}

//-------------------------------------------------------------------------------------------------------------
this.playerCancelledAutoPilot = function() {
	var p = player.ship;
	if (p.equipmentStatus("EQ_NDC_AUTODOCK") == "EQUIPMENT_OK" && this._abort == false) {
		// notify player
		player.consoleMessage("Control returned to pilot...depositing partial refund of " + formatCredits(this._payment / 2, false, true) + " to your account.", 5);
		// refund player
		player.credits += (this._payment / 2);
		// make sure the player still has enough cash for an autodock, and remove it if they don't
		if (player.credits < this._payment) p.removeEquipment("EQ_NDC_AUTODOCK");
	}
	this._abort = false;
}

//-------------------------------------------------------------------------------------------------------------
this.equipmentDamaged = function(equipment) {
	// if the dock computer gets damaged, add the autodock equipment
	if (equipment == "EQ_DOCK_COMP") {
		// if we're only doing this at main stations, check if we're within the aegis when the docking computer was damaged
		if (this._mainStationOnly == true && player.ship.withinStationAegis == false) {
			// if not, return at this point, as the autodocker will be installed when we hit the aegis
			return;
		}
		this.$installAutoDock();
	}
}

//-------------------------------------------------------------------------------------------------------------
this.equipmentRepaired = function(equipment){
	// check for equipment being repaired in flight
	if (equipment == "EQ_DOCK_COMP") {
		var p = player.ship;
		// if the dock computer gets repaired in flight, remove the autodock
		if (p.status == "STATUS_IN_FLIGHT") p.removeEquipment("EQ_NDC_AUTODOCK");
	}
}

//-------------------------------------------------------------------------------------------------------------
this.$installAutoDock = function() {
	var p = player.ship;
	// give the player the autodock equipment if the tech level is greater than/equal to min tech level and the player doesn't have a working dock comp and has more than required credit
	if (system.info.techlevel >= this._minTechLevel && player.credits >= this._payment) {
		if (p.equipmentStatus("EQ_DOCK_COMP") != "EQUIPMENT_OK") {
			p.awardEquipment("EQ_NDC_AUTODOCK");
		}
	}
}

//-------------------------------------------------------------------------------------------------------------
this.$notifyAndDeduct = function() {
	player.consoleMessage("Transferring flight control to station for docking procedure...deducting " + formatCredits(this._payment, false, true) + " from your account.", 5);
	player.credits -= this._payment;
}