From ab95a8b8907168b273dad912d9eef7d214157dce Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Mon, 6 Jun 2022 00:12:51 +1000 Subject: [PATCH] - Duke: Interpolate `fist_incs` when drawing onscreen (hitting the nuke detonator at the end of each level). --- source/games/duke/src/gameexec.cpp | 2 +- source/games/duke/src/hudweapon_d.cpp | 10 +++++----- source/games/duke/src/player.cpp | 1 + source/games/duke/src/premap.cpp | 2 +- source/games/duke/src/savegame.cpp | 1 + source/games/duke/src/types.h | 2 +- 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index e1ef9f6f80f..9a6159e2793 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -645,7 +645,7 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, break; case PLAYER_FIST_INCS: - if (bSet) ps[iPlayer].fist_incs = lValue; + if (bSet) ps[iPlayer].ofist_incs = ps[iPlayer].fist_incs = lValue; else SetGameVarID(lVar2, ps[iPlayer].fist_incs, sActor, sPlayer); break; diff --git a/source/games/duke/src/hudweapon_d.cpp b/source/games/duke/src/hudweapon_d.cpp index ce3a2a631ce..189b4233ea8 100644 --- a/source/games/duke/src/hudweapon_d.cpp +++ b/source/games/duke/src/hudweapon_d.cpp @@ -86,15 +86,15 @@ void displayloogie(player_struct* p) // //--------------------------------------------------------------------------- -int animatefist(int gs, player_struct* p, double look_anghalf, double looking_arc, double plravel, int fistpal) +int animatefist(int gs, player_struct* p, double look_anghalf, double looking_arc, double plravel, int fistpal, double const smoothratio) { - int fisti = min(p->fist_incs, short(32)); + const double fisti = min(interpolatedvaluef(p->ofist_incs, p->fist_incs, smoothratio), 32.); if (fisti <= 0) return 0; hud_drawsprite( (-fisti + 222 + plravel), - (looking_arc + 194 + bsinf((6 + fisti) << 7, -9)), - clamp(65536. - bcosf(fisti << 6, 2), 40920., 90612.), 0, FIST, gs, fistpal, 2); + (looking_arc + 194 + bsinf((6 + fisti) * 128., -9)), + clamp(65536. - bcosf(fisti * 64., 2), 40920., 90612.), 0, FIST, gs, fistpal, 2); return 1; } @@ -257,7 +257,7 @@ void displayweapon_d(int snum, double smoothratio) auto adjusted_arc = looking_arc - hard_landing; bool playerVars = p->newOwner != nullptr || ud.cameraactor != nullptr || p->over_shoulder_on > 0 || (p->GetActor()->spr.pal != 1 && p->GetActor()->spr.extra <= 0); - bool playerAnims = animatefist(shade, p, look_anghalf, looking_arc, plravel, pal) || animateknuckles(shade, p, look_anghalf, adjusted_arc, horiz16th, plravel, pal) || + bool playerAnims = animatefist(shade, p, look_anghalf, looking_arc, plravel, pal, smoothratio) || animateknuckles(shade, p, look_anghalf, adjusted_arc, horiz16th, plravel, pal) || animatetip(shade, p, look_anghalf, adjusted_arc, horiz16th, plravel, pal) || animateaccess(shade, p, look_anghalf, adjusted_arc, horiz16th, plravel); if(playerVars || playerAnims) diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index dbd2a396701..2abb3320601 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -644,6 +644,7 @@ int endoflevel(int snum) auto p = &ps[snum]; // the fist puching the end-of-level thing... + p->ofist_incs = p->fist_incs; p->fist_incs++; if (p->fist_incs == 28) { diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index 1022727a9d9..f394d9437de 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -167,7 +167,7 @@ void resetplayerstats(int snum) p->weapon_ang = 0; p->knuckle_incs = 1; - p->fist_incs = 0; + p->ofist_incs = p->fist_incs = 0; p->knee_incs = 0; p->stairs = 0; p->noise.X = 0; diff --git a/source/games/duke/src/savegame.cpp b/source/games/duke/src/savegame.cpp index 17e84c8ac04..313b748af8b 100644 --- a/source/games/duke/src/savegame.cpp +++ b/source/games/duke/src/savegame.cpp @@ -170,6 +170,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, player_struct& w, ("one_parallax_sectnum", w.one_parallax_sectnum) ("over_shoulder_on", w.over_shoulder_on) ("random_club_frame", w.random_club_frame) + ("ofist_incs", w.ofist_incs) ("fist_incs", w.fist_incs) ("dummyplayersprite", w.dummyplayersprite) ("extra_extra8", w.extra_extra8) diff --git a/source/games/duke/src/types.h b/source/games/duke/src/types.h index 748eb7de3e0..2182a050694 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -248,7 +248,7 @@ struct player_struct short jumping_counter, airleft, knee_incs, access_incs; short ftq; short got_access, weapon_ang, firstaid_amount; - short over_shoulder_on, fist_incs; + short over_shoulder_on, ofist_incs, fist_incs; short cheat_phase; short extra_extra8, quick_kick, last_quick_kick; short heat_amount, timebeforeexit, customexitsound;