Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.9.1a is out! (05/10/19); Blog post: Raiding for Fun and Profit (11/27/19)

Author Topic: How to add stable locations to existing save?  (Read 6250 times)

moyashii

  • Ensign
  • *
  • Posts: 3
    • View Profile
    • Email
How to add stable locations to existing save?
« on: December 04, 2018, 02:44:13 AM »

Hey, I'm new to the forums so I'm not sure if I should post this here or somewhere else, so I apologize in advance if it's in the wrong place.

I noticed some systems spawn without stable location slots, and that really cripples colony growth and doesn't exactly make sense since you'd technically still have plenty of options to build a structure around the system. It also becomes really annoying having to go out to a neighboring system just to get a refresh of intel.

So I was wondering if it's possible to edit the campaign.xml file in a way to add the stable locations? I've already successfully edited some stuff in it, such as swapping out an officer's skill that I picked by accident or renaming a couple systems and their respective planets. But with the stable location it appears to be a lot more complicated than just swapping out a couple localisation lines so I'd appreciate it if someone with any experience could lend me a hand. 

Logged

Histidine

  • Admiral
  • *****
  • Posts: 2423
    • View Profile
    • Bitbucket profile
    • Email
Re: How to add stable locations to existing save?
« Reply #1 on: December 04, 2018, 03:47:52 AM »

Editing the save is probably too complicated, but you can use the Console Commands mod with the following command (copy and paste):

Code: java
runcode SectorEntityToken fleet = Global.getSector().getPlayerFleet();  
      StarSystemAPI sys = (StarSystemAPI)fleet.getContainingLocation();
      SectorEntityToken stable = fleet.getContainingLocation().addCustomEntity(null, null, "stable_location", "neutral");
      float orbitRadius = com.fs.starfarer.api.util.Misc.getDistance(fleet, sys.getCenter());
      float orbitDays = orbitRadius / (20f + new Random().nextFloat() * 5f);
      float angle = com.fs.starfarer.api.util.Misc.getAngleInDegrees(sys.getCenter().getLocation(), fleet.getLocation());
      stable.setCircularOrbit(sys.getCenter(), angle, orbitRadius, orbitDays);
This creates a new stable location at your fleet's current location. You can tweak orbitDays for realism if you want.
« Last Edit: December 05, 2018, 03:29:45 AM by Histidine »
Logged

moyashii

  • Ensign
  • *
  • Posts: 3
    • View Profile
    • Email
Re: How to add stable locations to existing save?
« Reply #2 on: December 04, 2018, 04:38:57 AM »

Thanks! I've always used console commands, didn't know you could input code into it though.

A little sidenote, is there any resource here or somewhere else that I can use to learn how to make simple scripts such as those for the game? Or would I need to go all-out and get into javascript?
Right now I'm kinda just stuck with being able to edit the saves and basic configs, so I'd like to be able to do more.

Edit: Forgot to mention, with the orbitdays parameter, is there a way to see how long a planet's orbit cycle takes in-game to use as reference or do I just keep guessing while reloading the save to get a rough estimate of the speed it should be?
« Last Edit: December 04, 2018, 04:47:58 AM by moyashii »
Logged

Histidine

  • Admiral
  • *****
  • Posts: 2423
    • View Profile
    • Bitbucket profile
    • Email
Re: How to add stable locations to existing save?
« Reply #3 on: December 05, 2018, 03:43:40 AM »

Forgot to mention, with the orbitdays parameter, is there a way to see how long a planet's orbit cycle takes in-game to use as reference or do I just keep guessing while reloading the save to get a rough estimate of the speed it should be?
The orbital period is manually set for non-procgen planets, but apparently for the procgen ones it's just orbitalRadius/random(20, 25) (for planets; jump points and stars use a different denominator, and the objective/stable location orbit code appears to be hidden).
I've edited the code in the previous post to automatically calculate it.

(Johannes Kepler is mad at you, Alex!!!)

Quote
A little sidenote, is there any resource here or somewhere else that I can use to learn how to make simple scripts such as those for the game? Or would I need to go all-out and get into javascript?
Right now I'm kinda just stuck with being able to edit the saves and basic configs, so I'd like to be able to do more.
You can kind of make a faction mod with only cargo cult coding, but to do anything complex you'll have to learn Java (not Javascript, which is a rather different language. Yeah, confusing), yes.

I don't have any tutorials for setting up a Java IDE or learning the language (although for the former some are linked here) unfortunately, although a simple search will turn them up.
Of course, you're welcome ask questions here or on the Discord :)
Logged

moyashii

  • Ensign
  • *
  • Posts: 3
    • View Profile
    • Email
Re: How to add stable locations to existing save?
« Reply #4 on: December 05, 2018, 06:41:52 AM »

Alright, thanks again for clearing everything up. :)
Logged

gofastskatkat

  • Ensign
  • *
  • Posts: 49
    • View Profile
    • Email
Re: How to add stable locations to existing save?
« Reply #5 on: December 14, 2018, 09:10:34 PM »

I kinda want to piggyback off the op since my question is similar, but instead of stable locations, how would you spawn a planet? Ive found a star system where I want my main planet to be but no suitable planets for colonization...
Logged