From f9969aceab95783a537902282d127d4c88daf5ae Mon Sep 17 00:00:00 2001 From: Vaqtincha <51029683+Vaqtincha@users.noreply.github.com> Date: Mon, 12 Aug 2024 11:48:41 +0500 Subject: [PATCH 1/2] fix https://github.com/s1lentq/ReGameDLL_CS/issues/927 (#985) --- regamedll/dlls/wpn_shared/wpn_deagle.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/regamedll/dlls/wpn_shared/wpn_deagle.cpp b/regamedll/dlls/wpn_shared/wpn_deagle.cpp index e9bbc7132..f04ab55d6 100644 --- a/regamedll/dlls/wpn_shared/wpn_deagle.cpp +++ b/regamedll/dlls/wpn_shared/wpn_deagle.cpp @@ -204,11 +204,23 @@ void CDEAGLE::WeaponIdle() if (m_flTimeWeaponIdle <= UTIL_WeaponTimeBase()) { - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 20.0f; +#ifdef REGAMEDLL_FIXES + if (m_pPlayer->HasShield()) +#endif + { + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 20.0f; - if (m_iWeaponState & WPNSTATE_SHIELD_DRAWN) + if (m_iWeaponState & WPNSTATE_SHIELD_DRAWN) + { + SendWeaponAnim(DEAGLE_SHIELD_IDLE_UP, UseDecrement() != FALSE); + } + } +#ifdef REGAMEDLL_FIXES + else if (m_iClip) { - SendWeaponAnim(DEAGLE_SHIELD_IDLE_UP, UseDecrement() != FALSE); + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 3.0625f; + SendWeaponAnim(DEAGLE_IDLE1, UseDecrement() != FALSE); } +#endif } } From 5779d61557e7949ffa337da689063625397a2f5c Mon Sep 17 00:00:00 2001 From: dystopm Date: Tue, 13 Aug 2024 15:43:31 -0400 Subject: [PATCH 2/2] Shield hit punchangle change logic grouped --- regamedll/dlls/cbase.cpp | 54 ++++++++++++++++++++++----------------- regamedll/dlls/cbase.h | 1 + regamedll/dlls/player.cpp | 25 +++++------------- 3 files changed, 38 insertions(+), 42 deletions(-) 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 {