Code:
/**
*
* Accuracy Fix
* by Numb
*
*
* Description:
* One of the least known bugs in Counter-Strike is that accuracy of your bullet is
* predefined at the moment you made your previous shot, and how much time you wait
* has no effect on the bullet you just fired. However it has effect on the next time
* when you shall shoot. Sometimes players even think that their reg (bullet
* registration on the server) is off quite a bit. Fortunately this isn't a net code
* issue, but the actual glitch in accuracy calculation, what this plugin fixes. Also
* this plugin has few more extra features. Shortly here's everything what it does:
* + Fixes "use last fired bullet accuracy" glitch.
* + Improving accuracy drastically, when you aren't moving and your recoil is cooled
* down so to speak. You must stay on ground of course for that to happen. If you
* crouch, than effect becomes even stronger (in most weapons this scenario makes
* first bullet dead on center).
* + One more drastic change is major improvement on sg550 weapon recoil - as you may
* noticed, normally it isn't accurate at all, and recoil is simply horrible,
* especially comparing to terrorist automatic sniper rifle g3sg1.
* Last, but not least, when standing, scout accuracy is somewhat improved - normally,
* scout is really inaccurate, you must duck to make a shot, after what you wont ask
* yourself "Whaaat??? How did I miss?".
*
*
* Requires:
* FakeMeta
* HamSandWich
*
*
* Additional info:
* Tested in Counter-Strike 1.6 with amxmodx 1.8.2 (dev build hg21). You may also
* download demos to see for yourself this bugs and how well plugin handles them.
*
*
* Notes:
* Once installed, you wont see no graphical changes in accuracy. This is due to
* client-side accuracy calculation, what server does not update by default. In order to
* see actual location where bullet decal appears, you have to type "cl_lw 0" in console.
* But don't use this setting in actual gameplay, cause it disables client-side fire
* animations, and forces server-side ones what are delayed due to ping ("cl_lw 0" may
* and will lead to laggy gameplay).
*
*
* Credits:
* Special thanks to Arkshine ( <a href="http://forums.alliedmods.net/member.php?u=7779" target="_blank" rel="nofollow noopener">http://forums.alliedmods.net/member.php?u=7779</a> ) for
* Counter-Strike SDK ( <a href="http://code.google.com/p/cs-sdk/" target="_blank" rel="nofollow noopener">http://code.google.com/p/cs-sdk/</a> )!
*
*
* Change-Log:
*
* + 1.0
* - First release.
*
*
* Downloads:
* Amx Mod X forums: <a href="http://forums.alliedmods.net/showthread.php?p=1549133#post1549133" target="_blank" rel="nofollow noopener">http://forums.alliedmods.net/showthr...33#post1549133</a>
*
**/
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#define PLUGIN_NAME "Accuracy Fix"
#define PLUGIN_VERSION "1.0"
#define PLUGIN_AUTHOR "Numb"
#define m_pPlayer 41
#define m_flAccuracy 62
#define m_flLastFire 63
#define m_iShotsFired 64
#define m_fWeaponState 74
#define WEAPONSTATE_GLOCK18_BURST_MODE (1<<1)
new Float:g_fAccuracy;
public plugin_init()
{
register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_ak47", "Ham_Attack_ak47_Pre", 0);
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_aug", "Ham_Attack_aug_Pre", 0);
// awp accuracy offset does not exist
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_deagle", "Ham_Attack_deagle_Pre", 0);
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_deagle", "Ham_Attack_deagle_Post", 1);
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_elite", "Ham_Attack_elite_Pre", 0);
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_elite", "Ham_Attack_elite_Post", 1);
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_famas", "Ham_Attack_famas_Pre", 0);
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_fiveseven", "Ham_Attack_57_Pre", 0);
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_fiveseven", "Ham_Attack_57_Post", 1);
// g3sg1 accuracy offset has no effect
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_galil", "Ham_Attack_galil_Pre", 0);
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_glock18", "Ham_Attack_glock_Pre", 0);
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_glock18", "Ham_Attack_glock_Post", 1);
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_m249", "Ham_Attack_m249_Pre", 0);
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_m4a1", "Ham_Attack_m4a1_Pre", 0);
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_mac10", "Ham_Attack_mac10_Pre", 0);
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_mp5navy", "Ham_Attack_mp5_Pre", 0);
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_p228", "Ham_Attack_p228_Pre", 0);
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_p228", "Ham_Attack_p228_Post", 1);
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_p90", "Ham_Attack_p90_Pre", 0);
// scout accuracy offset does not exist
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_scout", "Ham_Attack_scout_Pre", 0);
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_scout", "Ham_Attack_scout_Post", 1);
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_sg550", "Ham_Attack_sg550_Pre", 0);
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_sg552", "Ham_Attack_sg552_Pre", 0);
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_tmp", "Ham_Attack_tmp_Pre", 0);
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_ump45", "Ham_Attack_ump45_Pre", 0);
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_usp", "Ham_Attack_usp_Pre", 0);
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_usp", "Ham_Attack_usp_Post", 1);
}
public Ham_Attack_ak47_Pre(iEnt)
{
static s_iShotsFired;
s_iShotsFired = get_pdata_int(iEnt, m_iShotsFired, 4)+1;
if( s_iShotsFired>1 )
{
g_fAccuracy = ((s_iShotsFired*s_iShotsFired*s_iShotsFired)/200.0)+0.35;
if( g_fAccuracy>1.25 )
g_fAccuracy = 1.25;
set_pdata_float(iEnt, m_flAccuracy, g_fAccuracy, 4);
}
else
{
static s_iOwner, s_iFlags;
s_iOwner = get_pdata_cbase(iEnt, m_pPlayer, 4);
s_iFlags = pev(s_iOwner, pev_flags);
if( s_iFlags&FL_ONGROUND )
{
static Float:s_fVelocity[3];
pev(s_iOwner, pev_velocity, s_fVelocity);
if( !s_fVelocity[0] && !s_fVelocity[1] )
{
if( s_iFlags&FL_DUCKING )
set_pdata_float(iEnt, m_flAccuracy, 0.0, 4);
else
set_pdata_float(iEnt, m_flAccuracy, 0.1, 4);
}
else
set_pdata_float(iEnt, m_flAccuracy, 0.2, 4);
}
else
set_pdata_float(iEnt, m_flAccuracy, 0.2, 4);
}
}
public Ham_Attack_aug_Pre(iEnt)
{
static s_iShotsFired;
s_iShotsFired = get_pdata_int(iEnt, m_iShotsFired, 4)+1;
if( s_iShotsFired>1 )
{
g_fAccuracy = ((s_iShotsFired*s_iShotsFired*s_iShotsFired)/215.0)+0.3;
if( g_fAccuracy>1.0 )
g_fAccuracy = 1.0;
set_pdata_float(iEnt, m_flAccuracy, g_fAccuracy, 4);
}
else
{
static s_iOwner, s_iFlags;
s_iOwner = get_pdata_cbase(iEnt, m_pPlayer, 4);
s_iFlags = pev(s_iOwner, pev_flags);
if( s_iFlags&FL_ONGROUND )
{
static Float:s_fVelocity[3];
pev(s_iOwner, pev_velocity, s_fVelocity);
if( !s_fVelocity[0] && !s_fVelocity[1] )
{
if( s_iFlags&FL_DUCKING )
set_pdata_float(iEnt, m_flAccuracy, 0.0, 4);
else
set_pdata_float(iEnt, m_flAccuracy, 0.1, 4);
}
else
set_pdata_float(iEnt, m_flAccuracy, 0.2, 4);
}
else
set_pdata_float(iEnt, m_flAccuracy, 0.2, 4);
}
}
public Ham_Attack_deagle_Pre(iEnt)
{
static Float:s_fLastFire;
s_fLastFire = get_pdata_float(iEnt, m_flLastFire, 4);
if( !s_fLastFire )
{
static s_iOwner, s_iFlags;
s_iOwner = get_pdata_cbase(iEnt, m_pPlayer, 4);
s_iFlags = pev(s_iOwner, pev_flags);
if( s_iFlags&FL_ONGROUND )
{
static Float:s_fVelocity[3];
pev(s_iOwner, pev_velocity, s_fVelocity);
if( !s_fVelocity[0] && !s_fVelocity[1] )
{
if( s_iFlags&FL_DUCKING )
g_fAccuracy = 1.0;
else
g_fAccuracy = 0.96;
}
else
g_fAccuracy = 0.92;
}
else
g_fAccuracy = 0.92;
set_pdata_float(iEnt, m_flAccuracy, g_fAccuracy, 4);
}
else if( get_pdata_int(iEnt, m_iShotsFired, 4)<=0 )
{
g_fAccuracy = get_pdata_float(iEnt, m_flAccuracy, 4);
g_fAccuracy -= (0.4-(get_gametime()-s_fLastFire))*0.35;
if( g_fAccuracy<0.55 )
g_fAccuracy = 0.55;
else if( g_fAccuracy>0.92 )
{
static s_iOwner, s_iFlags;
s_iOwner = get_pdata_cbase(iEnt, m_pPlayer, 4);
s_iFlags = pev(s_iOwner, pev_flags);
if( s_iFlags&FL_ONGROUND )
{
static Float:s_fVelocity[3];
pev(s_iOwner, pev_velocity, s_fVelocity);
if( !s_fVelocity[0] && !s_fVelocity[1] )
{
if( s_iFlags&FL_DUCKING )
g_fAccuracy = 1.0;
else
g_fAccuracy = 0.96;
}
else
g_fAccuracy = 0.92;
}
else
g_fAccuracy = 0.92;
}
set_pdata_float(iEnt, m_flAccuracy , g_fAccuracy, 4);
}
else
g_fAccuracy = -1.0;
}
public Ham_Attack_deagle_Post(iEnt)
{
if( g_fAccuracy>0.92 )
set_pdata_float(iEnt, m_flAccuracy , 0.92, 4);
else if( g_fAccuracy>0.0 )
set_pdata_float(iEnt, m_flAccuracy , g_fAccuracy, 4);
}
public Ham_Attack_elite_Pre(iEnt)
{
static Float:s_fLastFire;
s_fLastFire = get_pdata_float(iEnt, m_flLastFire, 4);
if( !s_fLastFire )
{
static s_iOwner, s_iFlags;
s_iOwner = get_pdata_cbase(iEnt, m_pPlayer, 4);
s_iFlags = pev(s_iOwner, pev_flags);
if( s_iFlags&FL_ONGROUND )
{
static Float:s_fVelocity[3];
pev(s_iOwner, pev_velocity, s_fVelocity);
if( !s_fVelocity[0] && !s_fVelocity[1] )
{
if( s_iFlags&FL_DUCKING )
g_fAccuracy = 1.0;
else
g_fAccuracy = 0.94;
}
else
g_fAccuracy = 0.88;
}
else
g_fAccuracy = 0.88;
set_pdata_float(iEnt, m_flAccuracy, g_fAccuracy, 4);
}
else if( get_pdata_int(iEnt, m_iShotsFired, 4)<=0 )
{
g_fAccuracy = get_pdata_float(iEnt, m_flAccuracy, 4);
g_fAccuracy -= (0.325-(get_gametime()-s_fLastFire))*0.275;
if( g_fAccuracy<0.55 )
g_fAccuracy = 0.55;
else if( g_fAccuracy>0.88 )
{
static s_iOwner, s_iFlags;
s_iOwner = get_pdata_cbase(iEnt, m_pPlayer, 4);
s_iFlags = pev(s_iOwner, pev_flags);
if( s_iFlags&FL_ONGROUND )
{
static Float:s_fVelocity[3];
pev(s_iOwner, pev_velocity, s_fVelocity);
if( !s_fVelocity[0] && !s_fVelocity[1] )
{
if( s_iFlags&FL_DUCKING )
g_fAccuracy = 1.0;
else
g_fAccuracy = 0.94;
}
else
g_fAccuracy = 0.88;
}
else
g_fAccuracy = 0.88;
}
set_pdata_float(iEnt, m_flAccuracy , g_fAccuracy, 4);
}
else
g_fAccuracy = -1.0;
}
public Ham_Attack_elite_Post(iEnt)
{
if( g_fAccuracy>0.88 )
set_pdata_float(iEnt, m_flAccuracy , 0.88, 4);
else if( g_fAccuracy>0.0 )
set_pdata_float(iEnt, m_flAccuracy , g_fAccuracy, 4);
}
public Ham_Attack_famas_Pre(iEnt)
{
static s_iShotsFired;
s_iShotsFired = get_pdata_int(iEnt, m_iShotsFired, 4)+1;
if( s_iShotsFired>1 )
{
g_fAccuracy = ((s_iShotsFired*s_iShotsFired*s_iShotsFired)/215.0)+0.3;
if( g_fAccuracy>1.0 )
g_fAccuracy = 1.0;
set_pdata_float(iEnt, m_flAccuracy, g_fAccuracy, 4);
}
else
{
static s_iOwner, s_iFlags;
s_iOwner = get_pdata_cbase(iEnt, m_pPlayer, 4);
s_iFlags = pev(s_iOwner, pev_flags);
if( s_iFlags&FL_ONGROUND )
{
static Float:s_fVelocity[3];
pev(s_iOwner, pev_velocity, s_fVelocity);
if( !s_fVelocity[0] && !s_fVelocity[1] )
{
if( s_iFlags&FL_DUCKING )
set_pdata_float(iEnt, m_flAccuracy, 0.0, 4);
else
set_pdata_float(iEnt, m_flAccuracy, 0.1, 4);
}
else
set_pdata_float(iEnt, m_flAccuracy, 0.2, 4);
}
else
set_pdata_float(iEnt, m_flAccuracy, 0.2, 4);
}
}
public Ham_Attack_57_Pre(iEnt)
{
static Float:s_fLastFire;
s_fLastFire = get_pdata_float(iEnt, m_flLastFire, 4);
if( !s_fLastFire )
{
static s_iOwner, s_iFlags;
s_iOwner = get_pdata_cbase(iEnt, m_pPlayer, 4);
s_iFlags = pev(s_iOwner, pev_flags);
if( s_iFlags&FL_ONGROUND )
{
static Float:s_fVelocity[3];
pev(s_iOwner, pev_velocity, s_fVelocity);
if( !s_fVelocity[0] && !s_fVelocity[1] )
{
if( s_iFlags&FL_DUCKING )
g_fAccuracy = 1.0;
else
g_fAccuracy = 0.96;
}
else
g_fAccuracy = 0.92;
}
else
g_fAccuracy = 0.92;
set_pdata_float(iEnt, m_flAccuracy, g_fAccuracy, 4);
}
else if( get_pdata_int(iEnt, m_iShotsFired, 4)<=0 )
{
g_fAccuracy = get_pdata_float(iEnt, m_flAccuracy, 4);
g_fAccuracy -= (0.275-(get_gametime()-s_fLastFire))*0.25;
if( g_fAccuracy<0.725 )
g_fAccuracy = 0.725;
else if( g_fAccuracy>0.92 )
{
static s_iOwner, s_iFlags;
s_iOwner = get_pdata_cbase(iEnt, m_pPlayer, 4);
s_iFlags = pev(s_iOwner, pev_flags);
if( s_iFlags&FL_ONGROUND )
{
static Float:s_fVelocity[3];
pev(s_iOwner, pev_velocity, s_fVelocity);
if( !s_fVelocity[0] && !s_fVelocity[1] )
{
if( s_iFlags&FL_DUCKING )
g_fAccuracy = 1.0;
else
g_fAccuracy = 0.96;
}
else
g_fAccuracy = 0.92;
}
else
g_fAccuracy = 0.92;
}
set_pdata_float(iEnt, m_flAccuracy , g_fAccuracy, 4);
}
else
g_fAccuracy = -1.0;
}
public Ham_Attack_57_Post(iEnt)
{
if( g_fAccuracy>0.92 )
set_pdata_float(iEnt, m_flAccuracy , 0.92, 4);
else if( g_fAccuracy>0.0 )
set_pdata_float(iEnt, m_flAccuracy , g_fAccuracy, 4);
}
public Ham_Attack_galil_Pre(iEnt)
{
static s_iShotsFired;
s_iShotsFired = get_pdata_int(iEnt, m_iShotsFired, 4)+1;
if( s_iShotsFired>1 )
{
g_fAccuracy = ((s_iShotsFired*s_iShotsFired*s_iShotsFired)/200.0)+0.35;
if( g_fAccuracy>1.25 )
g_fAccuracy = 1.25;
set_pdata_float(iEnt, m_flAccuracy, g_fAccuracy, 4);
}
else
{
static s_iOwner, s_iFlags;
s_iOwner = get_pdata_cbase(iEnt, m_pPlayer, 4);
s_iFlags = pev(s_iOwner, pev_flags);
if( s_iFlags&FL_ONGROUND )
{
static Float:s_fVelocity[3];
pev(s_iOwner, pev_velocity, s_fVelocity);
if( !s_fVelocity[0] && !s_fVelocity[1] )
{
if( s_iFlags&FL_DUCKING )
set_pdata_float(iEnt, m_flAccuracy, 0.0, 4);
else
set_pdata_float(iEnt, m_flAccuracy, 0.1, 4);
}
else
set_pdata_float(iEnt, m_flAccuracy, 0.2, 4);
}
else
set_pdata_float(iEnt, m_flAccuracy, 0.2, 4);
}
}
public Ham_Attack_glock_Pre(iEnt)
{
static Float:s_fLastFire;
s_fLastFire = get_pdata_float(iEnt, m_flLastFire, 4);
if( !s_fLastFire )
{
static s_iOwner, s_iFlags;
s_iOwner = get_pdata_cbase(iEnt, m_pPlayer, 4);
s_iFlags = pev(s_iOwner, pev_flags);
if( s_iFlags&FL_ONGROUND )
{
static Float:s_fVelocity[3];
pev(s_iOwner, pev_velocity, s_fVelocity);
if( !s_fVelocity[0] && !s_fVelocity[1] )
{
if( s_iFlags&FL_DUCKING )
g_fAccuracy = 1.0;
else
g_fAccuracy = 0.95;
}
else
g_fAccuracy = 0.90;
}
else
g_fAccuracy = 0.90;
set_pdata_float(iEnt, m_flAccuracy, g_fAccuracy, 4);
}
else if( get_pdata_int(iEnt, m_iShotsFired, 4)<=0 || get_pdata_int(iEnt, m_fWeaponState, 4)&WEAPONSTATE_GLOCK18_BURST_MODE )
{
g_fAccuracy = get_pdata_float(iEnt, m_flAccuracy, 4);
g_fAccuracy -= (0.325-(get_gametime()-s_fLastFire))*0.275;
if( g_fAccuracy<0.6 )
g_fAccuracy = 0.6;
else if( g_fAccuracy>0.90 )
{
static s_iOwner, s_iFlags;
s_iOwner = get_pdata_cbase(iEnt, m_pPlayer, 4);
s_iFlags = pev(s_iOwner, pev_flags);
if( s_iFlags&FL_ONGROUND )
{
static Float:s_fVelocity[3];
pev(s_iOwner, pev_velocity, s_fVelocity);
if( !s_fVelocity[0] && !s_fVelocity[1] )
{
if( s_iFlags&FL_DUCKING )
g_fAccuracy = 1.0;
else
g_fAccuracy = 0.95;
}
else
g_fAccuracy = 0.90;
}
else
g_fAccuracy = 0.90;
}
set_pdata_float(iEnt, m_flAccuracy , g_fAccuracy, 4);
}
else
g_fAccuracy = -1.0;
}
public Ham_Attack_glock_Post(iEnt)
{
if( g_fAccuracy>0.90 )
set_pdata_float(iEnt, m_flAccuracy , 0.90, 4);
else if( g_fAccuracy>0.0 )
set_pdata_float(iEnt, m_flAccuracy , g_fAccuracy, 4);
}
public Ham_Attack_m249_Pre(iEnt)
{
static s_iShotsFired;
s_iShotsFired = get_pdata_int(iEnt, m_iShotsFired, 4)+1;
if( s_iShotsFired>1 )
{
g_fAccuracy = ((s_iShotsFired*s_iShotsFired*s_iShotsFired)/175.0)+0.4;
if( g_fAccuracy>0.9 )
g_fAccuracy = 0.9;
set_pdata_float(iEnt, m_flAccuracy, g_fAccuracy, 4);
}
else
{
static s_iOwner, s_iFlags;
s_iOwner = get_pdata_cbase(iEnt, m_pPlayer, 4);
s_iFlags = pev(s_iOwner, pev_flags);
if( s_iFlags&FL_ONGROUND )
{
static Float:s_fVelocity[3];
pev(s_iOwner, pev_velocity, s_fVelocity);
if( !s_fVelocity[0] && !s_fVelocity[1] )
{
if( s_iFlags&FL_DUCKING )
set_pdata_float(iEnt, m_flAccuracy, 0.0, 4);
else
set_pdata_float(iEnt, m_flAccuracy, 0.1, 4);
}
else
set_pdata_float(iEnt, m_flAccuracy, 0.2, 4);
}
else
set_pdata_float(iEnt, m_flAccuracy, 0.2, 4);
}
}
public Ham_Attack_m4a1_Pre(iEnt)
{
static s_iShotsFired;
s_iShotsFired = get_pdata_int(iEnt, m_iShotsFired, 4)+1;
if( s_iShotsFired>1 )
{
g_fAccuracy = ((s_iShotsFired*s_iShotsFired*s_iShotsFired)/220.0)+0.35;
if( g_fAccuracy>1.25 )
g_fAccuracy = 1.25;
set_pdata_float(iEnt, m_flAccuracy, g_fAccuracy, 4);
}
else
{
static s_iOwner, s_iFlags;
s_iOwner = get_pdata_cbase(iEnt, m_pPlayer, 4);
s_iFlags = pev(s_iOwner, pev_flags);
if( s_iFlags&FL_ONGROUND )
{
static Float:s_fVelocity[3];
pev(s_iOwner, pev_velocity, s_fVelocity);
if( !s_fVelocity[0] && !s_fVelocity[1] )
{
if( s_iFlags&FL_DUCKING )
set_pdata_float(iEnt, m_flAccuracy, 0.0, 4);
else
set_pdata_float(iEnt, m_flAccuracy, 0.1, 4);
}
else
set_pdata_float(iEnt, m_flAccuracy, 0.2, 4);
}
else
set_pdata_float(iEnt, m_flAccuracy, 0.2, 4);
}
}
public Ham_Attack_mac10_Pre(iEnt)
{
static s_iShotsFired;
s_iShotsFired = get_pdata_int(iEnt, m_iShotsFired, 4)+1;
if( s_iShotsFired>1 )
{
g_fAccuracy = ((s_iShotsFired*s_iShotsFired*s_iShotsFired)/200.0)+0.6;
if( g_fAccuracy>1.65 )
g_fAccuracy = 1.65;
set_pdata_float(iEnt, m_flAccuracy, g_fAccuracy, 4);
}
else
{
static s_iOwner, s_iFlags;
s_iOwner = get_pdata_cbase(iEnt, m_pPlayer, 4);
s_iFlags = pev(s_iOwner, pev_flags);
if( s_iFlags&FL_ONGROUND )
{
static Float:s_fVelocity[3];
pev(s_iOwner, pev_velocity, s_fVelocity);
if( !s_fVelocity[0] && !s_fVelocity[1] )
{
if( s_iFlags&FL_DUCKING )
set_pdata_float(iEnt, m_flAccuracy, 0.0, 4);
else
set_pdata_float(iEnt, m_flAccuracy, 0.075, 4);
}
else
set_pdata_float(iEnt, m_flAccuracy, 0.15, 4);
}
else
set_pdata_float(iEnt, m_flAccuracy, 0.15, 4);
}
}
public Ham_Attack_mp5_Pre(iEnt)
{
static s_iShotsFired;
s_iShotsFired = get_pdata_int(iEnt, m_iShotsFired, 4)+1;
if( s_iShotsFired>1 )
{
g_fAccuracy = ((s_iShotsFired*s_iShotsFired)/220.1)+0.45;
if( g_fAccuracy>0.75 )
g_fAccuracy = 0.75;
set_pdata_float(iEnt, m_flAccuracy, g_fAccuracy, 4);
}
else
{
static s_iOwner, s_iFlags;
s_iOwner = get_pdata_cbase(iEnt, m_pPlayer, 4);
s_iFlags = pev(s_iOwner, pev_flags);
if( s_iFlags&FL_ONGROUND )
{
static Float:s_fVelocity[3];
pev(s_iOwner, pev_velocity, s_fVelocity);
if( !s_fVelocity[0] && !s_fVelocity[1] )
{
if( s_iFlags&FL_DUCKING )
set_pdata_float(iEnt, m_flAccuracy, 0.0, 4);
else
set_pdata_float(iEnt, m_flAccuracy, 0.1, 4);
}
else
set_pdata_float(iEnt, m_flAccuracy, 0.2, 4);
}
else
set_pdata_float(iEnt, m_flAccuracy, 0.2, 4);
}
}
public Ham_Attack_p228_Pre(iEnt)
{
static Float:s_fLastFire;
s_fLastFire = get_pdata_float(iEnt, m_flLastFire, 4);
if( !s_fLastFire )
{
static s_iOwner, s_iFlags;
s_iOwner = get_pdata_cbase(iEnt, m_pPlayer, 4);
s_iFlags = pev(s_iOwner, pev_flags);
if( s_iFlags&FL_ONGROUND )
{
static Float:s_fVelocity[3];
pev(s_iOwner, pev_velocity, s_fVelocity);
if( !s_fVelocity[0] && !s_fVelocity[1] )
{
if( s_iFlags&FL_DUCKING )
g_fAccuracy = 1.0;
else
g_fAccuracy = 0.95;
}
else
g_fAccuracy = 0.90;
}
else
g_fAccuracy = 0.90;
set_pdata_float(iEnt, m_flAccuracy, g_fAccuracy, 4);
}
else if( get_pdata_int(iEnt, m_iShotsFired, 4)<=0 )
{
g_fAccuracy = get_pdata_float(iEnt, m_flAccuracy, 4);
g_fAccuracy -= (0.325-(get_gametime()-s_fLastFire))*0.3;
if( g_fAccuracy<0.6 )
g_fAccuracy = 0.6;
else if( g_fAccuracy>0.90 )
{
static s_iOwner, s_iFlags;
s_iOwner = get_pdata_cbase(iEnt, m_pPlayer, 4);
s_iFlags = pev(s_iOwner, pev_flags);
if( s_iFlags&FL_ONGROUND )
{
static Float:s_fVelocity[3];
pev(s_iOwner, pev_velocity, s_fVelocity);
if( !s_fVelocity[0] && !s_fVelocity[1] )
{
if( s_iFlags&FL_DUCKING )
g_fAccuracy = 1.0;
else
g_fAccuracy = 0.95;
}
else
g_fAccuracy = 0.90;
}
else
g_fAccuracy = 0.90;
}
set_pdata_float(iEnt, m_flAccuracy , g_fAccuracy, 4);
}
else
g_fAccuracy = -1.0;
}
public Ham_Attack_p228_Post(iEnt)
{
if( g_fAccuracy>0.90 )
set_pdata_float(iEnt, m_flAccuracy , 0.90, 4);
else if( g_fAccuracy>0.0 )
set_pdata_float(iEnt, m_flAccuracy , g_fAccuracy, 4);
}
public Ham_Attack_p90_Pre(iEnt)
{
static s_iShotsFired;
s_iShotsFired = get_pdata_int(iEnt, m_iShotsFired, 4)+1;
if( s_iShotsFired>1 )
{
g_fAccuracy = ((s_iShotsFired*s_iShotsFired)/175.0)+0.45;
if( g_fAccuracy>1.0 )
g_fAccuracy = 1.0;
set_pdata_float(iEnt, m_flAccuracy, g_fAccuracy, 4);
}
else
{
static s_iOwner, s_iFlags;
s_iOwner = get_pdata_cbase(iEnt, m_pPlayer, 4);
s_iFlags = pev(s_iOwner, pev_flags);
if( s_iFlags&FL_ONGROUND )
{
static Float:s_fVelocity[3];
pev(s_iOwner, pev_velocity, s_fVelocity);
if( !s_fVelocity[0] && !s_fVelocity[1] )
{
if( s_iFlags&FL_DUCKING )
set_pdata_float(iEnt, m_flAccuracy, 0.0, 4);
else
set_pdata_float(iEnt, m_flAccuracy, 0.1, 4);
}
else
set_pdata_float(iEnt, m_flAccuracy, 0.2, 4);
}
else
set_pdata_float(iEnt, m_flAccuracy, 0.2, 4);
}
}
public Ham_Attack_scout_Pre(iEnt)
{
static s_iOwner, s_iFlags;
s_iOwner = get_pdata_cbase(iEnt, m_pPlayer, 4);
s_iFlags = pev(s_iOwner, pev_flags);
if( s_iFlags&FL_DUCKING || ~s_iFlags&FL_ONGROUND )
g_fAccuracy = 0.0;
else
{
static Float:s_fVelocity[3];
pev(s_iOwner, pev_velocity, s_fVelocity);
if( !s_fVelocity[0] && !s_fVelocity[1] )
{
set_pev(s_iOwner, pev_flags, (s_iFlags|FL_DUCKING));
g_fAccuracy = 1.0;
}
else
g_fAccuracy = 0.0;
}
}
public Ham_Attack_scout_Post(iEnt)
{
if( g_fAccuracy )
{
static s_iOwner;
s_iOwner = get_pdata_cbase(iEnt, m_pPlayer, 4);
set_pev(s_iOwner, pev_flags, (pev(s_iOwner, pev_flags)&~FL_DUCKING));
}
}
public Ham_Attack_sg550_Pre(iEnt)
{
static Float:s_fLastFire;
s_fLastFire = get_pdata_float(iEnt, m_flLastFire, 4);
if( !s_fLastFire )
{
static s_iOwner, s_iFlags;
s_iOwner = get_pdata_cbase(iEnt, m_pPlayer, 4);
s_iFlags = pev(s_iOwner, pev_flags);
if( s_iFlags&FL_ONGROUND )
{
static Float:s_fVelocity[3];
pev(s_iOwner, pev_velocity, s_fVelocity);
if( !s_fVelocity[0] && !s_fVelocity[1] )
{
if( s_iFlags&FL_DUCKING )
g_fAccuracy = 1.0;
else
g_fAccuracy = 0.99;
}
else
g_fAccuracy = 0.98;
}
else
g_fAccuracy = 0.98;
set_pdata_float(iEnt, m_flAccuracy, g_fAccuracy, 4);
}
else
{
g_fAccuracy = (0.65+(get_gametime()-s_fLastFire))*0.725; //*0.35; (this is way too inaccurate comparing to g3sg1)
if( g_fAccuracy>0.98 )
{
static s_iOwner, s_iFlags;
s_iOwner = get_pdata_cbase(iEnt, m_pPlayer, 4);
s_iFlags = pev(s_iOwner, pev_flags);
if( s_iFlags&FL_ONGROUND )
{
static Float:s_fVelocity[3];
pev(s_iOwner, pev_velocity, s_fVelocity);
if( !s_fVelocity[0] && !s_fVelocity[1] )
{
if( s_iFlags&FL_DUCKING )
g_fAccuracy = 1.0;
else
g_fAccuracy = 0.99;
}
else
g_fAccuracy = 0.98;
}
else
g_fAccuracy = 0.98;
}
set_pdata_float(iEnt, m_flAccuracy , g_fAccuracy, 4);
}
}
public Ham_Attack_sg552_Pre(iEnt)
{
static s_iShotsFired;
s_iShotsFired = get_pdata_int(iEnt, m_iShotsFired, 4)+1;
if( s_iShotsFired>1 )
{
g_fAccuracy = ((s_iShotsFired*s_iShotsFired*s_iShotsFired)/220.0)+0.3;
if( g_fAccuracy>1.0 )
g_fAccuracy = 1.0;
set_pdata_float(iEnt, m_flAccuracy, g_fAccuracy, 4);
}
else
{
static s_iOwner, s_iFlags;
s_iOwner = get_pdata_cbase(iEnt, m_pPlayer, 4);
s_iFlags = pev(s_iOwner, pev_flags);
if( s_iFlags&FL_ONGROUND )
{
static Float:s_fVelocity[3];
pev(s_iOwner, pev_velocity, s_fVelocity);
if( !s_fVelocity[0] && !s_fVelocity[1] )
{
if( s_iFlags&FL_DUCKING )
set_pdata_float(iEnt, m_flAccuracy, 0.0, 4);
else
set_pdata_float(iEnt, m_flAccuracy, 0.1, 4);
}
else
set_pdata_float(iEnt, m_flAccuracy, 0.2, 4);
}
else
set_pdata_float(iEnt, m_flAccuracy, 0.2, 4);
}
}
public Ham_Attack_tmp_Pre(iEnt)
{
static s_iShotsFired;
s_iShotsFired = get_pdata_int(iEnt, m_iShotsFired, 4)+1;
if( s_iShotsFired>1 )
{
g_fAccuracy = ((s_iShotsFired*s_iShotsFired*s_iShotsFired)/220.0)+0.55;
if( g_fAccuracy>1.4 )
g_fAccuracy = 1.4;
set_pdata_float(iEnt, m_flAccuracy, g_fAccuracy, 4);
}
else
{
static s_iOwner, s_iFlags;
s_iOwner = get_pdata_cbase(iEnt, m_pPlayer, 4);
s_iFlags = pev(s_iOwner, pev_flags);
if( s_iFlags&FL_ONGROUND )
{
static Float:s_fVelocity[3];
pev(s_iOwner, pev_velocity, s_fVelocity);
if( !s_fVelocity[0] && !s_fVelocity[1] )
{
if( s_iFlags&FL_DUCKING )
set_pdata_float(iEnt, m_flAccuracy, 0.0, 4);
else
set_pdata_float(iEnt, m_flAccuracy, 0.1, 4);
}
else
set_pdata_float(iEnt, m_flAccuracy, 0.2, 4);
}
else
set_pdata_float(iEnt, m_flAccuracy, 0.2, 4);
}
}
public Ham_Attack_ump45_Pre(iEnt)
{
static s_iShotsFired;
s_iShotsFired = get_pdata_int(iEnt, m_iShotsFired, 4)+1;
if( s_iShotsFired>1 )
{
g_fAccuracy = ((s_iShotsFired*s_iShotsFired)/210.0)+0.5;
if( g_fAccuracy>1.0 )
g_fAccuracy = 1.0;
set_pdata_float(iEnt, m_flAccuracy, g_fAccuracy, 4);
}
else
{
static s_iOwner, s_iFlags;
s_iOwner = get_pdata_cbase(iEnt, m_pPlayer, 4);
s_iFlags = pev(s_iOwner, pev_flags);
if( s_iFlags&FL_ONGROUND )
{
static Float:s_fVelocity[3];
pev(s_iOwner, pev_velocity, s_fVelocity);
if( !s_fVelocity[0] && !s_fVelocity[1] )
{
if( s_iFlags&FL_DUCKING )
set_pdata_float(iEnt, m_flAccuracy, 0.0, 4);
else
set_pdata_float(iEnt, m_flAccuracy, 0.1, 4);
}
else
set_pdata_float(iEnt, m_flAccuracy, 0.2, 4);
}
else
set_pdata_float(iEnt, m_flAccuracy, 0.2, 4);
}
}
public Ham_Attack_usp_Pre(iEnt)
{
static Float:s_fLastFire;
s_fLastFire = get_pdata_float(iEnt, m_flLastFire, 4);
if( !s_fLastFire )
{
static s_iOwner, s_iFlags;
s_iOwner = get_pdata_cbase(iEnt, m_pPlayer, 4);
s_iFlags = pev(s_iOwner, pev_flags);
if( s_iFlags&FL_ONGROUND )
{
static Float:s_fVelocity[3];
pev(s_iOwner, pev_velocity, s_fVelocity);
if( !s_fVelocity[0] && !s_fVelocity[1] )
{
if( s_iFlags&FL_DUCKING )
g_fAccuracy = 1.0;
else
g_fAccuracy = 0.96;
}
else
g_fAccuracy = 0.92;
}
else
g_fAccuracy = 0.92;
set_pdata_float(iEnt, m_flAccuracy, g_fAccuracy, 4);
}
else if( get_pdata_int(iEnt, m_iShotsFired, 4)<=0 )
{
g_fAccuracy = get_pdata_float(iEnt, m_flAccuracy, 4);
g_fAccuracy -= (0.3-(get_gametime()-s_fLastFire))*0.275;
if( g_fAccuracy<0.6 )
g_fAccuracy = 0.6;
else if( g_fAccuracy>0.92 )
{
static s_iOwner, s_iFlags;
s_iOwner = get_pdata_cbase(iEnt, m_pPlayer, 4);
s_iFlags = pev(s_iOwner, pev_flags);
if( s_iFlags&FL_ONGROUND )
{
static Float:s_fVelocity[3];
pev(s_iOwner, pev_velocity, s_fVelocity);
if( !s_fVelocity[0] && !s_fVelocity[1] )
{
if( s_iFlags&FL_DUCKING )
g_fAccuracy = 1.0;
else
g_fAccuracy = 0.96;
}
else
g_fAccuracy = 0.92;
}
else
g_fAccuracy = 0.92;
}
set_pdata_float(iEnt, m_flAccuracy , g_fAccuracy, 4);
}
else
g_fAccuracy = -1.0;
}
public Ham_Attack_usp_Post(iEnt)
{
if( g_fAccuracy>0.92 )
set_pdata_float(iEnt, m_flAccuracy , 0.92, 4);
else if( g_fAccuracy>0.0 )
set_pdata_float(iEnt, m_flAccuracy , g_fAccuracy, 4);
}