diff --git a/regamedll/dlls/cbase.cpp b/regamedll/dlls/cbase.cpp index 5be847bdc..f797f92a6 100644 --- a/regamedll/dlls/cbase.cpp +++ b/regamedll/dlls/cbase.cpp @@ -1443,30 +1443,7 @@ VectorRef CBaseEntity::__API_HOOK(FireBullets3)(VectorRef vecSrc, VectorRef vecD if (tr.iHitgroup == HITGROUP_SHIELD) { - EMIT_SOUND(pEntity->edict(), CHAN_VOICE, (RANDOM_LONG(0, 1) == 1) ? "weapons/ric_metal-1.wav" : "weapons/ric_metal-2.wav", VOL_NORM, ATTN_NORM); - UTIL_Sparks(tr.vecEndPos); - - pEntity->pev->punchangle.x = iCurrentDamage * RANDOM_FLOAT(-0.15, 0.15); - pEntity->pev->punchangle.z = iCurrentDamage * RANDOM_FLOAT(-0.15, 0.15); - -#ifndef REGAMEDLL_FIXES - if (pEntity->pev->punchangle.x < 4) -#else - if (pEntity->pev->punchangle.x < -4) -#endif - { - pEntity->pev->punchangle.x = -4; - } - - if (pEntity->pev->punchangle.z < -5) - { - pEntity->pev->punchangle.z = -5; - } - else if (pEntity->pev->punchangle.z > 5) - { - pEntity->pev->punchangle.z = 5; - } - + pEntity->HitShield(iCurrentDamage, &tr); break; } @@ -1503,6 +1480,35 @@ VectorRef CBaseEntity::__API_HOOK(FireBullets3)(VectorRef vecSrc, VectorRef vecD return vecRet; } +void CBaseEntity::HitShield(float flDamage, TraceResult *ptr) +{ + if (RANDOM_LONG(0, 1)) + EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/ric_metal-1.wav", VOL_NORM, ATTN_NORM); + else + EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/ric_metal-2.wav", VOL_NORM, ATTN_NORM); + + UTIL_Sparks(ptr->vecEndPos); + +#ifdef REGAMEDLL_FIXES + if (Q_fabs(pev->punchangle.x) < 4.0) + { + pev->punchangle.x = clamp(flDamage * RANDOM_FLOAT(-0.15, 0.15), -4.0f, 4.0f); + } +#else + pev->punchangle.x = flDamage * RANDOM_FLOAT(-0.15, 0.15); + + if (pev->punchangle.x < 4) + pev->punchangle.x = -4; +#endif + +#ifdef REGAMEDLL_FIXES + if (Q_fabs(pev->punchangle.z) < 5.0) +#endif + { + pev->punchangle.z = clamp(flDamage * RANDOM_FLOAT(-0.15, 0.15), -5.0f, 5.0f); + } +} + void CBaseEntity::TraceBleed(float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) { if (BloodColor() == DONT_BLEED) diff --git a/regamedll/dlls/cbase.h b/regamedll/dlls/cbase.h index 8149356fa..70cdd7d00 100644 --- a/regamedll/dlls/cbase.h +++ b/regamedll/dlls/cbase.h @@ -162,6 +162,7 @@ class CBaseEntity { bool Intersects(const Vector &mins, const Vector &maxs); bool CanTakeHealth(float flHealth = 0.0f) const; void MakeDormant(); + void HitShield(float flDamage, TraceResult* ptr); // This entity's classname. const char *GetClassname() const { return pev->classname.str(); } diff --git a/regamedll/dlls/player.cpp b/regamedll/dlls/player.cpp index 1a895df62..4ab8a4762 100644 --- a/regamedll/dlls/player.cpp +++ b/regamedll/dlls/player.cpp @@ -640,27 +640,16 @@ void EXT_FUNC CBasePlayer::__API_HOOK(TraceAttack)(entvars_t *pevAttacker, float if (bHitShield) { +#ifndef REGAMEDLL_FIXES flDamage = 0; - bShouldBleed = false; - - if (RANDOM_LONG(0, 1)) - EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/ric_metal-1.wav", VOL_NORM, ATTN_NORM); - else - EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/ric_metal-2.wav", VOL_NORM, ATTN_NORM); - - UTIL_Sparks(ptr->vecEndPos); - - pev->punchangle.x = flDamage * RANDOM_FLOAT(-0.15, 0.15); - pev->punchangle.z = flDamage * RANDOM_FLOAT(-0.15, 0.15); - - if (pev->punchangle.x < 4) - pev->punchangle.x = -4; +#endif - if (pev->punchangle.z < -5) - pev->punchangle.z = -5; + bShouldBleed = false; + HitShield(flDamage, ptr); - else if (pev->punchangle.z > 5) - pev->punchangle.z = 5; +#ifdef REGAMEDLL_FIXES + flDamage = 0; +#endif } else {