From 4a6e2683f289265713a7fb764f0929a639600340 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Thu, 24 Nov 2022 13:38:03 +1100 Subject: [PATCH] - Duke/RR: Properly fix `movement()` so the player's Z always makes it back to floorz. * The `abs(k)` here was really messing it up. * RR's height of 40 is actually a fix of Duke's 38, which left the player slightly off the ground. * Duke when returning from crouching, jumping, or otherwise changing the Z always correctly ends up at the floor's Z now. --- source/games/duke/src/constants.h | 2 -- source/games/duke/src/flags_r.cpp | 1 - source/games/duke/src/gamedef.cpp | 2 +- source/games/duke/src/player_d.cpp | 5 ++--- source/games/duke/src/player_r.cpp | 5 ++--- 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/source/games/duke/src/constants.h b/source/games/duke/src/constants.h index 9b9657098..637dc522e 100644 --- a/source/games/duke/src/constants.h +++ b/source/games/duke/src/constants.h @@ -438,8 +438,6 @@ enum miscConstants MOVEFIFOSIZ =256, AUTO_AIM_ANGLE =48, - PHEIGHT_DUKE =38, - PHEIGHT_RR =40, MAXMINECARTS = 16, MAXJAILDOORS = 32, diff --git a/source/games/duke/src/flags_r.cpp b/source/games/duke/src/flags_r.cpp index c3d25e902..fbc94a4ae 100644 --- a/source/games/duke/src/flags_r.cpp +++ b/source/games/duke/src/flags_r.cpp @@ -321,7 +321,6 @@ void initactorflags_r() TILE_BIGORBIT1 = BIGORBIT1; TILE_EGG = EGG; - gs.playerheight = PHEIGHT_RR; gs.firstdebris = SCRAP6; } diff --git a/source/games/duke/src/gamedef.cpp b/source/games/duke/src/gamedef.cpp index 299d0f34f..a4fb32699 100644 --- a/source/games/duke/src/gamedef.cpp +++ b/source/games/duke/src/gamedef.cpp @@ -3187,7 +3187,7 @@ void loadcons() gs.shrinkerblastradius = 650; gs.gravity = 0.6875; gs.tripbombblastradius = 3880; - gs.playerheight = PHEIGHT_DUKE; + gs.playerheight = 40; gs.displayflags = DUKE3D_NO_WIDESCREEN_PINNING; diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index e31ddea6a..0159245b4 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -1754,7 +1754,7 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, double floo if (p->scuba_on == 1) p->scuba_on = 0; - double i = 40; + double i = gs.playerheight; if (psectlotag == ST_1_ABOVE_WATER && p->spritebridge == 0) { if (shrunk == 0) @@ -1844,12 +1844,11 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, double floo p->on_ground = 1; - if (i == 40) + if (i == gs.playerheight) { //Smooth on the ground double k = (floorz - i - p->GetActor()->getOffsetZ()) * 0.5; - if (abs(k) < 1) k = 0; p->GetActor()->spr.pos.Z += k; p->vel.Z -= 3; if (p->vel.Z < 0) p->vel.Z = 0; diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index 3fc28bd66..dac748447 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -2034,7 +2034,7 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, double floo if (p->scuba_on == 1) p->scuba_on = 0; - double i = 40; + double i = gs.playerheight; if (psectlotag == ST_1_ABOVE_WATER && p->spritebridge == 0) { if (shrunk == 0) @@ -2171,12 +2171,11 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, double floo p->on_ground = 1; - if (i == 40) + if (i == gs.playerheight) { //Smooth on the ground double k = (floorz - i - p->GetActor()->getOffsetZ()) * 0.5; - if (abs(k) < 1) k = 0; p->GetActor()->spr.pos.Z += k; p->vel.Z -= 3; if (p->vel.Z < 0) p->vel.Z = 0;