Back to Index Page generated: Jun 13, 2026, 7:54:51 PM

Expansion Satellites

Content

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description Adds some (0 to 15, dependent on tech level and size of population) of four small satellites to every main planet. Adds some (0 to 15, dependent on tech level and size of population) of four small satellites to every main planet.
Identifier oolite.oxp.Rorschachhamster.Satellites oolite.oxp.Rorschachhamster.Satellites
Title Satellites Satellites
Category Ambience Ambience
Author Rorschachhamster Rorschachhamster
Version 1.12 1.12
Tags
Required Oolite Version
Maximum Oolite Version
Required Expansions
Optional Expansions
Conflict Expansions
Dependent Expansions
  • oolite.oxp.Norby.Ambience_Collection:1.3
  • Information URL https://wiki.alioth.net/index.php/Satellites n/a
    Download URL https://wiki.alioth.net/img_auth.php/9/9d/Satellites.oxz n/a
    License CC BY-NC-SA 3 CC BY-NC-SA 3
    File Size n/a
    Upload date 1771214305

    Relationships Diagram

    Documentation

    Also read http://wiki.alioth.net/index.php/Satellites

    Readme.txt

    Satellites OXP.
    By Rorschachhamster aka Christian Sturke 2013
    License:CC-by-nc-sa-3.0
    
    Adds a random number (0 to 15, dependent on tech level and size of population) of four small satellites to every main planet. Many thanks to Eric Walch for the script/ai-combo I could use to bash on until I got them into orbit. ;)
    Oh, and I took a GNN Logo from Snoopers for one of the satellites. :)
    
    INSTALLATION
    Unzip the Satellites.oxp into your addons folder. 
    
    Version 1.12
    Added ship library entries for satellites.
    
    Version 1.11
    Added normal and specular maps and gloss values to all satellites.
    Moved (very limited) text to descriptions.plist for easier localisation.
    Fixed issue where Library Config settings were not being added correctly.
    
    Version 1.10
    Fixed small bug that was preventing 2 satellite types from having their beacons hidden on secondary planets.
    
    Version 1.09
    Fixed bugs with Library interface.
    
    Version 1.08
    Destroyed satellites will stay destroyed in the current system until you leave.
    Small bugfix in the save game routine.
    
    Version 1.07
    Small bugfix in the new populator.
    
    Version 1.06
    Reworked populator methods to use new functions, and to make the number and types of satellites the same in each system.
    Added satellites to any extra planets in the system.
    Added Library config options to turn off beacons and control the number of satellites spawned.
    
    version 1.05
    Added check if mainplanet is existant, in case of nova system... and corrected versions in scripts.
    
    version 1.04 
    Added AI-code by Dr.Tripsa, that will let spy-sats work as police, and reduzed texture size with Optipng thanks to a tip from Shipbuilder. Cleaned up the shipdata.plist, as well. 
    
    Version 1.03
    ...and if you change the texture names, you should change the names in the model.dats as well... and I should propably test before I release a "fixed" version. Sorry.
    
    Version 1.02
    --and deleted a paste and copy error... <_<�
    
    Version 1.01
    Changed the roles, models , textures etc. to more unique names to avoid compability issues, thanks again to Eric Walch. Corrected the demoship.plist, so that all 4 satellites can be seen... 
    
    Version 1.0
    Original release. 
    
    
        
    

    Equipment

    This expansion declares no equipment.

    Ships

    Name
    Surveillance-Satellite
    COMLR-Satellite
    COM-Satellite
    Satellite Telescope

    Models

    This expansion declares no models.

    Scripts

    Path
    Config/script.js
    "use strict";
    this.name = "Satellite";
    this.author = "Rorschachhamster";
    this.copyright = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0 license";
    this.description = "Populator for Satellites around Main Planet";
    
    this._mainBeacons = true;
    this._maxSatsMain = 6;
    this._epBeacons = true;
    this._maxSatsEP = 2;
    this._trueValues = ["yes", "1", 1, "true", true];
    this._extraPlanetSatellites = null;
    this._lastID = 0;
    this._destroyed = [];
    
    // configuration settings for use in Lib_Config
    this._satConfig = {
        Name: this.name, Alias: expandDescription("[rssat_config_alias]"), Display: expandDescription("[rssat_config_display]"), Alive: "_satConfig",
        Bool: {
            B0: { Name: "_mainBeacons", Def: true, Desc: expandDescription("[rssat_main_beacons]") },
            B1: { Name: "_epBeacons", Def: true, Desc: expandDescription("[rssat_extra_beacons]") },
            Info: expandDescription("[rssat_config_bool_info]")
        },
        SInt: {
            S0: { Name: "_maxSatsMain", Def: 6, Min: 0, Max: 15, Desc: expandDescription("[rssat_main_sats]") },
            S1: { Name: "_maxSatsEP", Def: 2, Min: 0, Max: 5, Desc: expandDescription("[rssat_extra_sats]") },
            Info: expandDescription("[rssat_config_sint_info]")
        }
    };
    
    //-------------------------------------------------------------------------------------------------------------
    this.startUp = function () {
        if (missionVariables.Satellites_MainBeacons) this._mainBeacons = (this._trueValues.indexOf(missionVariables.Satellites_MainBeacons) >= 0 ? true : false);
        if (missionVariables.Satellites_ExtraPlanetBeacons) this._epBeacons = (this._trueValues.indexOf(missionVariables.Satellites_ExtraPlanetBeacons) >= 0 ? true : false);
        if (missionVariables.Satellites_MaxMain) this._maxSatsMain = parseInt(missionVariables.Satellites_MaxMain);
        if (missionVariables.Satellites_MaxEP) this._maxSatsEP = parseInt(missionVariables.Satellites_MaxEP);
        if (missionVariables.Satellites_Destroyed) this._destroyed = JSON.parse(missionVariables.Satellites_Destroyed);
    }
    
    this.startUpComplete = function() {
        // register our settings, if Lib_Config is present
        if (worldScripts.Lib_Config) worldScripts.Lib_Config._registerSet(this._satConfig);
    }
    
    //-------------------------------------------------------------------------------------------------------------
    this.playerWillSaveGame = function () {
        missionVariables.Satellites_MainBeacons = this._mainBeacons;
        missionVariables.Satellites_ExtraPlanetBeacons = this._epBeacons;
        missionVariables.Satellites_MaxMain = this._maxSatsMain;
        missionVariables.Satellites_MaxEP = this._maxSatsEP;
        missionVariables.Satellites_Destroyed = JSON.stringify(this._destroyed);
    }
    
    //-------------------------------------------------------------------------------------------------------------
    this.shipWillEnterWitchspace = function () {
        this._destroyed = [];
    }
    
    //-------------------------------------------------------------------------------------------------------------
    this.systemWillPopulate = function () {
        this._lastID = 0;
        if (system.isInterstellarSpace) return;
        if (!system.mainPlanet) return;
        // random number of sats, but consistent per system
        var RaSaCount = system.scrambledPseudoRandomNumber(3873 + system.ID) * (system.techLevel + 1) * ((system.population + 33) / 100);
        if (RaSaCount > this._maxSatsMain) RaSaCount = this._maxSatsMain;
        for (var i = 0; i <= RaSaCount; i++) {
            // skip any satellites that might have been destroyed
            if (Array.isArray(this._destroyed) && this._destroyed.indexOf(i + 1) >= 0) continue;
            // random initial position of sats, but consistent per system
            var Schalter = Math.round(system.scrambledPseudoRandomNumber(11212 + system.ID + i) * 6);
    
            switch (Schalter) {
                case 1:
                    var pos = Vector3D((Math.random() - 0.5), (Math.random() - 0.5), 1.6).fromCoordinateSystem("pwp");
                    //system.legacy_addShipsAtPrecisely(this.role1, 1, "pwp", [(Math.random() - 0.5), (Math.random() - 0.5), 1.6]);
                    break;
                case 2:
                    var pos = Vector3D((Math.random() - 0.5), 1.6, (Math.random() - 0.5)).fromCoordinateSystem("pwp");
                    //system.legacy_addShipsAtPrecisely(this.role1, 1, "pwp", [(Math.random() - 0.5), 1.6, (Math.random() - 0.5)]);
                    break;
                case 3:
                    var pos = Vector3D(1.6, (Math.random() - 0.5), (Math.random() - 0.5)).fromCoordinateSystem("pwp");
                    //system.legacy_addShipsAtPrecisely(this.role1, 1, "pwp", [1.6, (Math.random() - 0.5), (Math.random() - 0.5)]);
                    break;
                case 4:
                    var pos = Vector3D((Math.random() - 0.5), (Math.random() - 0.5), - 1.6).fromCoordinateSystem("pwp");
                    //system.legacy_addShipsAtPrecisely(this.role1, 1, "pwp", [(Math.random() - 0.5), (Math.random() - 0.5), - 1.6]);
                    break;
                case 5:
                    var pos = Vector3D((Math.random() - 0.5), - 1.6, (Math.random() - 0.5)).fromCoordinateSystem("pwp");
                    //system.legacy_addShipsAtPrecisely(this.role1, 1, "pwp", [(Math.random() - 0.5), - 1.6, (Math.random() - 0.5)]);
                    break;
                case 6:
                    var pos = Vector3D(-1.6, (Math.random() - 0.5), (Math.random() - 0.5)).fromCoordinateSystem("pwp");
                    //system.legacy_addShipsAtPrecisely(this.role1, 1, "pwp", [ - 1.6, (Math.random() - 0.5), (Math.random() - 0.5)]);
                    break;
                default:
                    var pos = Vector3D((Math.random() - 0.5), (Math.random() - 0.5), 1.6).fromCoordinateSystem("pwp");
                    //system.legacy_addShipsAtPrecisely(this.role1, 1, "pwp", [(Math.random() - 0.5), (Math.random() - 0.5), 1.6]);
                    break;
            }
            // random types, but consistent in system
            var satType = i % 4; //Math.floor(system.scrambledPseudoRandomNumber(983 + system.ID + i) * 4);
            switch (satType) {
                case 0:
                    system.setPopulator("rs_satellite_" + i, {
                        location: "COORDINATES",
                        coordinates: pos,
                        callback: function (pos) {
                            var sat = system.addShips("[RSSatellite_1]", 1, pos, 0);
                            if (sat && sat.length > 0) {
                                sat[0].primaryRole = "RSsatellite";
                                sat[0].script._ID = worldScripts.Satellite.$getID();
                                sat[0].script._orbiting = system.mainPlanet;
                                if (worldScripts.Satellite._mainBeacons === false) {
                                    sat[0].beaconCode = "";
                                    sat[0].beaconLabel = "";
                                }
                            }
                        }
                    }
                    );
                    break;
                case 1:
                    system.setPopulator("rs_satellite_" + i, {
                        location: "COORDINATES",
                        coordinates: pos,
                        callback: function (pos) {
                            var sat = system.addShips("[RSSatellite_2]", 1, pos, 0);
                            if (sat && sat.length > 0) {
                                sat[0].primaryRole = "RSsatellite";
                                sat[0].script._ID = worldScripts.Satellite.$getID();
                                sat[0].script._orbiting = system.mainPlanet;
                                if (worldScripts.Satellite._mainBeacons === false) {
                                    sat[0].beaconCode = "";
                                    sat[0].beaconLabel = "";
                                }
                            }
                        }
                    }
                    );
                    break;
                case 2:
                    system.setPopulator("rs_satellite_" + i, {
                        location: "COORDINATES",
                        coordinates: pos,
                        callback: function (pos) {
                            var sat = system.addShips("[RSSatellite_3]", 1, pos, 0);
                            if (sat && sat.length > 0) {
                                sat[0].primaryRole = "RSsatellite";
                                sat[0].script._ID = worldScripts.Satellite.$getID();
                                sat[0].script._orbiting = system.mainPlanet;
                                if (worldScripts.Satellite._mainBeacons === false) {
                                    sat[0].beaconCode = "";
                                    sat[0].beaconLabel = "";
                                }
                            }
                        }
                    }
                    );
                    break;
                case 3:
                    system.setPopulator("rs_satellite_" + i, {
                        location: "COORDINATES",
                        coordinates: pos,
                        callback: function (pos) {
                            var sat = system.addShips("[RSSatellite_4]", 1, pos, 0);
                            if (sat && sat.length > 0) {
                                sat[0].primaryRole = "RSsatellite";
                                sat[0].script._ID = worldScripts.Satellite.$getID();
                                sat[0].script._orbiting = system.mainPlanet;
                                if (worldScripts.Satellite._mainBeacons === false) {
                                    sat[0].beaconCode = "";
                                    sat[0].beaconLabel = "";
                                }
                            }
                        }
                    }
                    );
                    break;
            }
        }
        // we'll add extra planet satellites via a timer, because we can't be sure when the planets will actually be created and ready to use
        this._extraPlanetSatellites = new Timer(this, this.$addExtraPlanetSatellites, 2, 0);
    }
    
    //-------------------------------------------------------------------------------------------------------------
    this.$addExtraPlanetSatellites = function $addExtraPlanetSatellites() {
        if (system.planets.length > 1) {
            var satCount = system.countShipsWithRole("RSsatellite");
            var idCount = 0;
            var list = system.planets;
            for (var i = 0; i < list.length; i++) {
                // only add to non-main planets and to planets with atmosphere
                var pl = list[i];
                if (pl.isMainPlanet === false && pl.hasAtmosphere === true) {
                    // random number, but consistent per system
                    var s = Math.floor(system.scrambledPseudoRandomNumber(1245 + system.ID) * (this._maxSatsEP + 1));
                    for (var j = 1; j <= s; j++) {
                        idCount += 1;
                        // skip any that have been destroyed
                        if (Array.isArray(this._destroyed) && this._destroyed.indexOf(satCount + idCount) >= 0) continue;
                        // random position
                        var eppos = pl.position.add(new Vector3D.randomDirection(pl.radius * (1 + (Math.random() * 0.4) + 0.2)));
                        // random types, but consistent in system
                        var satType = Math.floor(system.scrambledPseudoRandomNumber(785 + system.ID + i) * 4);
                        switch (satType) {
                            case 0:
                                var sat = system.addShips("[RSSatellite_1]", 1, eppos, 0);
                                if (sat && sat.length > 0) {
                                    sat[0].primaryRole = "RSsatellite";
                                    sat[0].script._ID = worldScripts.Satellite.$getID();
                                    sat[0].script._orbiting = pl;
                                    if (this._epBeacons === false) {
                                        sat[0].beaconCode = "";
                                        sat[0].beaconLabel = "";
                                    }
                                }
                                break;
                            case 1:
                                var sat = system.addShips("[RSSatellite_2]", 1, eppos, 0);
                                if (sat && sat.length > 0) {
                                    sat[0].primaryRole = "RSsatellite";
                                    sat[0].script._ID = worldScripts.Satellite.$getID();
                                    sat[0].script._orbiting = pl;
                                    if (this._epBeacons === false) {
                                        sat[0].beaconCode = "";
                                        sat[0].beaconLabel = "";
                                    }
                                }
                                break;
                            case 2:
                                var sat = system.addShips("[RSSatellite_3]", 1, eppos, 0);
                                if (sat && sat.length > 0) {
                                    sat[0].primaryRole = "RSsatellite";
                                    sat[0].script._ID = worldScripts.Satellite.$getID();
                                    sat[0].script._orbiting = pl;
                                    if (this._epBeacons === false) {
                                        sat[0].beaconCode = "";
                                        sat[0].beaconLabel = "";
                                    }
                                }
                                break;
                            case 3:
                                var sat = system.addShips("[RSSatellite_4]", 1, eppos, 0);
                                if (sat && sat.length > 0) {
                                    sat[0].primaryRole = "RSsatellite";
                                    sat[0].script._ID = worldScripts.Satellite.$getID();
                                    sat[0].script._orbiting = pl;
                                    if (this._epBeacons === false) {
                                        sat[0].beaconCode = "";
                                        sat[0].beaconLabel = "";
                                    }
                                }
                                break;
                        }
                    }
                }
            }
        }
    }
    
    //-------------------------------------------------------------------------------------------------------------
    this.$getID = function () {
        this._lastID += 1;
        return this._lastID;
    }
    Scripts/RSsatellite.js
    "use strict";
    this.name					= "RSsatellite.js";
    this.author					= "Rorschachhamster";
    this.copyright				= "Creative Commons: attribution, non-commercial, sharealike.";
    this.description			= "Satellites";
    
    //-------------------------------------------------------------------------------------------------------------
    this.shipSpawned = function() {
        this.ship.radiusorbit = ((this.ship.script._orbiting.radius * 1.1) + (Math.random() * this.ship.script._orbiting.radius * 0.5));
    }
    	
    //-------------------------------------------------------------------------------------------------------------
    this.OrbitSatellite = function() {
        var v = this.ship.position.add(this.ship.heading.multiply(10000));
        v = v.subtract(this.ship.script._orbiting.position).direction().multiply(this.ship.radiusorbit);
        this.ship.savedCoordinates = this.ship.script._orbiting.position.add(v);
    }
        
    //-------------------------------------------------------------------------------------------------------------
    this.shipDied = function(whom, why) {
        worldScripts.Satellite._destroyed.push(this.ship.script._ID);
    	this.ship.commsMessage("[END_OF_A_SAT]");
    };