Hi, guys. I would like to add a specific Fighter Wing to the Converted Hangar code.
This is the starsector-core code for Converted Hangar:
Spoiler
package data.hullmods;
import java.util.HashMap;
import java.util.Map;
import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import com.fs.starfarer.api.impl.campaign.ids.HullMods;
import com.fs.starfarer.api.impl.campaign.ids.Stats;
import com.fs.starfarer.api.impl.hullmods.DefectiveManufactory;
public class ConvertedHangar extends BaseHullMod {
public static final int CREW_REQ = 20;
//public static final int CARGO_REQ = 80;
public static final int ALL_FIGHTER_COST_PERCENT = 50;
public static final int BOMBER_COST_PERCENT = 100;
private static Map mag = new HashMap();
static {
mag.put(HullSize.FRIGATE, 0f);
mag.put(HullSize.DESTROYER, 75f);
mag.put(HullSize.CRUISER, 50f);
mag.put(HullSize.CAPITAL_SHIP, 25f);
}
public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
//stats.getFighterRefitTimeMult().modifyPercent(id, ((Float) mag.get(hullSize)));
stats.getNumFighterBays().modifyFlat(id, 1f);
stats.getMinCrewMod().modifyFlat(id, CREW_REQ);
//stats.getDynamic().getMod(Stats.ALL_FIGHTER_COST_MOD).modifyPercent(id, ALL_FIGHTER_COST_PERCENT);
stats.getDynamic().getMod(Stats.BOMBER_COST_MOD).modifyPercent(id, BOMBER_COST_PERCENT);
stats.getDynamic().getMod(Stats.FIGHTER_COST_MOD).modifyPercent(id, ALL_FIGHTER_COST_PERCENT);
stats.getDynamic().getMod(Stats.INTERCEPTOR_COST_MOD).modifyPercent(id, ALL_FIGHTER_COST_PERCENT);
stats.getDynamic().getMod(Stats.SUPPORT_COST_MOD).modifyPercent(id, ALL_FIGHTER_COST_PERCENT);
//stats.getCargoMod().modifyFlat(id, -CARGO_REQ);
}
public boolean isApplicableToShip(ShipAPI ship) {
//if (ship.getMutableStats().getCargoMod().computeEffective(ship.getHullSpec().getCargo()) < CARGO_REQ) return false;
return ship != null && !ship.isFrigate() && ship.getHullSpec().getFighterBays() <= 0 &&
//ship.getNumFighterBays() <= 0 &&
!ship.getVariant().hasHullMod(HullMods.CONVERTED_BAY) &&
!ship.getVariant().hasHullMod(HullMods.PHASE_FIELD);
//ship.getHullSpec().getShieldType() != ShieldType.PHASE;
}
public String getUnapplicableReason(ShipAPI ship) {
if (ship != null && ship.isFrigate()) return "Can not be installed on a frigate";
if (ship != null && ship.getHullSpec().getFighterBays() > 0) return "Ship has standard fighter bays";
if (ship != null && ship.getVariant().hasHullMod(HullMods.CONVERTED_BAY)) return "Ship has fighter bays";
//if (ship != null && ship.getNumFighterBays() > 0) return "Ship has fighter bays";
return "Can not be installed on a phase ship";
}
public void applyEffectsToFighterSpawnedByShip(ShipAPI fighter, ShipAPI ship, String id) {
new DefectiveManufactory().applyEffectsToFighterSpawnedByShip(fighter, ship, id);
}
public String getDescriptionParam(int index, HullSize hullSize, ShipAPI ship) {
if (index == 2) return "" + CREW_REQ;
if (index == 3) return "" + BOMBER_COST_PERCENT + "%";
if (index == 4) return "" + ALL_FIGHTER_COST_PERCENT + "%";
return new DefectiveManufactory().getDescriptionParam(index, hullSize, ship);
// if (index == 0) return "" + ((Float) mag.get(HullSize.DESTROYER)).intValue() + "%";
// if (index == 1) return "" + ((Float) mag.get(HullSize.CRUISER)).intValue() + "%";
// if (index == 2) return "" + ((Float) mag.get(HullSize.CAPITAL_SHIP)).intValue() + "%";
// if (index == 3) return "" + CREW_REQ;
// return null;
//if (index == 0) return "" + ((Float) mag.get(hullSize)).intValue();
//return null;
}
@Override
public boolean affectsOPCosts() {
return true;
}
}
Could this be simple to mod? Will adding a line after " stats.getNumFighterBays().modifyFlat(id, 1f); " work? I think that
ship.getVariant().setWingId(0, ssx_drone_pod_wing);
might work? Wouldn't it? The " ship.getVariant() " is already used in the original and " void setWingId(int index, String wingId); " is a function of ShipVariantAPI.
If it does work, then I might have follow up questions.