From 3f66a8e72f351f1008189cc450257c734cc41a23 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Wed, 21 Sep 2022 01:38:21 -0400 Subject: [PATCH] Fix fast fall preventing stumble --- src/k_kart.c | 63 +++++++++++++++++++++++++++++++--------------------- src/k_kart.h | 1 + src/p_user.c | 13 +++++++++-- 3 files changed, 50 insertions(+), 27 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 8b0f472a9..00c99c8e1 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3865,6 +3865,8 @@ boolean K_CheckStumble(player_t *player, angle_t oldPitch, angle_t oldRoll, bool // Oh jeez, you landed on your side. // You get to tumble. + P_ResetPlayer(player); + #if 0 // Single, medium bounce player->tumbleBounces = TUMBLEBOUNCES; @@ -9568,31 +9570,7 @@ static void K_KartSpindash(player_t *player) } else if (player->fastfall != 0) { - // Handle fastfall bounce. - const fixed_t maxBounce = player->mo->scale * 10; - const fixed_t minBounce = player->mo->scale; - fixed_t bounce = 2 * abs(player->fastfall) / 3; - - if (bounce > maxBounce) - { - bounce = maxBounce; - } - else - { - // Lose speed on bad bounce. - player->mo->momx /= 2; - player->mo->momy /= 2; - - if (bounce < minBounce) - { - bounce = minBounce; - } - } - - S_StartSound(player->mo, sfx_ffbonc); - player->mo->momz = bounce * P_MobjFlip(player->mo); - - player->fastfall = 0; + // Still handling fast-fall bounce. return; } @@ -9659,6 +9637,41 @@ static void K_KartSpindash(player_t *player) #undef SPINDASHTHRUSTTIME +boolean K_FastFallBounce(player_t *player) +{ + // Handle fastfall bounce. + if (player->fastfall != 0) + { + const fixed_t maxBounce = player->mo->scale * 10; + const fixed_t minBounce = player->mo->scale; + fixed_t bounce = 2 * abs(player->fastfall) / 3; + + if (bounce > maxBounce) + { + bounce = maxBounce; + } + else + { + // Lose speed on bad bounce. + player->mo->momx /= 2; + player->mo->momy /= 2; + + if (bounce < minBounce) + { + bounce = minBounce; + } + } + + S_StartSound(player->mo, sfx_ffbonc); + player->mo->momz = bounce * P_MobjFlip(player->mo); + + player->fastfall = 0; + return true; + } + + return false; +} + static void K_AirFailsafe(player_t *player) { const fixed_t maxSpeed = 6*player->mo->scale; diff --git a/src/k_kart.h b/src/k_kart.h index b44258a9a..46f97a3f5 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -149,6 +149,7 @@ fixed_t K_GetNewSpeed(player_t *player); fixed_t K_3dKartMovement(player_t *player); boolean K_PlayerEBrake(player_t *player); SINT8 K_Sliptiding(player_t *player); +boolean K_FastFallBounce(player_t *player); void K_AdjustPlayerFriction(player_t *player); void K_MoveKartPlayer(player_t *player, boolean onground); void K_CheckSpectateStatus(void); diff --git a/src/p_user.c b/src/p_user.c index e7cc525cc..f733bad28 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1354,15 +1354,24 @@ boolean P_PlayerHitFloor(player_t *player, boolean fromAir, angle_t oldPitch, an K_SpawnSplashForMobj(player->mo, abs(player->mo->momz)); } - if (player->mo->health) + if (player->mo->health > 0) { boolean air = fromAir; if (P_IsObjectOnGround(player->mo) && (player->mo->eflags & MFE_JUSTHITFLOOR)) + { air = true; + } - if (K_CheckStumble(player, oldPitch, oldRoll, air)) + if (K_CheckStumble(player, oldPitch, oldRoll, air) == true) + { return false; + } + + if (air == false && K_FastFallBounce(player) == true) + { + return false; + } } }