#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
const SECONDARY_WPN_BS = ((1<<CSW_P228)|(1<<CSW_ELITE)|(1<<CSW_FIVESEVEN)|(1<<CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_DEAGLE))
const EXP_WPN_BS = ((1<<CSW_HEGRENADE)|(1<<CSW_SMOKEGRENADE)|(1<<CSW_FLASHBANG)|(1<<CSW_KNIFE)|(1<<CSW_C4))
const SNIPER_WPN_BS = ((1<<CSW_AWP)|(1<<CSW_SCOUT)|(1<<CSW_SG550)|(1<<CSW_G3SG1))
const m_pPlayer = 41
const m_iFOV = 363
const random_seed = 96
const m_flAccuracy = 62
const m_flLastFire = 63
const m_iShotsFired = 64
const m_iId = 43
const XO_WEAPON = 4
#define MAX_CLIENTS 32
new Float:g_vecPunchAngle[MAX_CLIENTS + 1][3], Float:g_vecVelocity[MAX_CLIENTS + 1][3]
public plugin_init()
{
register_plugin("Patch Accuracy", "0.2", "Vaqtincha")
for(new szWeaponName[17], iId = CSW_P228; iId <= CSW_P90; iId++)
{
if(!(EXP_WPN_BS & (1 << iId)) && get_weaponname(iId, szWeaponName, charsmax(szWeaponName)))
{
RegisterHam(Ham_Weapon_PrimaryAttack, szWeaponName, "CBasePlayerWeapon_PrimAttack", false)
RegisterHam(Ham_Weapon_PrimaryAttack, szWeaponName, "CBasePlayerWeapon_PrimAttackP", true)
}
}
}
public CBasePlayerWeapon_PrimAttackP(const pWeapon)
{
if(pWeapon <= 0)
return
new pPlayer = get_pdata_cbase(pWeapon, m_pPlayer, XO_WEAPON)
if(pPlayer > 0)
{
set_pev(pPlayer, pev_punchangle, g_vecPunchAngle[pPlayer])
if(g_vecVelocity[pPlayer][0] && g_vecVelocity[pPlayer][0] && g_vecVelocity[pPlayer][0])
{
set_pev(pPlayer, pev_velocity, g_vecVelocity[pPlayer])
set_pev(pPlayer, pev_fov, float(get_pdata_int(pPlayer, m_iFOV)))
set_pev(pPlayer, pev_flags, pev(pPlayer, pev_flags) & ~(FL_ONGROUND|FL_DUCKING))
g_vecVelocity[pPlayer][0] = g_vecVelocity[pPlayer][0] = g_vecVelocity[pPlayer][0] = 0.0
}
}
}
public CBasePlayerWeapon_PrimAttack(const pWeapon)
{
if(pWeapon <= 0)
return
new pPlayer = get_pdata_cbase(pWeapon, m_pPlayer, XO_WEAPON)
if(pPlayer > 0)
{
pev(pPlayer, pev_punchangle, g_vecPunchAngle[pPlayer])
set_pdata_int(pPlayer, random_seed, 0)
new iId = get_pdata_int(pWeapon, m_iId, XO_WEAPON)
if(SECONDARY_WPN_BS & (1 << iId))
{
set_pdata_float(pWeapon, m_flLastFire, 0.0, XO_WEAPON)
set_pdata_float(pWeapon, m_flAccuracy, 1.0, XO_WEAPON)
}
else if(SNIPER_WPN_BS & (1 << iId))
{
pev(pPlayer, pev_velocity, g_vecVelocity[pPlayer])
set_pev(pPlayer, pev_flags, pev(pPlayer, pev_flags) | (FL_ONGROUND|FL_DUCKING))
set_pev(pPlayer, pev_velocity, Float:{0.0, 0.0, 0.0})
set_pev(pPlayer, pev_fov, 40.0)
if(iId == CSW_SG550 || iId == CSW_G3SG1)
{
set_pdata_float(pWeapon, m_flLastFire, 0.0, XO_WEAPON)
set_pdata_float(pWeapon, m_flAccuracy, 1.0, XO_WEAPON)
}
}
else
{
set_pdata_int(pWeapon, m_iShotsFired, 0, XO_WEAPON)
set_pdata_float(pWeapon, m_flAccuracy, 0.0, XO_WEAPON)
}
}
}