Fractal Softworks Forum

Please login or register.

Login with username, password and session length

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - John the Gamer

Pages: [1]
1
Modding / Small improvement to the Legion battlecarrier
« on: June 25, 2022, 11:26:40 AM »
I felt like the Legion had a few empty spots on the hull that were clearly meant for turrets.
Add this to the Legion's hullfile to give it two rear-facing PD weapon slots;

(file location: Starsector\starsector-core\data\hulls)

        {
            "angle": -150,
            "arc": 120,
            "id": "WS 022",
            "locations": [
                -45,
                -15
            ],
            "mount": "TURRET",
            "size": "SMALL",
            "type": "BALLISTIC"
        },
        {
            "angle": 150,
            "arc": 120,
            "id": "WS 023",
            "locations": [
                -45,
                15
            ],
            "mount": "TURRET",
            "size": "SMALL",
            "type": "BALLISTIC"
        },

It gives your engines at least a small amount of protection. I felt it only right to post this here for others to make use of (or not).

[attachment deleted by admin]

2
Modding / Re: [0.95a] Hullmod Specialization 1.19
« on: May 30, 2022, 08:42:42 AM »
Hey, just wanted to say that I used the script of the MissileReloader hullmod to increase the size of fighter wings. It seems to work just fine. I just use it for myself as a test to figure out how to code this game. I basically used the code from the 'reservewing' shipsystem.

Perhaps you can use something like this to make a 'real' hullmod as an addition to your mod. Something like 'all-in fighter tactics' which doubles the amount of hangars on the ship, and doubles the size of the fighter wings during battle, but disables fighters being replaced when they get shot down. So you are completely relient on the first-strike capability.

I don't know. I just wanted to let everyone know that this works to overcome the max-6 hardcoded fighter amounts.

Spoiler
package data.hullmods;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.WeaponAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import com.fs.starfarer.api.combat.WeaponAPI.WeaponType;
import com.fs.starfarer.api.util.IntervalUtil;
import com.fs.starfarer.api.combat.FighterLaunchBayAPI;
import com.fs.starfarer.api.combat.ShipSystemAPI;
import com.fs.starfarer.api.loading.FighterWingSpecAPI;

public class MissileReloader extends BaseHullMod {

   public static final float MIN_RELOAD_TIME = 12f;
   public static final float MAX_RELOAD_TIME = 60f;
   public static final float RELOAD_FRACTION_NUMERATOR = 1f;
   public static final float RELOAD_FRACTION_DENOMINATOR = 1f;
   
   public static String RD_NO_EXTRA_CRAFT = "rd_no_extra_craft";
   public static String RD_FORCE_EXTRA_CRAFT = "rd_force_extra_craft";
   
   public static float EXTRA_FIGHTER_DURATION = 15;
   public static float RATE_COST = 0.25f;   
   
   public static String MR_DATA_KEY = "core_reloader_data_key";
   
   public static class MissileReloaderData {
      IntervalUtil interval = new IntervalUtil(MIN_RELOAD_TIME, MAX_RELOAD_TIME);
   }
   
   public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
   }
      
   public String getDescriptionParam(int index, HullSize hullSize) {
      if (index == 0) return "" + (int) MIN_RELOAD_TIME;
      if (index == 1) return "" + (int) MAX_RELOAD_TIME;
      if (index == 2) return "" + (int) RELOAD_FRACTION_NUMERATOR;
      if (index == 3) return "" + (int) RELOAD_FRACTION_DENOMINATOR;
      return null;
   }
   
   @Override
   public void advanceInCombat(ShipAPI ship, float amount) {
      super.advanceInCombat(ship, amount);

      if (!ship.isAlive()) return;
      
      CombatEngineAPI engine = Global.getCombatEngine();
      
      String key = MR_DATA_KEY + "_" + ship.getId();
      MissileReloaderData data = (MissileReloaderData) engine.getCustomData().get(key);
      if (data == null) {
         data = new MissileReloaderData();
         engine.getCustomData().put(key, data);
      }
      
      data.interval.advance(amount);
      if (data.interval.intervalElapsed()) {
         for (WeaponAPI w : ship.getAllWeapons()) {
            if (w.getType() != WeaponType.MISSILE) continue;
            int currentAmmo = w.getAmmo();
            int maxAmmo = w.getMaxAmmo();
            
            if (w.usesAmmo() && currentAmmo < maxAmmo) {
               float numerator = maxAmmo * RELOAD_FRACTION_NUMERATOR;
               float reloadCount = numerator / RELOAD_FRACTION_DENOMINATOR;
               if (reloadCount < 1){
                  reloadCount = 1;
               }
               int newAmmo = currentAmmo + (int)reloadCount;
               if (newAmmo > maxAmmo){
                  w.setAmmo(maxAmmo);
               } else {
                  w.setAmmo(newAmmo);
               }
            }
         }
         
         //need to make this more balanced
         //possibly don't count the "added" fighters to helping restore the replacement rate?
         //also: need to adjust the AI to be more conservative using this
         
         float minRate = Global.getSettings().getFloat("minFighterReplacementRate");
         
         for (FighterLaunchBayAPI bay : ship.getLaunchBaysCopy()) {
            if (bay.getWing() == null) continue;
            
   //         float rate = Math.max(minRate, bay.getCurrRate() - RATE_COST);
   //         bay.setCurrRate(rate);
            
   //         bay.makeCurrentIntervalFast();
            FighterWingSpecAPI spec = bay.getWing().getSpec();
            
            int addForWing = getAdditionalFor(spec);
            int maxTotal = spec.getNumFighters() + addForWing;
            int actualAdd = maxTotal - bay.getWing().getWingMembers().size();
            //int actualAdd = addForWing;
            //actualAdd = Math.min(spec.getNumFighters(), actualAdd);
            if (actualAdd > 0) {
               bay.setFastReplacements(bay.getFastReplacements() + addForWing);
               bay.setExtraDeployments(actualAdd);
               bay.setExtraDeploymentLimit(maxTotal);
               //bay.setExtraDuration(EXTRA_FIGHTER_DURATION);
               bay.setExtraDuration(360f);
            }
         }
      }
   }
   
   public static int getAdditionalFor(FighterWingSpecAPI spec) {
      //if (spec.isBomber() && !spec.hasTag(RD_FORCE_EXTRA_CRAFT)) return 0;
      if (spec.hasTag(RD_NO_EXTRA_CRAFT)) return 0;
      
      int size = spec.getNumFighters();
//      if (size <= 3) return 1;
//      return 2;
      if (size <= 1) return 2;
      if (size <= 2) return 3;
      if (size <= 3) return 4;
      if (size <= 4) return 5;
      if (size <= 5) return 6;      
      return 6;
   }
   
}
[close]

Pages: [1]