Ease hitlag vibration over time

This commit is contained in:
Sally Coolatta 2020-07-29 11:26:24 -04:00
parent c9b17c456d
commit 1bec6945ee
2 changed files with 12 additions and 5 deletions

View file

@ -410,7 +410,7 @@ typedef struct mobj_s
fixed_t sprxoff, spryoff, sprzoff; // Sprite offsets in real space, does NOT affect position or collision
INT32 hitlag;
INT32 hitlag; // Sal-style hit lag, straight from Captain Fetch's jowls
// WARNING: New fields must be added separately to savegame and Lua.
} mobj_t;

View file

@ -1469,11 +1469,18 @@ static void R_ProjectSprite(mobj_t *thing)
fixed_t this_scale = thing->scale;
// hitlag vibrating
if (thing->hitlag > 0 && (leveltime & 1))
if (thing->hitlag > 0)
{
thingxpos += thing->momx;
thingypos += thing->momy;
thingzpos += thing->momz;
fixed_t mul = (thing->hitlag * FRACUNIT) / (TICRATE);
if (leveltime & 1)
{
mul = -mul;
}
thingxpos += FixedMul(thing->momx, mul);
thingypos += FixedMul(thing->momy, mul);
thingzpos += FixedMul(thing->momz, mul);
}
// transform the origin point