Bizarre locations of Stranger's World Stations

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: winston, another_commander

Alnivel
Dangerous
Dangerous
Posts: 100
Joined: Fri Jun 10, 2022 7:05 pm

Re: Bizarre locations of Stranger's World Stations

Post by Alnivel »

dybal wrote: Tue Aug 23, 2022 6:26 pm
I looked at the Planetary Systems code... it adjusts the planetary system objects' positions every time the player launches from a station to simulate those objects moving along their orbits.
Isn't Planetary Systems moves orbits when the player launches from a station only for the first time? After first launch this.systemDone becomes true and never changes its value again, so orbit changing method is never called again in shipWillLaunchFromStation and shipLaunchedFromStation.
However, I can't be sure that when loading from a save, the same system rotation will be performed as when loading, so this can also break the save on stations (but this needs to be checked).
dybal
---- E L I T E ----
---- E L I T E ----
Posts: 499
Joined: Mon Feb 10, 2020 12:47 pm

Re: Bizarre locations of Stranger's World Stations

Post by dybal »

Alnivel wrote: Tue Aug 23, 2022 6:50 pm
dybal wrote: Tue Aug 23, 2022 6:26 pm
I looked at the Planetary Systems code... it adjusts the planetary system objects' positions every time the player launches from a station to simulate those objects moving along their orbits.
Isn't Planetary Systems moves orbits when the player launches from a station only for the first time? After first launch this.systemDone becomes true and never changes its value again, so orbit changing method is never called again in shipWillLaunchFromStation and shipLaunchedFromStation.
Oops! You are right, my bad!

Stranger, is that intentional?

I got the impression from a previous post that your intention was for the orbit positions to be updated whenever the player docked/launched, but that systemDone variable becoming true in this.shipLaunchedFromStation and this.shipExitedWitchspace changes that...
However, I can't be sure that when loading from a save, the same system rotation will be performed as when loading, so this can also break the save on stations (but this needs to be checked).
It uses clock.days and what I will simplify and call a hash of the system's name... the clock.days on which the [coordinates a station has when a new save is written] is based *might* not be the same as the clock.days when the game is saved (there was a in-game time period between the system generation - by witchspace jump or loading a previous savefile - and the time of the new save, and the game calendar might have moved to a new day), so yes, it can change.

That could be fixed by storing the clock.days used to create the system in a mission variable and using its value when re-creating the system after a savefile load. If we can know what the clock will be at witchspace exit, the createOrbits call could be moved to a system populator callback and my original proposed solution (Planetary Systems sun positioning in a high priority system populator callback, other OXPs sun or sun lane relative stations on lower priority system populator callbacks that look for the sun position in their bodies instead of using the position passed on by the system populator) would work.
Alnivel
Dangerous
Dangerous
Posts: 100
Joined: Fri Jun 10, 2022 7:05 pm

Re: Bizarre locations of Stranger's World Stations

Post by Alnivel »

I think I came up with a posible solution, but it's a bit "dirty". I'll leave it here, maybe it will give an idea for a better solution, or in case such a solution is not found. The idea is to wrap all *WillPopulate handlers to callculate orbits once per system before origin handler call. As a result, populations use the coordinates of an already rotated system without any direct changes in them and even in Planetary Systems.

Download link: https://www.dropbox.com/s/rckt7m0ct5pgx ... s.oxz?dl=1

I don't really know which stations I have located relative to the position of the sun, so I only checked the correct placement on CZGFs, they are in the zone of pleasant warming up by the star, which seems to be right.
User avatar
Cholmondely
Archivist
Archivist
Posts: 5365
Joined: Tue Jul 07, 2020 11:00 am
Location: The Delightful Domains of His Most Britannic Majesty (industrial? agricultural? mainly anything?)
Contact:

Re: Bizarre locations of Stranger's World Stations

Post by Cholmondely »

Downloaded, thanks! Will give it a stab tonight.
Comments wanted:
Missing OXPs? What do you think is missing?
Lore: The economics of ship building How many built for Aronar?
Lore: The Space Traders Flight Training Manual: Cowell & MgRath Do you agree with Redspear?
dybal
---- E L I T E ----
---- E L I T E ----
Posts: 499
Joined: Mon Feb 10, 2020 12:47 pm

Re: Bizarre locations of Stranger's World Stations

Post by dybal »

Alnivel wrote: Wed Aug 24, 2022 11:02 am
I think I came up with a posible solution, but it's a bit "dirty". I'll leave it here, maybe it will give an idea for a better solution, or in case such a solution is not found. The idea is to wrap all *WillPopulate handlers to callculate orbits once per system before origin handler call. As a result, populations use the coordinates of an already rotated system without any direct changes in them and even in Planetary Systems.

Download link: https://www.dropbox.com/s/rckt7m0ct5pgx ... s.oxz?dl=1

I don't really know which stations I have located relative to the position of the sun, so I only checked the correct placement on CZGFs, they are in the zone of pleasant warming up by the star, which seems to be right.
You are far better with javascript than I (me?... not a native English speaker...)! When nesting functions I am still not sure what 'this' will mean at each level, and if the variables from an upper level are visible...

You might put Planetary System OXP as required in the manifest, and test SW_PS_script and quit if undefined (if PS is installed, that would mean a syntax error in its script).

I suggest testing with an OXP solar positioned deterministic station (like Kiota Solar Station from WildShips OXP - even if the commies states deterministic:true in the populator settings in systemWillPopulate, I don't remember ever being able to save a game there... I don't know why, but I'm looking into it): while in the main station, spend time enough for the day to change (I suggest buying and installing something), then going to the OXP station, docking there, saving the game and reloading the savefile to see if anything breaks... the station coordinates when the system populates in the reload will be based on different orbit positions (since the day changed) from those when the savefile was created... you might yourself in the main station after reloading :D
User avatar
Cholmondely
Archivist
Archivist
Posts: 5365
Joined: Tue Jul 07, 2020 11:00 am
Location: The Delightful Domains of His Most Britannic Majesty (industrial? agricultural? mainly anything?)
Contact:

Re: Bizarre locations of Stranger's World Stations

Post by Cholmondely »

Alnivel wrote: Wed Aug 24, 2022 11:02 am
I think I came up with a possible solution, but it's a bit "dirty". I'll leave it here, maybe it will give an idea for a better solution, or in case such a solution is not found. The idea is to wrap all *WillPopulate" handlers to calculate orbits once per system before origin handler call. As a result, populations use the coordinates of an already rotated system without any direct changes in them and even in Planetary Systems.

Download link: https://www.dropbox.com/s/rckt7m0ct5pgx ... s.oxz?dl=1

I don't really know which stations I have located relative to the position of the sun, so I only checked the correct placement on CZGFs, they are in the zone of pleasant warming up by the star, which seems to be right.
Much, much better!

Thank you, Alnivel.

I'll see if I can faff about with it a bit, move the CZGF a little closer to the sun, add in the SLAPU's (if needed and possibly one or two others). But it is at least believably closer. Again, thanks!
Comments wanted:
Missing OXPs? What do you think is missing?
Lore: The economics of ship building How many built for Aronar?
Lore: The Space Traders Flight Training Manual: Cowell & MgRath Do you agree with Redspear?
Alnivel
Dangerous
Dangerous
Posts: 100
Joined: Fri Jun 10, 2022 7:05 pm

Re: Bizarre locations of Stranger's World Stations

Post by Alnivel »

And once again I was mistaken in that almost everything is alright...
As it turned out, everything worked due to the fact that the movement in orbits essentially did not work. Luckily, this is a relatively easy fix, but for now, you need to tweak the orbits script in Planet Orbits. Here is the tweaked code, I indicated the places where I made changes:

Code: Select all

"use strict";
this.name = "PlanetOrbits";
this.author = "Stranger";
this.description = "Adds planets on concentric orbits around the sun."
this.version = "1.8";
this.copyright = "This work is hereby placed in the public domain.";

/*
This script tightly based on Ebi, Kaks Orbits 1.2.1 script.
Original planet seeding procedure is overrided.
Moon filter radius increased to 2500 km.
Local year duration is a function of sun spectral class (reference to Sun Gear AstroLibrary included).
Periods of outer planets readjusted (0.5x multiplier added).
Original code reformatted to ease readings (yet too complicated to me!).
*/

function pow(x, y)
    {
    return Math.exp(y * Math.log(x));
    }

// Maximum number of planets to be added (See planetinfo.plist as well).
this.MaxPlanets = 8;
// Outer planet orbits scale factor
this.$scaleOrbits = 0.5;    // No works yet. Edit number in line 360 directly to have effect.
                            // Default scale value was 1.0. 

// Days per year of the Main planet
this.Yr = 360;

// Get weights by linearily interpolating the planet radii as defined
// by [X0,Y0] and [X1,Y1]. Those weights are used as multiplier when
// calculating orbital periods. If X0 or X1 are 0 or undefined "orbits"
// will select the minimum or maximum from the planets in the
// system.planets list.
this.X0 = 2500 * 10;		// planetinfo.plist minimum in game units
this.X1 = 18000 * 10;		// planetinfo.plist maximum in game units
this.Y0 = pow(2, 3.0 / 4.0);	// Compensate Keplers law and take square root
this.Y1 = pow(3.5, 3.0 / 4.0);  // Thus, scale radius by values in [2,3.5]
// System spread factor
this.SpreadFactor = 3.0;
// Add a random offset in the range [0, t*RandomOffsetFactor] to the
// orbital period t of a planet.
this.RandomOffsetFactor = 0.1;
// Log to logfile (1) and/or console (2)
this.Verbose = 0; //1|4;
// Oh man, it's too tricky to get the OXP initialization order right
// for Oolite. It may be random, therefore I offer the farsun
// functionality here as well. Shifts the sun and increases (or
// decreases if less than 1) its distance to the main planet by this
// factor. Thus, the value 1 will not show any effect.
this.FarsunMultiplier = 1; // 6;

this.Log = function(dest, msg)
    {
    if (dest & 1)
	log (msg);
    if (dest & 2)
	player.commsMessage(msg);
    }

this.startUp = this.reset = function()
    {
    this.systemDone = false;
    this.Log(this.Verbose & 1, "Initialising OXP " + this.name);
    }

this.shipWillLaunchFromStation  =  function()
    {
    if (!this.systemDone)
        {
        this.shipWillExitWitchspace();
        delete this.shipWillLaunchFromStation;
        }
    }

this.shipLaunchedFromStation = function()
    {
    if (!this.systemDone)
	this.shipExitedWitchspace();
    }

this.shipWillExitWitchspace = function()
    {
    if (system.isInterstellarSpace) return;
    var w = worldScripts.AstroLibrary;
    var sunRadius = system.sun.radius;
    var sunMass = w.$astroLib_sunMass(sunRadius);
    var mainYr = w.$astroLib_solPeriod(sunMass);
    this.Yr = mainYr;
    this.createOrbits();
    }

this.shipExitedWitchspace = function()
    {
    if (system.isInterstellarSpace) return;
    this.systemDone = true;
    if ((this.Verbose & (2|4)) == 0 || this.innerPlanets == 0)
	return;
    var msg =
	system.name + ": " +
	this.innerPlanets + "+" +
	this.outerPlanets + " planets";
    if (this.info != undefined)
	msg = msg + "[" + this.info + "]";
    this.Log(2, msg);
    }

this.isMoon = function(p)
    {
    // 10 * Radius from planetinfo.plist
    return !p.isMainPlanet && p.radius < 2500 * 10;
    }

this.mkPlanetIndex = function mkPlanetIndex()
    {
    function aPlanet(entity)
        {
        return entity.isPlanet
        }
  
    return system.filteredEntities(this, aPlanet, system.sun);
    }

this.planetsMinMax = function(x)
    {
    var needX0 = this.X0 == undefined || this.X0 == 0;
    var needX1 = this.X1 == undefined || this.X1 == 0;
    var np = system.planets.length;
    var x0 = +Infinity, x1 = 0;

    if (needX0 || needX1)
        {
        for (var i = 0; i < system.planets.length; ++i)
            {
            if (this.isMoon(system.planets[i]))
                {
                np--;
                continue;
                }
            if (system.planets[i].radius > x1)
            x1 = system.planets[i].radius;
            if (system.planets[i].radius < x0)
            x0 = system.planets[i].radius;
            }
        }
    x[0] = needX0 ? x0 : this.X0;
    x[1] = needX1 ? x1 : this.X1;
    return np;
    }

this.addPlanets = function(id)
    {
    // Add planets in system dependent order. Id is used here in two
    // ways:
    // - Its lower bits determine the planets in planetinfo.plist
    // - It represents a permutation and hence the order how the selected
    //   planets are added (see wikipedia for factoradic) and Entity-IDs
    //   are assigned.

    var selectPlanet1 = system.scrambledPseudoRandomNumber(163);
    var selectPlanet2 = system.scrambledPseudoRandomNumber(171);
    var selectPlanet3 = system.scrambledPseudoRandomNumber(179);
    var selectPlanet4 = system.scrambledPseudoRandomNumber(187);
    var selectPlanet5 = system.scrambledPseudoRandomNumber(195);
    var selectPlanet6 = system.scrambledPseudoRandomNumber(203);
    var selectPlanet7 = system.scrambledPseudoRandomNumber(211);
    var selectPlanet8 = system.scrambledPseudoRandomNumber(219);

    var selectPlanetData = [
    selectPlanet1,
    selectPlanet2,
    selectPlanet3,
    selectPlanet4,
    selectPlanet5,
    selectPlanet6,
    selectPlanet7,
    selectPlanet8
    ];

    var v = new Array(this.MaxPlanets), w = new Array(this.MaxPlanets);
    // Avoid huge factorials by grouping up to 12 planets.
    var mask = id;
    for (var i = 0; i < this.MaxPlanets && mask != 0 && id != 0; )
        {
        var m = 0, f = 1;
        // Type conversion prohibits use of the shift operator. Kind
        // of weird to apply "&" on a floating point number!
        for (; m < 12 && i < this.MaxPlanets; ++i, mask = Math.floor(mask / 2))
            if ((mask & 1) != 0)
            v[m] = i, w[m] = m, f *= ++m;
        var fn = id % f;	// fn = sum(j in [0..m-1]:j!*c[j]), c[j] <= j
        id = Math.floor(id / f);
        for (; m > 0; --m)
            {
            f /= m;
            var c = Math.floor(fn / f);
            fn -= f * c;
            this.Log(this.Verbose,
                "" + m + ":selecting oplanet" +
                (v[w[c]] + 1) + "," + w[c] + "," +
                c + "," + f + "," + fn);

            var addPlanetTagIn = v[w[c]];
            var addPlanetTagOut = 10*(addPlanetTagIn + 1) + Math.floor(selectPlanetData[addPlanetTagIn]*10);

            system.addPlanet("oplanet" + addPlanetTagOut);
//          system.addPlanet("oplanet" + (v[w[c]] + 1));
            for (; c + 1 < m; ++c)
            w[c] = w[c + 1];
            }
        }
    }

this.createOrbits = function()
    {
    this.outerPlanets = 0;
    this.innerPlanets = 0;

    var s = system.sun;
    // Is there system.witchpoint?
    //var w = system.shipsWithPrimaryRole("buoy-witchpoint")[0]; // <-- tweaked: witchpoint always in (0, 0, 0)
    var pm = system.mainPlanet;

    //if (!s || !w || !pm) return; // <-- tweaked: variable w is removed
    if (!s || !pm) return;    

    s.position=(pm.position.add(
	s.position.subtract(pm.position).multiply(this.FarsunMultiplier)));

    function PlanetVecs(s, w, p)
        {
        // "this" for sizzies:(
        this.s = s;
        this.sp = p.subtract(s);
        this.dist = this.sp.magnitude();
        // Rotation axis, perpendicular to the plane of triangle [s,p,w]
        this.rx = this.sp.cross(w.subtract(s)).direction();
        this.q = new Quaternion (1,0,0,0);
        this.rotateQ = function(q, axis, angle)
            {
            // Ahruman's replacement for buggy Quaternion.rotate()
            angle *= 0.5;
            axis = axis.multiply(Math.sin(angle));
            return q.multiply([Math.cos(angle), axis.x, axis.y, axis.z]);
            }
        this.position = function(a, d)
            {
            // Move sun to origin, rotate planet, and translate back again
            return this.s.add(this.sp.rotateBy(
            this.rotateQ(this.q, this.rx, a)).multiply(d));
            }
        }

    var pv = new PlanetVecs(s.position, /* w.position */ new Vector3D(), pm.position); // <-- tweaked: witchpoint always in (0, 0, 0)

    function SystemId(name)
        {
        this.prime = 29;
        this.name = name;
        this.code = 0;

        this.charToInt = function(c)
            {
            var l = "abcdefghijklmnopqrstuvwxyz";
            var i = l.indexOf(c);
            if (i >= 0)
            return i;
            var u = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
            i = u.indexOf(c);
            return i >= 0 ? i : 0; 
            }

        this.nextPrime = function()
            {
            var p = this.prime;
            if ((p & 1) == 0)
            ++p;
            for (;;)
                {
                p += 2;
                for (var i = 3; ; i += 2)
                    {
                    if (i * i > p)
                    return this.prime = p;
                    if (p % i == 0)
                    break;
                    }
                }
            }

        this.calcCode = function()
            {
            // Use letters of n as digits of number with base prime.
            var l = this.name.length;
            var x = 0;
            var pp = 1;
            for (var i = 0; i < l; ++i)
                {
                x += this.charToInt (this.name.charAt(i)) * pp;
                pp *= this.prime;
                }
            return this.code = x;
            }
        }
    // Derive numbers from system name
    var id = new SystemId(system.name);

    id.calcCode();
    this.Log (this.Verbose, system.name + ":id is " + id.code);
    this.addPlanets(id.code);
    this.innerPlanets = 1;

    var x = [+Infinity, 0];
    var np = this.planetsMinMax(x);
    if (np <= 1)
    return;

    function Map(x0, y0, x1, y1)
        {
        var m, X0 = x0, Y0 = y0;
        if (x0 == x1 || y0 == y1)
            {
            m = (y0 + y1) / 2;
            this.interpolate = function(x) { return m; }
            }
        else
            {
            m = (y1 - y0) / (x1 - x0);
            this.interpolate = function(x) { return Y0 + m * (x - X0); }
            }
        }
    var map = new Map(x[0], this.Y0, x[1], this.Y1);

    function PlanetWeights(p, s)
        {
        this.c = 0, this.p = p, this.s = s;
        this.product = function() { return this.s * this.c * this.p; }
        this.next = function() { this.p = this.c; }
        }
    var ow = new PlanetWeights(
	map.interpolate(pm.radius),    
	pow(this.SpreadFactor, 1.0 / (np - 1)));
    var iw = new PlanetWeights(ow.p, ow.s);

    function InnerOrbitalPeriod(orbits, s)
        {
        this.t = orbits.Yr;
        var r = orbits.RandomOffsetFactor;
        r /= 1 + r;
        var f = orbits.Yr / (orbits.Y1 * orbits.Y1 * s);
        this.calc = function(id, iw)
            {
            var mod = this.t * r;
            return this.t - id.code % mod - f * iw.product();
            }
        }
    var iop = new InnerOrbitalPeriod(this, iw.s);

    function OuterOrbitalPeriod(orbits)
        {
        this.t = orbits.Yr;
        var r = orbits.RandomOffsetFactor;
        var f = orbits.Yr;
        this.calc = function(id, ow)
            {
            var t = this.t + 0.5 * f * ow.product();
            var mod = t * r;
            if (mod != 0)
            t += id.code % mod;
            return t;
            }
        }
    var oop = new OuterOrbitalPeriod(this);

    // Grrr, need an index sorted by Entity.ID as planets[] order may
    // change on different system entries.
    var planetsarray = this.mkPlanetIndex();
    var today = clock.days + id.code;
    var a = 2.0 * Math.PI * (today % this.Yr) / this.Yr;
    var info = (180 * a / Math.PI).toFixed();

    this.Log(this.Verbose, system.name + ":" +
	     today + "," +
	     ow.p.toFixed(4) + "," +
	     ow.s.toFixed(4) + "," +
	     (pm.radius  / 10).toFixed()+ "," +
	     (180 * a / Math.PI).toFixed());

    // Pretend to rotate the main planet.
    var pmOffset = pm.position.subtract(pv.position(a, 1));

    for (var i = 0; i < planetsarray.length; ++i)
        {
        var pi = planetsarray[i];
        if (pi.isMainPlanet || this.isMoon(pi))
            continue;
        iw.c = ow.c = map.interpolate(pi.radius);

        id.nextPrime();
        id.calcCode();

        // Current planet's days per year. Try to make it an inner
        // planet. If that fails it will be an outer planet.
        var d;
        var t = iop.calc(id, iw);
        var inner = t > this.Yr / 3;
        if (inner)
            {
            // Orbit Radius in planet-sun units (3. Kepler's law)
            d = pow(t / this.Yr, 2.0 / 3.0);
            inner =
            // idea: 0.3 * pv.dist / pm.r <= d * pv.dist / pi.r 
            pm.radius * d >= pi.radius * 0.3  &&
            d * pv.dist > 15 * s.radius;
            }

        if (!inner)
            {
            t = oop.calc(id, ow);
            d = pow(t / this.Yr, 2.0 / 3.0);
            }

        // Current angle in radians
        var a = 2.0 * Math.PI * (today % t) / t;
        var aa = (180.0 * a / Math.PI).toFixed();
        this.Log(this.Verbose,
            system.name + "[" + i + "]" + ":" +
            id.prime + "," +
            id.code + "," +
            (pi.radius / 10).toFixed() + "," +
            ow.c.toFixed(4) + "," +
            t.toFixed() + "," +
            d.toFixed(4) + "," +
            aa);
        pi.position=pv.position(a, d).add(pmOffset);
        if (inner)
            {
            iw.next(), iop.t = t, ++this.innerPlanets;
            info = aa + "," + info;
            }
        else
            {
            ow.next(), oop.t = t, ++this.outerPlanets;
            info = info + "," + aa;
            }
        }
    s.position=(s.position.add(pmOffset));
    this.info = info;
    }

To go into a bit of detail, the stranger's script uses the witchpoint buoy to get the witchpoint's position. My script calls this code before buoy appears in the system, which causes the code to exit without doing anything to the system.
Since the witchpoint is always the start of absolute coordinate system - (0, 0, 0) , it can simply be written directly in the script itself.
@stranger, could you consider updating the Planetary System with this suggestion?

dybal wrote: Wed Aug 24, 2022 3:55 pm
You might put Planetary System OXP as required in the manifest, and test SW_PS_script and quit if undefined (if PS is installed, that would mean a syntax error in its script).
Great suggestion, thanks for the reminder! I'll add it in the next version if I ever get around to it.
By the way, this oxz is entirely the result of a midnight insight, so I didn’t really pay attention to everything else, except, in fact, the working capacity of the solution.

dybal wrote: Wed Aug 24, 2022 3:55 pm
I suggest testing with an OXP solar positioned deterministic station (like Kiota Solar Station from WildShips OXP - even if the commies states deterministic:true in the populator settings in systemWillPopulate, I don't remember ever being able to save a game there... I don't know why, but I'm looking into it): while in the main station, spend time enough for the day to change (I suggest buying and installing something), then going to the OXP station, docking there, saving the game and reloading the savefile to see if anything breaks... the station coordinates when the system populates in the reload will be based on different orbit positions (since the day changed) from those when the savefile was created... you might yourself in the main station after reloading :D
I can confirm that such a teleportation to the main station is indeed possible, however, according to my observations, it seems that it will take more than a day in the one system to get this. And thanks for the suggested stations.
Regarding stations from Commies, this was one of my fears that could break my solution, but since it showed up even without this tweak, I just assumed save/load broke something else from my oxp.
Cholmondely wrote: Wed Aug 24, 2022 8:25 pm
You are welcome!
I would like to note that I also did this to a great degree for myself - I have been using this part of SW World for some time already and was already thinking about giving it up, because before this thread I thought that nothing could be done about this throwing OXP stations and waypoints into middle of nowhere.
dybal
---- E L I T E ----
---- E L I T E ----
Posts: 499
Joined: Mon Feb 10, 2020 12:47 pm

Re: Bizarre locations of Stranger's World Stations

Post by dybal »

BTW, I found out why I couldn't save at CZGF and SLAPU even if they are deterministic: the core game also checks if the station maxSpeed is 0, and both of them have max_flight_speed = 0.001 in their shipdata...
dybal
---- E L I T E ----
---- E L I T E ----
Posts: 499
Joined: Mon Feb 10, 2020 12:47 pm

Re: Bizarre locations of Stranger's World Stations

Post by dybal »

Alnivel wrote: Wed Aug 24, 2022 10:42 pm
dybal wrote: Wed Aug 24, 2022 3:55 pm
You might put Planetary System OXP as required in the manifest, and test SW_PS_script and quit if undefined (if PS is installed, that would mean a syntax error in its script).
Great suggestion, thanks for the reminder! I'll add it in the next version if I ever get around to it.
By the way, this oxz is entirely the result of a midnight insight, so I didn’t really pay attention to everything else, except, in fact, the working capacity of the solution.
It's a *great* job, midnight or not! :)
User avatar
Cholmondely
Archivist
Archivist
Posts: 5365
Joined: Tue Jul 07, 2020 11:00 am
Location: The Delightful Domains of His Most Britannic Majesty (industrial? agricultural? mainly anything?)
Contact:

Re: Bizarre locations of Stranger's World Stations

Post by Cholmondely »

Alnivel's solution works at the cost of preventing the dynamic orbits built into Strangers World.

It seems a crying shame to do this.



Again, Stranger changes the distance of the sun in his Sun Gear OXP - and his solar orbiting stations seem to orbit the sun's new location.

Stranger's short .js file to position stations in solar orbit is this (from his Orbital Stations OXP):

Code: Select all

"use strict";
this.name					= "OrbitStation_Solar";
this.author					= "Stranger";
this.copyright				= "Creative Commons: attribution, non-commercial, sharealike.";
this.description			= "Spawn processing complex";
this.version				= "2.4";
"use strict";

this.shipSpawned = function()
    {
    if (system.isInterstellarSpace) return;
    this.$radiusOrbit_Solar = 10 * system.sun.radius;
    }
	
this.OrbitSatellite = function()
	{
    var v = this.ship.position.add(this.ship.heading.multiply(10000));
    v = v.subtract(system.sun.position).direction().multiply(this.$radiusOrbit_Solar);
    this.ship.savedCoordinates = system.sun.position.add(v);
	}
This presumably works with both SunGear on its tod (one solar distancing) and also with HMP added in (possibly adding a second solar distancing - maybe due to planetary radius changes?)

There seems to be nothing in his Habitable Main Planets OXP other than a list of planetary radii for every single main (inhabited) planet in the Ooniverse. And Sun Gear OXP only defines planet orbits (not station orbits as far as I can ascertain). The HMP's rejig of planetary radii presumably leads to a second repositioning of the sun in Stranger's World after Sun Gear has done the first such.

BUT! The code in Commies for SLAPUs & CZGFs is this:

Code: Select all

 (earlier gubbins about other spawning Commie ships & Astrogulags)...
    if (system.techLevel > 6 && system.techLevel < 10) {
		if (!worldScripts.station_validator || worldScripts.station_validator.$deaths("comczgf").length === 0) {
			var posFct = Vector3D(0, 0.40, 2.6).fromCoordinateSystem("sps");
			system.setPopulator("commies_comczgf", {
				location: "COORDINATES",
				coordinates: posFct,
				deterministic: true,
				callback: function(pos) {
					var fct = system.addShips("comczgf", 1, pos, 0)[0];
					if ((!fct || fct.length === 0) && worldScripts.communist_population._debug === true) log("commies.populator", "OOPS! No factories spawned");
				}}
			);
		}
		//system.legacy_addShipsAt("comczgf", 1, "sps", [0, 0.40, 2.6]);
	}
    if (system.techLevel > 9) {
		if (!worldScripts.station_validator || worldScripts.station_validator.$deaths("comslapu").length === 0) {
			var posSlapu = Vector3D(0, 0.40, 2.6).fromCoordinateSystem("sps");
			system.setPopulator("commies_slapu", {
				location: "COORDINATES",
				coordinates: posSlapu,
				deterministic: true,
				callback: function(pos) {
					var sla = system.addShips("comslapu", 1, pos, 0)[0];
					if ((!sla || sla.length === 0) && worldScripts.communist_population._debug === true) log("commies.populator", "OOPS! No slapu's spawned");
				}}
... followed by a truly impressive collection of brackets and parantheses


Can somebody kindly show this dumb pilot how to either (i) modify the Commie js.script or (ii) install an override into Stranger's "OrbitStation_Solar.js" so that I can finally see some solar orbiting SLAPUs/CZGFs?


Reference
Examples for G1 Tibedied & Qube
Sun Gear planetinfo.plist:

Code: Select all

	"0 0" = {
		"sun_radius" = 900000;
		"sun_distance" = 34125780;
		"sun_color" = "0.999 0.782 0.611 1";
	};
	"0 1" = {
		"sun_radius" = 939961;
		"sun_distance" = 40311580;
		"sun_color" = "0.999 0.817 0.667 1";
	};
Planetary Systems planetinfo.plist is only for the various types of planets in the system (Mercury analogues, earth analogues, etc.)

HMP planetinfo.plist (there is no javascript.js file in this OXP)

Code: Select all

	"0 0" = {
		radius = 5803;
	};
	"0 1" = {
		radius = 6109;
	};
Links to Hiran's Database (which displays all javascript files inside each oxz)
SunGear OXP javascripts: https://ooliteproject.github.io/oolite- ... nGear.html
Planetary Systems OXP javascripts: https://ooliteproject.github.io/oolite- ... stems.html
Orbital Station OXP javascripts: https://ooliteproject.github.io/oolite- ... tions.html
Comments wanted:
Missing OXPs? What do you think is missing?
Lore: The economics of ship building How many built for Aronar?
Lore: The Space Traders Flight Training Manual: Cowell & MgRath Do you agree with Redspear?
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4830
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: Bizarre locations of Stranger's World Stations

Post by phkb »

Cholmondely wrote: Wed Jan 31, 2024 10:20 pm
Can somebody kindly show this dumb pilot how to either (i) modify the Commie js.script or (ii) install an override into Stranger's "OrbitStation_Solar.js" so that I can finally see some solar orbiting SLAPUs/CZGFs?
I'm having a look - but can I ask, is it true you can't save your game at *any* of Stranger's orbital stations? I'm looking at the spawning mechanic and literally none of them are spawned during systemWillPopulate, and none of them have the deterministic flag set to true. I mean, if they're orbiting planets, then the location of the station will constantly change, thus breaking any possibility of saving, so perhaps I'm answering my own question. But I'd just like to confirm that.
User avatar
Cholmondely
Archivist
Archivist
Posts: 5365
Joined: Tue Jul 07, 2020 11:00 am
Location: The Delightful Domains of His Most Britannic Majesty (industrial? agricultural? mainly anything?)
Contact:

Re: Bizarre locations of Stranger's World Stations

Post by Cholmondely »

phkb wrote: Wed Jan 31, 2024 11:45 pm
Cholmondely wrote: Wed Jan 31, 2024 10:20 pm
Can somebody kindly show this dumb pilot how to either (i) modify the Commie js.script or (ii) install an override into Stranger's "OrbitStation_Solar.js" so that I can finally see some solar orbiting SLAPUs/CZGFs?
I'm having a look - but can I ask, is it true you can't save your game at *any* of Stranger's orbital stations? I'm looking at the spawning mechanic and literally none of them are spawned during systemWillPopulate, and none of them have the deterministic flag set to true. I mean, if they're orbiting planets, then the location of the station will constantly change, thus breaking any possibility of saving, so perhaps I'm answering my own question. But I'd just like to confirm that.
Thanks for this!

The main orbitals (around the main planet), yes. The others, no - or at least I've yet to find one.

The orbitals orbit the planets/moons which orbit the sun/planets - so there is a double or treble whammy there! But not being able to save is no big deal. Especially with Dybal's "Save in Flight" which works just fine in SW with massively distant stations in the middle of nowhere!
Comments wanted:
Missing OXPs? What do you think is missing?
Lore: The economics of ship building How many built for Aronar?
Lore: The Space Traders Flight Training Manual: Cowell & MgRath Do you agree with Redspear?
User avatar
Cholmondely
Archivist
Archivist
Posts: 5365
Joined: Tue Jul 07, 2020 11:00 am
Location: The Delightful Domains of His Most Britannic Majesty (industrial? agricultural? mainly anything?)
Contact:

Re: Bizarre locations of Stranger's World Stations

Post by Cholmondely »

Oh - just to mention, External Docking/Nuit2.0 are loaded and still no problems! Found this in the latest.log but everything seems to work just fine. And I don't think that Nuits spawn in Commie systems.

Code: Select all

20:28:39.113 [bigShips_populator] GlobalLog (OOJSGlobal.m:266): 1 big trader(s) added to the Vetitice system.
20:28:41.873 [strings.conversion.vector] ScanVectorFromString (OOStringParsing.m:98): ***** ERROR: cannot make vector from '0.0, -2.5, 20.0': could not scan a float value.
20:28:41.879 [strings.conversion.vector] ScanVectorFromString (OOStringParsing.m:98): ***** ERROR: cannot make vector from '0.0, -2.5, 20.0': could not scan a float value.
20:28:41.911 [strings.conversion.vector] ScanVectorFromString (OOStringParsing.m:98): ***** ERROR: cannot make vector from '0.0, -2.5, 20.0': could not scan a float value.
20:28:41.914 [strings.conversion.vector] ScanVectorFromString (OOStringParsing.m:98): ***** ERROR: cannot make vector from '0.0, -2.5, 20.0': could not scan a float value.
20:28:41.917 [strings.conversion.vector] ScanVectorFromString (OOStringParsing.m:98): ***** ERROR: cannot make vector from '0.0, -2.5, 20.0': could not scan a float value.
20:28:41.919 [strings.conversion.vector] ScanVectorFromString (OOStringParsing.m:98): ***** ERROR: cannot make vector from '0.0, -2.5, 20.0': could not scan a float value.
20:28:41.922 [strings.conversion.vector] ScanVectorFromString (OOStringParsing.m:98): ***** ERROR: cannot make vector from '0.0, -2.5, 20.0': could not scan a float value.
20:28:41.925 [strings.conversion.vector] ScanVectorFromString (OOStringParsing.m:98): ***** ERROR: cannot make vector from '0.0, -2.5, 20.0': could not scan a float value.
20:28:41.927 [strings.conversion.vector] ScanVectorFromString (OOStringParsing.m:98): ***** ERROR: cannot make vector from '0.0, -2.5, 20.0': could not scan a float value.
20:28:42.122 [strings.conversion.vector] ScanVectorFromString (OOStringParsing.m:98): ***** ERROR: cannot make vector from '0.0, -2.5, 20.0': could not scan a float value.
20:28:42.134 [strings.conversion.vector] ScanVectorFromString (OOStringParsing.m:98): ***** ERROR: cannot make vector from '0.0, -2.5, 20.0': could not scan a float value.
20:28:42.768 [Sunskimmers] GlobalLog (OOJSGlobal.m:266): 1 ship(s) added in trader_5
20:28:42.768 [Sunskimmers] GlobalLog (OOJSGlobal.m:266): [Ship "Orca Worker's Commuter" position: (-4.36442e+06, 3.29362e+06, 4.27741e+06) scanClass: CLASS_NEUTRAL status: STATUS_IN_FLIGHT]
20:28:43.048 [strings.conversion.vector] ScanVectorFromString (OOStringParsing.m:98): ***** ERROR: cannot make vector from '0.0, -2.5, 20.0': could not scan a float value.
20:28:43.050 [Sunskimmers] GlobalLog (OOJSGlobal.m:266): 1 ship(s) added in police_3
20:28:43.050 [Sunskimmers] GlobalLog (OOJSGlobal.m:266): [Ship "People's Police Ray" position: (-8.7198e+06, 6.59786e+06, 8.55434e+06) scanClass: CLASS_POLICE status: STATUS_IN_FLIGHT]
20:28:43.419 [strings.conversion.vector] ScanVectorFromString (OOStringParsing.m:98): ***** ERROR: cannot make vector from '0.0, -2.5, 20.0': could not scan a float value.
20:28:43.945 [strings.conversion.vector] ScanVectorFromString (OOStringParsing.m:98): ***** ERROR: cannot make vector from '0.0, -3, 24.0': could not scan a float value.
20:28:43.948 [strings.conversion.vector] ScanVectorFromString (OOStringParsing.m:98): ***** ERROR: cannot make vector from '0.0, -3, 24.0': could not scan a float value.
20:28:43.950 [strings.conversion.vector] ScanVectorFromString (OOStringParsing.m:98): ***** ERROR: cannot make vector from '0.0, -3, 24.0': could not scan a float value.
Comments wanted:
Missing OXPs? What do you think is missing?
Lore: The economics of ship building How many built for Aronar?
Lore: The Space Traders Flight Training Manual: Cowell & MgRath Do you agree with Redspear?
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4830
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: Bizarre locations of Stranger's World Stations

Post by phkb »

I'm a bit hesitant to share this, as I've not really tested it at all. But it might at least set you on path to achieving what you're looking for.

CommiesOrbitUpdate.oxz

This is to be used in addition to the standard Commies mod, and the Orbital Stations mod, both of which are set as requirements.

Changes were need in the AI's, shipdata, and scripting. With the AI's, I am *really* not sure what will happen. Exciting, eh?
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4830
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: Bizarre locations of Stranger's World Stations

Post by phkb »

Cholmondely wrote: Thu Feb 01, 2024 12:03 am
Found this in the latest.log but everything seems to work just fine. And I don't think that Nuits spawn in Commie systems.
Correct, they shouldn't. And I don't recognise those numbers at all. They're not from EDS or Nuit 2.0. Something else is going wrong there, I suspect.
Post Reply