Skip to content

Commit

Permalink
- Duke: Interpolate loogcnt when drawing onscreen.
Browse files Browse the repository at this point in the history
  • Loading branch information
mjr4077au committed Jun 6, 2022
1 parent 3948ec7 commit a29bce9
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 17 deletions.
2 changes: 1 addition & 1 deletion source/games/duke/src/gameexec.cpp
Expand Up @@ -321,7 +321,7 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor,
break;

case PLAYER_LOOGCNT:
if (bSet) ps[iPlayer].loogcnt = lValue;
if (bSet) ps[iPlayer].oloogcnt = ps[iPlayer].loogcnt = lValue;
else SetGameVarID(lVar2, ps[iPlayer].loogcnt, sActor, sPlayer);
break;

Expand Down
18 changes: 8 additions & 10 deletions source/games/duke/src/hudweapon_d.cpp
Expand Up @@ -61,20 +61,18 @@ inline static void hud_drawpal(double x, double y, int tilenum, int shade, int o
//
//---------------------------------------------------------------------------

static void displayloogie(player_struct* p)
static void displayloogie(player_struct* p, double const smoothratio)
{
double a, y;
int z;
double x;

if (p->loogcnt == 0) return;

y = (p->loogcnt << 2);
const double loogi = interpolatedvaluef(p->oloogcnt, p->loogcnt, smoothratio);
const double y = loogi * 4.;

for (int i = 0; i < p->numloogs; i++)
{
a = fabs(bsinf((p->loogcnt + i) << 5, -5));
z = 4096 + ((p->loogcnt + i) << 9);
x = -getavel(p->GetPlayerNum()) + bsinf((p->loogcnt + i) << 6, -10);
const double a = fabs(bsinf((loogi + i) * 32., -5));
const double z = 4096. + ((loogi + i) * 512.);
const double x = -getavel(p->GetPlayerNum()) + bsinf((loogi + i) * 64., -10);

hud_drawsprite((p->loogie[i].X + x), (200 + p->loogie[i].Y - y), z - (i << 8), 256 - a, LOOGIE, 0, 0, 2);
}
Expand Down Expand Up @@ -1226,7 +1224,7 @@ void displayweapon_d(int snum, double smoothratio)
}
}

displayloogie(p);
displayloogie(p, smoothratio);

}

Expand Down
1 change: 1 addition & 0 deletions source/games/duke/src/player.cpp
Expand Up @@ -796,6 +796,7 @@ void player_struct::backupweapon()
oknee_incs = knee_incs;
oaccess_incs = access_incs;
ofist_incs = fist_incs;
oloogcnt = loogcnt;
}

//---------------------------------------------------------------------------
Expand Down
11 changes: 9 additions & 2 deletions source/games/duke/src/player_d.cpp
Expand Up @@ -2802,8 +2802,15 @@ void processinput_d(int snum)

p->last_extra = pact->spr.extra;

if (p->loogcnt > 0) p->loogcnt--;
else p->loogcnt = 0;
if (p->loogcnt > 0)
{
p->oloogcnt = p->loogcnt;
p->loogcnt--;
}
else
{
p->oloogcnt = p->loogcnt = 0;
}

if (p->fist_incs)
{
Expand Down
11 changes: 9 additions & 2 deletions source/games/duke/src/player_r.cpp
Expand Up @@ -3520,8 +3520,15 @@ void processinput_r(int snum)

p->last_extra = pact->spr.extra;

if (p->loogcnt > 0) p->loogcnt--;
else p->loogcnt = 0;
if (p->loogcnt > 0)
{
p->oloogcnt = p->loogcnt;
p->loogcnt--;
}
else
{
p->oloogcnt = p->loogcnt = 0;
}

if (p->fist_incs)
{
Expand Down
2 changes: 1 addition & 1 deletion source/games/duke/src/premap.cpp
Expand Up @@ -99,7 +99,7 @@ void resetplayerstats(int snum)
p->pycount = 0;
p->pyoff = 0;
p->opyoff = 0;
p->loogcnt = 0;
p->oloogcnt = p->loogcnt = 0;
p->psectlotag = 0;
p->weapon_sway = 0;
// p->select_dir = 0;
Expand Down
2 changes: 1 addition & 1 deletion source/games/duke/src/types.h
Expand Up @@ -224,7 +224,7 @@ struct player_struct
short psectlotag;

// From here on it is unaltered from JFDuke with the exception of a few fields that are no longer needed and were removed.
int numloogs, loogcnt;
int numloogs, oloogcnt, loogcnt;
int invdisptime;
int pyoff, opyoff;
int last_pissed_time, truefz, truecz;
Expand Down

0 comments on commit a29bce9

Please sign in to comment.