Fix some of C4 related bugs. (#179)

- Cancel C4 planting bartime on weapon change
- Infinite round, when bomb exploded underwater
- C4 explode after defuse
- Moving while defusing and silent defuse (partially)
- Silent defuse
This commit is contained in:
In-line 2017-08-19 19:01:33 +04:00 committed by Dmitry Novikov
parent b27d7bc05e
commit 8b1be212bf
3 changed files with 31 additions and 2 deletions

View File

@ -983,7 +983,9 @@ void CGrenade::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useTy
// TODO show messages on clients on event
ClientPrint(player->pev, HUD_PRINTCENTER, "#Defusing_Bomb_With_Defuse_Kit");
#ifndef REGAMEDLL_FIXES
EMIT_SOUND(ENT(player->pev), CHAN_ITEM, "weapons/c4_disarm.wav", VOL_NORM, ATTN_NORM);
#endif
player->m_bIsDefusing = true;
m_pBombDefuser = pActivator;
@ -1003,7 +1005,9 @@ void CGrenade::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useTy
// TODO: show messages on clients on event
ClientPrint(player->pev, HUD_PRINTCENTER, "#Defusing_Bomb_Without_Defuse_Kit");
#ifndef REGAMEDLL_FIXES
EMIT_SOUND(ENT(player->pev), CHAN_ITEM, "weapons/c4_disarm.wav", VOL_NORM, ATTN_NORM);
#endif
player->m_bIsDefusing = true;
m_pBombDefuser = pActivator;
@ -1014,6 +1018,10 @@ void CGrenade::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useTy
// start the progress bar
player->SetProgressBarTime(10);
}
#ifdef REGAMEDLL_FIXES
EMIT_SOUND(edict(), CHAN_ITEM, "weapons/c4_disarm.wav", VOL_NORM, ATTN_NORM); // Emit sound using bomb.
#endif
}
CGrenade *CGrenade::ShootSatchelCharge(entvars_t *pevOwner, Vector vecStart, Vector vecAngles)
@ -1201,7 +1209,11 @@ void CGrenade::C4Think()
}
// If the timer has expired ! blow this bomb up!
#ifdef REGAMEDLL_FIXES
if(gpGlobals->time >= m_flC4Blow && (!(m_bStartDefuse && m_pBombDefuser) || gpGlobals->time < m_flDefuseCountDown)) // Prevent exploding after defusing.
#else
if (gpGlobals->time >= m_flC4Blow)
#endif
{
if (TheBots)
{
@ -1232,10 +1244,15 @@ void CGrenade::C4Think()
g_pGameRules->m_bBombDropped = FALSE;
#ifndef REGAMEDLL_FIXES
if (pev->waterlevel != 0)
UTIL_Remove(this);
UTIL_Remove(this); // Causes infinite round
else
#endif
{
SetThink(&CGrenade::Detonate2);
}
}
// if the defusing process has started

View File

@ -960,7 +960,11 @@ void CBasePlayerWeapon::ItemPostFrame()
m_fInReload = FALSE;
}
if ((usableButtons & IN_ATTACK2) && CanAttack(m_flNextSecondaryAttack, UTIL_WeaponTimeBase(), UseDecrement()))
if ((usableButtons & IN_ATTACK2) && CanAttack(m_flNextSecondaryAttack, UTIL_WeaponTimeBase(), UseDecrement())
#ifdef REGAMEDLL_FIXES
&& !m_pPlayer->m_bIsDefusing // In-line: I think it's fine to block secondary attack, when defusing. It's better then blocking speed resets in weapons.
#endif
)
{
if (pszAmmo2() && !m_pPlayer->m_rgAmmo[SecondaryAmmoIndex()])
{

View File

@ -72,6 +72,14 @@ BOOL CC4::Deploy()
void CC4::Holster(int skiplocal)
{
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5f;
#ifdef REGAMEDLL_FIXES
if(m_bStartedArming)
{
m_pPlayer->SetProgressBarTime(0);
}
#endif
m_bStartedArming = false; // stop arming sequence
if (!m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType])