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

Expansion Wildships Kiota stations relocator

Content

Warnings

  1. Required Expansions mismatch between OXP Manifest and Expansion Manager at character position 0063 (DIGIT ZERO vs LATIN SMALL LETTER N)
  2. No version in dependency reference to oolite.oxp.Thargoid.Wildships:null
  3. Unknown key 'upload_date' at https://wiki.alioth.net/img_auth.php/c/ca/Oolite.oxp.astrobe.sunkyota.oxz!manifest.plist

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description Restricts Wildships to spawn at most one Kiota station near the sun. Also prevents it from replacing main stations. Restricts Wildships to spawn at most one Kiota station near the sun. Also prevents it from replacing main stations.
Identifier oolite.oxp.Astrobe.sunkyota oolite.oxp.Astrobe.sunkyota
Title Wildships Kiota stations relocator Wildships Kiota stations relocator
Category Dockables Dockables
Author Astrobe Astrobe
Version 1.1 1.1
Tags
Required Oolite Version
Maximum Oolite Version
Required Expansions
  • oolite.oxp.Thargoid.Wildships:0
  • oolite.oxp.Thargoid.Wildships:
  • Optional Expansions
    Conflict Expansions
    Information URL http://www.aegidian.org/bb/viewtopic.php?f=4&t=19033 n/a
    Download URL https://wiki.alioth.net/img_auth.php/c/ca/Oolite.oxp.astrobe.sunkyota.oxz http://wiki.alioth.net/img_auth.php/c/ca/Oolite.oxp.astrobe.sunkyota.oxz
    License CC-BY-NC-SA 4.0 CC-BY-NC-SA 4.0
    File Size n/a
    Upload date 1610873473

    Documentation

    Also read http://wiki.alioth.net/index.php/Wildships%20Kiota%20stations%20relocator

    Equipment

    This expansion declares no equipment. This may be related to warnings.

    Ships

    This expansion declares no ships. This may be related to warnings.

    Models

    This expansion declares no models. This may be related to warnings.

    Scripts

    Path
    Config/script.js
    "use strict";
    
    this.name           = "Kyota_relocator";
    this.author         = "Astrobe";
    this.copyright      = "Astrobe";
    this.licence        = "Public domain";
    this.description    = "Only one Kyota station per system at most, located near the sun.";
    this.version        = "1.0.1";
    
    this.kyotaPopulator = function ()
    {
    	//calculate distances
    	var planetToSun = system.sun.position.distanceTo(system.mainPlanet.position);
    	var wpToSun = system.sun.position.magnitude();
    
    	var distanceFromPlanetSurface = 0.9 * (planetToSun  - system.sun.radius - system.mainPlanet.radius);
    	//randomize the position a bit
    	var x_coord = system.scrambledPseudoRandomNumber(600) * 25E3;
    	var y_coord = system.scrambledPseudoRandomNumber(484) * 25E3;
    	var z_coord = system.mainPlanet.radius + distanceFromPlanetSurface;
    	var exactPosition = Vector3D(x_coord, y_coord, z_coord).fromCoordinateSystem("psm");
    
    	 if(system.scrambledPseudoRandomNumber(188) < 0.2 ) {
    		// add Disc stations
    		if(system.population > 40)
    			var solar_station = "wildShips_kiota4Disc";
    		else
    			var solar_station = "wildShips_kiota2Disc";
    		system.setPopulator("wild_ships_disc", {
    			callback: function(pos) {			
    				system.addShips(solar_station, 1, pos, 0);					
    			}.bind(this),
    			location: "COORDINATES",
    			coordinates: exactPosition,
    			deterministic: true
    		})		
    	 }
    	 else if(system.scrambledPseudoRandomNumber(189) < 0.2 ) {
    		// add solar stations
    		if(system.population > 40)
    			var solar_station = "wildShips_kiota4Solar";
    		else
    			var solar_station = "wildShips_kiota2Solar";
    		system.setPopulator("wild_ships_solar", {
    			callback: function(pos) {			
    				system.addShips(solar_station, 1, pos, 0);					
    			}.bind(this),
    			location: "COORDINATES",
    			coordinates: exactPosition,
    			deterministic: true
    		})		
    	}
    	else if(system.scrambledPseudoRandomNumber(127) < 0.2) {
    		//comms stations
    		// add comms stations
    		if(system.population > 40)
    			var comms_station = "wildShips_kiota4Comms";
    		else
    			var comms_station = "wildShips_kiota2Comms";
    		system.setPopulator("wild_ships_comms", {
    			callback: function(pos) {			
    				system.addShips(comms_station, 1, pos, 0);					
    			}.bind(this),
    			location: "COORDINATES",
    			coordinates: exactPosition,
    			deterministic: true
    		})
    	}
    	else if(system.scrambledPseudoRandomNumber(891) < 0.2 ) {
    		if (system.population < 30)
    			var hab_station = "wildShips_kiota2Ring";
    		else {
    			if (system.population > 45) {
    				if (system.scrambledPseudoRandomNumber(319) > 0.5)
    					var hab_station = "wildShips_kiota8Ring";
    				else
    					var hab_station = "wildShips_kiota8RingV";
    			}
    			else {
    				if(system.scrambledPseudoRandomNumber(319) > 0.5)
    					var hab_station = "wildShips_kiota4Ring";
    				else
    					var hab_station = "wildShips_kiota4RingV";
    			}
    		}
    		system.setPopulator("wild_ships_habitat", {
    			callback: function(pos) {			
    				system.addShips(hab_station, 1, pos, 0);					
    			}.bind(this),
    			location: "COORDINATES",
    			coordinates: exactPosition,
    			deterministic: true
    		})
    	}
    	else if(system.techLevel > 6 && system.scrambledPseudoRandomNumber(713) < 0.2 ) {
    		// add research stations to higher tech systems
    		if(system.techLevel > 11)
    			var research_station = "wildShips_kiota4Spur";
    		else
    			var research_station = "wildShips_kiota2Spur";
    
    		system.setPopulator("wild_ships_research", {
    			callback: function(pos) {			
    				system.addShips(research_station, 1, pos, 0);					
    			}.bind(this),
    			location: "COORDINATES",
    			coordinates: exactPosition,
    			deterministic: true
    		})
    	}
    	else if (system.scrambledPseudoRandomNumber(301) < 0.2 ) {
    		// add manufacturing stations to industrial systems
    		if (system.economy < 3) {
    			if(system.productivity > (30000 - (system.economy * 2500)))
    				var man_station = "wildShips_kiota4Sphere";
    			else
    				var man_station = "wildShips_kiota2Sphere";
    		}
    		else if (system.economy > 4) {
    			if(system.productivity > (30000 - ((system.economy - 5) * 2500)))
    				var man_station = "wildShips_kiota4Sphere";
    			else
    				var man_station = "wildShips_kiota2Sphere";
    		}
    		else return;
    
    		system.setPopulator("wild_ships_manufacturing", {
    			callback: function(pos) {			
    				system.addShips(man_station, 1, pos, 0);					
    			}.bind(this),
    			location: "COORDINATES",
    			coordinates: exactPosition,
    			deterministic: true
    		})
    	}
    	log(this.name, "relocated a station succesfully");
    }
    
    this.startUp = function()
    {
    	// This is taken from http://wiki.alioth.net/index.php/Handling_OXP_Dependencies_with_JavaScript
          delete this.startUp;
    
    
          // function to handle the initialising of other scripts
          function runOtherStartUp(s) {
    	if (worldScripts[s].startUp) worldScripts[s].startUp(); // Call the other startUp.
    	if (worldScripts[s].startUp) delete worldScripts[s].startUp; // Make sure the other startUp is deleted as it may not be written using
                                                                         // this template.
          };
    
          runOtherStartUp("wildShips_populator.js");
    
    
          // Test for existence of an OXP that isn't required but effects the way this OXP works.
          this.Oxp_X_Script_Exists = !!worldScripts["wildShips_populator.js"];
    
    
          worldScripts["wildShips_populator.js"].systemWillPopulate=this.kyotaPopulator; // This is what I want to do.
    
          log(this.name, this.version +" loaded."); // This goes last so the load messages appear in a sensible order.
    
    }