Skip to content

Fix Vaccinator charge sounds playing multiple times per tick #22

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

Open
wants to merge 1 commit into
base: tc2-mod
Choose a base branch
from

Conversation

treacherousfiend
Copy link

@treacherousfiend treacherousfiend commented Feb 25, 2025

Due to prediction, the PrimaryAttack() function runs multiple times every tick. Every time the function runs on a tick where the player gains a charge, it will stack a copy of the sound that plays, which quickly becomes extremely loud. Commonly this will play 2 or 3, but in testing I've seen upwards of 7 or 8 playing at the same time.

This PR partially relies on #21, as prediction errors also can cause the charge to revert back to below the threshold for playing the sound, so this isn't a full fix unfortunately. I'm not sure how you would fix that to not cause issues when poor connection causes prediction errors.

Related Issue

Source-1-Games Issue 4479

Implementation

Add a IsFirstTimePredicted() check to the Vaccinator specific sound code, preventing it from playing on extra function calls used for prediction. Valve uses this function themselves twice in the medigun code alone to try and prevent some sound code from being run more than once.

Screenshots

Checklist

  • No other PRs implement this idea.
  • This PR does not introduce any regressions.
  • I certify that this PR is my own entirely original work, or I have permission from and have attributed the relevant authors.
  • I have agreed to and signed this project's Contributor License Agreement.
  • This PR targets the tc2-mod branch.
  • This change has been filed as an issue.
  • No other PRs address this.
  • This PR is as minimal as possible.
  • This PR does not introduce any regressions.
  • This PR has been built and locally tested on at least one platform.
  • This PR has been tested on all platforms, on both a dedicated server and on a listen server.

Testing Checklist

Client Server Version
Windows Built & Tested N/A Windows 10 Home 22H2
Linux

Caveats

Its possible that in an attempt to mitigate the issue Valve may have made the vaccinator charge noises quieter than they otherwise would've been, causing them to be pretty quiet in the instance that the bug was fixed. I have not tested if I think this is an issue, and I feel like it partially would be subjective anyway

Alternatives

In the past I implemented a very poor bandaid fix involving a variable which was incremented when a new charge was gotten and decremented when one was used, preventing the sound from playing more than once for each charge. Comparatively it was over-complicated and did not fix the heart of the issue

Due to prediction, the PrimaryAttack() function runs multiple times every tick.
Every time the function runs on a tick where the player gains another charge, it will stack a copy of the sound that plays, which quickly becomes extremely loud. Commonly this will play 2 or 3, but in testing I've seen upwards of 7 or 8 playing at the same time.
@treacherousfiend treacherousfiend changed the title Fix Vaccinator charge sounds playing 2+ times/tick Fix Vaccinator charge sounds playing multiple times per tick Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant