How I change a faction color programatically? Specially the player, so a menu can be made for those that prefer it orange or something instead of blue.
I don't think you can; it's not set up to keep that data in a campaign-instance-specific copy of the faction data.
Hey Alex, I've noticed the ShipHullSpecAPI lacks a method to tell you if a ship is a station, module, or ship. I've had to create janky workarounds like seeking ShipTypeHints.STATION, looking at the top speed, acceleration, and deceleration, and checking for a module anchor. There's gotta be a better way, right?
private static boolean isModule(ShipHullSpecAPI shipHullSpec) {
try { return shipHullSpec.getModuleAnchor() != null
|| (shipHullSpec.getEngineSpec().getMaxSpeed() == 0
&& shipHullSpec.getEngineSpec().getAcceleration() == 0
&& shipHullSpec.getEngineSpec().getDeceleration() == 0);
} catch (Throwable t) { return false; }
}
private static boolean isStation(ShipHullSpecAPI shipHullSpec) {
try { return shipHullSpec.getHints().contains(ShipHullSpecAPI.ShipTypeHints.STATION); }
catch (Throwable t) { return false; }
}
That's quite literally what ShipTypeHints.STATION is for! Not sure why you have it in a try/catch, though, that should not be necessary.
I've got 2 questions about bad ideas modular frigates -
1 - is there a way to make a module completely untargetable in battle? for now I'm using the "module_hull_bar_only" tag, but that still looks iffy when the player zooms in / gets their mouse too close to the ship.
You could make it take no hull damage (by setting the hull damage taken multiplier to 0) but I don't think that's what you want. Aside from that, no - if something can get damaged, it can have a hull bar and can be targeted; that seems fairly fundamental.
2 - is there a good, consistent way to prevent explosions from missiles / projectiles "leaking" past a module's shields & hitting the main hull?
I've got a frigate with a secondary shield as a system, and if a missile w/ a big enough explosion (it's pretty close to the main hull so an atropos can do it in my case) hits the outer shield, it'll deal damage to both the outer shield & main ship in 2 separate instances (one for the missile on the module, one for the explosion on the main ship) with nothing really connecting the two for me to throw into a damageTakenModifier listener.
Hmm - that sounds like a bug. Are you positive this is what's happening? Looking at the code, it seems like when a missile hits something and explodes, the explosion treats... ahh, crap, I see. What it was doing is making sure the explosion could not hit 1) any of the target's child modules, and 2) any of its parents' child modules. But it was not including the parent - which, in vanilla, didn't matter because the parent hull is always undamageable so it never came up. Fixed!