Got inspired to pull an old hullmod out of mothball. It still doesn't work, feedback appreciated:
Spoiler
public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
if (stats.getVariant().getSMods().contains("ordstore")) {
stats.getDynamic().getMod(Stats.SMALL_BALLISTIC_MOD).modifyFlat(id, -1f);
stats.getDynamic().getMod(Stats.MEDIUM_BALLISTIC_MOD).modifyFlat(id, -2f);
stats.getDynamic().getMod(Stats.LARGE_BALLISTIC_MOD).modifyFlat(id, -4f);
stats.getCargoMod().modifyMult(id, 0.75f);
} else {
stats.getDynamic().getMod(Stats.SMALL_BALLISTIC_MOD).modifyFlat(id, -0f);
stats.getDynamic().getMod(Stats.MEDIUM_BALLISTIC_MOD).modifyFlat(id, -1f);
stats.getDynamic().getMod(Stats.LARGE_BALLISTIC_MOD).modifyFlat(id, -2f);
stats.getCargoMod().modifyMult(id, 0.5f);
}
}
Basically, if the mod is not built-in the Cargo and Ballistic mods apply as intended (yay!),
But when it is built in only the CargoMod updates, the ballistic mod doesn't update (nay!).
The IF values for the Ballistic mods do apply if the referenced hullmod is built in
before applying this one. e.g. if I referenced turretgyros and had that built in as an SMod prior to applying this then the IF value would be used.
(Or the event of self referencing, the player can install it as an Smod, save, exit and reload to use the correct value)
So really, what I need is some way to force-update/reapply the hullmod
after it is has been installed as an SMod.
I'm guessing we're back in "unsupported by game" territory as you outlined previously:
The other thing to get around somehow is the player installing the hullmod, using the extra OP, and then removing it. Generally speaking the game assumes that hullmods that modify OP costs are non-removable, and breaking that assumption puts it into "unsupported by the game" territory. Not to say it couldn't be made to work somehow, perhaps!
The new plan was to have it modify the weapon OP only when the hullmod was built in (the else values are currently for testing purposes to check it initially applies). I've got a dirty dirty work around on standby if we can't get this working correctly (Make the OP cost for the hullmod more than any potential gains so you won't see the benefits unless you SMod it).