Raptor007 / aq2-tng

Action Quake 2: The Next Generation. Raptor007's sandbox for testing changes. When verified stable, this code is pushed to the official aq2-tng repo:
https://github.com/aq2-tng/aq2-tng/tree/bots
4 stars 2 forks source link

Third-person player models sometimes animate too fast when firing full-auto. #57

Closed Raptor007 closed 7 years ago

Raptor007 commented 7 years ago

Seemingly randomly on sv_fps servers, it looks like the weapon is jiggling really fast when you view someone 3rd person who is firing full-auto MP5 or M4. My guess it that the animation state is being allowed to change too quickly when going to firing, possibly if they started shooting on a non-framesync frame.

Raptor007 commented 7 years ago

Probably around here somewhere: https://github.com/Raptor007/aq2-tng/blob/eed99469fb23a2756d9eaca4436bdad9061c423c/source/p_view.c#L1003

Raptor007 commented 7 years ago

Actually I think this is the main reason this happens randomly, although it probably only matters with sv_fps because anim_framesync isn't quite working as intended: https://github.com/Raptor007/aq2-tng/blob/eed99469fb23a2756d9eaca4436bdad9061c423c/source/p_weapon.c#L2357 https://github.com/Raptor007/aq2-tng/blob/eed99469fb23a2756d9eaca4436bdad9061c423c/source/p_weapon.c#L2514

m4son commented 7 years ago

Skuller's openffa has no problems with animation at all, you might wanna peek at his openffa repository @ http://git.skuller.net/openffa/

Raptor007 commented 7 years ago

I just checked it out, and the reason they don't have any animation issues is that their animations and Weapon_Think are still restricted to 10fps via FRAMESYNC: http://git.skuller.net/openffa/tree/p_client.c#n1900

So sv_fps doesn't reduce the shot lag in OpenFFA like it does in TNG: https://github.com/Raptor007/aq2-tng/commit/3d81db187fbe9c0da418d6fc4d3565cb98e9d82c

Raptor007 commented 7 years ago

To reduce lag with sv_fps (#47 #48) I allowed animations and shooting to begin on any frame instead of the original FRAMESYNC 10fps, but I didn't synchronize them. I'm pretty sure this is what caused the player shooting animation to move too quickly.

When a weapon fires, it sets the animation frame to 1 before the first actual firing frame: https://github.com/Raptor007/aq2-tng/blob/12e0a2d09b406133804aadc9c942be16e74db2d7/source/p_weapon.c#L1746

This is because it expects G_SetClientFrame to increment the animation during this frame: https://github.com/Raptor007/aq2-tng/blob/12e0a2d09b406133804aadc9c942be16e74db2d7/source/p_view.c#L1025

But if it's not lined up with anim_framesync that won't happen until a later frame: https://github.com/Raptor007/aq2-tng/blob/12e0a2d09b406133804aadc9c942be16e74db2d7/source/p_view.c#L1011

This is most noticeable with full-auto. For example, with sv_fps 20 the weapon could be firing on odd frames but with animations being updated on even frames.

This should fix it: https://github.com/Raptor007/aq2-tng/commit/12e0a2d09b406133804aadc9c942be16e74db2d7

Please reopen this issue if I'm wrong and you see this bug again.