From bdf2ddc2d12f0ac0cbc4788cea1695dbeadcd94b Mon Sep 17 00:00:00 2001 From: Alik Aslanyan Date: Sun, 1 Apr 2018 12:50:51 +0400 Subject: [PATCH] Fix C4 dissapearance on inclined surfaces with Valve HLDS (#234) --- regamedll/dlls/ggrenade.cpp | 13 +++++++++++++ regamedll/dlls/wpn_shared/wpn_c4.cpp | 10 ++++++++++ 2 files changed, 23 insertions(+) diff --git a/regamedll/dlls/ggrenade.cpp b/regamedll/dlls/ggrenade.cpp index b86b6325..a67289c4 100644 --- a/regamedll/dlls/ggrenade.cpp +++ b/regamedll/dlls/ggrenade.cpp @@ -1187,6 +1187,10 @@ CGrenade *CGrenade::__API_HOOK(ShootSatchelCharge)(entvars_t *pevOwner, VectorRe pGrenade->pev->spawnflags = SF_DETONATE; #ifdef REGAMEDLL_FIXES + TraceResult tr; + UTIL_TraceLine(vecStart, vecStart + Vector(0, 0, -8192), ignore_monsters, ENT(pevOwner), &tr); + pGrenade->pev->oldorigin = (tr.flFraction == 1.0) ? vecStart : tr.vecEndPos; + pGrenade->pev->nextthink = gpGlobals->time + 0.01f; #else pGrenade->pev->nextthink = gpGlobals->time + 0.1f; @@ -1277,8 +1281,17 @@ void CGrenade::C4Think() { if (!IsInWorld()) { +#ifdef REGAMEDLL_FIXES + pev->origin = pev->oldorigin; + + if (DROP_TO_FLOOR(edict()) > 0) + { + pev->velocity = g_vecZero; + } +#else UTIL_Remove(this); return; +#endif } #ifdef REGAMEDLL_FIXES diff --git a/regamedll/dlls/wpn_shared/wpn_c4.cpp b/regamedll/dlls/wpn_shared/wpn_c4.cpp index 4226fb55..b9ab8d09 100644 --- a/regamedll/dlls/wpn_shared/wpn_c4.cpp +++ b/regamedll/dlls/wpn_shared/wpn_c4.cpp @@ -106,6 +106,16 @@ void CC4::PrimaryAttack() int inBombZone = (m_pPlayer->m_signals.GetState() & SIGNAL_BOMB) == SIGNAL_BOMB; int onGround = (m_pPlayer->pev->flags & FL_ONGROUND) == FL_ONGROUND; + +#ifdef REGAMEDLL_FIXES + if (!onGround) + { + TraceResult tr; + UTIL_TraceLine(m_pPlayer->pev->origin, m_pPlayer->pev->origin + Vector(0, 0, -8192), ignore_monsters, m_pPlayer->edict(), &tr); + onGround = tr.flFraction != 1.0; + } +#endif + bool bPlaceBomb = (onGround && inBombZone); if (!m_bStartedArming)