Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.97a is out! (02/02/24); In-development patch notes for Starsector 0.98a (2/8/25)

Author Topic: Any Idea How To Define A Star System Orbiting A Stable Location  (Read 795 times)

PFleur

  • Ensign
  • *
  • Posts: 30
    • View Profile
Any Idea How To Define A Star System Orbiting A Stable Location
« on: November 24, 2024, 02:03:11 PM »

Does anyone know how to define a system orbiting a stable locations. I'm trying to make a star system composed of two gravitational systems (will be referred to as subsystems) with and for ease of scripting they'd need to orbit a stable location representing the system centre of gravity. I know it's possible with Customizable Star System's empty_location entity, would there be any way to easily emulate such behaviour?
Logged

banano of doom

  • Captain
  • ****
  • Posts: 314
    • View Profile
Re: Any Idea How To Define A Star System Orbiting A Stable Location
« Reply #1 on: November 24, 2024, 03:10:55 PM »

provided you are creating a system with script and not via csv, anything can orbit anything
all it takes is casting star.setCircularOrbit(focus, radius, period)
anything can serve as orbit focus, even a stable location as you pointed out, though i'm not sure if something weird would happen if something is built on that location, and the stable location entity is despawned, so you'd be better off making your own customEntity with no sprite or map marker

also note, while you can make anything orbit anything, there are many things under-the-hood, that assume that every entity in system orbits a star, or orbits something that orbits a star, or that there is no star at all
tldr if you have at least one star, everything in system must be linked to that star, or things go bad
ask me how i know...
Logged
my mods:


please do not ask me for permission to use my code or sprites - the answer is "yes" by default, on condition that my involvement is never mentioned

PFleur

  • Ensign
  • *
  • Posts: 30
    • View Profile
Re: Any Idea How To Define A Star System Orbiting A Stable Location
« Reply #2 on: November 24, 2024, 07:16:54 PM »

Thank you for the information! For the custom entity where should it be defined? I'm looking through the Customizable Star System source code but the only place where their empty_location entity that serves the purpose of such is as a variable:
Code
private final String ENTITY_EMPTY_LOCATION = "empty_location";
Is that all that's needed for such?
For linking everything to a star how would that work since looking at vanilla systems that's done through entity.setCircularOrbit/setCircularOrbitPointingDown/etc(focus, angle, radius, period) it there another way?
Logged

SafariJohn

  • Admiral
  • *****
  • Posts: 3100
    • View Profile
Re: Any Idea How To Define A Star System Orbiting A Stable Location
« Reply #3 on: November 24, 2024, 08:01:50 PM »

Calling initNonStarCenter() on your system will create an invisible token and assign it to the system's center. You can then create your stars and have them orbit the system's center.

See com.fs.starfarer.api.impl.campaign.procgen.StarSystemGenerator.addStars() (starting at line 714)
Logged

PFleur

  • Ensign
  • *
  • Posts: 30
    • View Profile
Re: Any Idea How To Define A Star System Orbiting A Stable Location
« Reply #4 on: November 25, 2024, 06:48:08 AM »

Thank you for the information and where in the docs to look!
Logged

Great Wound

  • Captain
  • ****
  • Posts: 310
    • View Profile
Re: Any Idea How To Define A Star System Orbiting A Stable Location
« Reply #5 on: November 25, 2024, 10:48:57 AM »

You know you want to...

PFleur

  • Ensign
  • *
  • Posts: 30
    • View Profile
Re: Any Idea How To Define A Star System Orbiting A Stable Location
« Reply #6 on: November 25, 2024, 07:32:48 PM »

Orbital mechanics already hurt. Adding such non-keplarian orbits just seem utterly miserable.
Logged

Princess of Evil

  • Admiral
  • *****
  • Posts: 943
  • Balance is not an endpoint, but a direction.
    • View Profile
Re: Any Idea How To Define A Star System Orbiting A Stable Location
« Reply #7 on: November 26, 2024, 02:34:00 AM »

You just have to do a standard system under the hood and use some basic math to change the locations of objects afterwards.
Logged
Proof that you don't need to know any languages to translate, you just need to care.

nathan67003

  • Commander
  • ***
  • Posts: 224
  • Excellent imagination, mediocre implementation.
    • View Profile
Re: Any Idea How To Define A Star System Orbiting A Stable Location
« Reply #8 on: November 26, 2024, 05:46:23 AM »

You could do a nebula and just plop down a stable location in the center, no?
Logged
I have some ideas but can't sprite worth a damn and the ideas imply really involved stuff which I've no clue how to even tackle.

PFleur

  • Ensign
  • *
  • Posts: 30
    • View Profile
Re: Any Idea How To Define A Star System Orbiting A Stable Location
« Reply #9 on: November 29, 2024, 02:51:48 PM »

Ended up just using SectorEntityToken sysCent = system.initNonStarCenter(); and it seems to be going well. Figuring out how the correct values for coronas and just how to make a black hole is a pain though but that's just the price for wanting more control over how the system forms.
Logged