HL2 Bunnyhop restriction


#1

Hello. A moment of your time to help a new coder, please.

I am trying to create a convar to remove the bunnyhop speed limiter imposed by the HL2 update, which will be “cl_enable_bunnyhop” and setting it to 1 will cause this change.
I am using the Source SDK 2013 master files along with Visual Studio 2013 Community.
I edit the following block inside of the gamemovement.cpp

         // We give a certain percentage of the current forward movement as a bonus to the jump speed. That bonus is clipped 

         // to not accumulate over time. 
         float flSpeedBoostPerc = ( !pMoveData->m_bIsSprinting && !player->m_Local.m_bDucked ) ? 0.5f : 0.1f; 
         float flSpeedAddition = fabs( mv->m_flForwardMove * flSpeedBoostPerc ); 
         float flMaxSpeed = mv->m_flMaxSpeed + ( mv->m_flMaxSpeed * flSpeedBoostPerc ); 
         float flNewSpeed = ( flSpeedAddition + mv->m_vecVelocity.Length2D() ); 
         // If we're over the maximum, we want to only boost as much as will get us to the goal speed 
         if ( flNewSpeed > flMaxSpeed ) 
         { 
         flSpeedAddition -= flNewSpeed - flMaxSpeed; 
         } 
         if ( mv->m_flForwardMove < 0.0f ) 
         flSpeedAddition *= -1.0f; 
         // Add it on 
         VectorAdd( (vecForward*flSpeedAddition), mv->m_vecVelocity, mv->m_vecVelocity );

To look like this:

      if(cl_enable_bunnyhop.GetInt() == 0)
      {
         // We give a certain percentage of the current forward movement as a bonus to the jump speed.  That bonus is clipped
         // to not accumulate over time.
         float flSpeedBoostPerc = ( !pMoveData->m_bIsSprinting && !player->m_Local.m_bDucked ) ? 0.5f : 0.1f;
         float flSpeedAddition = fabs( mv->m_flForwardMove * flSpeedBoostPerc );
         float flMaxSpeed = mv->m_flMaxSpeed + ( mv->m_flMaxSpeed * flSpeedBoostPerc );
         float flNewSpeed = ( flSpeedAddition + mv->m_vecVelocity.Length2D() ); 
         // If we're over the maximum, we want to only boost as much as will get us to the goal speed 
         if ( flNewSpeed > flMaxSpeed )
         { 
         flSpeedAddition -= flNewSpeed - flMaxSpeed;
         } 
         if ( mv->m_flForwardMove < 0.0f )
            flSpeedAddition *= -1.0f; 
         // Add it on 
         VectorAdd( (vecForward*flSpeedAddition), mv->m_vecVelocity, mv->m_vecVelocity );
      }
      else
      { 
         if ( !pMoveData->m_bIsSprinting && !player->m_Local.m_bDucked )
         {
            for ( int iAxis = 0; iAxis < 2 ; ++iAxis )
            {
               vecForward[iAxis] *= ( mv->m_flForwardMove * 0.5f );
            }
         }
         else
         {
            for ( int iAxis = 0; iAxis < 2 ; ++iAxis )
            {
               vecForward[iAxis] *= ( mv->m_flForwardMove * 0.1f );
            }
         }
         VectorAdd( vecForward, mv->m_vecVelocity, mv->m_vecVelocity );
      }

Then I find the limit jump convar line:

#if defined( HL2_DLL ) || defined( HL2_CLIENT_DLL )
ConVar player_limit_jump_speed( "player_limit_jump_speed", "1", FCVAR_REPLICATED );
#endif

And add this after it so it reads:

#if defined( HL2_DLL ) || defined( HL2_CLIENT_DLL )
ConVar player_limit_jump_speed( "player_limit_jump_speed", "1", FCVAR_REPLICATED );
#endif
ConVar cl_enable_bunnyhop( "cl_enable_bunnyhop", "0", FCVAR_ARCHIVE );

I have tried compiling as a client.dll and when I load it into HL2 I get past the logo but when I hit the main screen it pauses for a few seconds and then crashes to desktop with no asserts or errors.

I have even tried removing the bits that clip jump speed, as well as the convar add, and tried only using the other half, and still I get the near instant CTD once I hit the menu.

One thing to note: HL2 has a client.dll there by default, and I have to overwrite it with my modded one. Could this be causing incompatibility issues?

Any help is appreciated.


#2

Use the beta version of the 2013 ssdk base.


#3

Will give that a try. Thanks!


#4

When I download the steam version of the Source SDK 2013 and opt into the ‘upcoming’ beta;

then navigate to D:\Steam\steamapps\common\Source SDK Base 2013 Multiplayer, I can’t find the mp or sp folder, neither can I find the createprojects.bat to create a games.sln.

Do I need to compile the SDK files first to aquire these? And if so, how?

Sorry, I’m still pretty fresh to this. :o


#5

DL the SSDK base 2013, opt into the beta, then launch both at least once. Then in the Source SDK tool you create a mod on the 2013 engine, this will both give you the source code and put a folder into steamapps\sourcemods for your mod, where you will need to place your client and server DLLs. After you restart steam afterwards, it will also put your mod into the game list, this is how you will launch it.