QL movement foundation: auto-hop, PM_Jump/PM_CanJump extraction, lastJumpTime
- Extract PM_Jump from PM_CheckJump for reuse by future step jump code - Add PM_CanJump gate function (checks respawned, pm_type, upmove) - Remove PMF_JUMP_HELD gate for QL-style auto-hop (hold jump to bunny hop) - Add lastJumpTime to playerState_t (networked via msg.c) for jump cooldown - bg_slidemove.c unchanged (no step jump yet -- needs proper QL analysis) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
009dc313d4
commit
3327e9680c
4 changed files with 39 additions and 12 deletions
|
|
@ -77,6 +77,8 @@ void PM_ClipVelocity( vec3_t in, vec3_t normal, vec3_t out, float overbounce );
|
|||
void PM_AddTouchEnt( int entityNum );
|
||||
void PM_AddEvent( int newEvent );
|
||||
|
||||
qboolean PM_CanJump( void );
|
||||
void PM_Jump( void );
|
||||
qboolean PM_SlideMove( qboolean gravity );
|
||||
void PM_StepSlideMove( qboolean gravity );
|
||||
|
||||
|
|
|
|||
|
|
@ -360,13 +360,40 @@ Extracted from PM_CheckJump so it can be called
|
|||
from other contexts (step jump, double jump, etc).
|
||||
=============
|
||||
*/
|
||||
static void PM_Jump( void ) {
|
||||
/*
|
||||
=============
|
||||
PM_CanJump
|
||||
|
||||
Returns qtrue if a jump would succeed right now.
|
||||
Checks both player state AND input (upmove >= 10).
|
||||
Used by PM_StepSlideMove to decide whether stepping
|
||||
up stairs should trigger a jump.
|
||||
=============
|
||||
*/
|
||||
qboolean PM_CanJump( void ) {
|
||||
if ( pm->ps->pm_flags & PMF_RESPAWNED ) {
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
if ( pm->ps->pm_type != PM_NORMAL ) {
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
if ( pm->cmd.upmove < 10 ) {
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
return qtrue;
|
||||
}
|
||||
|
||||
void PM_Jump( void ) {
|
||||
pml.groundPlane = qfalse; // jumping away
|
||||
pml.walking = qfalse;
|
||||
pm->ps->pm_flags |= PMF_JUMP_HELD;
|
||||
|
||||
pm->ps->groundEntityNum = ENTITYNUM_NONE;
|
||||
pm->ps->velocity[2] = JUMP_VELOCITY;
|
||||
pm->ps->lastJumpTime = pm->cmd.serverTime;
|
||||
PM_AddEvent( EV_JUMP );
|
||||
|
||||
if ( pm->cmd.forwardmove >= 0 ) {
|
||||
|
|
@ -384,19 +411,13 @@ PM_CheckJump
|
|||
=============
|
||||
*/
|
||||
static qboolean PM_CheckJump( void ) {
|
||||
if ( pm->ps->pm_flags & PMF_RESPAWNED ) {
|
||||
return qfalse; // don't allow jump until all buttons are up
|
||||
}
|
||||
|
||||
if ( pm->cmd.upmove < 10 ) {
|
||||
// not holding jump
|
||||
if ( !PM_CanJump() ) {
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
// QL autohop: don't require jump release between hops.
|
||||
// The Pmove() outer loop already forces upmove=20 when
|
||||
// PMF_JUMP_HELD is set, so removing this gate lets the
|
||||
// player hold jump to bunny hop continuously.
|
||||
// QL autohop: no PMF_JUMP_HELD gate here.
|
||||
// The Pmove() outer loop forces upmove=20 when
|
||||
// PMF_JUMP_HELD is set, allowing continuous bunny hopping.
|
||||
|
||||
PM_Jump();
|
||||
|
||||
|
|
|
|||
|
|
@ -1212,6 +1212,9 @@ typedef struct playerState_s {
|
|||
int pmove_framecount; // FIXME: don't transmit over the network
|
||||
int jumppad_frame;
|
||||
int entityEventSequence;
|
||||
|
||||
// QL additions
|
||||
int lastJumpTime; // serverTime of last jump, for 100ms cooldown
|
||||
} playerState_t;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1147,7 +1147,8 @@ netField_t playerStateFields[] =
|
|||
{ PSF(grapplePoint[1]), 0 },
|
||||
{ PSF(grapplePoint[2]), 0 },
|
||||
{ PSF(jumppad_ent), 10 },
|
||||
{ PSF(loopSound), 16 }
|
||||
{ PSF(loopSound), 16 },
|
||||
{ PSF(lastJumpTime), 32 }
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
|||
Loading…
Reference in a new issue