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

Expansion Docking Fees

Content

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description Adds a small docking fee and docking messages to all GalCop stations based on system tech level. Many OXP stations are also given unique fees or docking messages. Adds a small docking fee and docking messages to all GalCop stations based on system tech level. Many OXP stations are also given unique fees or docking messages.
Identifier oolite.oxp.Layne.DockingFees oolite.oxp.Layne.DockingFees
Title Docking Fees Docking Fees
Category Ambience Ambience
Author Layne & Eris Layne & Eris
Version 2.2 2.2
Tags
Required Oolite Version
Maximum Oolite Version
Required Expansions
Optional Expansions
Conflict Expansions
Information URL https://wiki.alioth.net/index.php/Docking_Fees n/a
Download URL https://wiki.alioth.net/img_auth.php/5/59/DockingFees_2.2.oxz n/a
License CC-BY-NC-SA 4.0 CC-BY-NC-SA 4.0
File Size n/a
Upload date 1701399393

Documentation

Also read http://wiki.alioth.net/index.php/Docking%20Fees

Readme.txt

Layne's Docking Fees
====================
Version 1.6

This is a minor OXP for Oolite-- it adds docking fees based on tech level to all GalCop stations (the fee is 1/2 the system's tech level, between 0.5 credits for a tech 1 to 7.5 credits at tech 15) as well as some colourful docking messages chosen at random.  Rock hermits and many OXP stations are also included, either as no-cost landing stations (they either offer limited services or poor trading) or in some cases costing more than the main station to dock. (Astrofactories/commie factories cost a bribe to dock with because of the cheaper equipment prices, casinos cost twice as much as the main station because they're luxury retreats, etc.)  I have attempted to include as many OXP stations as I could find, but the list is by no means complete due to the number of additional stations that are mission-created or in older OXPs.  Thanks to additional station lists provided by Norby, I believe that all OXP stations that exist as of June 2015 have been at least accounted for (Though not all have been given special messages or fees).

Special thanks to phkb for help understanding the structure of the message callbacks; my friend Eris (who does not play Oolite but knows her Javascript very well in-deed).  Thanks to everyone on the Oolite forum who gave me scripting pointers.  Thanks to Norby for the comprehensive list of OXP stations and additional suggestions.

3rd Party interface
-------------------
To add a unique docking message for a specific station use the following code:
    worldScripts["Docking Fees"].$addFee("my_station_role", {fee:20, message:"Welcome to my station, commander! Have a nice day, and thanks for paying your [fee_amt] fee."});
"my_station_role" must be a role of the station in question.
Possible parameters:
    fee             the fee amount to deduct from the player
    multiplier      a multiplier which is applied to the default fee calculation, allowing you to make your station 
                    more expensive (numbers greater than 1) or cheaper (numbers between 0 and 1) than the default.
    messageKey      the key name of the docking message from descriptions.plist.
    message         the text of the message to be displayed.

Text in "message", and inside your descriptions.plist messageKey text, can include the following text inserts:
    [fee_amt]       will be replaced by the fee paid by the player.
    [st_name]       will be replaced by the station name where the player is docking.

To disable docking fees for a particular station, use the following code:
    worldScripts["Docking Fees"].$addFee("my_station_role", {messageKey:""});

This OXP is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0).  Please share and enjoy.

History:
4-22-15 1.0
Initial version of script posted on Oolite forum.

4-23-15 1.1
Changes to script by phkb to add support for non-galcop stations.

4-23-15 1.2
OXP (config files, etc.) constructed and messages moved to docking report screen.  Multiple new messages written for galcop and more OXP stations (Commies, Dictators, Feudal, etc.) added.

4-26-15 1.3
First public release of OXP package.

5-7-15  1.4
Corrections to scripting for compatibility with Combat Simulator OXP.  Additional stations (Sentinel, Lave Academy, Training) added to script.  Minor typos corrected in docking report.

6-9-15  1.5
One additional docking message per tech level for a total of fifteen new messages!

6-15-15 1.6
Fee script changed to exclude any station not specifically included in the script (random OXP stations will no longer have docking fees assigned).  Many, many (and did I say many?) new stations have been added to the list, though most have only a generic docking message or none at all.

7-27-15 1.6.1
Bugfix to correct Escape Capsule misbehaviours!

7-2-18 1.6.2
Fixed issue with long decimal values being displayed in arrival messages.
Fixed issue with incorrect role being used for current Black Monks stations.
Added message for Tionisla Orbital Graveyard station.

7-6-21 2.0
Reworked logic to allow for new stations to be added into the system without recoding.
Code refactoring.

8-1-22 2.1
Added currency symbol to arrival text.
Fixed issue of defaulting to main station fee when fee equals 0.

30-11-2023 2.2
Fixed incorrect lookup key for RRS stations.

Equipment

This expansion declares no equipment.

Ships

This expansion declares no ships.

Models

This expansion declares no models.

Scripts

Path
Scripts/docking_fee.js
// oolite.oxp.Layne.DockingFees
"use strict";
this.name = "Docking Fees";
this.license = "CC BY-NC-SA 4.0";

this._simulator = false; // holding variable to work out whether this launch/dock routine was part of a simulator run
this._escapepod = false;
this._fees = {};

//-------------------------------------------------------------------------------------------------------------
this.startUpComplete = function () {
	this.$addCoreFees();
}

//-------------------------------------------------------------------------------------------------------------
this.shipLaunchedEscapePod = function (escapepod, passengers) {
	this._escapepod = true;
}

//-------------------------------------------------------------------------------------------------------------
this.shipDockedWithStation = function (station) {
	// if this was a simulator run, reset the variable and return - no docking fee in this case
	if (this._simulator == true) {
		this._simulator = false;
		return;
	}
	// is this a redock after an escape pod
	if (this._escapepod == true) {
		this._escapepod = false;
		return;
	}

	// work out fee based on system tech level and station type
	var f = ((system.techLevel * 0.5) + 0.5);
	var fee = 0;
	var messageKey = ""; //no message by default
	var message = "";

	// add the current system techlevel, gov and eco to mission variables so they can be referenced by descriptions
	missionVariables.systemTechLevel = system.techLevel;
	missionVariables.systemGovernment = system.government;
	missionVariables.systemEconomy = system.economy;

	if (station.isMainStation) { // main system stations for GalCop
		var def = this._fees["_default"];
		fee = (def.hasOwnProperty("fee") ? def.fee : (def.hasOwnProperty("multiplier") ? f * def.multiplier : 0));
		// make sure the "messageKey" value is the same as what you used in the descriptions.plist file
		messageKey = expandDescription(def.messageKey);
		message = def.message;
	}
	
	var roles = Object.keys(this._fees);
	for (var i = 0; i < roles.length; i++) {
		if (station.hasRole(roles[i])) {
			var chk = this._fees[roles[i]];
			fee = (chk.hasOwnProperty("fee") ? chk.fee : (chk.hasOwnProperty("multiplier") ? f * chk.multiplier : 0));
			messageKey = expandDescription(chk.messageKey);
			message = chk.message;
		}
	}

	if (fee > 0) { // ignore any station not specifically assigned a fee or message
		if (player.credits > fee) { // make sure the player has enough credits
			player.credits -= fee;
		} else {
			player.addMessageToArrivalReport("Welcome Commander! You seem to be down on your luck, so we've waived the docking fee this time.  You can work it off washing dishes in the station commissary!");
			this.$cleanUp();
			// don't try to send any other message
			return;
		}
	}
	// display the docking message
	if (messageKey != "" || message != "") {
		if (messageKey != "") {
			player.addMessageToArrivalReport(expandDescription("[" + messageKey + "]", {
				fee_amt: formatCredits(fee, true, true),
				st_name: station.displayName
			}));
		} else {
			player.addMessageToArrivalReport(expandDescription(messageKey, {
				fee_amt: formatCredits(fee, true, true),
				st_name: station.displayName
			}));
		}
	}
	this.$cleanUp();
}

//-------------------------------------------------------------------------------------------------------------
this.$cleanUp = function() {
	delete missionVariables.systemTechLevel;
	delete missionVariables.systemGovernment;
	delete missionVariables.systemEconomy;
}

//-------------------------------------------------------------------------------------------------------------
// check when the player launches if this is a simulator run
this.shipLaunchedFromStation = function (station) {
	if (this.$simulatorRunning()) this._simulator = true;
}

//-------------------------------------------------------------------------------------------------------------
// routine to check the combat simulator worldscript, to see if it's running or not
this.$simulatorRunning = function () {
	var w = worldScripts["Combat Simulator"];
	if (w && w.$checkFight && w.$checkFight.isRunning) return true;
	return false;
}

//-------------------------------------------------------------------------------------------------------------
// adds a fee object to the dictionary
// role: the station role to be checked for
// obj is a dictionary with the following options:
//		fee: a simple value to be used for the fee (eg 20) which overrides the default calc
//		multiplier: a multiplier to be applied to the default fee calculation (eg 1.5)
//      messageKey: the key from descriptions.plist that holds the docking message to be added to the arrival report (eg "my_dock_message")
//		message: the docking message to be added to the arrival report (eg "Welcome to my station, commander!")
// note: if both messageKey and message are defined, the messageKey will take priority
// note: if no fee or multiplier are specified, but the message keys are defined and not blank, the multiplier will be set to 1, 
// 			which applies a normal fee calculation.
// note: descriptions can include [fee_amt] and [st_name], which will be expanded to be the fee amount and the station name respectively.
// note: to have a station ignored, just specify a blank message. For example: $addFee("my_station_role", {message:""});
this.$addFee = function (role, obj) {
	var newfee = {};

	if (obj.hasOwnProperty("fee")) {
		newfee.fee = obj.fee;
	}
	if (obj.hasOwnProperty("multiplier")) {
		newfee.multiplier = obj.multiplier;
	}
	if (obj.hasOwnProperty("messageKey")) {
		newfee.messageKey = obj.messageKey;
	} else {
		newfee.messageKey = "";
	}
	if (obj.hasOwnProperty("message")) {
		newfee.message = obj.message;
	} else {
		newfee.message = "";
	}
	if ((!newfee.hasOwnProperty("fee") || newfee.fee == 0) && (!newfee.hasOwnProperty("multiplier") || newfee.multiplier == 0) && (newfee.messageKey != "" || newfee.message != "")) {
		newfee.multiplier = 1;
	}

	this._fees[role] = newfee;
}

//-------------------------------------------------------------------------------------------------------------
this.$addCoreFees = function () {
	this.$addFee("_default", {messageKey: "dockfee_[mission_systemTechLevel]"}); // default for main stations
	this.$addFee("rockhermit", {fee: 0, messageKey: "dockfee_rock"}); // rockhermits are free, must be before astromine
	this.$addFee("sfep_station", {multiplier: 0.5, messageKey: "dockfee_[mission_systemTechLevel]"}); // stations for extra planets are cheaper to visit than main station
	this.$addFee("constore", {fee: 0, messageKey: "dockfee_store"}); // con stores are free for encouraging customers
	this.$addFee("smivs_pizza_giftshop", {messageKey: ""}); // space-pizza charges a fee of its own, so no dock message
	this.$addFee("oolite-tutorial-station", {messageKey: ""}); // the training station in the tutorial; no fee or message
	this.$addFee("rrs-plague-mine", {messageKey: ""}); // plague mine, free docking for medical couriers
	this.$addFee("random_hits_any_spacebar", {multiplier: 1.5, messageKey: "dockfee_spacebar"}); // space bars are a little bit more expensive
	this.$addFee("rrs_group_spacestation", {fee: 0, messageKey: "dockfee_RRS"}); // rescue stations are free
	this.$addFee("casinoship", {multiplier: 2, messageKey: "dockfee_hoopy"}); // casinos are a bit more expensive
	this.$addFee("wildShips_kiota", {multiplier: 1.3, messageKey: "dockfee_kiota"}); // kiota ships are a little bit more expensive
	this.$addFee("rrs-mining-outpost", {fee: 0,	messageKey: "dockfee_mining"}); // mining outposts are free
	this.$addFee("free_trade_zone", {fee: 0, messageKey: "dockfee_FTZ"}); // free trade zones charge huge fuel prices in lieu of fee
	this.$addFee("astromine", {fee: 20, messageKey: "dockfee_astromine"}); // penal colonies require a fair bribe to enter
	this.$addFee("comczgf", {multiplier: 2.5, messageKey: "dockfee_ZGF"}); // Zero-G-Factories require a small bribe to enter
	this.$addFee("comslapu", {multiplier: 2.5, messageKey: "dockfee_SLAPU"}); // SLAPU collectives require a small bribe to enter
	this.$addFee("astrofactory", {multiplier: 2, messageKey: "dockfee_astrofactory"}); // imperial factories require a small bribe to enter
	this.$addFee("laveAcademy_academy", {fee: 0, messageKey: "dockfee_laveacademy"}); // Lave Academy is free as a public service
	this.$addFee("anarchies_sentinel_station", {fee: 0, messageKey: "dockfee_secom"}); // Sentinel Stations are free naval bases
	this.$addFee("anarchies_renegade_station", {messageKey: ""}); // renegade stations have their own penalties for docking
	this.$addFee("anarchies_hacker_outpost", {fee: 0, messageKey: "dockfee_hackers"}); // if you can find them, hacker outposts are free
	this.$addFee("anarchies_salvage_gang", {multiplier: 2, messageKey: "dockfee_salvager"}); // salvage gangs need a bribe to grease the wheels
	this.$addFee("navystat", {fee: 0, messageKey: "dockfee_secom"}); // navy stations are free (your tax dollars at work)
	this.$addFee("behemoth", {fee: 0, messageKey: "dockfee_behemoth"}); // behemoths are free
	this.$addFee("liners_liner", {fee: 0, messageKey: "dockfee_liner"}); // passenger liners are free
	this.$addFee("feudal-hunting-lodge", {fee: 0, messageKey: "dockfee_hunting"}); // royal lodges are free
	this.$addFee("planetFall_surface", {multiplier: 1.2, messageKey: "dockfee_planet"}); // planets are slightly more to discourage spacers
	this.$addFee("monkbranch", {fee: 0, messageKey: "dockfee_monks"}); // black monk monasteries are free
	this.$addFee("blackmonk_monastery", {fee: 0, messageKey: "dockfee_monks"});
	this.$addFee("taxi_station", {multiplier: 0.5, messageKey: "dockfee_taxi"}); // taxi stations just charge for the parking
	this.$addFee("aquatics_HQ", {fee: 0, messageKey: "dockfee_aquatica"}); //Aquatics Shipyards are free to dock with
	this.$addFee("GRS-Station", {fee: 0, messageKey: "dockfee_buoystat"}); //BuoyRepair HQ is free to dock with
	this.$addFee("pagroove_superhub", {multiplier: 2, messageKey: "dockfee_suphub"}); //Superhubs are expensive to dock with
	this.$addFee("toriA", {multiplier: 1.2, messageKey: "dockfee_[mission_systemTechLevel]"}); //Torus station cost more than standard GalCop stations
	this.$addFee("toriB", {multiplier: 1.2, messageKey: "dockfee_[mission_systemTechLevel]"}); //Torus station cost more than standard GalCop stations
	this.$addFee("dredgers", {fee: 0, messageKey: "dockfee_dredgj"}); //Deep Space Dredger are free to dock with, if you can find one
	this.$addFee("globestation", {multiplier: 1.5, messageKey: "dockfee_[mission_systemTechLevel]"}); //Globe stations are more expensive to dock with
	this.$addFee("globestationxl", {multiplier: 1.5, messageKey: "dockfee_[mission_systemTechLevel]"}); //Globe stations are more expensive to dock with

	this.$addFee("tgy_station", {messageKey: "dockfee_togy"}); // tionisla orbital graveyard
	this.$addFee("togy_station", {messageKey: "dockfee_togy"}); // tionisla orbital graveyard
	this.$addFee("baakili-fartrader", {multiplier: 0.5, messageKey: "dockfee_short"}); //Baakili Far Trader
	this.$addFee("bh01", {multiplier: 0.5, messageKey: "dockfee_short"}); //Bulk Haulers
	this.$addFee("broadcast_array", {messageKey: ""}); //Tionisla Chronicle Array - ignore
	this.$addFee("cb68_sodalite_station-riredi-coluber", {messageKey: "dockfee_short"}); //Riredi
	this.$addFee("draven_c", {messageKey: "dockfee_short"}); //Draven Carrier
	this.$addFee("draven_st", {messageKey: "dockfee_short"}); //Draven Oodulldoff Station
	this.$addFee("habmk2", {messageKey: "dockfee_short"}); //Zieman's Habitat Station
	this.$addFee("kihq", {messageKey: "dockfee_short"}); //Koneko Industries OXP
	this.$addFee("mandotech-main-station", {messageKey: "dockfee_short"}); //MandotechStation Shipyard
	this.$addFee("medusa", {messageKey: "dockfee_short"}); //Nuit Space Station OXP
	this.$addFee("PAGroove-Orisis", {messageKey: "dockfee_short"}); //Orisis
	this.$addFee("ryan_villa", {fee: 0, messageKey: ""}); //Ryan's Villa - ignore
	this.$addFee("SIRF-YARD", {messageKey: "dockfee_short"}); //S.I.R.F.
	this.$addFee("sothis", {messageKey: "dockfee_short"}); //SothisTC
	this.$addFee("taranis", {messageKey: "dockfee_short"}); //Taranis
	this.$addFee("tianve-pulsar-station", {messageKey: "dockfee_short"}); //Tianve and Navy Station
	this.$addFee("transhabstation", {messageKey: "dockfee_short"}); //Transhab station
}