From 94faf486fdfc8c57a668f7882c3cc4f0ad3cae0a Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 13 Mar 2023 20:09:20 -0700 Subject: [PATCH 1/2] Add player->fastfallBase --- src/d_player.h | 1 + src/k_kart.c | 1 + src/lua_playerlib.c | 4 ++++ src/p_saveg.c | 2 ++ src/p_user.c | 1 + 5 files changed, 9 insertions(+) diff --git a/src/d_player.h b/src/d_player.h index 6641b30d6..1e4229e01 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -524,6 +524,7 @@ struct player_t UINT8 spindashboost; // Spindash release boost timer fixed_t fastfall; // Fast fall momentum + fixed_t fastfallBase; // Fast fall base speed multiplier UINT8 numboosts; // Count of how many boosts are being stacked, for after image spawning fixed_t boostpower; // Base boost value, for offroad diff --git a/src/k_kart.c b/src/k_kart.c index 09d552b1a..ab93d5cf0 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -10057,6 +10057,7 @@ boolean K_FastFallBounce(player_t *player) player->mo->momz = bounce * P_MobjFlip(player->mo); player->fastfall = 0; + player->fastfallBase = 0; return true; } diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index 327641362..76325ebc9 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -282,6 +282,8 @@ static int player_get(lua_State *L) lua_pushinteger(L, plr->spindashboost); else if (fastcmp(field,"fastfall")) lua_pushfixed(L, plr->fastfall); + else if (fastcmp(field,"fastfallBase")) + lua_pushfixed(L, plr->fastfallBase); else if (fastcmp(field,"numboosts")) lua_pushinteger(L, plr->numboosts); else if (fastcmp(field,"boostpower")) @@ -664,6 +666,8 @@ static int player_set(lua_State *L) plr->spindashboost = luaL_checkinteger(L, 3); else if (fastcmp(field,"fastfall")) plr->fastfall = luaL_checkfixed(L, 3); + else if (fastcmp(field,"fastfallBase")) + plr->fastfallBase = luaL_checkfixed(L, 3); else if (fastcmp(field,"numboosts")) plr->numboosts = luaL_checkinteger(L, 3); else if (fastcmp(field,"boostpower")) diff --git a/src/p_saveg.c b/src/p_saveg.c index 8f142fa20..eca813e50 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -311,6 +311,7 @@ static void P_NetArchivePlayers(savebuffer_t *save) WRITEUINT8(save->p, players[i].spindashboost); WRITEFIXED(save->p, players[i].fastfall); + WRITEFIXED(save->p, players[i].fastfallBase); WRITEUINT8(save->p, players[i].numboosts); WRITEFIXED(save->p, players[i].boostpower); @@ -686,6 +687,7 @@ static void P_NetUnArchivePlayers(savebuffer_t *save) players[i].spindashboost = READUINT8(save->p); players[i].fastfall = READFIXED(save->p); + players[i].fastfallBase = READFIXED(save->p); players[i].numboosts = READUINT8(save->p); players[i].boostpower = READFIXED(save->p); diff --git a/src/p_user.c b/src/p_user.c index dc6490fcf..0aefb2b90 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -482,6 +482,7 @@ void P_ResetPlayer(player_t *player) player->trickpanel = 0; player->glanceDir = 0; player->fastfall = 0; + player->fastfallBase = 0; if (player->mo != NULL && P_MobjWasRemoved(player->mo) == false) { From f390ff26ec8604610cf25451427e7599a8881cf1 Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 13 Mar 2023 20:09:38 -0700 Subject: [PATCH 2/2] Scale fast fall momentum with speed at time of trigger Previous was 4x gravity. Now 3x at the lowest, scales up to around 8x at 200% speed (can go further). --- src/k_kart.c | 7 +++++++ src/p_mobj.c | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index ab93d5cf0..d2d953b3f 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -9946,6 +9946,13 @@ static void K_KartSpindash(player_t *player) // Update fastfall. player->fastfall = player->mo->momz; player->spindash = 0; + + if (player->fastfallBase == 0) + { + // Factors 3D momentum. + player->fastfallBase = FixedHypot(player->speed, player->mo->momz); + } + return; } else if (player->fastfall != 0) diff --git a/src/p_mobj.c b/src/p_mobj.c index 4e466e937..e122f4a5d 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1148,7 +1148,11 @@ fixed_t P_GetMobjGravity(mobj_t *mo) else if (mo->player->fastfall != 0) { // Fast falling - gravityadd *= 4; + + const fixed_t unit = 64 * mapobjectscale; + const fixed_t mult = 3*FRACUNIT + (3 * FixedDiv(mo->player->fastfallBase, unit)); + + gravityadd = FixedMul(gravityadd, mult); } } else