Fractal Softworks Forum

Please login or register.

Login with username, password and session length

Author Topic: How to mod officer xp/level?  (Read 3286 times)

PCCL

  • Admiral
  • *****
  • Posts: 2016
  • still gunnyfreak
    • View Profile
How to mod officer xp/level?
« on: December 05, 2015, 07:14:00 PM »

Basically as title says. I want to slow down leveling for both the player and officers

The player's leveling speed can be changed via data>scripts>plugins>leveluppluginimpl, but that doesn't seem to work on mercenary officers

Has anyone looked into this yet? If so, any insights?

thanks in advance

gunny
Logged
mmm.... tartiflette

hunters1

  • Ensign
  • *
  • Posts: 29
    • View Profile
Re: How to mod officer xp/level?
« Reply #1 on: December 05, 2015, 07:37:15 PM »

Starsector\starsector-core\starfarer.api.zip\com\fs\starfarer\api\impl\campaign\OfficerLevelupPluginlmpl.java
Logged

PCCL

  • Admiral
  • *****
  • Posts: 2016
  • still gunnyfreak
    • View Profile
Re: How to mod officer xp/level?
« Reply #2 on: December 05, 2015, 08:48:53 PM »

interesting, I messed around with a little bit and got it to load without crashing

The following file is in data>scripts>plugin

Spoiler
Quote
package data.scripts.plugins;

import java.util.ArrayList;
import java.util.List;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.characters.PersonAPI;
import com.fs.starfarer.api.characters.SkillSpecAPI;
import com.fs.starfarer.api.plugins.OfficerLevelupPlugin;
import com.fs.starfarer.api.util.WeightedRandomPicker;

public class OfficerLevelupPluginImpl implements OfficerLevelupPlugin {

   public long getXPForLevel(int level) {

      if (level <= 1) return 0;
      
      float p1 = 10;
      float p2 = 35;
      
      float f1 = 1f;
      float f2 = Math.min(1, Math.max(0, level - p1) / 5f);
      float f3 = Math.max(0, level - p2);
      
      float p1level = Math.max(0, level - p1 + 1);
      float p2level = Math.max(0, level - p2 + 1);
      float mult1 = (1f + (float) level) * 0.5f * (float) level * 1f;
      float mult2 = (1f + (float) p1level) * 0.5f * (float) p1level * 0.25f;
      float mult3 = (1f + (float) p2level) * 0.5f * (float) p2level * 2f;
      
      float base = 15000;
      
      float r = f1 * mult1 * base +
               f2 * mult2 * base +
               f3 * mult3 * base;
      
      return (long) r;
   }

   public int getMaxLevel(PersonAPI person) {
      return (int) Global.getSettings().getFloat("officerMaxLevel");
   }

   public List<String> pickLevelupSkills(PersonAPI person) {
      WeightedRandomPicker<String> nonMaxedSkills = new WeightedRandomPicker<String>();
      WeightedRandomPicker<String> knownSkills = new WeightedRandomPicker<String>();
      List<String> allSkillIds = Global.getSettings().getSortedSkillIds();
      for (String skillId : allSkillIds) {
         SkillSpecAPI skill = Global.getSettings().getSkillSpec(skillId);
         if (skill.isCombatOfficerSkill()) {
            addSkill(person, nonMaxedSkills, skillId);
            float level = person.getStats().getSkillLevel(skillId);
            if (level > 0) {
               addSkill(person, knownSkills, skillId);
            }
         }
      }
      List<String> result = new ArrayList<String>();

      if (!knownSkills.isEmpty()) {
         Object pick = knownSkills.pickAndRemove();
         nonMaxedSkills.remove(pick);
         result.add(pick);
      }
      if (!nonMaxedSkills.isEmpty()) {
         Object pick = nonMaxedSkills.pickAndRemove();
         knownSkills.remove(pick);
         result.add(pick);
      }
      
      if (result.size() < 2) {
         if (!knownSkills.isEmpty()) {
            Object pick = knownSkills.pickAndRemove();
            nonMaxedSkills.remove(pick);
            result.add(pick);
         }
      }
      if (result.size() < 2) {
         if (!nonMaxedSkills.isEmpty()) {
            Object pick = nonMaxedSkills.pickAndRemove();
            knownSkills.remove(pick);
            result.add(pick);
         }
      }
      
//      if (!skills.isEmpty()) result.add(skills.pickAndRemove());
//      if (!skills.isEmpty()) result.add(skills.pickAndRemove());
      
      return result;
   }
   
   private void addSkill(PersonAPI person, WeightedRandomPicker<String> picker, String skill) {
      if (person.getStats().getSkillLevel(skill) >= 10) return;
      picker.add(skill);
   }
   
   

//   public static void main(String[] args) {
//      LevelupPluginImpl impl = new LevelupPluginImpl();
//      for (int i = 0; i <= 100; i++) {
//         System.out.println(String.format("% 4d: % 20d", i, impl.getXPForLevel(i)));
//      }
//   }

}
[close]

However, when I'm in game with an officer, they still only have the original exp per level

Logged
mmm.... tartiflette

hunters1

  • Ensign
  • *
  • Posts: 29
    • View Profile
Re: How to mod officer xp/level?
« Reply #3 on: December 05, 2015, 09:08:42 PM »

the only other way i can see to doing this is to go to settings.json and modify the easy version by putting everything on 0 and having the officer xp multipler at a negative number if it allows it
just to be safe did u remove the plugin from the starfarer.api.zip?
if yes i think u might have to change its loading in settings.json for the game to load it correctly
if no then try with it still in there
« Last Edit: December 05, 2015, 09:10:50 PM by hunters1 »
Logged

PCCL

  • Admiral
  • *****
  • Posts: 2016
  • still gunnyfreak
    • View Profile
Re: How to mod officer xp/level?
« Reply #4 on: December 05, 2015, 09:28:27 PM »

that did it, ty
Logged
mmm.... tartiflette