From f4b78dc3c792a52e7e8c9c979f1b42ceb1577fbf Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Mon, 6 Jun 2022 09:47:30 +1000 Subject: [PATCH] - Duke: Interpolate `access_incs` when drawing onscreen (security card usage). --- source/games/duke/src/gameexec.cpp | 2 +- source/games/duke/src/hudweapon_d.cpp | 16 +++++++--------- source/games/duke/src/player_d.cpp | 3 ++- source/games/duke/src/player_r.cpp | 3 ++- source/games/duke/src/savegame.cpp | 1 + source/games/duke/src/types.h | 2 +- 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index 18c53bd5b..b03ace897 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -581,7 +581,7 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, break; case PLAYER_ACCESS_INCS: - if (bSet) ps[iPlayer].access_incs = lValue; + if (bSet) ps[iPlayer].oaccess_incs = ps[iPlayer].access_incs = lValue; else SetGameVarID(lVar2, ps[iPlayer].access_incs, sActor, sPlayer); break; diff --git a/source/games/duke/src/hudweapon_d.cpp b/source/games/duke/src/hudweapon_d.cpp index 0bead4df5..63bc4da30 100644 --- a/source/games/duke/src/hudweapon_d.cpp +++ b/source/games/duke/src/hudweapon_d.cpp @@ -178,23 +178,21 @@ static int animatetip(int gs, player_struct* p, double look_anghalf, double look // //--------------------------------------------------------------------------- -int animateaccess(int gs, player_struct* p, double look_anghalf, double looking_arc, double horiz16th, double plravel) +int animateaccess(int gs, player_struct* p, double look_anghalf, double looking_arc, double horiz16th, double plravel, double const smoothratio) { if(p->access_incs == 0 || p->GetActor()->spr.extra <= 0) return 0; static const int8_t access_y[] = {0,-8,-16,-32,-64,-84,-108,-108,-108,-108,-108,-108,-108,-108,-108,-108,-96,-72,-64,-32,-16}; - looking_arc += access_y[p->access_incs]; + const double accessi = interpolatedvaluef(access_y[p->oaccess_incs], access_y[p->access_incs], smoothratio); + looking_arc += accessi; - int pal; - if (p->access_spritenum != nullptr) - pal = p->access_spritenum->spr.pal; - else pal = 0; + const int pal = p->access_spritenum != nullptr ? p->access_spritenum->spr.pal : 0; if((p->access_incs-3) > 0 && (p->access_incs-3)>>3) - hud_drawpal(170 + plravel - look_anghalf + (access_y[p->access_incs] >> 2), looking_arc + 266 - horiz16th, HANDHOLDINGLASER + (p->access_incs >> 3), gs, 0, pal); + hud_drawpal(170 + plravel - look_anghalf + (accessi * 0.25), looking_arc + 266 - horiz16th, HANDHOLDINGLASER + (p->access_incs >> 3), gs, 0, pal); else - hud_drawpal(170 + plravel - look_anghalf + (access_y[p->access_incs] >> 2), looking_arc + 266 - horiz16th, HANDHOLDINGACCESS, gs, 4, pal); + hud_drawpal(170 + plravel - look_anghalf + (accessi * 0.25), looking_arc + 266 - horiz16th, HANDHOLDINGACCESS, gs, 4, pal); return 1; } @@ -260,7 +258,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, smoothratio) || animateknuckles(shade, p, look_anghalf, adjusted_arc, horiz16th, plravel, pal) || - animatetip(shade, p, look_anghalf, adjusted_arc, horiz16th, plravel, pal, smoothratio) || animateaccess(shade, p, look_anghalf, adjusted_arc, horiz16th, plravel); + animatetip(shade, p, look_anghalf, adjusted_arc, horiz16th, plravel, pal, smoothratio) || animateaccess(shade, p, look_anghalf, adjusted_arc, horiz16th, plravel, smoothratio); if(playerVars || playerAnims) return; diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index ef227078a..8f48a0202 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -1540,6 +1540,7 @@ int doincrements_d(struct player_struct* p) if (p->access_incs && p->GetActor()->spr.pal != 1) { + p->oaccess_incs = p->access_incs; p->access_incs++; if (p->GetActor()->spr.extra <= 0) p->access_incs = 12; @@ -1570,7 +1571,7 @@ int doincrements_d(struct player_struct* p) if (p->access_incs > 20) { - p->access_incs = 0; + p->oaccess_incs = p->access_incs = 0; p->oweapon_pos = p->weapon_pos = 10; p->okickback_pic = p->kickback_pic = 0; } diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index b396f2c68..59f6e606a 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -1396,6 +1396,7 @@ int doincrements_r(struct player_struct* p) if (p->access_incs && p->GetActor()->spr.pal != 1) { + p->oaccess_incs = p->access_incs; p->access_incs++; if (p->GetActor()->spr.extra <= 0) p->access_incs = 12; @@ -1426,7 +1427,7 @@ int doincrements_r(struct player_struct* p) if (p->access_incs > 20) { - p->access_incs = 0; + p->oaccess_incs = p->access_incs = 0; p->oweapon_pos = p->weapon_pos = 10; p->okickback_pic = p->kickback_pic = 0; } diff --git a/source/games/duke/src/savegame.cpp b/source/games/duke/src/savegame.cpp index d2e8dbddf..199140dc1 100644 --- a/source/games/duke/src/savegame.cpp +++ b/source/games/duke/src/savegame.cpp @@ -157,6 +157,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, player_struct& w, ("airleft", w.airleft) ("oknee_incs", w.oknee_incs) ("knee_incs", w.knee_incs) + ("oaccess_incs", w.oaccess_incs) ("access_incs", w.access_incs) ("ftq", w.ftq) ("access_wallnum", w.access_wall) diff --git a/source/games/duke/src/types.h b/source/games/duke/src/types.h index 72a9c54dd..63903197f 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, otipincs, tipincs, wantweaponfire; short holoduke_amount, hurt_delay, hbomb_hold_delay; - short jumping_counter, airleft, oknee_incs, knee_incs, access_incs; + short jumping_counter, airleft, oknee_incs, knee_incs, oaccess_incs, access_incs; short ftq; short got_access, weapon_ang, firstaid_amount; short over_shoulder_on, ofist_incs, fist_incs;