Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ This means that plugins that do binary code analysis (Orpheu for example) probab
| mp_hostage_hurtable | 1 | 0 | 1 | The hostages can take damage.<br/>`0` disabled<br/>`1` from any team<br/>`2` only from `CT`<br/>`3` only from `T` |
| mp_show_radioicon | 1 | 0 | 1 | Show radio icon.<br/>`0` disabled<br/>`1` enabled |
| mp_show_scenarioicon | 0 | 0 | 1 | Show scenario icon in HUD such as count of alive hostages or ticking bomb.<br/>`0` disabled<br/>`1` enabled |
| mp_show_bomb_timer | 0 | 0 | 1 | Show the time until the planted bomb explodes on the HUD round timer.<br/>`0` disabled<br/>`1` enabled (when the bomb is planted, the round timer shows the C4 countdown) |
| mp_old_bomb_defused_sound | 1 | 0 | 1 | Play "Bomb has been defused" sound instead of "Counter-Terrorists win" when bomb was defused<br/>`0` disabled<br/>`1` enabled |
| showtriggers | 0 | 0 | 1 | Debug cvar shows triggers. |
| sv_alltalk | 0 | 0 | 5 | When players can hear each other ([further explanation](../../wiki/sv_alltalk)).<br/>`0` dead don't hear alive<br/>`1` no restrictions<br/>`2` teammates hear each other<br/>`3` Same as 2, but spectators hear everybody<br/>`4` alive hear alive, dead hear dead and alive.<br/>`5` alive hear alive teammates, dead hear dead and alive.
Expand Down
7 changes: 7 additions & 0 deletions dist/game.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,13 @@ mp_show_radioicon "1"
// Default value: "0"
mp_show_scenarioicon "0"

// Show the time until the planted bomb explodes on the HUD round timer
// 0 - disabled (default behavior)
// 1 - enabled (when the bomb is planted, the round timer shows the C4 countdown)
//
// Default value: "0"
mp_show_bomb_timer "0"

// Play "Bomb has been defused" sound instead of "Counter-Terrorists win" when bomb was defused
// 0 - disabled (default behavior)
// 1 - enabled
Expand Down
4 changes: 4 additions & 0 deletions regamedll/dlls/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ cvar_t playerid_field = { "mp_playerid_field", "3", 0, 3.0f, nullptr };

cvar_t knockback = { "mp_knockback", "170", 0, 170.0f, nullptr };

cvar_t show_bomb_timer = { "mp_show_bomb_timer", "0", 0, 0.0f, nullptr };

void GameDLL_Version_f()
{
if (Q_stricmp(CMD_ARGV(1), "version") != 0)
Expand Down Expand Up @@ -489,6 +491,8 @@ void EXT_FUNC GameDLLInit()

CVAR_REGISTER(&knockback);

CVAR_REGISTER(&show_bomb_timer);

// print version
CONSOLE_ECHO("ReGameDLL version: " APP_VERSION "\n");

Expand Down
1 change: 1 addition & 0 deletions regamedll/dlls/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ extern cvar_t randomspawn;
extern cvar_t playerid_showhealth;
extern cvar_t playerid_field;
extern cvar_t knockback;
extern cvar_t show_bomb_timer;

#endif

Expand Down
13 changes: 13 additions & 0 deletions regamedll/dlls/ggrenade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ void CGrenade::__API_HOOK(Explode2)(TraceResult *pTrace, int bitsDamageType)
m_bJustBlew = true;
CSGameRules()->CheckWinConditions();

#ifdef REGAMEDLL_ADD
// restore the HUD round timer if the round did not end on the explosion
// (e.g. mp_round_infinite blocks the bomb round-end check)
if (show_bomb_timer.value != 0.0f)
SyncRoundTimerForAll();
#endif

// Pull out of the wall a bit
if (pTrace->flFraction != 1.0f)
{
Expand Down Expand Up @@ -1155,6 +1162,12 @@ void CGrenade::__API_HOOK(DefuseBombEnd)(CBasePlayer *pPlayer, bool bDefused)
g_pGameRules->m_bBombDropped = FALSE;
m_pBombDefuser = nullptr;
m_bStartDefuse = false;

#ifdef REGAMEDLL_ADD
// restore the HUD round timer
if (show_bomb_timer.value != 0.0f)
SyncRoundTimerForAll();
#endif
}
else
{
Expand Down
54 changes: 54 additions & 0 deletions regamedll/dlls/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3603,15 +3603,60 @@ void CBasePlayer::ResetMenu()
MESSAGE_END();
}

#ifdef REGAMEDLL_ADD
// Find the planted C4 in the world, if any
static CGrenade *FindPlantedBomb()
{
CGrenade *pBomb = nullptr;
while ((pBomb = UTIL_FindEntityByClassname(pBomb, "grenade")))
{
// skip the ones marked for removal (just defused)
if (pBomb->m_bIsC4 && !(pBomb->pev->flags & FL_KILLME))
return pBomb;
}

return nullptr;
}

// Resync the HUD round timer for all players
// (used when the timer switches between the round time and the C4 countdown)
void SyncRoundTimerForAll()
{
for (int i = 1; i <= gpGlobals->maxClients; i++)
{
CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
if (UTIL_IsValidPlayer(pPlayer))
pPlayer->SyncRoundTimer();
}
}
#endif

void CBasePlayer::SyncRoundTimer()
{
float tmRemaining = 0;
BOOL bFreezePeriod = g_pGameRules->IsFreezePeriod();

#ifdef REGAMEDLL_ADD
bool bBombTimer = false;
#endif

if (g_pGameRules->IsMultiplayer())
{
tmRemaining = CSGameRules()->GetRoundRemainingTimeReal();

#ifdef REGAMEDLL_ADD
// show the time until the planted bomb explodes instead of the round timer
if (show_bomb_timer.value != 0.0f && !bFreezePeriod)
{
CGrenade *pBomb = FindPlantedBomb();
if (pBomb && pBomb->m_flC4Blow > gpGlobals->time)
{
tmRemaining = pBomb->m_flC4Blow - gpGlobals->time;
bBombTimer = true;
}
}
#endif

#ifdef REGAMEDLL_FIXES
// hide timer HUD because it is useless.
if (tmRemaining <= 0.0f && CSGameRules()->m_iRoundTime <= 0) {
Expand All @@ -3631,6 +3676,15 @@ void CBasePlayer::SyncRoundTimer()
if (tmRemaining < 0)
tmRemaining = 0;

#ifdef REGAMEDLL_ADD
// the client hides the HUD timer once the bomb is planted, re-show it
if (bBombTimer)
{
MESSAGE_BEGIN(MSG_ONE, gmsgShowTimer, nullptr, pev);
MESSAGE_END();
}
#endif

MESSAGE_BEGIN(MSG_ONE, gmsgRoundTime, nullptr, pev);
WRITE_SHORT(int(tmRemaining));
MESSAGE_END();
Expand Down
4 changes: 4 additions & 0 deletions regamedll/dlls/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -1060,3 +1060,7 @@ bool IsSecondaryWeaponClass(int classId);
bool IsSecondaryWeaponId(int id);
const char *GetWeaponAliasFromName(const char *weaponName);
bool CurrentWeaponSatisfies(CBasePlayerWeapon *pWeapon, int id, int classId);

#ifdef REGAMEDLL_ADD
void SyncRoundTimerForAll();
#endif
7 changes: 7 additions & 0 deletions regamedll/dlls/wpn_shared/wpn_c4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,13 @@ void CC4::PrimaryAttack()
WRITE_BYTE(BOMB_FLAG_PLANTED);
MESSAGE_END();

#ifdef REGAMEDLL_ADD
// show the C4 countdown on the HUD round timer;
// must be sent after gmsgBombDrop, the client hides the timer on it
if (show_bomb_timer.value != 0.0f)
SyncRoundTimerForAll();
#endif

UTIL_ClientPrintAll(HUD_PRINTCENTER, "#Bomb_Planted");
if (TheBots)
{
Expand Down
Loading