Browse Source

Add autojump from OpenAG.

aghl
Night Owl 6 years ago
parent
commit
b4113ac7cd
  1. 28
      cl_dll/input.cpp
  2. 9
      pm_shared/pm_shared.c

28
cl_dll/input.cpp

@ -78,6 +78,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.
}
/* /*
=============================================================================== ===============================================================================
@ -873,6 +881,25 @@ 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 )
{ {
@ -1127,6 +1154,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 );

9
pm_shared/pm_shared.c

@ -32,6 +32,9 @@
int iJumpSpectator; int iJumpSpectator;
extern float vJumpOrigin[3]; extern float vJumpOrigin[3];
extern float vJumpAngles[3]; extern float vJumpAngles[3];
extern int g_onground;
extern int g_inwater;
extern int g_walking;
#endif #endif
static int pm_shared_initialized = 0; static int pm_shared_initialized = 0;
@ -3322,6 +3325,12 @@ void PM_Move( struct playermove_s *ppmove, int server )
{ {
pmove->friction = 1.0f; pmove->friction = 1.0f;
} }
#ifdef CLIENT_DLL
g_onground = ( pmove->onground != -1 );
g_inwater = ( pmove->waterlevel > 1 );
g_walking = ( pmove->movetype == MOVETYPE_WALK );
#endif
} }
int PM_GetVisEntInfo( int ent ) int PM_GetVisEntInfo( int ent )

Loading…
Cancel
Save