I love this idea!
A couple of suggestions in the following code. (1) Check the player credit balance before deducting something. If the player doesn't have enough to cover the fee we can assume that the station has a lenient attitude to taking the fee. (2) Have some variation in the fee at different stations. I've put a few in, but there are probably others that could be included, and what happens to the fee can be adjusted as well.
You could also change the voice of the station by storing different message texts in a descriptions.plist file. That way, a mining outpost can sound different to a rockhermit or a space bar.
Code:
// oolite.oxp.Layne.DockingFees
this.name = "Docking Fees";
this.version = "1.0";
this.shipDockedWithStation = function (station) {
// work out fee based on system tech level and station type
// default for galcop stations (and any other station that is not covered in the examples below
var fee = (system.techLevel * 0.5 + 0.5);
if (station.hasRole("rockhermit")) fee = 0; // rockhermits are free
if (station.hasRole("constore")) fee *= 2; // con stores are a bit more expensive
if (station.hasRole("random_hits_any_spacebar")) fee *= 1.5; // space bars are a little bit more expensive
if (station.hasRole("rrs_group_spacestation")) fee = 0; // rescue stations are free
if (station.hasRole("casinoship")) fee *= 2; // casinos are a bit more expensive
if (station.hasRole("wildShips_kiota")) fee *= 1.5; // kiota ships are a little bit more expensive
if (station.hasRole("rrs-mining-outpost")) fee = 0; // mining outposts are free
if (station.hasRole("smivs_pizza_giftshop")) fee = 0; // space-pizza gift shop charges a fee of its own
// make sure the player has enough credits
if (fee > 0) {
if (player.credits > fee) {
player.credits -= fee;
player.consoleMessage("Welcome Commander! A docking fee of " + fee + " credits has been deducted.", 7);
} else {
player.consoleMessage("Welcome Commander! We've waived the docking fee this time.", 7);
}
}
}
Edit: Corrected a couple of errors in the code (one highlighted by Wildeblood, the other a missing comment marker).