Adjust spawned mobj z by gravity inversion

This commit is contained in:
Eidolon 2022-05-03 15:07:35 -05:00
parent 805941a98f
commit 7ec0420ce6

View file

@ -14084,6 +14084,7 @@ void P_FlashPal(player_t *pl, UINT16 type, UINT16 duration)
mobj_t *P_SpawnMobjFromMobj(mobj_t *mobj, fixed_t xofs, fixed_t yofs, fixed_t zofs, mobjtype_t type)
{
mobj_t *newmobj;
fixed_t elementheight;
xofs = FixedMul(xofs, mobj->scale);
yofs = FixedMul(yofs, mobj->scale);
@ -14093,24 +14094,31 @@ mobj_t *P_SpawnMobjFromMobj(mobj_t *mobj, fixed_t xofs, fixed_t yofs, fixed_t zo
if (!newmobj)
return NULL;
elementheight = FixedMul(newmobj->info->height, mobj->scale);
if (mobj->eflags & MFE_VERTICALFLIP)
{
fixed_t elementheight = FixedMul(newmobj->info->height, mobj->scale);
newmobj->eflags |= MFE_VERTICALFLIP;
newmobj->flags2 |= MF2_OBJECTFLIP;
newmobj->z = mobj->z + mobj->height - zofs - elementheight;
}
if (mobj->flags2 & MF2_OBJECTFLIP || mobj->eflags & MFE_VERTICALFLIP)
{
newmobj->old_z = mobj->old_z + mobj->height - zofs - elementheight;
newmobj->old_z2 = mobj->old_z2 + mobj->height - zofs - elementheight;
} else {
newmobj->old_z = mobj->old_z;
newmobj->old_z2 = mobj->old_z2;
}
newmobj->destscale = mobj->destscale;
P_SetScale(newmobj, mobj->scale);
newmobj->old_x2 = mobj->old_x2 + xofs;
newmobj->old_y2 = mobj->old_y2 + yofs;
newmobj->old_z2 = mobj->old_z2 + zofs;
newmobj->old_x = mobj->old_x + xofs;
newmobj->old_y = mobj->old_y + yofs;
newmobj->old_z = mobj->old_z + zofs;
// This angle hack is needed for Lua scripts that set the angle after
// spawning, to avoid erroneous interpolation.