From 67cc153f5d0abab1e42b32a83ef4a470c8781a5c Mon Sep 17 00:00:00 2001 From: Vaqtincha <51029683+Vaqtincha@users.noreply.github.com> Date: Tue, 31 Aug 2021 16:05:25 +0500 Subject: [PATCH] Fix "use accuracy from last bullet fired earlier" glitch. (#662) * Fixes "use accuracy from last bullet fired earlier" glitch. * fix newline at wapons.h Co-authored-by: Sergey Shorokhov --- regamedll/dlls/weapons.cpp | 31 +++++++++++++++++++++++++++++++ regamedll/dlls/weapons.h | 1 + 2 files changed, 32 insertions(+) diff --git a/regamedll/dlls/weapons.cpp b/regamedll/dlls/weapons.cpp index ba5543ee..22d61fc9 100644 --- a/regamedll/dlls/weapons.cpp +++ b/regamedll/dlls/weapons.cpp @@ -49,6 +49,29 @@ int MaxAmmoCarry(WeaponIdType weaponId) return CBasePlayerItem::m_ItemInfoArray[weaponId].iMaxAmmo1; } +// All automatic weapons are represented here +float GetBaseAccuracy(WeaponIdType id) +{ + switch (id) + { + case WEAPON_M4A1: + case WEAPON_AK47: + case WEAPON_AUG: + case WEAPON_SG552: + case WEAPON_FAMAS: + case WEAPON_GALIL: + case WEAPON_M249: + case WEAPON_P90: + case WEAPON_TMP: + return 0.2f; + case WEAPON_MAC10: + return 0.15f; + case WEAPON_UMP45: + case WEAPON_MP5N: + return 0.0f; + } +} + // Resets the global multi damage accumulator void ClearMultiDamage() { @@ -1024,6 +1047,14 @@ void CBasePlayerWeapon::ItemPostFrame() { m_flDecreaseShotsFired = gpGlobals->time + 0.0225f; m_iShotsFired--; + +#ifdef REGAMEDLL_FIXES + // Reset accuracy + if (m_iShotsFired == 0) + { + m_flAccuracy = GetBaseAccuracy((WeaponIdType)m_iId); + } +#endif } } diff --git a/regamedll/dlls/weapons.h b/regamedll/dlls/weapons.h index 04429c46..45020c39 100644 --- a/regamedll/dlls/weapons.h +++ b/regamedll/dlls/weapons.h @@ -2056,3 +2056,4 @@ void EjectBrass2(const Vector &vecOrigin, const Vector &vecVelocity, float rotat void AddAmmoNameToAmmoRegistry(const char *szAmmoname); void UTIL_PrecacheOtherWeapon(const char *szClassname); BOOL CanAttack(float attack_time, float curtime, BOOL isPredicted); +float GetBaseAccuracy(WeaponIdType id);