From ebb79fa34bc8728b603599d7e2865d9f45b723f2 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 17 Aug 2023 18:09:03 -0700 Subject: [PATCH 1/6] Add player_t.cameraOffset, offset chasecam Z position --- src/d_player.h | 1 + src/k_kart.c | 2 ++ src/p_user.c | 6 ++++-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index 35795e9fa..6d6e887d1 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -504,6 +504,7 @@ struct player_t fixed_t deltaviewheight; // bounded/scaled total momentum. fixed_t bob; + fixed_t cameraOffset; skybox_t skybox; diff --git a/src/k_kart.c b/src/k_kart.c index 7e49c0847..815004164 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -7794,6 +7794,8 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) player->mo->spritexoffset = 0; player->mo->spriteyoffset = 0; + player->cameraOffset = 0; + if (player->curshield == KSHIELD_TOP) { mobj_t *top = K_GetGardenTop(player); diff --git a/src/p_user.c b/src/p_user.c index d2f148283..63b6ca6a9 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3542,6 +3542,8 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall z = mo->z + pviewheight + distz; } + z += player->cameraOffset; + // point viewed by the camera // this point is just 64 unit forward the player dist = 64*cameraScale; @@ -3586,13 +3588,13 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall if (mo->eflags & MFE_VERTICALFLIP) { - angle = R_PointToAngle2(0, thiscam->z + thiscam->height, dist, mo->z + mo->height - player->mo->height); + angle = R_PointToAngle2(0, thiscam->z + thiscam->height, dist, mo->z + mo->height - player->mo->height + player->cameraOffset); if (thiscam->pitch < ANGLE_180 && thiscam->pitch > angle) angle += (thiscam->pitch - angle)/2; } else { - angle = R_PointToAngle2(0, thiscam->z, dist, mo->z + player->mo->height); + angle = R_PointToAngle2(0, thiscam->z, dist, mo->z + player->mo->height + player->cameraOffset); if (thiscam->pitch >= ANGLE_180 && thiscam->pitch < angle) angle -= (angle - thiscam->pitch)/2; } From a680e1167559df9c5cad65ff6628d27da54707a4 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 17 Aug 2023 18:10:56 -0700 Subject: [PATCH 2/6] 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) From fe6da4e0875b7c1a2c62d03c770be5fc806f1bc8 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 17 Aug 2023 18:12:59 -0700 Subject: [PATCH 3/6] Instawhip: consistently flicker on opposite frame of player flashing tics --- src/objects/instawhip.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/objects/instawhip.c b/src/objects/instawhip.c index 64ddd8ae5..dc1e410ed 100644 --- a/src/objects/instawhip.c +++ b/src/objects/instawhip.c @@ -34,7 +34,8 @@ void Obj_InstaWhipThink (mobj_t *whip) // Visuals whip->renderflags |= RF_NOSPLATBILLBOARD|RF_FULLBRIGHT; - if (whip->renderflags & RF_DONTDRAW) + // This is opposite of player flashing tics + if (leveltime & 1) whip->renderflags &= ~RF_DONTDRAW; else whip->renderflags |= RF_DONTDRAW; From 9e5c9cfbd9a8cdd85839ebd8f09437e6d5006e0d Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 19 Aug 2023 04:27:51 -0700 Subject: [PATCH 4/6] Instawhip: don't hop if activated in the air --- src/k_kart.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index 6b06c1d8a..a9d9deb70 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -7816,7 +7816,7 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) } } - if (!P_MobjWasRemoved(player->whip)) + if (!P_MobjWasRemoved(player->whip) && (player->whip->flags2 & MF2_AMBUSH)) { // Linear acceleration and deceleration to a peak. // There is a constant total time to complete but the @@ -10963,6 +10963,11 @@ void K_MoveKartPlayer(player_t *player, boolean onground) whip->fuse = INSTAWHIP_DURATION; player->flashing = max(player->flashing, INSTAWHIP_DURATION); + if (P_IsObjectOnGround(player->mo)) + { + whip->flags2 |= MF2_AMBUSH; + } + if (!K_PowerUpRemaining(player, POWERUP_BADGE)) { // Spawn in triangle formation From 2d7a224e8e25425716724ac7a11343612364e871 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 19 Aug 2023 04:29:52 -0700 Subject: [PATCH 5/6] Instawhip hop: 1.5x height, slightly tweak timing --- src/k_kart.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index a9d9deb70..08e80e2cf 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -7822,9 +7822,9 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) // 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 fixed_t hop = 24 * mapobjectscale; const INT32 duration = 12; - const INT32 mid = (duration / 2) - 2; + const INT32 mid = (duration / 2) - 1; const INT32 t = (duration - mid) - player->whip->fuse; player->cameraOffset = hop - (abs(t * hop) / (t < 0 ? mid : duration - mid)); From 3282a2581b02639cf31fc89b34f2c85ba81169eb Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 19 Aug 2023 04:58:55 -0700 Subject: [PATCH 6/6] Instawhip cooldown: don't flicker dark frames while whip is still out --- src/r_spritefx.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_spritefx.cpp b/src/r_spritefx.cpp index 4db957880..756e0a96e 100644 --- a/src/r_spritefx.cpp +++ b/src/r_spritefx.cpp @@ -22,7 +22,7 @@ INT32 R_ThingLightLevel(mobj_t* thing) if (player) { - if (player->instaShieldCooldown && (player->rings <= 0) && (leveltime & 1)) + if (player->instaShieldCooldown && !player->whip && (player->rings <= 0) && (leveltime & 1)) { // Darken on every other frame of instawhip cooldown lightlevel -= 128;