From fdeb290fc54d3d46bf30f1b303f89e284f7637be Mon Sep 17 00:00:00 2001 From: LegendaryGuard Date: Sat, 10 Feb 2024 22:59:01 +0100 Subject: [PATCH] game: Make player, when flying, stick to the movers while being close to them --- source/game/bg_pmove.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/source/game/bg_pmove.c b/source/game/bg_pmove.c index 0e89826..c3d20d7 100644 --- a/source/game/bg_pmove.c +++ b/source/game/bg_pmove.c @@ -1246,6 +1246,9 @@ static void PM_GroundTrace( void ) { // BFP - NOTE: Originally, BFP doesn't stop "groundtracing" until here when the player is flying // BFP - If flying, prevent from doing a jumping action on flat ground if ( pm->ps->pm_flags & PMF_FLYING ) { + // BFP - To stick to the movers if the player is near to them + pm->ps->groundEntityNum = trace.entityNum; + PM_AddTouchEnt( trace.entityNum ); return; } @@ -1427,6 +1430,11 @@ static void PM_Footsteps( void ) { return; } + // BFP - Hit stun + if ( pm->ps->pm_flags & PMF_FLYING ) { + return; + } + // // calculate speed and cycle to be used for // all cyclic walking effects @@ -2145,17 +2153,27 @@ Enables/disables flight */ static qboolean PM_EnableFlight( void ) { // BFP - Flight + // BFP - Hit stun, avoid enabling flight if the player is in this status + if ( pm->ps->pm_flags & PMF_HITSTUN ) { + return qfalse; + } + if ( !( pm->ps->pm_flags & PMF_FLYING ) ) { return qfalse; } + // Handle the PMF flag if it's already flying + if ( ( pm->ps->pm_flags & PMF_FLYING ) && !( pm->ps->pm_flags & PMF_FALLING ) ) { + return qtrue; + } + // do not proceed to the jump event while enables the flight in the charging status if ( ( pm->ps->pm_flags & PMF_KI_CHARGE ) && ( pm->ps->pm_flags & PMF_FLYING ) ) { pm->ps->groundEntityNum = ENTITYNUM_NONE; return qfalse; } - if ( ( pm->ps->pm_flags & PMF_FLYING ) && !( pm->ps->pm_flags & PMF_HITSTUN ) ) { + if ( pm->ps->pm_flags & PMF_FLYING ) { if ( ( pml.groundTrace.contents & MASK_PLAYERSOLID ) && pm->ps->groundEntityNum != ENTITYNUM_NONE ) { // do a smooth jump animation like BFP does if ( !( pm->cmd.buttons & BUTTON_KI_CHARGE ) ) { @@ -2192,7 +2210,10 @@ static void PM_KiCharge( void ) { // BFP - Ki Charge pm->cmd.buttons &= ~( BUTTON_ATTACK | BUTTON_KI_USE | BUTTON_MELEE | BUTTON_BLOCK | BUTTON_ENABLEFLIGHT ); } - pm->ps->pm_flags |= PMF_FALLING; // Handle PMF_FALLING flag + if ( !( pm->ps->pm_flags & PMF_FLYING ) ) { + pm->ps->pm_flags |= PMF_FALLING; // Handle PMF_FALLING flag + } + if ( ( pm->ps->pm_flags & PMF_KI_CHARGE ) && pm->ps->pm_time <= 0 ) { pm->ps->stats[STAT_KI]++; }