twhl-community / halflife-unified-sdk

Half-Life Updated SDK with Opposing Force and Blue Shift merged in, along with other improvements. Check README.md for more information.
Other
147 stars 26 forks source link

Hornet gun does not play fire animation on regen when previously empty. #530

Closed malortie closed 1 year ago

malortie commented 1 year ago

Description

When the hornet gun was empty and regenerates one ammo, the fire animation does not play. This happens for primary and secondary attack modes.

Steps to reproduce

  1. Open the console and type the following:
    sv_cheats 1
    map t0a0
    impulse 101
  2. Switch to hornet gun.
  3. Hold down the primary attack key. Keep holding down even when you are out of ammo.
  4. Hold down the secondary attack key. Keep holding down even when you are out of ammo.

In both attack modes, the fire animation does not play.

Build : Half-Life Unified SDK V1.0.0 Release Candidate 001

Project info

Using cl_projectinfo_print_all :

Project info for client:
Version: 1.0.0-Beta
Branch: master
Tag: UNIFIED-V1.0.0-RC001
Commit Hash: 68ea0b7ec048935f1e1e740c5778aedebb00458d
Build Timestamp: 20:02:58 Jul 30 2023
Project info for server:
Version: 1.0.0-Beta
Branch: master
Tag: UNIFIED-V1.0.0-RC001
Commit Hash: 68ea0b7ec048935f1e1e740c5778aedebb00458d
Build Timestamp: 20:03:54 Jul 30 2023
SamVanheer commented 1 year ago

This is caused by an edge case in the game's weapon prediction system.

The server simulates the frame first, runs the attack logic and decrements the ammo count. That ammo count is then sent to the client which simulates the same frame with the state the player is in at the end of the frame so the ammo count is already 0, so it doesn't run the attack logic and doesn't play the animation.

It should be simulating frames using the state from the start of the frame to work properly but that's not possible within the limits of the SDK.

There are other problems like this in the weapons code. With some ugly workarounds this can be fixed but it's fragile. I've fixed this issue by manually tracking this edge case and having the server play the animation instead.