I think that this contains Stranger's code for choosing one's landing site (nabbed from Roolite).
Code: Select all
"use strict";
this.name = "PlanetFall";
this.author = "Stranger";
this.copyright = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0 license with clauses - see readme.txt.";
this.description = "Enables planetary landing. Tightly based on Thargoid's PlanetFall v 1.51.1";
this.version = "2.6.1";
//Main events
this.startUp = function()
{
this.$lastPlanet = system.mainPlanet; // details of the last planet to be landed on, so we know what to move the player away from on launch
this.$planetFallLaunch = false; // as in 1.77 the alert condition is still set on launch - need a mask
this.$lastPlanetType = "Prime"; // what type of planet/moon we landed on
this.$messageBlock = false; // flag to stop request/cancel messages at launch from planet
this.$planetCount = 1; // default setting
this.$moonCount = 0; // default setting
this.$systemScan(); // set up the initial planet and moon count
this.planetFallOverride = false; // flag to allow other OXPs to override PlanetFall locations
this.overrideRole = "default"; // if other OXPs want to ensure a specific role is used
this.$checkForSpecialPlanets();
this.$gasGiantRadius = 100000; // set filter fo giant planets
this.$planetTerranRadius = 40000; // set filter to planets with dense atmosphere
this.$systemState();
this.$trafficState();
this.$sectorOnePlanetList = [0,1,2,3,4,7,8,10,11,13,16,17,18,19,20,21,23,28,29,35,36,39,42,44,46,50,55,62,66,73,86,89,90,93,99,100,101,111,118,124,126,129,131,132,141,147,150,153,154,172,177,186,188,198,200,221,222,227,228,241,246,250]; // Famous Planets Sector One
this.$sectorTwoPlanetList = [6,23,24,29,33,42,45,48,53,54,57,58,65,66,74,78,82,88,94,109,113,114,115,122,127,136,140,144,178,188,189,193,202,204,207,221,236]; // Famous Planets Sector Two
/* For convenience of mission writers, access for other OXPs is via "worldScripts.PlanetFall.lastPlanet" and "worldScripts.PlanetFall.lastPlanetType".
Values for lastPlanetType are "Prime" for the main planet, "Sub" for every other planet, "Moon" for any moon and "Sun" / "GasGiant" for a sun or a Solar System OXP
gas giant (for completeness - cannot land on either of the last two). */
}
this.shipWillLaunchFromStation = function(station)
{
if(station)
{
this.$planetFallLaunch = true;
player.ship.hudHidden = false;
if(station.hasRole("planetFall_surface"))
{
this.fx = system.addVisualEffect("planetFall_launchFX",player.ship.position.add(player.ship.vectorForward.multiply(150)));
this.fx.orientation = player.ship.orientation;
}
}
}
this.shipLaunchedFromStation = function(station)
{
if(EquipmentInfo.infoForKey("EQ_FRAME_SAVE") != null) // if launch is for Save Anywhere, don't want to move the player or nuke the station
{ return; }
if(station && station.hasRole("planetFall_surface"))
{
if(this.$landingTimer)
{ delete this.$landingTimer; }
player.commsMessage(system.name + " Planetary Control - orbital boost complete.",5);
player.commsMessage("Farewell Commander " + player.name + ".",5);
this.$removePort(station); // remove the surface-simulating station
this.$messageBlock = false;
missionVariables.planetFallBreak += 0.001; // 0.1% cumulative chance of equipment failure
if(Math.random() < missionVariables.planetFallBreak) // landing equipment needs maintenance
{
player.ship.setEquipmentStatus("EQ_PLANETFALL", "EQUIPMENT_DAMAGED");
player.consoleMessage("ALERT - Planetary landing modifications require urgent maintenance.", 10);
player.consoleMessage("Do not attempt to land again before they are repaired!", 10);
missionVariables.planetFallBreak = 0; // used equipment, no guarantee
}
}
this.$systemScan();
}
this.shipExitedWitchspace = function()
{
this.$checkForSpecialPlanets();
this.overrideRole = "default";
this.$systemScan();
this.$systemState();
this.$trafficState();
}
this.shipEnteredPlanetaryVicinity = function(planet)
{
if(!planet) { return; }
this.$trafficState();
this.$lastPlanet = planet;
if(!planet.isSun && !planet.hasOwnProperty("solarGasGiant") && !planet.hasOwnProperty("isGasGiant") && !planet.hasOwnProperty("PFNoLand") && !planet.hasOwnProperty("PFNoLandQuiet") && player.ship.equipmentStatus("EQ_PLANETFALL") == "EQUIPMENT_OK")
{
player.commsMessage(system.name + " Planetary Control - for planetfall please approach and request landing clearance.",5);
}
else
{
if(planet.isSun)
{ player.consoleMessage("ALERT - Approaching the Sun. Temperature monitoring is critical!", 10); }
if(planet.hasOwnProperty("solarGasGiant") || planet.hasOwnProperty("isGasGiant"))
{ player.consoleMessage("ALERT - You are approaching a Gas Giant. Landing here is not possible!", 10); }
if(planet.hasOwnProperty("PFNoLand"))
{ player.commsMessage("ALERT - Landing is not possible here, please pull up!", 10); }
}
}
this.shipExitedPlanetaryVicinity = function()
{
this.$messageBlock = false;
this.shipDied(); // clean-up of any unremoved surface stations.
}
this.alertConditionChanged = function()
{
if(this.$planetFallLaunch)
{
this.$planetFallLaunch = false;
return;
}
if(player.alertAltitude && !this.$lastPlanet.isSun && !this.$lastPlanet.hasOwnProperty("solarGasGiant") && !this.$lastPlanet.hasOwnProperty("PFNoLand") && !this.$lastPlanet.hasOwnProperty("PFNoLandQuiet") && !this.$lastPlanet.hasOwnProperty("isGasGiant"))
{
if(player.ship.equipmentStatus("EQ_PLANETFALL") != "EQUIPMENT_OK")
{
player.commsMessage(system.name + " Planetary Control - Your ship is not equipped for planetfall.", 10);
player.commsMessage("Do not attempt landing, your ship will be destroyed!", 10);
}
else
{
if(!this.$messageBlock)
{
player.commsMessage(system.name + " Planetary Control - Landing clearance request received.", 6);
player.commsMessage("Please await confirmation before beginning final approach.", 6);
}
if(Math.random() > 0.75 - 0.5 * missionVariables.planetFallBreak + 0.25 * this.$serviceLevel) // malfuncttion of homing beacon
{
this.$homingLock = 0;
}
else
{
this.$homingLock = 1;
}
this.$clearanceDelay = 5 + Math.ceil(Math.random() * 15); // delay between 6 and 20 seconds
this.$landingTimer = new Timer(this, this.$landingClearance, this.$clearanceDelay);
// a bit surprice...
if(Math.random() > 0.90 + 0.025 * system.government && this.$lastPlanet.radius < this.$gasGiantRadius)
{
system.addShips("pirate", 4, player.ship.position, 15000);
}
}
}
if(player.alertAltitude && (this.$lastPlanet.hasOwnProperty("solarGasGiant") || this.$lastPlanet.hasOwnProperty("isGasGiant")))
{ player.consoleMessage("ALERT - You are approaching a Gas Giant. Landing here is not possible!", 10); }
if(player.alertAltitude && this.$lastPlanet.hasOwnProperty("PFNoLand"))
{
player.consoleMessage("ALERT - Landing here is not possible!", 10);
return;
}
if(!player.alertAltitude && this.$landingTimer && this.$landingTimer.isRunning && !player.ship.docked && EquipmentInfo.infoForKey("EQ_FRAME_SAVE") == null)
{
this.$landingTimer.stop();
delete this.$landingTimer;
missionVariables.planetFallBreak += 0.001; // 0.1% cumulative chance of equipment failure
if(!this.$messageBlock)
{
player.commsMessage(system.name + " Planetary Control - Landing clearance request cancelled.", 6);
player.commsMessage("Goodbye Commander " + player.name + ".", 6);
this.$messageBlock = false;
}
}
}
this.shipApproachingPlanetSurface = function(planet)
{
if(!planet || player.ship.equipmentStatus("EQ_PLANETFALL") != "EQUIPMENT_OK" || planet.hasOwnProperty("PFNoLandQuiet"))
{
return;
}
if(planet.hasOwnProperty("PFNoLand"))
{
player.commsMessage(system.name + " Planetary Control - Urgent warning - landing is not possible here!", 6);
return;
}
this.$lastPlanet = planet;
var landingFlag;
if(player.ship.speed > 0.25 * player.ship.maxSpeed)
{
landingFlag = 2; // excess speed - missed approach
}
else
{
landingFlag = 1;
}
// ENTER COMPASS CHECK HERE
var targetVector = new Vector3D(player.ship.position.subtract(player.ship.compassTarget.position));
var targetDistance = Math.floor(targetVector.magnitude());
var targetDistanceMax = this.$lastPlanet.radius + 500;
if(targetDistance < this.$lastPlanet.radius || targetDistance > targetDistanceMax)
{
this.$landingChoice = 0;
}
else
{
this.$landingChoice = landingFlag;
}
if(this.$landingChoice != 0)
{
this.planetFallOverride = false;
}
if(!this.$landingTimer)
{
if(!planet.isSun && !planet.hasOwnProperty("solarGasGiant") && !planet.hasOwnProperty("isGasGiant"))
{
this.$messageBlock = true;
if(planet === system.mainPlanet)
{
this.$lastPlanetType = "Prime";
if(this.planetFallOverride)
{
if(this.overrideRole === "default")
{ this.overrideRole = "planetFall_mainSurface_externalOXP" };
this.$port = player.ship.spawnOne(this.overrideRole);
this.$turnStation(this.$port);
this.overrideRole = "default";
}
else
{
if(this.$landingChoice == 1) // spawn capital city
{
this.$port = player.ship.spawnOne(this.$mainPort1);
this.$turnStation(this.$port);
}
if(this.$landingChoice == 2 || this.$homingLock == 0) // spawn open fields
{
this.$port = player.ship.spawnOne(this.$mainPort2);
this.$turnStation(this.$port);
}
if(this.$landingChoice == 0) // spawn external OXP location, or if none then open fields
{
if(this.overrideRole !== "default")
{ this.$port = player.ship.spawnOne(this.overrideRole); }
else
{ this.$port = player.ship.spawnOne("planetFall_mainSurface_externalOXP"); }
if(!this.$port)
{
log(this.name, "Main surface external spawn failure");
this.$port = player.ship.spawnOne(this.$mainPort2);
}
this.$turnStation(this.$port);
this.overrideRole = "default";
}
}
if(this.$lastPlanet.radius >= this.$gasGiantRadius)
{
this.$port = player.ship.spawnOne(this.$mainPort3);
this.$turnStation(this.$port);
}
if(this.$lastPlanet.name)
{ this.$port.displayName = this.$lastPlanet.name + " - " + this.$port.displayName; }
else
{ this.$port.displayName = system.name + " Prime - " + this.$port.displayName; } // set the name to the surface of the prime planet in the system
}
else
{
if(planet.hasAtmosphere)
{
this.$lastPlanetType = "Sub";
if(this.planetFallOverride)
{
if(this.overrideRole == "default") { this.overrideRole = "planetFall_subSurface_externalOXP"; };
this.$port = player.ship.spawnOne(this.overrideRole);
this.$turnStation(this.$port);
this.overrideRole = "default";
}
else
{
if(this.$landingChoice == 1) // spawn colony city
{
this.$port = player.ship.spawnOne(this.$minorPort1);
this.$turnStation(this.$port);
}
if(this.$landingChoice == 2 || this.$homingLock == 0) // spawn open fields
{
this.$port = player.ship.spawnOne(this.$minorPort2);
this.$turnStation(this.$port);
}
if(this.$landingChoice == 0) // spawn external OXP location, or if none then open fields
{
if(this.overrideRole !== "default")
{ this.$port = player.ship.spawnOne(this.overrideRole); }
else
{ this.$port = player.ship.spawnOne("planetFall_subSurface_externalOXP"); }
if(!this.$port)
{
log(this.name, "Sub surface external spawn failure");
this.$port = player.ship.spawnOne(this.$minorPort2);
}
this.$turnStation(this.$port);
this.overrideRole = "default";
}
if(this.$lastPlanet.radius >= this.$gasGiantRadius)
{
this.$port = player.ship.spawnOne(this.$minorPort3);
this.$turnStation(this.$port);
}
}
if(this.$lastPlanet.name)
{ this.$port.displayName = this.$lastPlanet.name + " - " + this.$port.displayName; }
else
{ this.$port.displayName = system.name + " Minor - " + this.$port.displayName; } // set the name to just the surface, so we can identify easily the main planet
}
else
{
this.$lastPlanetType = "Moon";
if(this.planetFallOverride)
{
if(this.overrideRole == "default") { this.overrideRole = "planetFall_moonSurface_externalOXP" };
this.$port = player.ship.spawnOne(this.overrideRole);
this.$turnStation(this.$port);
this.overrideRole = "default";
}
else
{
if(this.$landingChoice == 1) // spawn lunar colony
{
this.$port = player.ship.spawnOne(this.$moonPort1);
this.$turnStation(this.$port);
}
if(this.$landingChoice == 2 || this.$homingLock == 0) // spawn open fields
{
this.$port = player.ship.spawnOne(this.$moonPort2);
this.$turnStation(this.$port);
}
if(this.$landingChoice == 0) // spawn external OXP location, or if none then open fields
{
if(this.overrideRole !== "default")
{ this.$port = player.ship.spawnOne(this.overrideRole); }
else
{ this.$port = player.ship.spawnOne("planetFall_moonSurface_externalOXP"); }
if(!this.$port)
{
log(this.name, "Moon external spawn failure");
this.$port = player.ship.spawnOne(this.$moonPort2);
}
this.$turnStation(this.$port);
this.overrideRole = "default";
}
}
if(this.$lastPlanet.name)
{ this.$port.displayName = this.$lastPlanet.name + " - " + this.$port.displayName; }
else
{ this.$port.displayName = "Moon of " + system.name + " - " + this.$port.displayName; } // set the name to the moon, so we can identify it as a moon
}
}
this.fx = system.addVisualEffect("planetFall_landingFX",player.ship.position.add(player.ship.vectorForward.multiply(170)));
this.$port.dockPlayer();
}
else
{
if(planet.hasOwnProperty("solarGasGiant") || planet.hasOwnProperty("isGasGiant"))
{
this.$lastPlanetType = "GasGiant";
}
else
{
this.$lastPlanetType = "Sun";
}
}
}
else
{ // if the PF landing timer is still running
player.commsMessage(system.name + " Planetary Control - Pull up, you have no landing clearance!", 6);
player.commsMessage("Return to orbit and approach again.", 6);
this.$landingTimer.stop();
delete this.$landingTimer;
}
}
this.shipWillDockWithStation = function(station)
{
if(station.hasRole("planetFall_surface") || station.hasRole("planetFall_mainSurface_externalOXP") || station.hasRole("planetFall_subSurface_externalOXP") || station.hasRole("planetFall_moonSurface_externalOXP"))
{
if(!this.fx) { this.fx = system.addVisualEffect("planetFall_landingFX",player.ship.position.add(player.ship.vectorForward.multiply(170))); }
this.fx.setMaterials({"planetFall_planet1.png": {diffuse_map: "planetFall_planet1.png" }});
}
}
this.shipDockedWithStation = function(station)
{
if(this.$landingChoice == 0)
{ return; }
if(station.hasRole("planetFall_surface"))
{
this.$portImage();
player.ship.hudHidden = true;
}
else
{
player.ship.hudHidden = false;
}
// main planet - functional port
if(player.ship.dockedStation.hasRole("planetFall_mainSurface_city" + this.$mainPortFlag))
{
this.$portTitle = "Capital City Port";
this.$portImageCaptured = this.$mainPortImage;
this.$terminalImageCaptured = this.$mainTerminalImage;
this.$cityImageCaptured = this.$mainCityImage;
this.$fieldImageCaptured = this.$mainFieldImage;
}
// main planet - fields
if(player.ship.dockedStation.hasRole("planetFall_mainSurface_fields"))
{
missionVariables.planetFallBreak += 0.001; // additional tear and wear
this.$portTitle = "Open Fields";
this.$portImageCaptured = this.$mainFieldImage;
this.$terminalImageCaptured = this.$mainFieldImage;
this.$cityImageCaptured = this.$mainFieldImage;
this.$fieldImageCaptured = this.$mainFieldImage;
}
// main planet - derelict ports
if(player.ship.dockedStation.hasRole("planetFall_mainSurface_cityDerelict"))
{
missionVariables.planetFallBreak += 0.001; // additional tear and wear
this.$portTitle = "Derelict City";
this.$portImageCaptured = this.$mainPortDerelictImage;
this.$terminalImageCaptured = this.$mainTerminalDerelictImage;
this.$cityImageCaptured = this.$mainCityDerelictImage;
this.$fieldImageCaptured = this.$mainFieldImage;
}
// minor planet - functional port
if(player.ship.dockedStation.hasRole("planetFall_subSurface_colony" + this.$minorPortFlag))
{
this.$portTitle = "Colony City Port";
this.$portImageCaptured = this.$minorPortImage;
this.$terminalImageCaptured = this.$minorTerminalImage;
this.$cityImageCaptured = this.$minorCityImage;
this.$fieldImageCaptured = this.$minorFieldImage;
}
if(player.ship.dockedStation.hasRole("planetFall_subSurface_researchStation"))
{
this.$portTitle = "Research Station";
this.$portImageCaptured = this.$minorPortImage;
this.$terminalImageCaptured = this.$minorTerminalImage;
this.$cityImageCaptured = this.$minorLabImage;
this.$fieldImageCaptured = this.$minorFieldImage;
}
// minor planet - fields
if(player.ship.dockedStation.hasRole("planetFall_subSurface_fields"))
{
missionVariables.planetFallBreak += 0.001; // additional tear and wear
this.$portTitle = "Open Fields";
this.$portImageCaptured = this.$minorFieldImage;
this.$terminalImageCaptured = this.$minorFieldImage;
this.$cityImageCaptured = this.$minorFieldImage;
this.$fieldImageCaptured = this.$minorFieldImage;
}
// minor planet - derelict ports
if(player.ship.dockedStation.hasRole("planetFall_subSurface_colonyDerelict"))
{
missionVariables.planetFallBreak += 0.001; // additional tear and wear
this.$portTitle = "Derelict City";
this.$portImageCaptured = this.$minorPortDerelictImage;
this.$terminalImageCaptured = this.$minorTerminalDerelictImage;
this.$cityImageCaptured = this.$minorCityDerelictImage;
this.$fieldImageCaptured = this.$minorFieldImage;
}
// moon - ports
if(player.ship.dockedStation.hasRole("planetFall_moonSurface_dome" + this.$moonPortFlag))
{
this.$portTitle = "Lunar Colony Port";
this.$portImageCaptured = this.$moonPortImage;
this.$terminalImageCaptured = this.$moonTerminalImage;
this.$cityImageCaptured = this.$moonCityImage;
this.$fieldImageCaptured = this.$moonFieldImage;
}
if(player.ship.dockedStation.hasRole("planetFall_moonSurface_researchStation"))
{
this.$portTitle = "Research Station";
this.$portImageCaptured = this.$moonPortImage;
this.$terminalImageCaptured = this.$moonTerminalImage;
this.$cityImageCaptured = this.$moonLabImage;
this.$fieldImageCaptured = this.$moonFieldImage;
}
// moon - fields
if(player.ship.dockedStation.hasRole("planetFall_moonSurface_fields"))
{
missionVariables.planetFallBreak += 0.001; // additional tear and wear
this.$portTitle = "Lunar Field";
this.$portImageCaptured = this.$moonFieldImage;
this.$terminalImageCaptured = this.$moonFieldImage;
this.$cityImageCaptured = this.$moonFieldImage;
this.$fieldImageCaptured = this.$moonFieldImage;
}
// moon - derelict ports
if(player.ship.dockedStation.hasRole("planetFall_moonSurface_domeDerelict"))
{
missionVariables.planetFallBreak += 0.001; // additional tear and wear
this.$portTitle = "Derelict Colony Dome";
this.$portImageCaptured = this.$moonPortDerelictImage;
this.$terminalImageCaptured = this.$moonTerminalDerelictImage;
this.$cityImageCaptured = this.$moonColonyDerelictImage;
this.$fieldImageCaptured = this.$moonFieldImage;
}
if(station.hasRole("planetFall_surface"))
{
mission.runScreen({
title: this.$portTitle,
background: {name: this.$portImageCaptured, height: 480 },
}
);
}
}
this.shipLeavingPlanetSurface = function(planet)
{
this.$lastPlanet = planet;
this.$messageBlock = false;
}
this.guiScreenChanged = function(to,from)
{
if(!player.ship.docked) // for GUI screen changes whilst in flight, which we can ignore
{ return; }
if(!player.ship.dockedStation.hasRole("planetFall_surface")) // if we're at a trunk or other OXP's station
{ return; }
if(this.$landingChoice == 0) // if we're at a trunk or surface ports of external OXP's such as Feudal States
{ return; }
if(guiScreen == "GUI_SCREEN_EQUIP_SHIP" || guiScreen == "GUI_SCREEN_MARKET" || guiScreen == "GUI_SCREEN_SHIPYARD" || guiScreen == "GUI_SCREEN_STATUS")
{
player.ship.hudHidden = false;
}
else
{
player.ship.hudHidden = true;
}
if (to === "GUI_SCREEN_SYSTEM_DATA" && from === "GUI_SCREEN_STATUS")
{
mission.runScreen({
title: "Planet view",
background: {name: this.$fieldImageCaptured, height: 480 },});
}
if (to === "GUI_SCREEN_SYSTEM_DATA" && from === "GUI_SCREEN_MARKET")
{
mission.runScreen({
title: "City view",
background: {name: this.$cityImageCaptured, height: 480 },});
}
if (to === "GUI_SCREEN_SYSTEM_DATA" && from === "GUI_SCREEN_EQUIP_SHIP")
{
mission.runScreen({
title: "Port view",
background: {name: this.$portImageCaptured, height: 480 },});
}
if (to === "GUI_SCREEN_SYSTEM_DATA" && from === "GUI_SCREEN_INTERFACES")
{
mission.runScreen({
title: "Terminal view",
background: {name: this.$terminalImageCaptured, height: 480 },});
}
if(!player.ship.dockedStation.hasRole("planetFall_noTrade")) // if we're at a location where trading is possible
{ return; }
// no-one to trade with in empty fields
if(player.ship.dockedStation.hasRole("planetFall_mainSurface_fields"))
{
if(guiScreen == "GUI_SCREEN_EQUIP_SHIP" || guiScreen == "GUI_SCREEN_MARKET")
{
mission.runScreen({
title: "Open fields",
messageKey: "planetFall_noTrade",
background: {name: this.$mainFieldImage, height: 480 },});
}
}
// wartime is a hard time for regular trade, but sometimes your help is needed!
if (this.$civilWarState == 1)
{
if(player.ship.dockedStation.hasRole("planetFall_mainSurface_cityDerelict"))
{
if(guiScreen == "GUI_SCREEN_EQUIP_SHIP")
{
mission.runScreen({
title: "Derelict Port",
messageKey: "planetFall_cityDerelictWar",
background: {name: this.$mainPortDerelictImage, height: 480 },});
}
}
}
// no-one to trade with in empty fields
if(player.ship.dockedStation.hasRole("planetFall_subSurface_fields"))
{
if(guiScreen == "GUI_SCREEN_EQUIP_SHIP" || guiScreen == "GUI_SCREEN_MARKET" || guiScreen == "GUI_SCREEN_SHIPYARD")
{
mission.runScreen({
title:"Open fields",
messageKey:"planetFall_noTrade",
background: {name: this.$minorFieldImage, height: 480 },});
}
}
// no-one to trade with in derelict object
if(player.ship.dockedStation.hasRole("planetFall_subSurface_colonyDerelict"))
{
if(guiScreen == "GUI_SCREEN_EQUIP_SHIP" || guiScreen == "GUI_SCREEN_MARKET")
{
mission.runScreen({
title: "Derelict Colony City",
messageKey: "planetFall_minorColonyDerelict",
background: {name: this.$minorCityDerelictImage, height: 480 },});
}
}
// no-one to trade with on the empty lunar surface
if(player.ship.dockedStation.hasRole("planetFall_moonSurface_fields"))
{
if(guiScreen == "GUI_SCREEN_EQUIP_SHIP" || guiScreen == "GUI_SCREEN_MARKET")
{
mission.runScreen({
title:"Open fields",
messageKey:"planetFall_noTrade",
background: {name: this.$moonFieldImage, height: 480 },});
}
}
// no-one to trade with in derelict object
if(player.ship.dockedStation.hasRole("planetFall_moonSurface_domeDerelict"))
{
if(guiScreen == "GUI_SCREEN_EQUIP_SHIP" || guiScreen == "GUI_SCREEN_MARKET")
{
mission.runScreen({
title: "Derelict Colony Dome",
messageKey: "planetFall_moonColonyDerelict",
background: {name: this.$moonColonyDerelictImage, height: 480 },});
}
}
}
this.playerBoughtEquipment = function(equipment) // regular maintenance
{
if(equipment == "EQ_PLANETFALL")
{ missionVariables.planetFallBreak = 0; }
if(equipment == "EQ_RENOVATION" && player.ship.equipmentStatus ("EQ_PLANETFALL") == "EQUIPMENT_OK")
{ missionVariables.planetFallBreak = 0; }
}
this.$landingClearance = function()
{
this.$landingTimer.stop();
delete this.$landingTimer;
player.commsMessage(system.name + " Planetary Control - Landing clearance granted.",6);
player.commsMessage("Please approach the surface slowly.", 6);
}
this.shipDied = function()
{
let ports = system.shipsWithRole("planetFall_surface"); // an array of any rogue "surface stations" in the system
this.$portCount = ports.length; // how many rogues we have that need to be removed
if(this.$portCount > 0) for (let i = 0; i < this.$portCount; i++) // if there are any, loop through and remove them
{ this.$removePort(ports[i]); }
if(this.$landingTimer && this.$landingTimer.isRunning)
{
this.$landingTimer.stop();
delete this.$landingTimer;
}
}
this.$systemScan = function()
{
function isMoon(entity) {return (entity.isPlanet && !entity.hasAtmosphere) };
this.$systemArray = system.planets;
this.$systemCount = this.$systemArray.length;
this.$moonCount = system.filteredEntities(this.$systemArray, isMoon).length;
this.$planetCount = this.$systemCount - this.$moonCount;
}
this.$removePort = function(port)
{
if(port.hasRole("planetFall_surface"))
{ port.remove(); };
}
this.$checkForSpecialPlanets = function()
{ this.$scriptDelay = new Timer(this, this.$setFlags, 0.25); }
this.$setFlags = function()
{
if(galaxyNumber === 0 && system.ID === 246) // if we're at Tianve (G0, S227), set up the pulsar
{
for (let i = 0; i < system.planets.length; i++)
{
if(system.planets[i].texture === "tianve_pulsar.png")
{ system.planets[i].PFNoLand = true; }
}
}
}
this.$turnStation = function(tempStation)
{
if(!tempStation) { return; } // just in case the station doesn't survive spawning.
let stationVector = tempStation.position.subtract(this.$lastPlanet.position).direction(); // unit vector pointing away from the planet
let angle = tempStation.heading.angleTo(stationVector); // angle between current heading and target heading
let cross = tempStation.heading.cross(stationVector).direction(); // set the plane where we should rotate in
tempStation.orientation = tempStation.orientation.rotate(cross, -angle); // re-orient the station away from the planet
tempStation.position = tempStation.position.add(stationVector.multiply(3000));
tempStation.breakPattern = false;
}
// set system TL, EL & GNP flags
this.$systemState = function()
{
// define tech level
if(system.techLevel < 4)
{
this.$techFlag = "ArchaicTech";
}
else
{
if(system.techLevel < 7)
{
this.$techFlag = "LowTech";
}
else
{
if(system.techLevel < 10)
{
this.$techFlag = "CommonTech";
}
else
{
this.$techFlag = "HighTech";
}
}
}
// define economy
if(system.economy < 3)
{
this.$economyFlag = "Industrial";
}
else
{
if(system.economy < 5)
{
this.$economyFlag = "Mixed";
}
else
{
this.$economyFlag = "Agro";
}
}
this.$mainPortFlag = this.$techFlag + this.$economyFlag;
// define space activity via GNP level
this.$spaceActivity = system.productivity * (0.75 + 0.5 * system.scrambledPseudoRandomNumber(135));
// moons
if(this.$spaceActivity < 20000)
{
this.$moonPortFlag = "Minimal";
}
else
{
if(this.$spaceActivity < 30000)
{
this.$moonPortFlag = "Basic";
}
else
{
this.$moonPortFlag = "Advanced";
}
}
// and minor planets
if(this.$spaceActivity < 25000)
{
this.$minorPortFlag = "Minimal";
}
else
{
if(this.$spaceActivity < 35000)
{
this.$minorPortFlag = "Basic";
}
else
{
this.$minorPortFlag = "Advanced";
}
}
}
// set war & traffic state
this.$trafficState = function()
{
if (system.isInterstellarSpace) return;
// main planet - civil war
var planetInfo = system.description;
var civilWarKeyword1 = "civil";
this.$civilWarFlag1 = planetInfo.indexOf(civilWarKeyword1);
var civilWarKeyword2 = "war";
this.$civilWarFlag2 = planetInfo.indexOf(civilWarKeyword2);
if(this.$civilWarFlag1 != -1 && this.$civilWarFlag2 != -1)
{
this.$civilWarFlag = 1;
}
else
{
this.$civilWarFlag = 0;
}
this.$civilWarLevel = 0.75 + 0.025 * system.government + 0.025 * system.techLevel - 0.25 * this.$civilWarFlag; // threshold of war conflicts (high value - reduced risk)
if(Math.random() > this.$civilWarLevel)
{
this.$civilWarState = 1;
}
else
{
this.$civilWarState = 0;
}
this.$serviceLevel = 0.05 * system.techLevel + 0.05 * system.government; // level of ground control competence - reduced in low-tech unstable systems
if(this.$civilWarState == 1)
{
this.$serviceLevel = 0;// service dropped in wartime
}
this.$selectPort();
}
// set port type
this.$selectPort = function()
{
// main ports
this.$mainPort1 = "planetFall_mainSurface_city" + this.$mainPortFlag;
this.$mainPort3 = "planetFall_mainSurface_city" + this.$mainPortFlag;
// minor ports - colony complex
if(this.$minorPortFlag != "Minimal")
{
this.$minorPort1 = "planetFall_subSurface_colony" + this.$minorPortFlag;
}
else
{
this.$minorPort1 = "planetFall_subSurface_researchStation";
}
this.$minorPort3 = "planetFall_subSurface_researchStation";
// moon ports - colony complex
if(this.$moonPortFlag != "Minimal")
{
this.$moonPort1 = "planetFall_moonSurface_dome" + this.$moonPortFlag;
}
else
{
this.$moonPort1 = "planetFall_moonSurface_researchStation";
}
// open fields
this.$mainPort2 = "planetFall_mainSurface_fields";
this.$minorPort2 = "planetFall_subSurface_fields";
this.$moonPort2 = "planetFall_moonSurface_fields";
// civil war - affects all system ports!
if(this.$civilWarState == 1)
{
this.$mainPort1 = "planetFall_mainSurface_cityDerelict";
this.$minorPort1 = "planetFall_subSurface_colonyDerelict";
this.$moonPort1 = "planetFall_moonSurface_domeDerelict";
}
}
// set planet port view
this.$portImage = function()
{
var w = worldScripts.AstroLibrary;
// main planet temperature
var sunRadius = system.sun.radius;
var sunTemperature = w.$astroLib_sunTemperature(sunRadius);
var sunLuminosity = w.$astroLib_sunLuminosity(sunTemperature,sunRadius);
var mainPlanetTemperature = w.$astroLib_mainPlanetTemperature(sunLuminosity);
// Famous Planets landscapes
// Sector One
if(system.info.galaxyID == 0)
{
var countSectorOne = this.$sectorOnePlanetList.length;
var flagSectorOne = -1;
for (let i = 0; i < countSectorOne; i++)
{
if(this.$sectorOnePlanetList[i] == system.info.systemID)
{
flagSectorOne = this.$sectorOnePlanetList[i];
}
}
}
// Sector Two
if(system.info.galaxyID == 1)
{
var countSectorTwo = this.$sectorTwoPlanetList.length;
var flagSectorTwo = -1;
for (let i = 0; i < countSectorTwo; i++)
{
if(this.$sectorTwoPlanetList[i] == system.info.systemID)
{
flagSectorTwo = this.$sectorTwoPlanetList[i];
}
}
}
var mainCityFlag;
var tagPlanet;
if(flagSectorOne >= 0 || flagSectorTwo >= 0)
{
tagPlanet = system.name; // selecting Famous Planet landscape
this.$mainFieldImage = ('fieldFP_' + tagPlanet + '.png');
mainCityFlag = -1;
}
else
{
var info = system.info;
var s = worldScripts.Planet_Makeup;
tagPlanet = s.$home_planet_makeup(info); // selecting generic planet landscape
this.$mainFieldImage = ('field_home_planet' + tagPlanet + '.png');
mainCityFlag = tagPlanet;
}
var cityImageShift = 0;
if(system.government == 0 || system.government == 2)
{
cityImageShift = 1;
}
if(system.government == 3 || system.government == 4)
{
cityImageShift = 2;
}
if(system.government > 4)
{
cityImageShift = 3;
}
// main ports - regular case
this.$mainCityImage = "mainCity" + this.$mainPortFlag + (1 + cityImageShift) + ".png";
this.$mainPortImage = "mainPort" + this.$techFlag + ".png";
this.$mainTerminalImage = "mainTerminal" + this.$techFlag + ".png";
// desert worlds
if(mainCityFlag != -1 && mainCityFlag > 64 && system.economy > 2)
{
this.$mainCityImage = "mainCityGenericDesert.png";
}
// arctic ports
if(mainCityFlag != -1 && mainCityFlag < 13 || mainPlanetTemperature < 273)
{
this.$mainCityImage = "mainCityGenericWinter.png";
this.$mainPortImage = "mainPortWinter.png";
this.$mainTerminalImage = "mainTerminalWinter.png";
}
// main derelict port
this.$mainCityDerelictImage = "mainCityDerelict" + this.$techFlag + ".png";
this.$mainPortDerelictImage = "mainPortDerelict.png";
this.$mainTerminalDerelictImage = "mainTerminalDerelict.png";
// top level worlds
if(system.techLevel > 13)
{
this.$mainPortImage = "mainPortUltraHighTech.png";
this.$mainFieldImage = "field_home_planet128.png";
}
// minor planet - inner OR outer?
var planetOrbit = 0;
var sunDistance = player.ship.position.distanceTo(system.sun).toFixed(0);
if(sunDistance > system.info.sun_distance)
{
planetOrbit = 1;
}
else
{
planetOrbit = 0;
}
// minor planet landscapes
this.$minorFieldImage = "field_planet_Ares.png";
// Pluto or Mercury
if(this.$lastPlanet.radius >= 25000 && this.$lastPlanet.radius < 30000 && this.$lastPlanet != system.mainPlanet)
{
if(planetOrbit == 1)
{
this.$minorFieldImage = "field_planet_Hades.png";
}
else
{
this.$minorFieldImage = "field_planet_Hermes.png";
}
}
// Cold Mars OR Hot Mars
if(this.$lastPlanet.radius >= 30000 && this.$lastPlanet.radius < 50000 && this.$lastPlanet != system.mainPlanet)
{
if(planetOrbit == 1)
{
this.$minorFieldImage = "field_planet_Ares.png";
}
else
{
this.$minorFieldImage = "field_planet_Phaethon.png";
}
}
// Cold Terra or Venus
if(this.$lastPlanet.radius >= 50000 && this.$lastPlanet.radius < 75000 && this.$lastPlanet != system.mainPlanet)
{
if(planetOrbit == 1)
{
this.$minorFieldImage = "field_planet_Ares.png";
}
else
{
this.$minorFieldImage = "field_planet_Aphrodite.png";
}
}
// Superterra
if(this.$lastPlanet.radius >= 75000 && this.$lastPlanet.radius < 100000 && this.$lastPlanet != system.mainPlanet)
{
this.$minorFieldImage = "field_planet_Aphrodite.png";
}
// minor ports
if(this.$minorFieldImage == "field_planet_Hermes.png" || this.$minorFieldImage == "field_planet_Hades.png")
{
if(this.$minorPortFlag != "Minimal")
{
this.$minorCityImage = "minorCityLunar" + this.$minorPortFlag + ".png";
this.$minorPortImage = "minorPortLunar" + this.$minorPortFlag + ".png";
this.$minorTerminalImage = "minorTerminalLunar" + this.$minorPortFlag + ".png";
}
else
{
this.$minorCityImage = "minorLabLunar.png";
this.$minorPortImage = "minorLabLunar.png";
this.$minorTerminalImage = "minorTerminalLunar.png";
}
this.$minorLabImage = "minorLabLunar.png";
this.$minorCityDerelictImage = "minorCityDerelictLunar.png";
}
if(this.$minorFieldImage == "field_planet_Ares.png" || this.$minorFieldImage == "field_planet_Phaethon.png")
{
if(this.$minorPortFlag != "Minimal")
{
this.$minorCityImage = "minorCityMartian" + this.$minorPortFlag + ".png";
this.$minorPortImage = "minorPortMartian" + this.$minorPortFlag + ".png";
this.$minorTerminalImage = "minorTerminalMartian" + this.$minorPortFlag + ".png";
}
else
{
this.$minorCityImage = "minorLabMartian.png";
this.$minorPortImage = "minorLabMartian.png";
this.$minorTerminalImage = "minorTerminalMartian.png";
}
this.$minorLabImage = "minorLabMartian.png";
this.$minorCityDerelictImage = "minorCityDerelictMartian.png";
}
if(this.$minorFieldImage == "field_planet_Aphrodite.png")
{
if(this.$minorPortFlag != "Minimal")
{
this.$minorCityImage = "minorCityVenusian" + this.$minorPortFlag + ".png";
this.$minorPortImage = "minorPortVenusian" + this.$minorPortFlag + ".png";
this.$minorTerminalImage = "minorTerminalVenusian" + this.$minorPortFlag + ".png";
}
else
{
this.$minorCityImage = "minorLabVenusian.png";
this.$minorPortImage = "minorTerminalVenusian.png";
this.$minorTerminalImage = "minorTerminalVenusian.png";
}
this.$minorLabImage = "minorLabVenusian.png";
this.$minorCityDerelictImage = "minorCityDerelictVenusian.png";
}
this.$minorPortDerelictImage = "minorPortDerelict.png";
this.$minorTerminalDerelictImage = "minorTerminalDerelict.png";
// moon landscapes
this.$moonFieldImage = "field_moon_Luna.png";
var paintMoonInner = system.scrambledPseudoRandomNumber(143);
var paintMoonOuter = system.scrambledPseudoRandomNumber(159);
if(this.$lastPlanet.radius >= 17500 && this.$lastPlanet.radius < 20000)
{
this.$moonFieldImage = "field_moon_Selene.png";
}
if(this.$lastPlanet.radius >= 12500 && this.$lastPlanet.radius < 15000)
{
this.$moonFieldImage = "field_moon_Luna.png";
}
if(this.$lastPlanet.radius >= 15000 && this.$lastPlanet.radius < 17500)
{
if (paintMoonInner < 0.5)
{
this.$moonFieldImage = "field_moon_Io.png";
}
else
{
this.$moonFieldImage = "field_moon_Europa.png";
}
}
if(this.$lastPlanet.radius >= 20000 && this.$lastPlanet.radius < 25000)
{
if (paintMoonOuter < 0.5)
{
this.$moonFieldImage = "field_moon_Ganymede.png";
}
else
{
this.$moonFieldImage = "field_moon_Callisto.png";
}
}
// moon ports
if(this.$moonPortFlag != "Minimal")
{
this.$moonCityImage = "moonColony" + this.$moonPortFlag + ".png";
this.$moonPortImage = "moonPort" + this.$moonPortFlag + ".png";
this.$moonTerminalImage = "moonTerminal" + this.$moonPortFlag + ".png";
}
else
{
this.$moonCityImage = "moonLab.png";
this.$moonPortImage = "moonLab.png";
this.$moonTerminalImage = "moonTerminal.png";
}
this.$moonLabImage = "moonLab.png";
this.$moonColonyDerelictImage = "minorCityDerelictLunar.png";
this.$moonPortDerelictImage = "minorPortDerelict.png";
this.$moonTerminalDerelictImage = "minorTerminalDerelict.png";
// gas giants
if(this.$lastPlanet.radius >= this.$gasGiantRadius)
{
this.$mainPortImage = "gasGiantPort.png";
this.$mainTerminalImage = "gasGiantTerminal.png";
this.mainLabImage = "gasGiantStation.png";
this.$mainFieldImage = "gasGiantStation.png";
this.$minorPortImage = "gasGiantPort.png";
this.$minorTerminalImage = "gasGiantTerminal.png";
this.$minorLabImage = "gasGiantStation.png";
this.$minorFieldImage = "gasGiantStation.png";
}
}