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.