I really enjoyed bunny hopping through Half-Life 2, there is an element of fun being able to run at really high speeds, and was rather disappointed when it was removed once and for all from Episode 2. After a bit of exploring and hacky coding, I finally managed to re-implement the ability to bunny hop back into Half-Life 2: EP2 (And of course any mods that use it's engine).
Thanks to the guys at
sourceruns.org for the heads up as to what file the code is located in. If you haven't already, check out their Half-Life 2 and HL2 EP1 Speed runs.
Queue masses of code. (
Scroll down if you are not interested in the code)
Open up gamemovement.cpp (In the client project) and jump down to around line 2467 (About half-way down) and you will find the following code:
PHP Code:
// 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 );
Get rid of it. Delete the entire chunk. Replace it with the following code (This is the code from EP1):
PHP Code:
if ( !pMoveData->m_bIsSprinting && !player->m_Local.m_bDucked )
{
for ( int iAxis = 0; iAxis < 2 ; ++iAxis )
{
vecForward[iAxis] *= ( mv->m_flForwardMove * 0.5f );
// vecForward[iAxis] *= ( mv->m_flForwardMove * jumpforwardscale.GetFloat() );
}
}
else
{
for ( int iAxis = 0; iAxis < 2 ; ++iAxis )
{
vecForward[iAxis] *= ( mv->m_flForwardMove * 0.1f );
// vecForward[iAxis] *= ( mv->m_flForwardMove * jumpforwardsprintscale.GetFloat() );
}
}
VectorAdd( vecForward, mv->m_vecVelocity, mv->m_vecVelocity );
Recompile your code and voila! You should be able to bunny hop.
In
Operation Lambda the ability to bunny hop can be set via a Cvar, this is just a really simple change too.
First, up near the top of the file you will find some code that reads:
PHP Code:
#if defined( HL2_DLL ) || defined( HL2_CLIENT_DLL )
ConVar player_limit_jump_speed( "player_limit_jump_speed", "1", FCVAR_REPLICATED );
#endif
Add after that:
PHP Code:
ConVar cl_enable_bunnyhop( "cl_enable_bunnyhop", "0", FCVAR_ARCHIVE );
You can replace FCVAR_ARCHIVE with FCVAR_CHEAT if you would like it to be set as a cheat (meaning that sv_cheats needs to be enabled to enable bunny hopping)
Now back down the file where you found:
PHP Code:
// 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 );
Again, delete it and replace it with this chunk:
PHP Code:
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 );
// vecForward[iAxis] *= ( mv->m_flForwardMove * jumpforwardscale.GetFloat() );
}
}
else
{
for ( int iAxis = 0; iAxis < 2 ; ++iAxis )
{
vecForward[iAxis] *= ( mv->m_flForwardMove * 0.1f );
// vecForward[iAxis] *= ( mv->m_flForwardMove * jumpforwardsprintscale.GetFloat() );
}
}
VectorAdd( vecForward, mv->m_vecVelocity, mv->m_vecVelocity );
}
Now once you recompile you should be able to set cl_enable_bunnyhop to 1 (Optionally, enable cheats) and bunny hop your way around your mod.
The edited gamemovement file is attached to the bottom of the post. (With cvar toggling)
======================================================================
For those people who just wanna play and don't care about the coding of it... Then here ya go!
Download the replacement client and server DLL files here:
http://mirror.cazzaserver.com/bhop/bhop_dlls.zip (5mb)
If you are posting this info elsewhere, please link to this thread rather than the file, thanks
)
Place these in your Half-Life 2 EP2 bin(aries) folder which is usually located at C:\Program Files\Steam\steamapps\<STEAM USERNAME>\half-life 2 episode two\ep2\bin
Create the folder if it doesn't exist, then extract the two DLLs into it like so:
Now fire up EP2 and enjoy!
======================================================================
Can't quite get the hang of bunny hopping? Let this help you out!
Download
this (AutoHotkey with the bunny hop script already written), extract and run it. Now launch EP2 and instead of continually pressing space to jump simply just hold down the Alt key and it will automagically make you jump!
For the record, the script is:
Code:
*LAlt::
Loop
{
GetKeyState, state, LAlt, P
if State = U
break
; Otherwise:
Send, {Space}
Sleep, 1
}
return
======================================================================
These DLL files will also work for any other Mod that uses the EP2 (Orange Box) engine. If you launch the mod and it isn't working, place the DLLs into the mods bin folder, usually something like C:\Program Files\Steam\steamapps\SourceMods\<MOD NAME>\bin
!!! IF THERE ARE ALREADY FILES IN THERE, OVERWRITING THEM MAY STOP THE MOD FROM WORKING AS THE MOD DEVELOPERS MAY HAVE WRITTEN THEIR OWN DLL FILES !!!