Browse Source

Add autojump from OpenAG.

dmc
Night Owl 7 years ago
parent
commit
e75561b382
  1. 30
      cl_dll/input.cpp
  2. 10
      pm_shared/pm_shared.c

30
cl_dll/input.cpp

@ -73,7 +73,14 @@ cvar_t *cl_yawspeed;
cvar_t *cl_pitchspeed; cvar_t *cl_pitchspeed;
cvar_t *cl_anglespeedkey; cvar_t *cl_anglespeedkey;
cvar_t *cl_vsmoothing; cvar_t *cl_vsmoothing;
cvar_t *cl_autojump;
extern "C"
{
int g_onground = false;
int g_inwater = false;
int g_walking = true; // Movetype == MOVETYPE_WALK. Filters out noclip, being on ladder, etc.
}
/* /*
=============================================================================== ===============================================================================
@ -842,6 +849,28 @@ void DLLEXPORT CL_CreateMove( float frametime, struct usercmd_s *cmd, int active
// //
cmd->buttons = CL_ButtonBits( 1 ); cmd->buttons = CL_ButtonBits( 1 );
{
static bool s_jump_was_down_last_frame = false;
if( cl_autojump->value != 0.0f )
{
bool should_release_jump = ( !g_onground && !g_inwater && g_walking );
/*
* Spam pressing and releasing jump if we're stuck in a spot where jumping still results in
* being onground in the end of the frame. Without this check, +jump would remain held and
* when the player exits this spot they would have to release and press the jump button to
* start jumping again. This also helps with exiting water or ladder right onto the ground.
*/
if( s_jump_was_down_last_frame && g_onground && !g_inwater && g_walking )
should_release_jump = true;
if( should_release_jump )
cmd->buttons &= ~IN_JUMP;
}
s_jump_was_down_last_frame = ( ( cmd->buttons & IN_JUMP ) != 0 );
}
// Using joystick? // Using joystick?
if( in_joystick->value ) if( in_joystick->value )
{ {
@ -1099,6 +1128,7 @@ void InitInput( void )
cl_pitchdown = gEngfuncs.pfnRegisterVariable( "cl_pitchdown", "89", 0 ); cl_pitchdown = gEngfuncs.pfnRegisterVariable( "cl_pitchdown", "89", 0 );
cl_vsmoothing = gEngfuncs.pfnRegisterVariable( "cl_vsmoothing", "0.05", FCVAR_ARCHIVE ); cl_vsmoothing = gEngfuncs.pfnRegisterVariable( "cl_vsmoothing", "0.05", FCVAR_ARCHIVE );
cl_autojump = gEngfuncs.pfnRegisterVariable( "cl_autojump", "1", FCVAR_ARCHIVE );
m_pitch = gEngfuncs.pfnRegisterVariable( "m_pitch","0.022", FCVAR_ARCHIVE ); m_pitch = gEngfuncs.pfnRegisterVariable( "m_pitch","0.022", FCVAR_ARCHIVE );
m_yaw = gEngfuncs.pfnRegisterVariable( "m_yaw","0.022", FCVAR_ARCHIVE ); m_yaw = gEngfuncs.pfnRegisterVariable( "m_yaw","0.022", FCVAR_ARCHIVE );

10
pm_shared/pm_shared.c

@ -2734,6 +2734,16 @@ void PM_Move( struct playermove_s *ppmove, int server )
{ {
pmove->friction = 1.0f; pmove->friction = 1.0f;
} }
#ifdef CLIENT_DLL
extern int g_onground;
extern int g_inwater;
extern int g_walking;
g_onground = ( pmove->onground != -1 );
g_inwater = ( pmove->waterlevel > 1 );
g_walking = ( pmove->movetype == MOVETYPE_WALK );
#endif
} }
int PM_GetInfo( int ent ) int PM_GetInfo( int ent )

Loading…
Cancel
Save