mirror of
https://github.com/YGGverse/hlsdk-portable.git
synced 2025-03-12 05:22:55 +00:00
Add autojump from OpenAG.
This commit is contained in:
parent
774e22f6ec
commit
b4113ac7cd
@ -78,6 +78,14 @@ cvar_t *cl_yawspeed;
|
||||
cvar_t *cl_pitchspeed;
|
||||
cvar_t *cl_anglespeedkey;
|
||||
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 );
|
||||
|
||||
{
|
||||
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?
|
||||
if( in_joystick->value )
|
||||
{
|
||||
@ -1127,6 +1154,7 @@ void InitInput( void )
|
||||
cl_pitchdown = gEngfuncs.pfnRegisterVariable( "cl_pitchdown", "89", 0 );
|
||||
|
||||
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_yaw = gEngfuncs.pfnRegisterVariable( "m_yaw","0.022", FCVAR_ARCHIVE );
|
||||
|
@ -32,6 +32,9 @@
|
||||
int iJumpSpectator;
|
||||
extern float vJumpOrigin[3];
|
||||
extern float vJumpAngles[3];
|
||||
extern int g_onground;
|
||||
extern int g_inwater;
|
||||
extern int g_walking;
|
||||
#endif
|
||||
|
||||
static int pm_shared_initialized = 0;
|
||||
@ -3322,6 +3325,12 @@ void PM_Move( struct playermove_s *ppmove, int server )
|
||||
{
|
||||
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 )
|
||||
|
Loading…
x
Reference in New Issue
Block a user