Fractal Softworks Forum

Please login or register.

Login with username, password and session length

Author Topic: Adding new star system  (Read 5809 times)

MajorTheRed

  • Captain
  • ****
  • Posts: 289
    • View Profile
Adding new star system
« on: February 04, 2018, 12:14:46 PM »

Greetings,

I finally got some time to work on Stop Gap Measures.
I want to implement two star systems to add some new markets for Luddic and Neutral factions. I first want to add only uninhabited system before adding complication with market and tags.
So far there is two files which are ok:
-starmap.json
-the file describing orbital features located in data\scripts\world\systems
and there is no more error popping when starting the game. However the system does not appear when I create a new game. From what I understand, I need to add several other files to make the game generate the system, and this is were I've trouble:

The first file is "mod_info.json" which need to call for another file "FilgapModPlugin". So far so good...
Spoiler
Quote
{
   "id":"StopGapMeasures",
   "name":"Stop Gap Measures",
   "author":"MajorTheRed",
   "version":"v 0.1",
   "description":"Pack of ships to flesh in vanilla campaign",
   "gameVersion":"0.8.1a",
   "modPlugin":"data.scripts.FilgapModPlugin",

}
[close]

... but this file is more difficult. I don't know if the two last sentences are OK...
Spoiler
Quote
package data.scripts;

import com.fs.starfarer.api.BaseModPlugin;
import com.fs.starfarer.api.Global;

import data.scripts.world.FilgapGen;


public class FilgapModPlugin extends BaseModPlugin
{
    private static void initFilgap()
        {
            new FilgapGen().generate(Global.getSector());
        }

}
[close]

and finally FilgapGen.java in data\scripts\world:
Spoiler
Quote
package data.scripts.world;


import com.fs.starfarer.api.campaign.SectorAPI;

import data.scripts.world.systems.Byzas;


public class FilgapGen {

   public void generate(SectorAPI sector) {
            (new Byzas()).generate(sector);
                                               
        }

}
[close]

I think I'm doing something wrong in the last two files, but I don't know what... Any ideas?

In any case, many thanks for the support from the community, this is really great to be able to ask for so much help on this forum.
Logged

Morrokain

  • Admiral
  • *****
  • Posts: 2143
  • Megalith Dreadnought - Archean Order
    • View Profile
Re: Adding new star system
« Reply #1 on: February 04, 2018, 01:36:23 PM »

I think you just need this code:

Code
    @Override
    public void onNewGame() {
        initFilgap();
    }

Right below:

Code
    private static void initFilgap() 
        {
            new FilgapGen().generate(Global.getSector());
        }
Logged

Morrokain

  • Admiral
  • *****
  • Posts: 2143
  • Megalith Dreadnought - Archean Order
    • View Profile
Re: Adding new star system
« Reply #2 on: February 04, 2018, 01:38:57 PM »

Also, let me know if you need help implementing markets... they can be tricky. Especially if you want a balanced economy.

My first run at it had ~8 food shortages- 3 severe.. in the first month.  :D
Logged

MajorTheRed

  • Captain
  • ****
  • Posts: 289
    • View Profile
Re: Adding new star system
« Reply #3 on: February 04, 2018, 02:11:58 PM »

Ok, I added the code line, and got the following error when launching a new game (when starting on the character panel, before the game stabilize economy) :

Spoiler
Quote
39611 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
   at com.fs.starfarer.combat.entities.terrain.Planet.<init>(Unknown Source)
   at com.fs.starfarer.combat.entities.terrain.Planet.<init>(Unknown Source)
   at com.fs.starfarer.campaign.CampaignPlanet.<init>(Unknown Source)
   at com.fs.starfarer.campaign.CampaignPlanet.<init>(Unknown Source)
   at com.fs.starfarer.campaign.BaseLocation.addPlanet(Unknown Source)
   at data.scripts.world.systems.Byzas.generate(Byzas.java:35)
   at data.scripts.world.FilgapGen.generate(FilgapGen.java:12)
   at data.scripts.FilgapModPlugin.initFilgap(FilgapModPlugin.java:13)
   at data.scripts.FilgapModPlugin.onNewGame(FilgapModPlugin.java:17)
   at com.fs.starfarer.campaign.save.CampaignGameManager.o00000(Unknown Source)
   at com.fs.starfarer.title.TitleScreenState.dialogDismissed(Unknown Source)
   at com.fs.starfarer.ui.Oo0O.dismiss(Unknown Source)
   at com.fs.starfarer.ui.impl.J.dismiss(Unknown Source)
   at com.fs.starfarer.campaign.save.if.actionPerformed(Unknown Source)
   at com.fs.starfarer.ui.j.super(Unknown Source)
   at com.fs.starfarer.ui.I.processInput(Unknown Source)
   at com.fs.starfarer.ui.V.o00000(Unknown Source)
   at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]

Considering the log mention the Byzas system (the one I'm trying to add), I'm wondering if the error could come from the Byzas system file?

Also, let me know if you need help implementing markets... they can be tricky. Especially if you want a balanced economy.

My first run at it had ~8 food shortages- 3 severe.. in the first month.  :D

Yeah that's exactly why I want first to add the star systems then add the markets, seems pretty difficult to do the right way.
« Last Edit: February 04, 2018, 02:33:34 PM by MajorTheRed »
Logged

Morrokain

  • Admiral
  • *****
  • Posts: 2143
  • Megalith Dreadnought - Archean Order
    • View Profile
Re: Adding new star system
« Reply #4 on: February 04, 2018, 02:49:25 PM »

Ok, I added the code line, and got the following error when launching a new game (when starting on the character panel, before the game stabilize economy) :

Spoiler
Quote
39611 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
   at com.fs.starfarer.combat.entities.terrain.Planet.<init>(Unknown Source)
   at com.fs.starfarer.combat.entities.terrain.Planet.<init>(Unknown Source)
   at com.fs.starfarer.campaign.CampaignPlanet.<init>(Unknown Source)
   at com.fs.starfarer.campaign.CampaignPlanet.<init>(Unknown Source)
   at com.fs.starfarer.campaign.BaseLocation.addPlanet(Unknown Source)
   at data.scripts.world.systems.Byzas.generate(Byzas.java:35)
   at data.scripts.world.FilgapGen.generate(FilgapGen.java:12)
   at data.scripts.FilgapModPlugin.initFilgap(FilgapModPlugin.java:13)
   at data.scripts.FilgapModPlugin.onNewGame(FilgapModPlugin.java:17)
   at com.fs.starfarer.campaign.save.CampaignGameManager.o00000(Unknown Source)
   at com.fs.starfarer.title.TitleScreenState.dialogDismissed(Unknown Source)
   at com.fs.starfarer.ui.Oo0O.dismiss(Unknown Source)
   at com.fs.starfarer.ui.impl.J.dismiss(Unknown Source)
   at com.fs.starfarer.campaign.save.if.actionPerformed(Unknown Source)
   at com.fs.starfarer.ui.j.super(Unknown Source)
   at com.fs.starfarer.ui.I.processInput(Unknown Source)
   at com.fs.starfarer.ui.V.o00000(Unknown Source)
   at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]

Considering the log mention the Byzas system (the one I'm trying to add), I'm wondering if the error could come from the Byzas system file?

Yes, an early guess is it looks like an issue with the type of planet you are trying to make. For instance, its "lava" for the type id rather than "volcanic". I would check planet_gen_data under data/campaign/procgen to make sure your type id matches an entry there. If you have created your own, make sure you check those related files.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24105
    • View Profile
Re: Adding new star system
« Reply #5 on: February 04, 2018, 03:48:16 PM »

Quick note:

Byzas.java:35

Indicates that the error is on line 35 in that file. ... well, not the error specifically, since that happens a few more calls down, but this is the last line in your code that's being called at the time of the crash.
Logged

MajorTheRed

  • Captain
  • ****
  • Posts: 289
    • View Profile
Re: Adding new star system
« Reply #6 on: February 04, 2018, 03:49:15 PM »

Yep you were right, it was a problem of planet designation. Now the system is spawning, but not at the right place. Anyway, I should be able to fix that. Many thanks for the quick help. I will let you know if I embarass myself with market creation.
Logged

Morrokain

  • Admiral
  • *****
  • Posts: 2143
  • Megalith Dreadnought - Archean Order
    • View Profile
Re: Adding new star system
« Reply #7 on: February 05, 2018, 11:36:44 AM »

Yep you were right, it was a problem of planet designation. Now the system is spawning, but not at the right place. Anyway, I should be able to fix that. Many thanks for the quick help. I will let you know if I embarass myself with market creation.

No problem- glad you got it working.  :)

Quick note:

Byzas.java:35

Indicates that the error is on line 35 in that file. ... well, not the error specifically, since that happens a few more calls down, but this is the last line in your code that's being called at the time of the crash.
Yep! I probably should have explained how I came up with that. lol

I also figured it was most likely the planet designation because:

Code
   at com.fs.starfarer.campaign.BaseLocation.addPlanet(Unknown Source)

 - means it was a problem with adding a planet specifically. And:

Code
   at com.fs.starfarer.combat.entities.terrain.Planet.<init>(Unknown Source)

 - pointed to the designation being source of the problem.
Logged

MajorTheRed

  • Captain
  • ****
  • Posts: 289
    • View Profile
Re: Adding new star system
« Reply #8 on: February 05, 2018, 12:55:03 PM »

I'm really impressed how Starsector is "readable" for people with no knowledge of coding (like me). So far just mimicking and cannibalizing codes from other mods and vanilla was sufficient. Even in log error I'm able to, at least, grasp some intels of what is going on.
Logged

MajorTheRed

  • Captain
  • ****
  • Posts: 289
    • View Profile
Re: Adding new star system
« Reply #9 on: February 05, 2018, 02:00:20 PM »

Today market conditions were added to the system created yesterday, with :
-economy.json
Spoiler
Quote
{         
      "starSystems":
         [
         "byzas.json",
         ],
   
   "map":"../starmap.json",


}
[close]
-byzas.json
Spoiler
Quote
{
   "starSystem":"byzas",
   "markets":[
      {
         "entities":["lepia"],
         "faction":"pirate",
         "size":5,
         "startingConditions":[
            "arid",
            "spaceport",   
            "ore_refining_complex",
            "toxic_atmosphere",
            "population_5",
            "farmland_poor",
            "vice_demand",
            "organized_crime",
         ],
      },
      {
         "entities":["bythinia"],
         "faction":"luddic_church",
         "size":6,
         "startingConditions":[
            "military_base",
            "rural_polity",
            "luddic_majority",
            "cottage_industry",
            "population_6",
            "habitable",
            "desert",
            "shipbreaking_center",
            "stealth_minefields",
            "rare_ore_moderate",
         ],
      },
   ],
   
}



[close]

However, the game crashes when stabilizing economy :

Spoiler
Quote
39624 [Thread-4] INFO  com.fs.starfarer.campaign.econ.oOOO  - Loading star system: byzas.json
39624 [Thread-4] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [DIRECTORY: C:\Program Files (x86)\Fractal Softworks\Starsector\starsector-core\..\mods\Stop Gap Measure (data\campaign\econ/byzas.json)]
39635 [Thread-8] INFO  sound.oo0O  - Cleaning up music with id [miscallenous_main_menu.ogg]
40027 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: java.lang.NullPointerException
java.lang.RuntimeException: java.lang.NullPointerException
   at com.fs.starfarer.campaign.save.CampaignGameManager.o00000(Unknown Source)
   at com.fs.starfarer.title.TitleScreenState.dialogDismissed(Unknown Source)
   at com.fs.starfarer.ui.Oo0O.dismiss(Unknown Source)
   at com.fs.starfarer.ui.impl.J.dismiss(Unknown Source)
   at com.fs.starfarer.campaign.save.if.actionPerformed(Unknown Source)
   at com.fs.starfarer.ui.j.super(Unknown Source)
   at com.fs.starfarer.ui.I.processInput(Unknown Source)
   at com.fs.starfarer.ui.V.o00000(Unknown Source)
   at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
   at com.fs.starfarer.campaign.econ.oOOO.o00000(Unknown Source)
   at com.fs.starfarer.campaign.econ.oOOO.o00000(Unknown Source)
   at com.fs.starfarer.campaign.econ.oOOO.o00000(Unknown Source)
   ... 13 more
[close]

Is there another file needed somewhere? Or maybe a .api need to be inserted in the Byzas.java system file? Or the caps problem with ID in the different files?
Logged

Morrokain

  • Admiral
  • *****
  • Posts: 2143
  • Megalith Dreadnought - Archean Order
    • View Profile
Re: Adding new star system
« Reply #10 on: February 05, 2018, 09:58:33 PM »

Try taking out:

Code
   "map":"../starmap.json",

It's unnecessary, this file is just adding on additional .json files.

Your extension of the starmap.json file already present in the mod takes care of system placement, so the only reason you would use that line of code would be to completely write over the entire system placement and also use completely different system ids for the systems involved.
Logged

MajorTheRed

  • Captain
  • ****
  • Posts: 289
    • View Profile
Re: Adding new star system
« Reply #11 on: February 06, 2018, 05:35:44 AM »

Initially this line was not there. I added it later, thinking it would help.
Still, night brings counsel, this morning I try to delete one of the two markets and try if only one of them work. In fact, the system name was lacking a caps, and I forgot the "s" at the end of "pirates" which leads to the crash...

And you were right, balancing market is... interesting. I've got a not-so-bad pirate planet with a stability of 0, and a not-so-good luddic planet with a stability of 10. Definitly some tweaks!

Anyway, thank you again for the efficient and quick support.
Logged

Morrokain

  • Admiral
  • *****
  • Posts: 2143
  • Megalith Dreadnought - Archean Order
    • View Profile
Re: Adding new star system
« Reply #12 on: February 06, 2018, 11:38:01 AM »

Any time, and I know what you mean.

Many can probably attest to how many times I've posted an issue late at night only to solve it in the morning after a good night's rest.  8)
Logged