Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "use accuracy from last bullet fired earlier" glitch. #662

Merged
merged 2 commits into from
Aug 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions regamedll/dlls/weapons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down Expand Up @@ -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
}
}

Expand Down
1 change: 1 addition & 0 deletions regamedll/dlls/weapons.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);