PlanetFall2 OXP 
by Thargoid and phkb
====================

An OXP which allows the Commander to land at specific locations on planets and moons (but not suns, even at night). Each main planet has up to 5 designated landing sites, while additional planets can have 3, and each moon can have 2 (configurable via Library Config). Pick your landing site and point your ship at the flashing marker near the surface that indicates the Ground Control Interface Point for the landing zone. Ensure your flight path is not too steep, otherwise you may sustain damage when the automated landing protocol engages. 

Be careful of turbulence as you enter the atmosphere. To assist with atmospheric turbulence, the "Atmospheric Stabilisers" can be purchased at any TL9+ system for 5000cr. When equipped, this will reduce the impact of turbulence on your ship. Speed will have an impact on how much your ship is effected by turbulence. Slowing down will decrease the effect.

Your approach will trigger an automatic landing request. You should receive a response after a few seconds, indicating you are either cleared for landing or not. If you have clearance, continue towards the Ground Control Interface Point at less than 100 m/s until the automated system engages, captures your ship and lowers you to a landing pad. 

Planetary take-off is via a launch booster, with control being returned to the Commander once orbital insertion is achieved.

For information in making use of Planet Fall systems, see the "Developers ReadMe.txt" file.

Options:
========
There are a lot of options available to help configure the system the way you want it. Library Config has the following sections for PlanetFall2:

- General settings
- F3/F8: Main planet
- Spawn chances: Main planet
- F3/F8: Extra planets
- Spawn chances: Extra planets
- F3/F8: Moons
- Spawn chances: Moons
- Spawn chances: TL factors
- Transit costs
- Ship transfer costs

General settings:
-----------------
Flags:
	Move shipyards to planet: Controls whether shipyards are moved to planet-side locations.
	Move maintenance to planet: Controls whether the "Maintenance Overhaul" item is moved to only be offered on planet-side locations.
	Atmosphere turbulence: Controls whether the turbulence effect, when entering the atmosphere of a planet, is active or not.
	Shallow approach: Controls whether a shallow approach angle is required when landing on a surface location.
	Use landing images: Controls whether the images displayed after landing at a planetary site are displayed.
	Use Almanac names: Controls whether the names of planetary locations are given names based on the methodology from the Galactic Almanac.
	Allow planetary transit: Controls whether it is possible to fast travel to other planetary sites after landing.
	Planet rotation tweaks: Controls whether planetary rotation is slowed on approach (to reduce the visual impact of scaling issues).
	
Values:
	Main planet max: Maximum number of locations that could be spawned on the main planet.
	Extra planet max: Maximum number of locations that could be spawned on a secondary planet with an atmosphere.
	Moon max: Maximum number of locations that could be spawned on a moon with no atmosphere.
	Atmosphere max altitude: Maximum height (in km) of the atmosphere of a planet.
	Beacon range: Max distance (in km) that planetary beacons become visible to the player. Setting this to zero will mean all beacons are visible all the time.
	Service Level dec: Amount that service level will be reduced by when launching from a planet.
	Transfer Time: Amount of time (in hours) that will pass when transferring player ship to the current location.
	Train speed: Base average speed of trains (in kph), which is scaled up or down based on the TL of the system.
	Turbulence impact scale: Scales the impact of turbulence, where 1.0 means no change to the default, 0.5 halves the impact, and 0.0 means no impact (same as turning turbulence off)

F3/F8: Main planet:
-------------------
Flags:
	Capital cities: Whether capital cities will have access to the F3 Equip Ship screen.
	Military bases: Whether military bases will have access to the F3 Equip Ship screen.
	Leisure complexes: Whether leisure complexes will have access to the F3 Equip Ship screen.
	Factories: Whether factories will have access to the F3 Equip Ship screen.
	Rubbish dumps: Whether rubbish dumps will have access to the F3 Equip Ship screen.

Values:
	Capital cities: What type of market will be available at capital cities.
	Military bases: What type of market will be available at military bases.
	Leisure complexes: What type of market will be available at military bases.
	Factories: What type of market will be available at factories.
	Rubbish dumps: What type of market will be available at rubbish dumps.

	0 = No market; 
	1 = Default market, which will likely be the main station market; 
	2 = SFEP (Stations for Extra Planets) method, which adjusts prices and quantities based on the distance of the site from the main station.
	3 = Original market, as defined in PlanetFall v1.51. (but pre-Oolite 1.84).

Spawn chances: Main planet:
---------------------------
Values:
	Spawn city: Chance of spawning a capital city.
	Spawn military base: Chance of spawning a military base.
	Spawn leisure complex: Chance of spawning a leisure complex.
	Spawn factory: Chance of spawning a factory.
	Spawn rubbish dump: Chance of spawning a rubbish dump.

	eg 0.4 = 40% chance. The chance will be adjusted slightly by the TechLevel factor (see below).

F3/F8: Extra planets:
---------------------
Flags:
	Colony cities: Whether colony cities will have access to the F3 Equip Ship screen.
	Military bases: Whether military bases will have access to the F3 Equip Ship screen.
	Leisure complexes: Whether leisure complexes will have access to the F3 Equip Ship screen.
	Factories: Whether factories will have access to the F3 Equip Ship screen.
	Rubbish dumps: Whether rubbish dumps will have access to the F3 Equip Ship screen.

Values:
	Colony cities: What type of market will be available at colony cities.
	Military bases: What type of market will be available at military bases.
	Leisure complexes: What type of market will be available at leisure complexes.
	Factories: What type of market will be available at factories.
	Rubbish dumps: What type of market will be available at rubbish dumps.

	0 = No market; 
	1 = Default market, which will likely be the main station market; 
	2 = SFEP (Stations for Extra Planets) method, which adjusts prices and quantities based on the distance of the site from the main station.
	3 = Original market, as defined in PlanetFall v1.51 (but pre-Oolite 1.84).

Spawn chances: Extra planets:
-----------------------------
Values:
	Spawn colony city: Chance of spawning a colony city.
	Spawn military base: Chance of spawning a military base.
	Spawn leisure complex: Chance of spawning a leisure complex.
	Spawn factory: Chance of spawning a factory.
	Spawn rubbish dump: Chance of spawning a rubbish dump.

	eg 0.4 = 40% chance. The chance will be adjusted slightly by the TechLevel factor (see below).

F3/F8: Moons:
-------------
Flags:
	Colony domes: Whether colony domes will have access to the F3 Equip Ship screen.
	Mines: Whether mines will have access to the F3 Equip Ship screen.
	Prisons: Whether prisons will have access to the F3 Equip Ship screen.
	Leisure domes: Whether leisure domes will have access to the F3 Equip Ship screen.
	Robot factories: Whether robot factories will have access to the F3 Equip Ship screen.
	Research complexes: Whether research complexes will have access to the F3 Equip Ship screen.
	Wastelands: Whether wastelands will have access to the F3 Equip Ship screen.

Values:
	Colony domes: What type of market will be available at colony domes.
	Mines: What type of market will be available at mines.
	Prison: What type of market will be available at prisons.
	Leisure domes: What type of market will be available at leisure domes.
	Robot factories: What type of market will be available at robot factories.
	Research complexes: What type of market will be available at research complexes.
	Wastelands: What type of market will be available at wastelands.

	0 = No market; 
	1 = Default market, which will likely be the main station market; 
	2 = SFEP (Stations for Extra Planets) method, which adjusts prices and quantities based on the distance of the site from the main station.
	3 = Original market, as defined in PlanetFall v1.51 (but pre-Oolite 1.84).

Spawn chances: Moons:
---------------------
Values:
	Spawn colony dome: Chance of spawning a colony dome.
	Spawn mine: Chance of spawning a mine.
	Spawn prison: Chance of spawning a prison.
	Spawn leisure dome: Chance of spawning a leisure dome.
	Spawn robot factory: Chance of spawning a robot factory.
	Spawn research complex: Chance of spawning a research complex.
	Spawn wasteland: Chance of spawning a wasteland.

	eg 0.4 = 40% chance. The chance will be adjusted slightly by the TechLevel factor (see below).

Spawn chances: TL factors:
--------------------------
Values:
	Main planet min/max: Factor to apply to spawn chance of main planet locations based on the TL of the system.
	Extra planets min/max: Factor to apply to spawn chance of extra planet locations based on the TL of the system.
	Moons min/max: Factor to apply to spawn chance of moon locations based on the TL of the system.

	The min value would be applied at the lowest TL, while the max value would apply to the highest TL. 
	TL's in between would get a scaled value between min and max.

Transit costs:
--------------
Values:
	Fee: Base cost for a single trip (cr).
	Anarchy factor: Factor applied to fee in Anarchy systems
	Feudal factor: Factor applied to fee in Feudal systems.
	Multi-government factor: Factor applied to fee in Multi-Government systems.
	Dictatorship factor: Factor applied to fee in Dictatorship systems.
	Communist factor: Factor applied to fee in Communist systems.
	Confederacy factor: Factor applied to fee in Confederacy systems.
	Democracy factor: Factor applied to fee in Democracy systems.
	Corporate State factor: Factor applied to fee in Corporate State systems.

	Factors: eg 0.0 = All trips are free; 1.0 = Use base cost; 0.5 = 50% of base cost.

Ship transfer costs:
--------------------
Values:
	Fee: Base cost for ship transfer (cr).
	Anarchy factor: Factor applied to fee in Anarchy systems
	Feudal factor: Factor applied to fee in Feudal systems.
	Multi-government factor: Factor applied to fee in Multi-Government systems.
	Dictatorship factor: Factor applied to fee in Dictatorship systems.
	Communist factor: Factor applied to fee in Communist systems.
	Confederacy factor: Factor applied to fee in Confederacy systems.
	Democracy factor: Factor applied to fee in Democracy systems.
	Corporate State factor: Factor applied to fee in Corporate State systems.

	Factors: eg 0.0 = Ship transfers are free; 1.0 = Use base cost; 1.5 = 150% base cost.

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. Basically if it's unique or would identify or overwrite anything in the original OXP, then you may not re-use it (for obvious compatibility reasons).
* 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.
* The license information (either as this file or merged into a larger one) must be included in the OXP.
* Even though it is not compulsory, if you are re-using any sizable or recognisable piece of this OXP, please let me know :)

Image files:
------------
https://www.freepik.com/free-photo/empty-dark-room-modern-futuristic-sci-fi-background-3d-illustration_20850610.htm Image by user6702303 on Freepik
https://www.freepik.com/free-photo/empty-dark-room-modern-futuristic-sci-fi-background-3d-illustration_21988050.htm Image by user6702303 on Freepik
https://www.freepik.com/free-photo/empty-dark-room-modern-futuristic-sci-fi-background-3d-illustration_23326348.htm Image by user6702303 on Freepik
https://www.freepik.com/free-photo/empty-dark-room-modern-futuristic-sci-fi-background-3d-illustration_21988072.htm Image by user6702303 on Freepik
https://www.freepik.com/free-photo/empty-dark-room-modern-futuristic-sci-fi-background-3d-illustration_23326337.htm Image by user6702303 on Freepik
https://www.freepik.com/free-photo/empty-dark-room-modern-futuristic-sci-fi-background-3d-illustration_21835246.htm Image by user6702303 on Freepik

https://www.freepik.com/free-photo/blue-sky-with-scattered-white-clouds_12110221.htm Freepik
https://www.freepik.com/free-photo/beautiful-skyscape-during-daytime_22542965.htm Freepik
https://www.freepik.com/free-photo/cloudy-sky-daylight-background_19380968.htm Freepik
https://www.freepik.com/free-photo/beautiful-skyscape-during-daytime_22543011.htm Freepik
https://www.freepik.com/free-photo/blue-sky-with-cloud-closeup_6133056.htm Image by photogenia on Freepik
https://www.freepik.com/free-photo/beautiful-skyscape-during-daytime_22542943.htm Freepik
https://www.freepik.com/free-vector/20-vehicles-outline-icon-presentation_38543743.htm Image by flatart on Freepik

https://www.freepik.com/free-ai-image/subway-dark-atmosphere_76653967.htm Image by freepik
https://www.freepik.com/free-ai-image/new-york-city-subway-train-motion_69844323.htm Image by freepik
https://www.freepik.com/free-photo/motion-blur-automatic-train-moving-inside-tunnel-tokyo-japan_10824408.htm Image by tawatchai07 on Freepik

Some images were generated by AI at https://www.freepik.com/pikaso/ai-image-generator

Sound files:
------------
"e train 140kmh 04 190613_0029.wav" by klankbeeld -- https://freesound.org/s/476298/ -- License: Attribution 4.0
"Arrival of a passenger electric train.1950km station_2(Eq,lmtr).wav" by newlocknew -- https://freesound.org/s/580464/ -- License: Attribution 4.0

Instructions:
=============
To manually install the mod, unzip the file, and then move the folder "PlanetFall2.oxp" to the AddOns directory of your Oolite installation. Ensure you remove any previous version of PlanetFall before installing this one.

Requirements:
=============
The following OXP's are required in order to use this one:
- PlanetFall2 Resources A & B (oolite.oxp.phkb.PlanetFall_ResourcesA & oolite.oxp.phkb.PlanetFall_ResourcesB): Required for various graphical displays.
- Library (oolite.oxp.Svengali.Library): For changing configuration settings.
- GNN (oolite.oxp.Svengali.GNN): Used for random station naming functionality.
- Market Script Interface (oolite.oxp.phkb.MarketScriptInterface): Used to update market info on planetary locations.
- External Docking System (oolite.oxp.phkb.ExternalDockSystem): Used as part of the updated docking methodology.

It is also highly recommended that the Planet Rotation Cosmetics OXP be installed, as it makes the scale issues as you approach the planet less obvious.

Version History:
================
2.30
- Changed manifest title from "PlanetFall" to "PlanetFall2".
- Changed Library Config aliases to "PlanetFall2".
- Changed category to "Systems".
- Fixed issue with adding OXP locations to custom systems, where some keys were being added to the list twice.

2.29
- Shuttles that choose to land on a planet will now do so at one of the landing sites.
- Shuttles will also launch from the landing sites.

2.28
- Fixed method of detecting when two landing sites are too close together.
- Changed calculation method for positioning landing sites to ensure good separation from others.

2.27
- Fixed issue where stored names were not being restored from missionVariables reliably.
- Fixed issue with naming system for Oo-Haul sites, which wasn't including "(Distribution Centre)" in the name.
- Fixed issue with naming HOopy Casino sites, which wasn't including "(HOopy Casino)" in the name.
- OXP planet locations defined via the ship role "planetFall2_???_externalOXP" are now attempted to be added to custom systems. Random factors and spawn conditions can then come in to play to limit the number of spawns.

2.26
- Darkened overlay images for better compatibility with Oolite 1.92.

2.25
- Moved more text into missiontext.plist.
- Fixed issue with ship transfer fee not being calculated correctly when being deducted from the players account.

2.24
- Added check for, and warning message of, PlanetLand OXP conflict.

2.23
- Fixed issue where shipyards were not viewable on stations that have overridden the "move shipyards to planet" option.

2.22 
- Display a message when attempting to access shipyards on stations when they are located on planetary surfaces.
- Added option to disable the shallow approach angle requirement when landing on a surface location.
- Tweaked spawning logic so planetary locations can't be too close together, increasing the distance from the previous fix.

2.21
- Change to manifest file to match with split of resources pack into two.

2.20
- Added a function, $getSystemLocations, which returns an object containing the ship keys and place names of all planetary locations in a given system.

2.19
- Setting beacon range to zero will make all beacons visible all the time.
- Added ability to scale the maximum turbulence factor per planet.

2.18
- Added a "turbulence impact scale" option so the effect of turbulence can be scaled to taste.
- Allowed for blank entries in location overrides to switch to randomised location types and naming.
- Fixed issues when checking roles to determine the type of VFX to show for landing.
- Added ability to override the landing clouds, docks and overlays on a per-planet basis.
- Some code refactoring.

2.17
- Moved most text into missiontext.plist for easier localisation.
- Removed monkey patch on Market Inquirer as no longer required.

2.16
- Tweak to prevent LMSS and Laser Arrangement interfaces disappearing on non-PlanetFall locations.

2.15
- Increased the number of shipdata entities to better handle high values for the number of planetary landing points.

2.14
- Added protection for instances where a planet or moon has no air color value set.
- Fixed issue where the reason for the denial of a landing request was not being transmitted to the player.

2.13
- Further fixes to linkage between landing sites and planets.

2.12
- Fixed incorrect property setting in shipdata.
- Changed allegiance setting for research complexes to be neutral.
- Fixed issue where landing sites could spawn too close together.

2.11
- Fixed issue where link between landing sites and planets could occasionally break due to rounding errors.

2.10
- Prevented things like "Immigration Control" from appearing in Anarchy systems.
- Prevented turbulence frame callback from being started twice.
- Fixed error: this.serviceLevelDecrease is not a function.
- Tweaks to hopefully permanently fix issue where turbulence effect keeps running after a witchspace jump or docking.

2.9
- Fixed JS error in transit process code.
- Fixed issue where Vimana-X HUD was not resetting correctly on launch after using transit system.

2.8
- Split off planet rotation slowing into separate OXP, and made optional for this OXP.

2.7
- Dying while turbulence is active will now stop the frame callback.
- Added tweak to planet rotation when approaching planet, slowing it down to make scale issues less obvious (can be configured with Library Config).
- Code refactoring.

2.6
- Small tweak to the market script.
- Small fix to the name generation process for Capital Cities.

2.5
- Refined some text in messages for better understanding and integration with the built in voice.
- Added a pre-spawn check for a condition script on custom (ie non-built-in) surface locations.
- Fixed issue that was preventing custom names from being applied to custom system setups.
- Added a PDF document outlining how to create custom systems, for non-coders.
- Updates for the PlanetFall Oo-haul mission pack.
- Added conflict with PlanetFallMarketSaver - this OXP shouldn't be necessary with PlanetFall2.
- Added conflict with PlanetFall Markets - this OXP shouldn't be necessary with PlanetFall2.
- Removed some unused settings in config.
- Split off graphical assets into separate OXP, to make updating the core code easier for everyone.
- Added a second train FX image, so that the second animation doesn't just look completely like the first.
- Tweaked train FX images to make them more centred.
- Added scan class to station entities.

2.4
- Adjusted calculations to make landing when pointing at the GCIP more consistent.

2.3
- Added a planet-side transit system, so you don't have to launch and re-dock to visit another landing site on the same planet.
- Transit costs are adjusted based on government types. Configurable via Library Config.
- Ship transfer costs are adjusted based on government types. Configurable via Library Config.
- Fixed shipyard transfer process to not run more than once per system.
- Added fragment and vertex shaders to ensure all break patterns appear clearly and without shadow.
- Removed yaw turbulence factor. Only pitch and roll turbulence will be now be set.
- Fixed issue that was preventing subSurface colonies and moonSurface domes from being spawned.
- Amount of reduction to service level is now configurable via Library Config.
- Added a function (PlanetFall2.playerShipIsLocal) that can be called to determine if the player is near their ship or not.
- Removed the Blackmonks and HoOpy Casino config options, and incorporated spawn chances in script_info object of shipdata and condition script.

2.2
- Fixed issue where, if "Additional Planets" doesn't create any planets, no landing sites are created on the main planet.
- Reapplied monkey match for Market Inquirer to address issue with beacons not showing when more than 100000m from the player when docked.
- Removed conflicts with SW Planetary Systems and Moons, although it is unlikely any created moons will get landing sites.

2.1
- Added methods to allow for a fully customised system to be defined (with multiple sites per planet/moon).
- Moved Feudal States override code into a separate OXP.
- Fixed missing semi-colon in shipdata.plist.
- Switched ground control interface point to be a normal ship object (rather than a visual effect) to gain better compatibility with OXP's like Telescope.
- Made the ground control interface points more visible.
- Reduced the number of monkey patches required.
- Made the maximum range at which the space compass will detect ground control interface points configurable via Library Config, and changed the default value to 200km.
- Added some conflict oxps ("Planetary Systems" and "Moons" by stranger).
- Improved compatibility with Market Inquirer.
- Tweaked spawning methods to better reflect the original PlanetFall results, where OXP station roles are not added unless override flag is set.
- Added a warning screen for players, informing them that ship maintenance services are only available on the planet.
- Added a chance of a misjump when executing a witchspace jump inside the atmosphere.
- Fixed issue where entering witchspace while the turbulence effect is still active would result in it staying active.
- Fixed bug that was setting service level to the minimum value when launching from a planetary location.
- Turbulence now doesn't end when speed is zero.
- Added a config item to manage how much the service level of the player ship is reduced.
- Added shipdata entries to allow for multiple military bases, leisure complexes, factories and dumps on the main planet in custom systems. 
- Fixed issues where NaN, NaN, Nan is calculated for a vector.
- Log messages now controllable via a debug flag.
- Removed some unused code.

2.0
- Updated landing FX, with clouds and landing pads.
- Updated launching FX.
- Changed docking method to have a fixed location (rather than just descending towards the planet surface anywhere), which means you can now save your game at planetary locations.
- Access to equipment sales (F3 Equip Ship) configuration via Library Config.
- Updated market information to allow for 3 different methods to be applied to any of the locations. (Configurable via Library Config)
- Added a variety of arrival report screen backgrounds. (Can be turned off via Library Config)
- Added a turbulence effect when in the atmosphere of a planet. (Can be turned off via Library Config)
- Equipment item renamed to "Atmospheric Stabilisers", but is optional for planetary landings.
- Moved ships from shipyards on other stations to planetary locations. (Configurable via Library Config)
- Moved "Maintenance Overhaul" to only be available on the main planet. (Configurable via Library Config)
- Added script updates to Feudal Systems, Aquatics, Market Inquirer, Galactic Almanac and In-System cargo delivery to maintain compatibility.
- Additional compatibility settings updated via shipdata-overrides.plist.

For information about versions 1.51 and previous, see the "Planetfall v1.51 ReadMe & License.txt" file.