From d6549d63350240ec27dbadf4379ab5c30b57b1a1 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Mon, 6 Jun 2022 09:19:55 +1000 Subject: [PATCH] - Duke: Interpolate `knee_incs` when drawing onscreen (stomping on shrunken enemies). --- source/games/duke/src/gameexec.cpp | 2 +- source/games/duke/src/hudweapon_d.cpp | 9 +++++---- source/games/duke/src/player.cpp | 3 ++- source/games/duke/src/premap.cpp | 2 +- source/games/duke/src/savegame.cpp | 1 + source/games/duke/src/types.h | 2 +- 6 files changed, 11 insertions(+), 8 deletions(-) diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index 9a6159e27..e9b159f7c 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -576,7 +576,7 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, break; case PLAYER_KNEE_INCS: - if (bSet) ps[iPlayer].knee_incs = lValue; + if (bSet) ps[iPlayer].oknee_incs = ps[iPlayer].knee_incs = lValue; else SetGameVarID(lVar2, ps[iPlayer].knee_incs, sActor, sPlayer); break; diff --git a/source/games/duke/src/hudweapon_d.cpp b/source/games/duke/src/hudweapon_d.cpp index 189b4233e..3bf617695 100644 --- a/source/games/duke/src/hudweapon_d.cpp +++ b/source/games/duke/src/hudweapon_d.cpp @@ -105,15 +105,16 @@ int animatefist(int gs, player_struct* p, double look_anghalf, double looking_ar // //--------------------------------------------------------------------------- -int animateknee(int gs, player_struct* p, double look_anghalf, double looking_arc, double horiz16th, double plravel, int pal) +int animateknee(int gs, player_struct* p, double look_anghalf, double looking_arc, double horiz16th, double plravel, int pal, double const smoothratio) { if (p->knee_incs > 11 || p->knee_incs == 0 || p->GetActor()->spr.extra <= 0) return 0; static const int8_t knee_y[] = { 0,-8,-16,-32,-64,-84,-108,-108,-108,-72,-32,-8 }; + const double kneei = interpolatedvaluef(knee_y[p->oknee_incs], knee_y[p->knee_incs], smoothratio); - looking_arc += knee_y[p->knee_incs]; + looking_arc += kneei; - hud_drawpal(105 + plravel - look_anghalf + (knee_y[p->knee_incs] >> 2), looking_arc + 280 - horiz16th, KNEE, gs, 4, pal); + hud_drawpal(105 + plravel - look_anghalf + (kneei * 0.25), looking_arc + 280 - horiz16th, KNEE, gs, 4, pal); return 1; } @@ -263,7 +264,7 @@ void displayweapon_d(int snum, double smoothratio) if(playerVars || playerAnims) return; - animateknee(shade, p, look_anghalf, adjusted_arc, horiz16th, plravel, pal); + animateknee(shade, p, look_anghalf, adjusted_arc, horiz16th, plravel, pal, smoothratio); if (isWW2GI()) { diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index 2abb33206..a45b8b744 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -374,12 +374,13 @@ void dokneeattack(int snum, const std::initializer_list & respawnlist) if (p->knee_incs > 0) { + p->oknee_incs = p->knee_incs; p->knee_incs++; p->horizon.addadjustment(buildhoriz(-48)); p->sync.actions |= SB_CENTERVIEW; if (p->knee_incs > 15) { - p->knee_incs = 0; + p->oknee_incs = p->knee_incs = 0; p->holster_weapon = 0; if (p->weapon_pos < 0) p->weapon_pos = -p->weapon_pos; diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index f394d9437..c53d7a3cb 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -168,7 +168,7 @@ void resetplayerstats(int snum) p->knuckle_incs = 1; p->ofist_incs = p->fist_incs = 0; - p->knee_incs = 0; + p->oknee_incs = p->knee_incs = 0; p->stairs = 0; p->noise.X = 0; p->noise.Y = 0; diff --git a/source/games/duke/src/savegame.cpp b/source/games/duke/src/savegame.cpp index 313b748af..d2e8dbddf 100644 --- a/source/games/duke/src/savegame.cpp +++ b/source/games/duke/src/savegame.cpp @@ -155,6 +155,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, player_struct& w, ("hbomb_hold_delay", w.hbomb_hold_delay) ("jumping_counter", w.jumping_counter) ("airleft", w.airleft) + ("oknee_incs", w.oknee_incs) ("knee_incs", w.knee_incs) ("access_incs", w.access_incs) ("ftq", w.ftq) diff --git a/source/games/duke/src/types.h b/source/games/duke/src/types.h index 2182a0506..e8589f18c 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -245,7 +245,7 @@ struct player_struct short curr_weapon, last_weapon, tipincs, wantweaponfire; short holoduke_amount, hurt_delay, hbomb_hold_delay; - short jumping_counter, airleft, knee_incs, access_incs; + short jumping_counter, airleft, oknee_incs, knee_incs, access_incs; short ftq; short got_access, weapon_ang, firstaid_amount; short over_shoulder_on, ofist_incs, fist_incs;