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 <wopox1337@ya.ru>
This commit is contained in:
Vaqtincha 2021-08-31 16:05:25 +05:00 committed by GitHub
parent 38dda25a84
commit 67cc153f5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 0 deletions

View File

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

View File

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