Add mp_show_bomb_timer cvar: show C4 countdown on the HUD round timer#1164
Open
belomaxorka wants to merge 2 commits into
Open
Add mp_show_bomb_timer cvar: show C4 countdown on the HUD round timer#1164belomaxorka wants to merge 2 commits into
mp_show_bomb_timer cvar: show C4 countdown on the HUD round timer#1164belomaxorka wants to merge 2 commits into
Conversation
When enabled, the HUD round timer shows the time remaining until the planted C4 explodes instead of hiding after the bomb plant, and is restored back to the round time after a successful defuse. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
mp_show_bomb_timer cvar: show C4 countdown on the HUD round timer
With mp_show_bomb_timer enabled the round timer shows the C4 countdown after a plant. If the bomb round-end check is blocked (mp_round_infinite flag e), the explosion does not end the round and the HUD timer stays frozen at 0:00 until the next resync event. Resync the timer for all players in CGrenade::Explode2 so it falls back to the real round time once the bomb has blown, mirroring the resync already done on defuse. Co-Authored-By: Claude Fable 5 <noreply@anthropic.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.
What
New cvar
mp_show_bomb_timer(default0- original behavior). When enabled, after the C4 is planted the HUD round timer shows the countdown to the explosion (driven bym_flC4Blow, the same value the game uses to detonate) instead of disappearing. After a successful defuse the timer switches back to the round time.How it works
The stock CS 1.6 client hides the HUD round timer when it receives
BombDropwith the "planted" flag. Two things make the countdown display possible:CBasePlayer::SyncRoundTimer()now substitutes the remaining C4 time and precedes theRoundTimemessage with an emptyShowTimermessage, which un-hides the timer on the client. SinceSyncRoundTimeris the single place that drives the HUD timer, every existing sync point picks the feature up automatically: initial HUD sync on connect (UpdateClientData), respawn (Spawn), freeze end (OnRoundFreezeEnd).gmsgBombDropis broadcast (wpn_c4.cpp), so within one frame the client processes: hide (BombDrop) ? show (ShowTimer) ? countdown value (RoundTime). No periodic resending is needed - the client counts down locally from the exact value.Unlike the popular AMXX implementations (which hook the plant and re-send
ShowTimer+RoundTimeto all players every second forever), this is fully event-driven: two messages per player at plant/defuse and nothing in between.Edge cases covered
FL_KILLMEbyUTIL_Removebefore the resync, so the bomb lookup can never pick it up.+use/ defuser died): no resync, the countdown correctly keeps running.ShowTimer+ the exact remaining time.CleanUpMap()removes the C4 before any sync, plus the freeze-period guard - no stale bomb can leak into the new round.mp_roundtime 0servers (timer normally hidden as useless): the existingHIDEHUD_TIMERlogic shows the timer for the countdown and hides it back after the defuse.m_flC4Blow.Behavior notes
mp_round_infinite(flage) or plugins that supersede the round end, the round continues after a defuse and the round time is meaningful again. On regular servers the round ends a few seconds later anyway and the next round resyncs everything - same visuals as any other round ending.m_flC4Blowafter the plant (ReAPI), the client countdown will not follow automatically - the plugin can trigger a resync itself; a periodic resync was intentionally avoided to keep the feature zero-cost.Tested
Verified on a live ReHLDS server (Windows, CS 1.6): plant (as T and observing as CT), successful defuse, aborted defuse, explosion, reconnect mid-countdown,
mp_show_bomb_timer 0- behavior identical to the original.Edit: restore the HUD round timer after the bomb explodes. If the bomb round-end check is blocked (
mp_round_infiniteflage), the explosion does not end the round and the timer stayed frozen at 0:00; it is now resynced for all players inCGrenade::Explode2, mirroring the resync already done on defuse.