Open up hl_wpn_glock.cpp and go to the GlockFire function and replace
void CGlock::GlockFire( float flSpread , float flCycleTime, BOOL fUseAutoAim )
with
void CGlock::GlockFire( float Spread , float flCycleTime, BOOL fUseAutoAim )
Inside the function, below m_iClip--; add this
flSpread = Spread + MoveSpread;
IdentifySpread();
Now inside the WeaponIdle function at the beginning add
IdentifySpread();
Now lets add the IdentifySpread(); function
Under the WeaponIdle function add:
void CGlock::IdentifySpread( void )
{
if ( m_pPlayer->m_afButtonPressed & IN_FORWARD )
{
// If we press the forward button
MoveSpread = 0.02;
}
else if ( m_pPlayer->m_afButtonPressed & IN_BACK )
{
// If we press the back button
MoveSpread = 0.03;
}
else if ( m_pPlayer->m_afButtonPressed & IN_LEFT )
{
// If we press the left strafe button
MoveSpread = RANDOM_LONG( 0.01, 0.05);
}
else if ( m_pPlayer->m_afButtonPressed & IN_RIGHT )
{
// If we press the right strafe button
MoveSpread = RANDOM_LONG( 0.01, 0.05);
}
else if (( m_pPlayer->m_afButtonPressed & IN_FORWARD ) && ( m_pPlayer->m_afButtonPressed & ( IN_LEFT | IN_RIGHT )))
{
// If we press the forward and left or right strafe button
MoveSpread = RANDOM_LONG( 0.01, 0.09);
}
else if (( m_pPlayer->m_afButtonPressed & IN_BACK ) && ( m_pPlayer->m_afButtonPressed & ( IN_LEFT | IN_RIGHT )))
{
// If we press the back and left or right strafe button
MoveSpread = RANDOM_LONG( 0.01, 0.07);
}
else if (( m_pPlayer->m_afButtonPressed & IN_DUCK ) && ( m_pPlayer->m_afButtonPressed & ( IN_FORWARD | IN_BACK )))
{
// If we duck and press the forward or back button
MoveSpread = RANDOM_LONG( 0.0, 0.02);
}
else if ( m_pPlayer->m_afButtonPressed & IN_DUCK )
{
// If we duck
MoveSpread = 0.00;
}
else if (( m_pPlayer->m_afButtonPressed & IN_DUCK ) && ( m_pPlayer->m_afButtonPressed & (IN_LEFT|IN_RIGHT)) )
{
// If we duck and press the left or right strafe button
MoveSpread = 0.00;
}
else
{
// If we press nothing
MoveSpread = 0.01;
}
}
And we ared done with hl_wpn_glock.cpp.
Now open weapons.h and inside the CGlock class definiton replace:
void GlockFire( float flSpread, float flCycleTime, BOOL fUseAutoAim );
With
void GlockFire( float Spread, float flCycleTime, BOOL fUseAutoAim );
void IdentifySpread( void );
float flSpread;
Now we are finished! If you have any problems, please address it in the comments.