If I check for Global.getSector().getPlayerFleet().getBattle() being null, is that a reliable way of ensuring the player fleet is not currently in combat when the script is running? Or is there a way to do that at all?
Context:
I'm testing out a skill that changes OP costs for bombers by adding/removing a hullmod. I am trying to prevent an exploit where the player sets his/her character on a ship, assigns the extra OP - and then assigns the character to another ship. I am handling this by simply removing all non-built in fighters (assuming clearing the list even does that) and returning the wings back to the player's inventory.
But! I don't want to do that if the player is switching flagships in combat because the AI ship would lose all the wings (is the theory). I only want this to occur if the player is in the refit screen - with the reasoning that once the battle is over the player character is in the same flagship as when the battle started even they switch ships during battle.Warning: DO NOT TRY THIS!
*EDIT*
Errr, ok it looks like "apply" and "unapply" are
both called when you change the piloted ship in the refit screen??
I have: ship.getVariant().clear();
under "unapply"
- And when I switch ships it immediately clears the variant
of the ship I'm switching to rather than the one I am switching
from. So I'm pretty confused at this point haha.
*EDIT 2*
Ok yikes yeah the behavior is really inconsistent. Sometimes it calls: ship.getVariant().removePermaMod("archeus_warship_bays_high");
- and sometimes it doesn't. It also clears the variant but doesn't seem to update the UI or finalize things until moving to a different screen? So if I switch to a different ship with my character it clears the variant and adds the hullmod - if I immediately switch to another ship it sometimes preserves the variant and sometimes doesn't but it seems to consistently remove the hullmod.
However, if I switch to a ship and then go out of the refit screen then it finalizes the variant clear and updates the UI - but if I switch again it
doesn't remove the hullmod.