From a680e1167559df9c5cad65ff6628d27da54707a4 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 17 Aug 2023 18:10:56 -0700 Subject: [PATCH] Instawhip: adjust player sprzoff and cameraOffset instead of momz Since gravity is not involved, this will be more consistent but it is also slightly different than before. I tried to match it closely to how it behaved before, though. --- src/k_kart.c | 20 +++++++++++++++++--- src/k_kart.h | 1 + 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 815004164..6b06c1d8a 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -7816,6 +7816,21 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) } } + if (!P_MobjWasRemoved(player->whip)) + { + // Linear acceleration and deceleration to a peak. + // There is a constant total time to complete but the + // acceleration and deceleration times can be made + // asymmetrical. + const fixed_t hop = 16 * mapobjectscale; + const INT32 duration = 12; + const INT32 mid = (duration / 2) - 2; + const INT32 t = (duration - mid) - player->whip->fuse; + + player->cameraOffset = hop - (abs(t * hop) / (t < 0 ? mid : duration - mid)); + player->mo->sprzoff += player->cameraOffset; + } + K_UpdateOffroad(player); K_UpdateDraft(player); K_UpdateEngineSounds(player); // Thanks, VAda! @@ -10945,9 +10960,8 @@ void K_MoveKartPlayer(player_t *player, boolean onground) P_SetTarget(&whip->target, player->mo); K_MatchGenericExtraFlags(whip, player->mo); P_SpawnFakeShadow(whip, 20); - whip->fuse = 12; // Changing instawhip animation duration? Look here - player->flashing = max(player->flashing, 12); - player->mo->momz += 4*mapobjectscale; + whip->fuse = INSTAWHIP_DURATION; + player->flashing = max(player->flashing, INSTAWHIP_DURATION); if (!K_PowerUpRemaining(player, POWERUP_BADGE)) { diff --git a/src/k_kart.h b/src/k_kart.h index 22e7ac9fa..8982e9d75 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -29,6 +29,7 @@ Make sure this matches the actual number of states #define GROW_PHYSICS_SCALE (3*FRACUNIT/2) #define SHRINK_PHYSICS_SCALE (3*FRACUNIT/4) +#define INSTAWHIP_DURATION (12) #define INSTAWHIP_COOLDOWN (TICRATE*2) #define INSTAWHIP_STARTOFRACE (255) #define INSTAWHIP_STARTOFBATTLE (1)