Skip to content

Commit

Permalink
- Duke: Interpolate access_incs when drawing onscreen (security car…
Browse files Browse the repository at this point in the history
…d usage).
  • Loading branch information
mjr4077au committed Jun 5, 2022
1 parent 3b2ef4d commit f4b78dc
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion source/games/duke/src/gameexec.cpp
Expand Up @@ -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;

Expand Down
16 changes: 7 additions & 9 deletions source/games/duke/src/hudweapon_d.cpp
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion source/games/duke/src/player_d.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion source/games/duke/src/player_r.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions source/games/duke/src/savegame.cpp
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion source/games/duke/src/types.h
Expand Up @@ -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;
Expand Down

0 comments on commit f4b78dc

Please sign in to comment.