Skip to content

Add mp_show_bomb_timer cvar: show C4 countdown on the HUD round timer#1164

Open
belomaxorka wants to merge 2 commits into
rehlds:masterfrom
belomaxorka:feat/show-bomb-timer
Open

Add mp_show_bomb_timer cvar: show C4 countdown on the HUD round timer#1164
belomaxorka wants to merge 2 commits into
rehlds:masterfrom
belomaxorka:feat/show-bomb-timer

Conversation

@belomaxorka

@belomaxorka belomaxorka commented Jul 3, 2026

Copy link
Copy Markdown

What

New cvar mp_show_bomb_timer (default 0 - original behavior). When enabled, after the C4 is planted the HUD round timer shows the countdown to the explosion (driven by m_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 BombDrop with the "planted" flag. Two things make the countdown display possible:

  • CBasePlayer::SyncRoundTimer() now substitutes the remaining C4 time and precedes the RoundTime message with an empty ShowTimer message, which un-hides the timer on the client. Since SyncRoundTimer is 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).
  • On plant, all players are resynced right after gmsgBombDrop is 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 + RoundTime to all players every second forever), this is fully event-driven: two messages per player at plant/defuse and nothing in between.

Edge cases covered

  • Same-frame defuse: the just-defused C4 is marked FL_KILLME by UTIL_Remove before the resync, so the bomb lookup can never pick it up.
  • Aborted defuse (released +use / defuser died): no resync, the countdown correctly keeps running.
  • Late join / reconnect / respawn while the bomb is ticking: the initial HUD sync sends ShowTimer + the exact remaining time.
  • Round restart: CleanUpMap() removes the C4 before any sync, plus the freeze-period guard - no stale bomb can leak into the new round.
  • mp_roundtime 0 servers (timer normally hidden as useless): the existing HIDEHUD_TIMER logic shows the timer for the countdown and hides it back after the defuse.
  • Explosion: the client display reaches 0:00 exactly at the detonation, since both are driven by m_flC4Blow.
  • The displayed value uses the same floor semantics as the stock round timer (the digit means "full seconds remaining").

Behavior notes

  • After a successful defuse the round timer is restored, not hidden. This is deliberate: with mp_round_infinite (flag e) 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.
  • If a plugin changes m_flC4Blow after 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_infinite flag e), the explosion does not end the round and the timer stayed frozen at 0:00; it is now resynced for all players in CGrenade::Explode2, mirroring the resync already done on defuse.

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>
@belomaxorka belomaxorka changed the title Add mp_show_bomb_timer cvar: show C4 countdown on the HUD round timer Add mp_show_bomb_timer cvar: show C4 countdown on the HUD round timer Jul 3, 2026
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>
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