- SW: Create inline function pspPresentRetractScale() to scale the rate at which weapons present and retract based on the current tile's height vs. the original asset's height.

* Reported to me by @Phredreeke, who had it reported to him from someone else.
* The sword in the widescreen assets pack we load by default has a height of 216px vs 136px of the default tile.
* Because the game presents and retracts weapons at a set rate, the time it took to swap between the sword and other weapons took ~1.58x longer than the original assets.
* This speeds up the present/retract rate based on the loaded asset's height to ensure the weapon switches in the same elapsed time.
* This may be extended to other weapons if required but the sword is the only one I'm aware of that has more height.
* Confirmed no matter what motion the sword was performing, `psp->picndx` was always 2080 so we shouldn't need a hashtable or anything like this.
This commit is contained in:
Mitchell Richters 2021-07-11 19:22:59 +10:00
parent 8a8379f5fc
commit 5441272bec

View file

@ -745,6 +745,12 @@ inline double pspCosVel(PANEL_SPRITEp const psp, int const ang = INT_MAX)
return psp->vel * synctics * bcosf(ang == INT_MAX ? psp->ang : ang, -6) * (1. / FRACUNIT); return psp->vel * synctics * bcosf(ang == INT_MAX ? psp->ang : ang, -6) * (1. / FRACUNIT);
} }
inline double pspPresentRetractScale(int const picnum, double const defaultheight)
{
double const picheight = tileHeight(picnum);
return picheight == defaultheight ? 1 : picheight / defaultheight;
}
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
// //
@ -1009,7 +1015,7 @@ pSwordPresent(PANEL_SPRITEp psp)
return; return;
psp->backupy(); psp->backupy();
psp->y -= 3 * synctics; psp->y -= 3 * synctics * pspPresentRetractScale(psp->picndx, 136);
if (psp->y < SWORD_YOFF) if (psp->y < SWORD_YOFF)
{ {
@ -1239,7 +1245,7 @@ pSwordRetract(PANEL_SPRITEp psp)
short picnum = psp->picndx; short picnum = psp->picndx;
psp->backupy(); psp->backupy();
psp->y += 3 * synctics; psp->y += 3 * synctics * pspPresentRetractScale(picnum, 136);
if (psp->y >= SWORD_YOFF + tileHeight(picnum)) if (psp->y >= SWORD_YOFF + tileHeight(picnum))
{ {