[TF2] Fix redeployed Sentry Guns consuming metal incorrectly - #2026
Open
rockbruno wants to merge 2 commits into
Open
[TF2] Fix redeployed Sentry Guns consuming metal incorrectly#2026rockbruno wants to merge 2 commits into
rockbruno wants to merge 2 commits into
Conversation
Co-Authored-By: Luciano Ferruzzi <ferruzzi.luciano@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First, some context on how sentries work before explaining the problem:
With the way the code is structured today, the max health restriction on redeployed sentries applies not just to the initial building state but rather throughout the entire upgrade process. So if you're redeploying a level 3 sentry, its health will be capped until it returns to the level 3 state.
These facts combined can cause a very specific bug where if you time your wrench hits to land at precisely this moment where the sentry is in-between upgrades, the game will believe that a previously damaged sentry is actually at max health (due to the health being currently capped), and incorrectly result in metal being consumed to replenish ammo if possible. Gameplay-wise this is an issue because if it happens while repositioning sentries under fire, the player can end up accidentally running out of metal to heal the sentry.
Additionally, there is a second bug in this code where if the sentry has its health capped, gets damaged during redeployment, is in the upgrade animation, you heal it, and the heal amount overshoots the health cap, that heal will always cost zero metal regardless of the amount. The code makes it seem this might have been intentional but I'm guessing it's a bug because I've never seen this behavior documented anywhere (and it even plays the "failed" sound effect). (This one affects all buildings, not just the sentry)
These videos show the two problems. In the first one, you can see how the metal is consumed when the sentry upgrades to level 3 despite it being damaged, and the second one shows how heals can cost zero metal.
engie_reploy_before.mp4
engie_zero_metal.mp4
Determining the right way to fix these issues depends on whether Valve intended for the health cap to apply all the way through or if that's a bug that was never addressed. So there are a couple of options:
The PR itself implements option 1 because I feel that Valve probably didn't intend for the health cap or the zero cost thing to work the way it does today, but obviously it's up to Valve to confirm this. Option 2 is an easy fix and wouldn't affect balance. I'm not a fan of Option 3 because it might break interactions with things like the Red Tape Recorder.
Fixes ValveSoftware/Source-1-Games#8244