From dd40f7db546e1d385b7d4a11fc0c20d0c0ac66d8 Mon Sep 17 00:00:00 2001 From: In-line Date: Mon, 6 Nov 2017 13:43:39 +0400 Subject: [PATCH] Fixed: defuse can be started in air (#199) * Fixed: defuse can be started in air --- regamedll/dlls/ggrenade.cpp | 38 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/regamedll/dlls/ggrenade.cpp b/regamedll/dlls/ggrenade.cpp index 9dc451a8..55e17db3 100644 --- a/regamedll/dlls/ggrenade.cpp +++ b/regamedll/dlls/ggrenade.cpp @@ -951,6 +951,14 @@ void CGrenade::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useTy return; } +#ifdef REGAMEDLL_FIXES + if((player->pev->flags & FL_ONGROUND) != FL_ONGROUND) // Defuse should start only on ground + { + ClientPrint(player->pev, HUD_PRINTCENTER, "#C4_Defuse_Must_Be_On_Ground"); + return; + } +#endif + if (m_bStartDefuse) { m_fNextDefuse = gpGlobals->time + 0.5f; @@ -965,12 +973,9 @@ void CGrenade::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useTy TheBots->OnEvent(EVENT_BOMB_DEFUSING, pActivator); } - if (CSGameRules()->IsCareer()) + if (CSGameRules()->IsCareer() && TheCareerTasks) { - if (TheCareerTasks) - { - TheCareerTasks->HandleEvent(EVENT_BOMB_DEFUSING); - } + TheCareerTasks->HandleEvent(EVENT_BOMB_DEFUSING); } if (player->m_bHasDefuser) @@ -982,15 +987,8 @@ 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 = static_cast(pActivator); - m_bStartDefuse = true; m_flDefuseCountDown = gpGlobals->time + 5.0f; - m_fNextDefuse = gpGlobals->time + 0.5f; // start the progress bar player->SetProgressBarTime(5); @@ -1004,22 +1002,22 @@ 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 = static_cast(pActivator); - m_bStartDefuse = true; m_flDefuseCountDown = gpGlobals->time + 10.0f; - m_fNextDefuse = gpGlobals->time + 0.5f; - + // start the progress bar player->SetProgressBarTime(10); } + player->m_bIsDefusing = true; + m_pBombDefuser = static_cast(pActivator); + m_bStartDefuse = true; + m_fNextDefuse = gpGlobals->time + 0.5f; + #ifdef REGAMEDLL_FIXES EMIT_SOUND(edict(), CHAN_ITEM, "weapons/c4_disarm.wav", VOL_NORM, ATTN_NORM); // Emit sound using bomb. +#else + EMIT_SOUND(ENT(player->pev), CHAN_ITEM, "weapons/c4_disarm.wav", VOL_NORM, ATTN_NORM); #endif }