From 043e3a2def75db1a9cbd9248f2b2ff9f5bbd0945 Mon Sep 17 00:00:00 2001 From: serge_shubin Date: Sat, 21 Mar 2026 15:08:16 +0800 Subject: [PATCH] QL stair traversal: conditional velocity clip + air steps Two changes to PM_StepSlideMove that transform stair traversal: 1. Remove Q3 velocity[2]>0 gate (QL pm_airSteps): allow step-ups while airborne, enabling bunny-hop stair traversal. 2. Conditional velocity clip: only clip velocity to step-down surface when moving INTO it (dot product < 0). Skip clip when velocity is moving away (dot >= 0), preserving upward momentum through steps. This is THE key mechanic for smooth QL-style stair hopping. Also adds 100ms jump cooldown (lastJumpTime) to prevent same-frame double-fires during rapid step-ups. Co-Authored-By: Claude Opus 4.6 (1M context) --- code/game/bg_local.h | 2 +- code/game/bg_pmove.c | 8 ++++++++ code/game/bg_slidemove.c | 20 ++++++++++---------- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/code/game/bg_local.h b/code/game/bg_local.h index d3ede18..0b67651 100644 --- a/code/game/bg_local.h +++ b/code/game/bg_local.h @@ -26,7 +26,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define STEPSIZE 18 -#define JUMP_VELOCITY 270 +#define JUMP_VELOCITY 275 #define TIMER_LAND 130 #define TIMER_GESTURE (34*66+50) diff --git a/code/game/bg_pmove.c b/code/game/bg_pmove.c index 36bae08..9d1a188 100644 --- a/code/game/bg_pmove.c +++ b/code/game/bg_pmove.c @@ -383,6 +383,14 @@ qboolean PM_CanJump( void ) { return qfalse; } + // QL: 100ms minimum delay between jumps. + // Prevents same-frame double-fires. Step jumps launch the player + // high enough (~400ms airtime) that the next stair collision + // naturally exceeds this threshold. + if ( pm->cmd.serverTime - pm->ps->lastJumpTime < 100 ) { + return qfalse; + } + return qtrue; } diff --git a/code/game/bg_slidemove.c b/code/game/bg_slidemove.c index ed1349f..6c7b307 100644 --- a/code/game/bg_slidemove.c +++ b/code/game/bg_slidemove.c @@ -246,15 +246,9 @@ void PM_StepSlideMove( qboolean gravity ) { return; // we got exactly where we wanted to go first try } - VectorCopy(start_o, down); - down[2] -= STEPSIZE; - pm->trace (&trace, start_o, pm->mins, pm->maxs, down, pm->ps->clientNum, pm->tracemask); - VectorSet(up, 0, 0, 1); - // never step up when you still have up velocity - if ( pm->ps->velocity[2] > 0 && (trace.fraction == 1.0 || - DotProduct(trace.plane.normal, up) < 0.7)) { - return; - } + // QL pm_airSteps: allow step-ups with upward velocity. + // Q3 blocked step-ups during jumps unless ground was directly below. + // This prevented smooth stair traversal while bunny-hopping. VectorCopy (pm->ps->origin, down_o); VectorCopy (pm->ps->velocity, down_v); @@ -285,8 +279,14 @@ void PM_StepSlideMove( qboolean gravity ) { if ( !trace.allsolid ) { VectorCopy (trace.endpos, pm->ps->origin); } + // QL: only clip velocity to step surface when moving INTO it. + // Skip clip when velocity is already moving away (preserves + // upward momentum through stair steps during bunny-hopping). if ( trace.fraction < 1.0 ) { - PM_ClipVelocity( pm->ps->velocity, trace.plane.normal, pm->ps->velocity, OVERCLIP ); + float vdotn = DotProduct( pm->ps->velocity, trace.plane.normal ); + if ( vdotn < 0 || fabs( vdotn ) < 0.001f ) { + PM_ClipVelocity( pm->ps->velocity, trace.plane.normal, pm->ps->velocity, OVERCLIP ); + } } #if 0