-
Notifications
You must be signed in to change notification settings - Fork 203
[jak2/3] Fix same-attack-invulnerable-timeout clock drift original game bug
#3978
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
some sample logs I added to show the clock drift before/after the glider cutscene |
|
Can you figure out which clocks are being used? |
|
Quick test in jak3: I'm not sure where the behavior differs between the two clocks during the temple example though. It looks like they've got the same mask So the only other thing I can think of is something changing one of the |
|
Looks like the |
oh yeah good find, if I duplicate all the |
|
I think that's what makes Jak seem normal speed while a mission is restarting. Definitely don't touch that stuff. I need to doublecheck if this is the correct clock to use in this attacking context, but I think it is. |
So
targethas some logic here which checks if the pending attack has the same ID as the last attack, and if so it checks for a 2s grace period(-> *TARGET-bank* same-attack-invulnerable-timeout)before the attack will actually count:jak-project/goal_src/jak3/engine/target/target-util.gc
Lines 1664 to 1674 in 7320bfc
This
same-attack-invulnerable-timeoutcheck usestime-elapsed?, which under the hood references(current-time)AKA(-> PP clock frame-counter), which makes sense.However the code that actually stores the
attack-timeuses a different clock(-> *display* base-clock frame-counter):jak-project/goal_src/jak3/engine/target/target-util.gc
Lines 1765 to 1768 in 7320bfc
So if these two clocks get out of sync - say the
targetprocess clock falls behind the*display*clock - then we can end up storing anattack-timethat's "in the future" fromtarget's perspective, effectively increasing thesame-attack-invulnerable-timeout.This clock drift can happen in real gameplay - Usual today was having it happen consistently with the route he was attempting for NoOOB. I was able to reproduce it consistently in OpenGOAL as well:
(target-flags disable-attacks)but not(focus-status dead ignore))Somewhere in this^ cutscene/blackout, the two clocks drift apart - presumably
target's clock is paused but the other is not. Later in the speedrun, this causes the extra long invuln timeout bug, which wastes time while trying to intentionally lower health.https://www.youtube.com/watch?v=WD2MLj8ccfg
As far as I can tell, any other code interacting with
attack-timealso uses(current-time)or one of the wrapping macros likeset-time!ortime-elapsed?