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); New blog post: Anubis-class Cruiser (12/20/24)

Author Topic: How to mod colony administrators  (Read 3309 times)

Pokpaul

  • Lieutenant
  • **
  • Posts: 59
    • View Profile
How to mod colony administrators
« on: October 01, 2019, 04:10:23 PM »

Hello, looked around, both in the forums and in the Star Sector files, and I can't see how to mod colony administrators.

Specifically, I want to make them less irrelevant compared to alpha cores by giving them a chance to have all 3 colony admin skills and not cost so much.
Logged

Histidine

  • Admiral
  • *****
  • Posts: 4904
    • View Profile
    • GitHub profile
Re: How to mod colony administrators
« Reply #1 on: October 01, 2019, 07:00:27 PM »

You can change costs in data/config/settings.json:
Code: json
	"adminHireTier0":5000,
"adminHireTier1":10000,
"adminHireTier2":50000,
"adminSalaryTier0":2500,
"adminSalaryTier1":5000,
"adminSalaryTier2":25000,
"idleAdminSalaryMult":0.1,
You could make 3-skill officers available for hire by replacing the officer manager event (search for CoreEventProbabilityManager and OfficerManagerEvent in the extracted API zip), but making such officers available for finding in salvage may require more work than is desirable.
Logged

Pokpaul

  • Lieutenant
  • **
  • Posts: 59
    • View Profile
Re: How to mod colony administrators
« Reply #2 on: October 01, 2019, 08:26:30 PM »

Thank you.
Logged

Pokpaul

  • Lieutenant
  • **
  • Posts: 59
    • View Profile
Re: How to mod colony administrators
« Reply #3 on: October 02, 2019, 11:50:24 AM »

So if I could impose on someone who knows what they're doing, if I just wanted to bump all the randomly generated administrators up by a level (because that looks easy enough), I would go here in the OfficerManagerEvent.java :

private AvailableOfficer createAdmin() {
      WeightedRandomPicker<MarketAPI> marketPicker = new WeightedRandomPicker<MarketAPI>();
      for (MarketAPI market : Global.getSector().getEconomy().getMarketsCopy()) {
         marketPicker.add(market, market.getSize());
      }
      MarketAPI market = marketPicker.pick();
      if (market == null) return null;

      WeightedRandomPicker<Integer> tierPicker = new WeightedRandomPicker<Integer>();
      tierPicker.add(0, 50);
      tierPicker.add(1, 45);
      tierPicker.add(2, 5);

      int tier = tierPicker.pick();
      
      PersonAPI person = createAdmin(market.getFaction(), tier, null);
      person.setFaction(Factions.INDEPENDENT);
      
      String hireKey = "adminHireTier" + tier;
      int hiringBonus = Global.getSettings().getInt(hireKey);
      
      int salary = (int) Misc.getAdminSalary(person);
      
      AvailableOfficer result = new AvailableOfficer(person, market.getId(), hiringBonus, salary);
      return result;
   }

and add 1 to the first value in brackets after each tierPicker.add? And I'm assuming the second value is probability, so if I wanted more high-tier admins to appear I'd fiddle with that?

Logged

Histidine

  • Admiral
  • *****
  • Posts: 4904
    • View Profile
    • GitHub profile
Re: How to mod colony administrators
« Reply #4 on: October 03, 2019, 04:29:54 AM »

That's what goes into the tier picker, yeah. (You'll also need to enter the level new hire and salary costs in settings.json, since they're not specified for tier 3 officers by default)

Afterwards, your mod will need to end the vanilla officer manager event in the campaign and start your own.
Logged

Pokpaul

  • Lieutenant
  • **
  • Posts: 59
    • View Profile
Re: How to mod colony administrators
« Reply #5 on: October 03, 2019, 10:39:15 AM »

Gotcha, thanks again.

I've been looking around at modding tutorials and resources, and if I understood what Alex wrote about how .json merging works in order to implement that I would create a settings.json file in folder mymod\data\config with only those lines you highlighted in it with the new costs plus lines for tier 3 admins.

I haven't been able to figure out how I would implement changes to OfficerManagerEvent.java though.  Alex said that all .java files are always replaced, so I'm guessing I'd have to create a new .java file just for the new event, but I'm not to sure what the rules are around that or how to make this new event replace the vanilla one as you mentioned.

Is there a tutorial or instructions on that somewhere that I missed that addresses this?
Logged

Histidine

  • Admiral
  • *****
  • Posts: 4904
    • View Profile
    • GitHub profile
Re: How to mod colony administrators
« Reply #6 on: October 04, 2019, 07:37:01 AM »

I thought you'd have to do some fancy stuff, but it turns out the old-style events are easily replaceable.
Though you'll have to use an IDE to compile the script and create a .jar file (look around the modding subforums for help, or ask on Discord).

Short version of the instructions:
- Make a new mod
- Add your modified copy of the officer manager event, and compile it into a .jar
- In mod_info.json, include a jars array that specifies the .jar you created (example)
- Add a file data/campaign/events.json (look at the one in vanilla)
- Add an officer_manager entry to that file like the vanilla one has, but make it point to your own script:
Code: json
	"officer_manager":{
"script":"data.scripts.events.MyOfficerManagerEvent",  /* or similar, just make sure the line here and the class's actual package + name match */
},
Logged