Need to start some were in modding right? Why not try the Half-Life modding Kit. This Kit is designed to have all the tools you need to start your own Half-Life mod, simple mods can be made or advance ones like Base Defense with this small set of tools. If you want to start modding Half-Life you should try this.

Post tutorial Report RSS Wider Spread with Movement

Well.. its has been a long time since I have posted a tutorial. Hope it helps!

Posted by on - Intermediate Server Side Coding

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.


Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.

Follow Report Profile
Icon
Half-Life
Game
Half-Life
Creator
badsniper365
Contact
Send Message
Release date
Mod watch
Follow
Tutorial
Browse
Tutorials
Report
Report
Views
64 (1 today)
Share
Related Games
Half-Life
Half-Life First Person Shooter