Skip to content

Commit

Permalink
- Duke: Interpolate fist_incs when drawing onscreen (hitting the nu…
Browse files Browse the repository at this point in the history
…ke detonator at the end of each level).
  • Loading branch information
mjr4077au authored and coelckers committed Jun 5, 2022
1 parent 55408e6 commit ab95a8b
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion source/games/duke/src/gameexec.cpp
Expand Up @@ -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;

Expand Down
10 changes: 5 additions & 5 deletions source/games/duke/src/hudweapon_d.cpp
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions source/games/duke/src/player.cpp
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion source/games/duke/src/premap.cpp
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions source/games/duke/src/savegame.cpp
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion source/games/duke/src/types.h
Expand Up @@ -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;
Expand Down

0 comments on commit ab95a8b

Please sign in to comment.