KOTORCommunityPatches / K1_Community_Patch

K1 Community Patch
62 stars 8 forks source link

Tatooine and Kashyyyk – Final Star Map Animation Timing Issues #756

Closed WildKarrde1138 closed 9 months ago

WildKarrde1138 commented 10 months ago

The utility function UT_StarMap4RunStarMap(), which is called to play most of the Star Maps, includes a 60 second delay between opening and closing the final map to allow the more elaborate final animation to play out exactly once. However, on Tatooine and Kashyyyk, I have observed cases where the timing is off and the closes partway through a second animation loop. If the diagram of the Star Forge system is showing when it closes, the star does not disappear but continues to show even after the map has shut down: Bugged Star Map Animation

The issue seems to be related to the party’s reaction dialog: If I click through it fast enough, the animation timing works as it should. Based on some experimenting, it appears that the animation timing doesn’t track properly when the map is not on screen during the dialog. That would also explain why I have never noticed the issue on Korriban, where there is no party to interject. Unfortunately, if that’s the case, I’m not sure of a way to fix it short of using custom camera angles so that the map is always in view.

DarthParametric commented 10 months ago

Hrm, odd. Could possibly be avoided by signalling an invisible placeable to fire the anim rather than from in the DLG itself. Although I would have thought the DLG owner in both cases was already an invisible placeable.

I know I have edited the Kashyyyk anim before because it was closing too early (see #123). Might be some issue with those changes perhaps. Can't recall if something similar was done on Tatooine, although I know the party was jumped for the scene at the very least.

Edit: #315 is the equivalent Tatooine issue. The anim length was changed there too.

WildKarrde1138 commented 10 months ago

Ah, I hadn't noticed that K1CP already edited those scripts. I had been testing with edited versions based on the vanilla script archive with the vanilla delay length of 60 seconds. I wonder if #123 has the same root cause: Perhaps the map fails to close properly if it is not on-screen when the animation should play?

(Side note, the 93.34 second delay in the K1CP version of k_pkas_openmap should probably be extended an additional 13.1 seconds to account for the length of the opening animation. The original 60 second delay approximately matches 13.1s + 46.67s for the opening and a single loop.)

Edit: On Kashyyyk, at least, the star map dialogs are owned by kas24_computer.utc (for the dialog that triggers the animation) and kas25_starspeak.utp (for the party interjections), so the root cause doesn't seem to be the Star Map being a dialog participant. I wonder if it could be an issue with how the engine tracks animations that aren't on-screen.

Edit 2: I just tested it with the K1CP version of k_pkas_openmap, and it still ends with the star hanging in place after the map closes. The looping animation ends at a different point depending on whether I click quickly through Jolee's dialog or let him speak, so the star ends up in slightly different locations.

DarthParametric commented 10 months ago

account for the length of the opening animation

You don't need to account for that anim. The function adds the new animation to the placeable's action stack (via ActionPlayAnimation), so it will fire once the open anim is finished.

it still ends with the star hanging in place after the map closes

It may not be something that is fixable. Although maybe the anims themselves could be edited.

WildKarrde1138 commented 10 months ago

You don't need to account for that anim. The function adds the new animation to the placeable's action stack (via ActionPlayAnimation), so it will fire once the open anim is finished.

I was referring to the delay for the close animation to fire. From what I can tell, DelayCommand does not queue as an action but starts counting from the moment it is run in the script. So for the map animation to loop X times, the delay before firing the close animation should be (Length of opening animation) + X*(Length of looping animation), so 106.44s for two loops. I believe that is why the vanilla 60 second delay more or less works on Korriban where there are no party interjections to interfere: 13.1 seconds + 46.67 seconds = 59.77 seconds.

DarthParametric commented 10 months ago

DelayCommand delays when the stated function fires, but it's firing ActionPlayAnimation, so it gets added to the action stack.

Edit: You are correct. The problem seems to be that placeables do not work in the same manner as creatures when it comes to ActionPlayAnimation, at least for loop anims. On a creature you can specify the anim length and that will be added to the stack for that length of time. But for a placeable loop anim it will apparently ignore a specified anim length and just loop it continuously until issued another command. Which I guess is for utility, since you will want certain placeables to be forced into one state or another without having to specify a time or reissue commands. Kind of annoying in this particular instance though.

DarthParametric commented 10 months ago

OK so testing this out on the Tatooine map by setting the K_TAT_STAR_MAP global to 40, I get the same issue where it cycles into a second loop of the anim and then closes halfway through. I guess because it's a loop it will just play endlessly until it gets another command. This is the same issue JC pointed out in #123, although the fix there wasn't correct, since setting the delay to double the length of the anim just makes it play twice, which looks weird. I think the problem in Kashyyyk's case was that that a single loop ended too soon, so the anim was over by the time Jolee finished yapping. Since I want to address the two separate DLGs there at some point anyway, we can probably add a shot that shows the full anim if it's the last map. I guess we could do the same for the other maps as well, since they're all handled in DLGs.

DarthParametric commented 10 months ago

One other thing to note is that the deactivate anim doesn't really work well with the final map's anim, since it briefly pops the initial outer sphere elements. Not sure if anything can be done about that, since altering the anim would affect all the others. It could be added as a new animloop I guess, since there's provision for up to 10, but you'd have to do a ClearAllActions on it right after to stop it looping.

Edit: OK so testing an added modified version of the On2Off anim with a few tweaks it works, but you need to use ActionPlayAnimation(ANIMATION_PLACEABLE_CLOSE), not ClearAllActions.

Edit 2: Frustratingly the added anim seems to randomly glitch out. Sometimes it works perfectly, sometimes a random VFX appears after it closes. Might need additional keys added, or perhaps certain nodes removed altogether. Not sure if I have time to troubleshoot it properly for inclusion 1.10.0, so we'll probably just have to stick with the default deactivate anim.

Edit 3: After leaving it for a bit and coming back to it, I think I have resolved it by shaving down the delay ever so slightly. Probably needs multiple runs to verify though. One other issue is that the added anim doesn't have any sound, since it's a loop not a proper deactivate. You can use PlaySound in a script, but that, as ever, seems completely unreliable as to whether or not it will decide to work. But it would be easy enough to add a sound object for it. Here's the modified star map model and a custom script to fire the animloop 6 on the Tatooine map (will set the global to 40 first). You can fire it from an armband or the like.

Edit 4: Beta fix removed. See committed files.

DarthParametric commented 10 months ago

The sound is proving extremely flaky. The inbuilt placeable sounds don't always fire, and even adding custom sound objects and telling them to play doesn't always work. Seems like enabling the "Sound Exists" flag on a DLG node helps with getting PlaySound to work, although it appears dialogue firing at the same time can interfere with it. It's difficult to tell for sure on Tatooine because of all the random background stuff going on.

DarthParametric commented 10 months ago

Might as well extend these changes to the Korriban map as well.

DarthParametric commented 9 months ago

1.10.0 beta test 2 observations: