CriticalFlaw / TF2HUD-Fixes

Bug fixes and minor visual improvements to the default Team Fortress 2 HUD.
https://steamcommunity.com/workshop/filedetails/?id=2153598398
128 stars 18 forks source link

[BUG] DamagedPlayer event causes FPS drops on fast firing weapons #263

Closed mtxfellen closed 7 months ago

mtxfellen commented 7 months ago

event DamagedPlayer in hudanimations_custom.txt currently looks like this:

event DamagedPlayer
{
    Animate CustomCrosshair     FgColor     "Hitmarker"     Linear  0.0     0.00001
    Animate CustomCrosshair     FgColor     "Crosshair"     Linear  0.10    0.10001
}

This will cause the animation to queue up on fast firing weapons and incur potentially significant performance penalties (regardless of whether you actually use a custom crosshair or hitmarker), most easily reproducible by using the Projectile Shield in MvM.

The remedy for this is to use a guard like this, which will cancel the previous event before running the next.

event DamagedPlayer
{
    StopEvent HitMarker 0.0
    RunEvent HitMarker 0.00001
}

event HitMarker
{
    Animate CustomCrosshair     FgColor     "Hitmarker"     Linear  0.0     0.00001
    Animate CustomCrosshair     FgColor     "Crosshair"     Linear  0.10    0.10001
}
CriticalFlaw commented 7 months ago

Good catch, other custom HUDs all use this.

Kruphixx commented 7 months ago

Tested the fix on another hud and it does seem to fix the perfomance issue as expected. No framerate drops with the shield.