- SW: Interpolate the player's weapon recoil.

* Reported as missing by @nashmuhandes.
This commit is contained in:
Mitch Richters 2021-10-31 08:53:26 +11:00
parent e8f9afb174
commit 9495b9e6d0
4 changed files with 7 additions and 4 deletions

View file

@ -1590,7 +1590,7 @@ drawscreen(PLAYERp pp, double smoothratio)
}
// recoil only when not in camera
thoriz = q16horiz(clamp(thoriz.asq16() + pp->recoil_horizoff, gi->playerHorizMin(), gi->playerHorizMax()));
thoriz = q16horiz(clamp(thoriz.asq16() + interpolatedvalue(pp->recoil_ohorizoff, pp->recoil_horizoff, smoothratio), gi->playerHorizMin(), gi->playerHorizMax()));
}
if (automapMode != am_full)// && !ScreenSavePic)

View file

@ -799,7 +799,7 @@ struct PLAYERstruct
short recoil_amt;
short recoil_speed;
short recoil_ndx;
fixed_t recoil_horizoff;
fixed_t recoil_ohorizoff, recoil_horizoff;
int oldposx,oldposy,oldposz;
int RevolveX, RevolveY;

View file

@ -1720,7 +1720,7 @@ DoPlayerBeginRecoil(PLAYERp pp, short pix_amt)
pp->recoil_amt = pix_amt;
pp->recoil_speed = 80;
pp->recoil_ndx = 0;
pp->recoil_horizoff = 0;
pp->recoil_ohorizoff = pp->recoil_horizoff = 0;
}
void
@ -1732,11 +1732,12 @@ DoPlayerRecoil(PLAYERp pp)
if (bsin(pp->recoil_ndx) < 0)
{
RESET(pp->Flags, PF_RECOIL);
pp->recoil_horizoff = 0;
pp->recoil_ohorizoff = pp->recoil_horizoff = 0;
return;
}
// move pp->q16horiz up and down
pp->recoil_ohorizoff = pp->recoil_horizoff;
pp->recoil_horizoff = pp->recoil_amt * bsin(pp->recoil_ndx, 2);
}
@ -7654,6 +7655,7 @@ DEFINE_FIELD_X(SWPlayer, PLAYERstruct, recoil_amt)
DEFINE_FIELD_X(SWPlayer, PLAYERstruct, recoil_speed)
DEFINE_FIELD_X(SWPlayer, PLAYERstruct, recoil_ndx)
DEFINE_FIELD_X(SWPlayer, PLAYERstruct, recoil_horizoff)
DEFINE_FIELD_X(SWPlayer, PLAYERstruct, recoil_ohorizoff)
DEFINE_FIELD_X(SWPlayer, PLAYERstruct, oldposx)
DEFINE_FIELD_X(SWPlayer, PLAYERstruct, oldposy)
DEFINE_FIELD_X(SWPlayer, PLAYERstruct, oldposz)

View file

@ -510,6 +510,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, PLAYERstruct& w, P
("recoil_speed", w.recoil_speed)
("recoil_ndx", w.recoil_ndx)
("recoil_horizoff", w.recoil_horizoff)
("recoil_ohorizoff", w.recoil_ohorizoff)
("oldposx", w.oldposx)
("oldposy", w.oldposy)
("oldposz", w.oldposz)