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

Expansion Fuel Station

Content

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description For the Commander on the go, fly-thru witchpoint and route 1 fuel stations and fuel satellites. For the Commander on the go, fly-thru witchpoint and route 1 fuel stations and fuel satellites.
Identifier oolite.oxp.Thargoid.FuelStation oolite.oxp.Thargoid.FuelStation
Title Fuel Station Fuel Station
Category Activities Activities
Author Thargoid, gsagostinho Thargoid, gsagostinho
Version 2.2 2.2
Tags activities, system activities, system
Required Oolite Version
Maximum Oolite Version
Required Expansions
Optional Expansions
Conflict Expansions
Information URL http://wiki.alioth.net/index.php/Fuel_Station_OXP n/a
Download URL https://wiki.alioth.net/img_auth.php/7/7d/Oolite.oxp.Thargoid.FuelStation.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 1610873345

Documentation

Also read http://wiki.alioth.net/index.php/Fuel%20Station

Fuel Station v2.2 ReadMe.txt

Fuel Station OXP by Thargoid, Eric Walch and gsagostinho.

For the hurried Commander on the go! No time to dock, just want to grab some fuel and run, then this is the place for you...

To grab some fuel, just fly into the yellow glow in the centre of the station (or approach the fuel satellite which sometimes are used in place of a station) and come to a halt. Your ship will notify you when transfer begins and when your tank is full (and if you run out of cash during the transfer, sorry no credit will be given to broke Commanders). Then just fly on out, check your summary receipt and carry on with your journey.

Stations are limited to tech levels of 4 and above and will not appear in Anarchy or Feudal systems. Not every system has them, but some have at both the witchpoint and half-way between the witchpoint and the main planet to fill-up on Route One (see below for update on this). To find one quickly just look for the fuel station logo on the ASC.

Oh and these stations are solidly built, but aren't designed for big ships (no Dredgers!). And Galcop don't take too kindly to acts of vandalism on them...

Requires Oolite v1.74 or later - will not work with any lower version

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

Update - Spawning Locations and Frequency:

With v1.33 and later of the OXP there is now built-in the option of whether to have the stations spawned in their default locations (randomly near the witchpoint and half-way along route 1) or in fixed place (at the edge of the scanner range on the far side of the witchpoint only). 

To change from the default original to the fixed, simply open up the file "fuelStation_stationSetup.js" in a text editor (not notepad under Windows!) and change "this.positionOverride = false" in line 11 to "this.positionOverride = true". Then restart the game with the shift-key held down until the spinning Cobra Mk III appears. 

To revert to the default just change the line back to false and repeat the shift-restart procedure.

The v1.33 also now includes pseudo-random spawning, so if the stations appear in a system then they should always do so (except for when the long way around mission is running).

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

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.
* 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.
* Even though it is not compulsory, if you are re-using any sizable or recognisable piece of this OXP, please let me know :)

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

Instructions:

Unzip the file, and then move the folder "Fuel Station 1.36.oxp" to the AddOns directory of your Oolite installation. Then start the game up whilst holding down the shift key (until the spinning Cobra Mk III screen appears) and the stations will appear in appropriate systems.

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

Version History:

10/02/2009 - Version 1.00, Initial release.
11/02/2009 - Version 1.01, set-up script tweak:
	* no stations in Nova systems (to prevent interference with Nova mission)
	* less chance (1 in 5 : 1 in 10 halfway : witchpoint) when the longwayround mission is active.
	* raise the price from 2cr/ly to 3cr/ly
16/02/2009 - Version 1.10, added the fuel satellite at a 1 in 3 chance where a fuel station could be, for ships which can't fly through the stations
19/02/2009 - Version 1.11, bugfix for situation where player jumps when within range of a satellite into system without one. Prevents system crash occurring.
20/07/2009 - Version 1.12, NPC traders using the fuel stations, plus 1.73 compatability.
27/08/2009 - Version 1.2, fuel satellite script upgrade for 1.73 compatibility, plus AI/script adjustment to stop NPCs using station if player is there.
03/09/2009 - Version 1.21, OXPConfig additions for turretted ships.
08/09/2009 - Version 1.22, bugfix for NPC scripting.
12/09/2009 - Version 1.23, bugfix to prevent spawning of stations and satellites in systems that have gone nova.
24/03/2010 - Version 1.30, update for 1.74 - will not run on lower versions.
19/06/2010 - Version 1.31, remove testing code left in by mistake
13/02/2011 - Version 1.32, removal of upper limit, to allow running with 1.75
23/08/2011 - Version 1.33, script tidy-up and merging, plus a little extra checking included after some log error reports.
24/01/2012 - Version 1.34, fix for the compass icon (again) - thanks to Makara for the heads-up.
05/02/2013 - Version 1.35, update for compatibility with OXPConfig.
25/09/2013 - Version 1.36, added compatibility with variable fuel pricing, plus new colour schemes and messages. 
30/07/2017 - Version 2.0, new textures including normal maps (by gsagostinho)
01/08/2017 - Version 2.1, small improvement to the 3D model (by gsagostinho)
20/08/2017 - Version 2.2, improvement to light reflection on satellite surfaces (by gsagostinho)

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

Acknowledgements:

With thanks to laxori666 for the thoughts on the variable fuel pricing for v1.36

Equipment

This expansion declares no equipment.

Ships

Name
Burning quirium fuel
Fuel Satellite
Fuel Station

Models

This expansion declares no models.

Scripts

Path
Scripts/fuelStation_satellite.js
this.name					= "FuelSatellite";
this.author					= "Thargoid";
this.copyright				= "Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description			= "Script for fuel satellite";
this.version				= "2.02";

this.shipSpawned = function()
	{ //  line the station up with the route one. Code borrowed from Anarchies for convenience.
	this.ship.scannerDisplayColor1 = "greenColor";
	this.ship.scannerDisplayColor2 = "darkGrayColor";

	if(system.isInterstellarSpace || !system.mainPlanet) {return;}
	var targetVector = system.mainPlanet.position.subtract(this.ship.position).direction()
	var angle = this.ship.heading.angleTo(targetVector)
	var cross = this.ship.heading.cross(targetVector).direction()
	this.ship.orientation = this.ship.orientation.rotate(cross, -angle);
	// this.setColour();
	this.setPrice();
	}

//this.setColour = function()
//	{
//	this.colRand = system.scrambledPseudoRandomNumber(45.32)
//	colName = "yellowColor";
//	if(this.colRand < 0.25) { colName = "blueColor"; }
//	if(this.colRand < 0.75) { colName = "redColor"; }
//	if(this.colRand > 0.25 && this.colRand < 0.5) { colName = "magentaColor"; }
//	this.ship.setMaterials({"fuelStation_satellite.png": { diffuse: colName }});
//	}	
	
this.setPrice = function()	
	{
	this.fuelPrice = 0.15 * EquipmentInfo.infoForKey("EQ_FUEL").price * player.ship.fuelChargeRate; // price per 0.1LY of fuel
	if(system.economy === 0 || system.economy === 5) { this.fuelPrice *= 1.2; } //  rich industrial or agricultural
	if(system.techLevel > 4 && system.techLevel < 11) { this.fuelPrice *= 1.1; } //  mid-tech level
	this.fuelPrice = this.decPlaces(this.fuelPrice,2);
	}

this.decPlaces = function(number, places)
	{
	if(!places || places < 0) {places = 0;}
	if(!number) {return 0;}
	return ((Math.round(number * Math.pow(10,places))) / Math.pow(10,places));
	}
		
this.playerDetected = function()
	{
	this.firstMessage = true;
	this.secondMessage = true;
	this.thirdMessage = true;
	this.fuelTransferred = 0; // how many 0.1LY units are transferred
	this.fuelBill = 0;
	this.ship.commsMessage("Greetings Commander " + player.name + ". Refuel here for only " + this.decPlaces((10 * this.fuelPrice),1) + " credits per ly");
	if(this.scanTimer)
		{
		this.scanTimer.start();
		}
	else
		{
		this.scanTimer = new Timer(this, this.locatePlayer, 0, 0.50);
		}
	}

this.locatePlayer = function()
	{
	if(!this.ship || !this.ship.isValid || !this.ship.position || !player.ship.isValid) // if the ship no longer exists but timer is running, e.g. if player has jumped whilst near a satellite into a system without one
		{
		this.playerGone();
		return;
		}

	if(this.ship.position.distanceTo(player.ship.position) < 150) // player ship within 150m of the centre of the satellite
		{
		if(player.ship.fuel < 7)
			{
			if(player.credits > this.fuelBill)
				{ // player in place, fuel tank not full and credit balance not empty
				player.ship.fuel += 0.1;
				this.fuelBill += this.fuelPrice;
				this.fuelTransferred++;

				if(this.firstMessage)
					{
					player.consoleMessage("Fuel transfer is underway, please come to a halt.", 6);
					this.firstMessage = false;
					}
				return;
				}
			else
				{ // not enough funds left
				if(this.secondMessage)
					{
					player.consoleMessage("Insufficient credits remaining for further transfer.", 6);
					this.secondMessage = false;
					}
				return;
				}
			}
		else
			{ // Fuel tank full
			if(this.thirdMessage)
				{
				player.consoleMessage("Fuel tanks are full.", 6);
				this.thirdMessage = false;
				}
			return;
			
			}
		}
	else
		{
		if(this.fuelTransferred > 0)
			{
			this.fuelBill = this.decPlaces(this.fuelPrice * this.fuelTransferred,1);
			player.consoleMessage("Summary - " + (this.fuelTransferred / 10) + " ly transferred, " + this.fuelBill + " credits charged.", 6);
			player.credits -= this.fuelBill;
			this.fuelTransferred = 0;
			this.fuelBill = 0;
			this.firstMessage = true;
			this.secondMessage = true;
			this.thirdMessage = true;
			}
		}
	}

this.playerWillEnterWitchspace = this.playerGone = function()
	{
	if(this.scanTimer)
		{
		this.scanTimer.stop();
		delete this.scanTimer;
		}
	}

this.shipDied = function(whom, why) 
	{
	this.playerGone();
	this.fuelCount = (Math.ceil(Math.random() * 30) + 30);
	this.ship.spawn("fuelStation_burningFuel", this.fuelCount); // lets make this go with a bang!

	if(whom && whom.isPlayer)
		{
		player.consoleMessage("CCTV beam towards the main station detected.", 6);
		player.score -=1; // don't condone vandalism!
		player.bounty += 20;
		}
	}
	
this.attackedMessage = function()
	{
	this.ship.commsMessage("ALERT - fuel satellite under attack, explosion danger!");
	}
Scripts/fuelStation_station.js
this.name					= "FuelStation";
this.author					= "Thargoid";
this.copyright				= "Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description			= "Script for fuel station";
this.version				= "2.02";

this.shipSpawned = function()
	{ 
	this.ship.scannerDisplayColor1 = "greenColor";
	this.ship.scannerDisplayColor2 = "lightGrayColor";

	var traders = system.shipsWithPrimaryRole("trader", this.ship, 50E3)	
	if(traders.length > 0 && worldScripts["FuelStation-Setup"].extraB && traders[0].AIState == "HEAD_FOR_PLANET") 
		{
		traders[0].script.checkFuelStationDistance = this.checkFuelStationDistance; // attach function to script.
		traders[0].script.checkUsage = this.checkUsage; // attach function to script.
		traders[0].setAI("fuelStation_gotoFuelStationAI.plist");
		}
		
	//  line the station up with the route one. Code borrowed from Anarchies for convenience.
	if(system.isInterstellarSpace || !system.mainPlanet) {return;}
	var targetVector = system.mainPlanet.position.subtract(this.ship.position).direction();
	var angle = this.ship.heading.angleTo(targetVector);
	var cross = this.ship.heading.cross(targetVector).direction();
	this.ship.orientation = this.ship.orientation.rotate(cross, -angle);	
//	this.setColour();
	this.setPrice();
	}

//this.setColour = function()
//	{
//	this.colRand = system.scrambledPseudoRandomNumber(45.32)
//	colName = "yellowColor";
//	if(this.colRand < 0.25) { colName = "blueColor"; }
//	if(this.colRand < 0.75) { colName = "redColor"; }
//	if(this.colRand > 0.25 && this.colRand < 0.5) { colName = "magentaColor"; }
//	this.ship.setMaterials({"fuelStation_station.png": { diffuse: colName }});
//	}
	
this.setPrice = function()	
	{
	this.fuelPrice = 0.15 * EquipmentInfo.infoForKey("EQ_FUEL").price * player.ship.fuelChargeRate; // price per 0.1LY of fuel
	if(system.economy === 0 || system.economy === 5) { this.fuelPrice *= 1.2; } //  rich industrial or agricultural
	if(system.techLevel > 4 && system.techLevel < 11) { this.fuelPrice *= 1.1; } //  mid-tech level
	this.fuelPrice = this.decPlaces(this.fuelPrice,2);
	}	

this.decPlaces = function(number, places)
	{
	if(!places || places < 0) {places = 0;}
	if(!number) {return 0;}
	return ((Math.round(number * Math.pow(10,places))) / Math.pow(10,places));
	}
	
this.playerDetected = function()
	{
	this.firstMessage = true;
	this.fuelTransferred = 0; // how many 0.1LY units are transferred
	this.fuelBill = 0;
	this.ship.commsMessage("Greetings Commander " + player.name + ". Refuel here for only " + this.decPlaces((10 * this.fuelPrice),1) + " credits per ly");
	if(this.scanTimer)
		{
		this.scanTimer.start();
		}
	else
		{
		this.scanTimer = new Timer(this, this.locatePlayer, 0, 0.50);
		}
	}

this.locatePlayer = function()
	{
	if(!this.ship ||!this.ship.isValid || !this.ship.position || !player.ship.isValid) // if the ship no longer exists but timer is running, e.g. if player has jumped whilst near a satellite into a system without one
		{
		this.playerGone();
		return;
		}

	if(this.ship.position.distanceTo(player.ship.position) < 150) // player ship within 150m of the centre of the fuel station
		{
		if(player.ship.fuel < 7)
			{
			if(player.credits > this.fuelBill)
				{ // player in place, fuel tank not full and credit balance not empty
				player.ship.fuel += 0.1;
				this.fuelBill += this.fuelPrice;
				this.fuelTransferred++;

				if(this.firstMessage)
					{
					player.consoleMessage("Fuel transfer is underway, please come to a halt.", 6);
					this.firstMessage = false;
					}
				return;
				}
			else
				{ // not enough funds left
				player.consoleMessage("Insufficient credits remaining, transfer terminated.", 6);
				this.scanTimer.stop();
				return;
				}
			}
		else
			{ // Fuel tank full
			player.consoleMessage("Fuel tanks are full.", 6);
			this.scanTimer.stop();
			return;
			
			}
		}
	}

this.shipTraversePositiveZ = this.shipTraverseNegativeZ = function(ship)
	{
	if(ship.isPlayer) this.playerLeaving()
	}

this.playerLeaving = function()
	{
	this.fuelBill = this.decPlaces(this.fuelPrice * this.fuelTransferred,1);
	player.consoleMessage("Summary - " + (this.fuelTransferred / 10) + " ly transferred, " + this.fuelBill + " credits charged.", 6);
	player.credits -= this.fuelBill;
	this.fuelTransferred = 0;
	this.fuelBill = 0;
	this.firstMessage = true;
	}
    
this.playerWillEnterWitchspace = this.playerGone = function()
	{
	if(this.scanTimer)
		{
		this.scanTimer.stop();
		delete this.scanTimer;
		}
	}

this.shipDied = function(whom, why) 
	{
	this.playerGone();
	this.fuelCount = (Math.ceil(Math.random() * 30) + 30);
	this.ship.spawn("fuelStation_burningFuel", this.fuelCount); // lets make this go with a bang!

	if(whom && whom.isPlayer)
		{
		player.consoleMessage("CCTV beam towards the main station detected.", 6);
		player.score -=1; // don't condone vandalism!
		player.bounty += 20;
		}
	}
    

// below not used by stationscript but is attached to traderscript.
this.checkFuelStationDistance = function()
	{	
	if(this.ship.position.distanceTo(this.ship.target.position) > 50E3)
		{
		this.ship.reactToAIMessage("NEXT_FUELSTATION")
		}
	}

this.checkUsage = function()
	{
	 if(this.ship.target.position.distanceTo(player.ship.position) < 1000)
		{
		this.ship.reactToAIMessage("NEXT_FUELSTATION")
		}
	else
		{
		this.ship.reactToAIMessage("STATION_CLEAR")
		}
	}
	
this.attackedMessage = function()
	{
	this.ship.commsMessage("ALERT - fuel station under attack, explosion danger!");
	}	
	
this.collisionMessage = function()
	{
	this.ship.commsMessage("ALERT - proximity detection, please take evasive action");
	}
Scripts/fuelStation_stationSetup.js
this.name					= "FuelStation-Setup";
this.author					= "Thargoid";
this.copyright				= "Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description			= "Script to add fuel station to certain systems";
this.version				= "2.02";

this.extraA = true;	// for use with turretted ships - set to false to only get fuel satellites
this.extraB = true;	// if set to false, no NPCs will use the stations (if extraA is false, has no effect)
	
this.oxpcSettings = {
	Info: {Name:this.name,Display:this.name,InfoB:"1 - If false only fuel satellites will appear.\n2 - If false NPCs will not use fuel stations (ignored if extraA is false)."},
	Bool0: {Name:"extraA",Def:true,Desc:"Suppress fuel stations."},
	Bool1: {Name:"extraB",Def:false,Desc:"Allow NPCs to use fuel stations."}
};	

this.startUp = function()
	{
	this.positionOverride = false; // set this to true to use alternative station positioning at far side of witchpoint only.
	}

this.shipWillLaunchFromStation = function()
	{
	this.shipExitedWitchspace();
	delete this.shipWillLaunchFromStation;
	}
	
this.shipExitedWitchspace = function()
	{
	if(this.positionOverride === false)
		{ this.originalStationSetup(); }
	else
		{ this.witchpointStationSetup(); }
	}
	
this.witchpointStationSetup = function() // fixed station position on far side of witchpoint area.
	{
	if(system.isInterstellarSpace || system.sun.isGoingNova || system.sun.hasGoneNova || missionVariables.longwayround === "STAGE1" || missionVariables.longwayround === "STAGE2") 
	// stop the script if interstellar space, or system is going Nova(to allow Nova mission unhindered) or indeed if it has gone nova already.
		{ return; }

	if(system.government > 1 && system.techLevel > 3 && system.countShipsWithRole("fuelStation_location") === 0)
		{
		if(this.extraA && system.scrambledPseudoRandomNumber(19.7) > 0.33)
			{ system.legacy_addShipsAt("fuelStation_station", 1, "wpm", [0, 0, -24000]); }
		else
			{ system.legacy_addShipsAt("fuelStation_satellite", 1, "wpm", [0, 0, -24000]); }
		}
	}	
	
this.originalStationSetup = function() // original locations, near witchpoint and on route 1.
	{
	if(system.isInterstellarSpace || system.sun.isGoingNova || system.sun.hasGoneNova) 
		{ // stop the script if interstellar space, or system is going Nova(to allow Nova mission unhindered) or indeed if it has gone nova already.
		return;
		}

	this.halfwayChance = 0.25; // 3 in 4 chance to add a station at the half-way point of route 1.
	this.witchpointChance = 0.33; // 2 in 3 chance to add a station near the witchpoint.

	if(missionVariables.longwayround === "STAGE1" || missionVariables.longwayround === "STAGE2")
		{ // drastically reduce the chances if you're in the middle of Long Way Round mission
		this.halfwayChance = 0.9; // 1 in 10 chance to add a station at the half-way point of route 1.
		this.witchpointChance = 0.95; // 1 in 20 chance to add a station near the witchpoint.
		}

	if(system.government > 1 && system.techLevel > 3 && system.countShipsWithRole("fuelStation_location") === 0)
		{
		if(system.scrambledPseudoRandomNumber(13.7) > this.witchpointChance)
			{
			if(this.extraA && system.scrambledPseudoRandomNumber(17.4) > 0.33)
				{
	 			system.legacy_addShipsAt("fuelStation_station", 1, "pwu", [0.02, 0, 1]);
				}
			else
				{
	 			system.legacy_addShipsAt("fuelStation_satellite", 1, "pwu", [0.02, 0, 1]);
				}
			}

		if(system.scrambledPseudoRandomNumber(25.3) > this.halfwayChance)
			{
			if(this.extraA && system.scrambledPseudoRandomNumber(24.1) > 0.33)
				{
	 			system.legacy_addShipsAt("fuelStation_station", 1, "pwu", [0.02, 0, 0.5]);
				}
			else
				{
	 			system.legacy_addShipsAt("fuelStation_satellite", 1, "pwu", [0.02, 0, 0.5]);
				}
			}

		}
	}