From 410419c8520a8d9526fbd89ff9dbf6559244e89f Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 17 Aug 2023 18:09:03 -0700 Subject: [PATCH] Add player_t.cameraOffset, offset chasecam Z position --- src/d_player.h | 1 + src/k_kart.c | 9 +++++++++ src/p_user.c | 6 ++++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index 36e1e34e1..6e8b6a3f5 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -319,6 +319,7 @@ typedef struct player_s fixed_t deltaviewheight; // bounded/scaled total momentum. fixed_t bob; + fixed_t cameraOffset; angle_t viewrollangle; // camera tilt diff --git a/src/k_kart.c b/src/k_kart.c index 5c01c909d..3944376d2 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -6536,6 +6536,15 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) { const boolean onground = P_IsObjectOnGround(player->mo); + /* reset sprite offsets :) */ + player->mo->sprxoff = 0; + player->mo->spryoff = 0; + player->mo->sprzoff = 0; + player->mo->spritexoffset = 0; + player->mo->spriteyoffset = 0; + + player->cameraOffset = 0; + K_UpdateOffroad(player); K_UpdateEngineSounds(player); // Thanks, VAda! diff --git a/src/p_user.c b/src/p_user.c index c52e5b136..6aab4aa4d 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3599,6 +3599,8 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall thiscam->z = thiscam->floorz; #endif // NOCLIPCAM + z += player->cameraOffset; + // point viewed by the camera // this point is just 64 unit forward the player dist = 64*mapobjectscale; @@ -3651,13 +3653,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; }