I've been tearing my hair out for about three weeks trying to figure out why I can't make (what I thought was) a pretty simple setup work, and I've come to the conclusion that there's something very strange and fundamental going on in the core game that's preventing me from achieving this. Whether it is a bug or not I have no clue, but I would very much like it to be looked into either way, as it makes zero sense. Regardless, that's why I've stuck it here in Bug Reports. If a moderator would rather it be in the Modded subforum, that's fine by me, as long as it gets addressed, or at the very least explained.
Situation/objective:I have a decorative weapon with multiple animation frames on a ship. The ship also has two unique hullmods: one built-in and hidden, the other modular and visible. The built-in hullmod does all the work. If the player tries to remove the modular hullmod, the built-in one notices this as a trigger, and "does something", before manually re-installing the modular hullmod. The result is a "cyclic" function that lets the player toggle through a series of options by repeatedly removing the modular hullmod. Presently, that series of options is the series of animation frames for the decorative weapon. (This is all cosmetic for now.)
Problem:No matter which way I slice this damn system, I cannot get the deco weapon to change animation frame in the way I want it. I can forcibly set it to a particular value if I just stick a hard number in the script, but the moment I put in a saved number attached to the ship ID (fleetMemberId actually), it refuses to change.
Worse, I've set up a logger so I can see if the saved value is incrementing... And it goddamn IS! For reasons beyond my comprehension, this line...
wpn.getAnimation().setFrame(SAVED_DATA.get(shipId));
... does not work.For full context, here's the whole of the meat of the script (this is the built-in hullmod). "dara_arrow_paintcycle_trigger" is the modular hullmod that the player removes to cycle the setup.
@Override
public void applyEffectsAfterShipCreation(ShipAPI ship, String id) {
String shipId = ship.getFleetMemberId();
if (SAVED_DATA.get(shipId) == null) {
SAVED_DATA.put(shipId, 0);
log.info("Reset frame to #0");
}
if (!ship.getVariant().hasHullMod("dara_arrow_paintcycle_trigger")) {
for (WeaponAPI wpn : ship.getAllWeapons()) {
if (wpn.getId().contains("dara_arrow_paint")) {
int currFrame = SAVED_DATA.get(shipId);
log.info("Retrieved frame #" + currFrame);
if (currFrame + 1 > 12) {
currFrame = 0;
} else {
currFrame += 1;
}
SAVED_DATA.put(shipId, currFrame);
log.info("Incremented to and saved frame #" + SAVED_DATA.get(shipId));
wpn.getAnimation().setFrame(SAVED_DATA.get(shipId));
ship.getVariant().addMod("dara_arrow_paintcycle_trigger");
runOnce = false;
break;
}
}
}
}
As you can see, I've got multiple log outputs here, which have very clearly been showing the saved value incrementing, live, as I try to cycle the hullmod from the refit screen:
98010 [Thread-4] INFO data.scripts.hullmods.dara_RedArrowPaint - Reset frame to #0
98010 [Thread-4] INFO data.scripts.hullmods.dara_RedArrowPaint - Retrieved frame #0
98010 [Thread-4] INFO data.scripts.hullmods.dara_RedArrowPaint - Incremented to and saved frame #1
98977 [Thread-4] INFO data.scripts.hullmods.dara_RedArrowPaint - Retrieved frame #1
98977 [Thread-4] INFO data.scripts.hullmods.dara_RedArrowPaint - Incremented to and saved frame #2
113244 [Thread-4] INFO data.scripts.hullmods.dara_RedArrowPaint - Retrieved frame #2
113245 [Thread-4] INFO data.scripts.hullmods.dara_RedArrowPaint - Incremented to and saved frame #3
114526 [Thread-4] INFO data.scripts.hullmods.dara_RedArrowPaint - Retrieved frame #3
114527 [Thread-4] INFO data.scripts.hullmods.dara_RedArrowPaint - Incremented to and saved frame #4
127248 [Thread-4] INFO data.scripts.hullmods.dara_RedArrowPaint - Retrieved frame #4
127248 [Thread-4] INFO data.scripts.hullmods.dara_RedArrowPaint - Incremented to and saved frame #5
And yet, in the refit screen, the animation frame of the weapon does not change.
YES the deco weapon has the right frames setup and is visible and all that jazz. I've tried multiple ways to ensure this, everything from manually giving the setFrame() call values for each one, to just making the animation have a non-zero frame rate and watching it go through each one from the refit screen.
NO the frame does not update in combat. It refuses to work anywhere...
Except for the codex. If you repeatedly click the ship's entry in the codex, you can see the image of the ship cycling through the animation frames exactly as I want it to elsewhere. What the hell!?
The worst bit about all of this? I KNOW that you CAN make a system just like this that manually changes weapon animation frame on a cyclic basis,
because I've already done it once. I'm not annoyed because it looks like this is impossible: I'm annoyed because I know it IS possible, and I cannot understand why I'm unable to make it work a second time.
I'm at my wit's end with this damn thing, tried about five different methods to make it work, and I'm |this close| to giving up. Help is sorely, desperately wanted.