Fix C4 dissapearance on inclined surfaces with Valve HLDS (#234)

This commit is contained in:
Alik Aslanyan 2018-04-01 12:50:51 +04:00 committed by GitHub
parent 99e54bb5b4
commit bdf2ddc2d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 0 deletions

View File

@ -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

View File

@ -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)