Author Topic: Orbit Speed Problem, Please Help...  (Read 604 times)

Bri

  • Newbie
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Orbit Speed Problem, Please Help...
« on: July 11, 2013, 02:24:07 PM »
Hello,

I was doing some modding to improve the realism of the galaxies generated in Star Ruler, despite being an excellent game, the odd star sizes, orbits and planet types have always bothered me.

I've managed to alter most everything to my liking, and I now have an almost perfectly realistic planet-star scale, M-B stars, also to realistic scale with one another, randomly generated galaxies produce believable planet types etc. but I've now come up against an infuriating problem, planet orbit speed.

Initially, orbit speed is acceptable with a simple:

   orbDesc.MassRadius = 200.f + (starDesc.Radius / 10);
   orbDesc.Mass = 200.f * starMassFactor;

I figured I'd tweak it later, maybe in conjunction with plDesc.Mass, but in my first alpha tests I found that the moment a planet is moved from its initial orbit (with a planetary thruster) and then re-parked in orbit it begins orbiting at... let's just call it faster than the speed of light.

I've tried everything that I can think of over the last two days, but I'm really just an amateur scripter, so I was hoping someone might have an idea or two of where I can look for the value to A) keep orbit speed the same, even after altering its orbit with a planetary thruster, or B) figure out what one can change to alter the orbit of a planet after it has been moved.

Currently, the post-move-orbit-speed seems to be tied to star size, and the only thing I ever managed to do that even touched it was reduce star size, by about 90%, but reducing star size kind of defeats the whole point of make things at a realistic scale, wouldn't you agree?

Star size is 200 (small Ms) to 6600 (large Bs). Small Ms (200ish) size results in an acceptable, though fast orbit, but by mid Ks (800ish) the orbit speed becomes ridiculous, orbiting the star in only a couple of seconds, then it just gets worse from there.

So far I have explored & tinkered with everything I could find in map_generation and scripts\server in general, but to no avail, and I'm quite frustrated after finding a way to get everything else working at a realistic scale (no zoom problems, minimal cut away problems, no orbit overlap, decently balanced gameplay etc.) that I should be thwarted from establishing my metropolis systems complete with a dozen stars' planets in orbit around a single G or F class star.

Alternatively, if this simply cannot be done, does anyone have any idea how to reduce moon & asteroid size? If nothing else I could simply reduce the scale of everything to 10% of what I have it currently, but that would result in moons twice the size of the planets they orbit and asteroids nearly the size of the gas giants. Plus I encountered more zoom-in cut away problems at smaller scales (planets < 2).

Thanks for any help anyone can provide!

Jon Micheelsen

  • Contributor
  • Sentient
  • *
  • Posts: 76
  • Karma: +19/-0
    • View Profile
Re: Orbit Speed Problem, Please Help...
« Reply #1 on: July 12, 2013, 07:36:04 AM »
Sorry to say, but real scale is not possible with the engine, only simulated sense of scale. If a system gets too big - which is still not even near real scale, you break the zoom, and can't zoom on the system. Also way before that problem - it becomes impossible to zoom in on a planet, and even more so on a ship, as they simply disappears if you try to zoom on them. That said.

sqrt() is your friend, for making relative scaling to size - if you want orbits to function.

orbDesc.MassRadius = sqrt(sqrt(starDesc.Radius)) * specialM * 100.f;
orbDesc.Mass = sqrt(sqrt(starDesc.Radius)) * starMassFactor * specialM * 100.f;

This calculation is the result of A LOT of testing. SpecialM, short for special mass, is a float set in my star code. It is 1 for all main sequence and sub-giants. Below that it's higher, above that it's lower. White dwarfs and neutron stars are high density, giants are relatively lower density, the larger they are.

6600 is very big :o My red C-Class Hypergiants max out at around 5700, they never generate planets(though they could with the above formula), and they are truly gigantic in game. Even a few systems away, they can still provide daylight on the dark side of a planet.

There are planets "out there" that orbit in only a couple of earth hours, but in the game a colony ship would never be able to catch the suckers, so realism will have to be adjusted to gameplay mechanics... A human player can catch a fast planet with a manual approach, but the ai is lost in the cause.

Bri

  • Newbie
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: Orbit Speed Problem, Please Help...
« Reply #2 on: July 12, 2013, 02:53:14 PM »
Thanks so much for replying!

Unfortunately, those numbers didn't seem to affect the post-planetary thruster speed, but they did result in some very good orbit speeds before being moved.

As far as my scale goes... yeah, I know. Needless to say, I've run into that "disappearing when zoomed in" problem as well as the "can't zoom in on big systems" problem. I seem to have hit a somewhat acceptable happy medium, though. Obviously, space between stars will never be realistic, but the systems themselves can get... somewhat close. If you're interested, here is what I've done/discovered:

First off, I have to say I've modded the scale of just about everything so far, all based on 1 solar radius = 1000 in game scale. This Earth is roughly .915% the radius of the sun, right? So an earth size planet is 9 game scale. I arbitrarily said the smallest rocky planet is 1/3 Earth size, and the largest is double, for 3-18 for rocky planets in game. I continued this logic for gas giants, ship etc. Currently I have (# in game scale):

Ship (Frigate) = 0.1
Ship (Cruiser) = 0.6
Ship (Dreadnought) = 1
Rocky Planets = 3-18
Gas Giants = 25-115
Stars = 200-6,600

The "can't zoom into large system" problem appears to occur at exactly 45,000 orbit radius, that means if any orbit (after eccentricity) ever goes further out, you can't zoom in. I've rectified this problem by modding "orbDesc.radius" & "orbDesc.radius+" here is an example of what my F stars look like:

   starDesc.Temperature = randomf(6000,7500);
   starDesc.Radius = (1150.f + ((starDesc.Temperature - 6000.f) / 6.f)) * RS_starSizeFactor;
   starDesc.Brightness = 1.5f + ((starDesc.Temperature - 6000.f) / 428.57f);
        ...
   orbDesc.Radius = (starDesc.Radius * 0.95f) + 60.f + (pow(starDesc.Brightness, 3) * 50.f);
   orbDesc.IsStatic = false;
   
   int pCount = rand(3, 6) + rand(4, 9) - floor(starDesc.Brightness);
   
   for(int p = 0; p < pCount; ++p) {
      orbDesc.Radius += (((p + 1.f) * (1.f + (p + 1.f) / 14.f)) * (starDesc.Radius * 0.05f)) * randomf((1.f + ((p +1) / 14)), (5.f - ((p +1) / 14))) * (14.f / pCount);
      orbDesc.DaysPerYear = 120.f;
      orbDesc.Eccentricity = randomf(1.0f, 1.1f);

I'm no expert in math, but I haven't seen an orbit over 45,000 yet, nor had that problem since I figured out this formula.

As far as the zoom = disappearing problem, well, that is a bit more problematic, in my game, ships are icons... only a super massive giant hull dreadnought is ever visible, but I've come to terms with that. All but the smallest planets seem okay when zooming in, so long as the galaxies size doesn't get too big.

Alternatively, someone somewhere here on the forums discovered a console command, "zplane 12000100" or something like that? It fixes the disappearing but then it introduces targeting problems for me...

Also, may I say that I, and so many others, I'm sure, were crushed to hear of GA detour. Even so, I'd like to congratulate your team on the amazing things that you've accomplished!