diff --git a/src/p_local.h b/src/p_local.h index c5eac863e..a6622b5c1 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -521,5 +521,6 @@ void P_Thrust(mobj_t *mo, angle_t angle, fixed_t move); void P_ExplodeMissile(mobj_t *mo); void P_CheckGravity(mobj_t *mo, boolean affect); void P_SetPitchRollFromSlope(mobj_t *mo, pslope_t *slope); +fixed_t P_ScaleFromMap(fixed_t, fixed_t scale); #endif // __P_LOCAL__ diff --git a/src/p_mobj.c b/src/p_mobj.c index 2bc6c620f..5975da344 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -12748,6 +12748,15 @@ void P_FlashPal(player_t *pl, UINT16 type, UINT16 duration) pl->flashpal = type; } +// +// P_ScaleFromMap +// Scales a number relative to the mapobjectscale. +// +fixed_t P_ScaleFromMap(fixed_t n, fixed_t scale) +{ + return FixedMul(n, FixedDiv(scale, mapobjectscale)); +} + // // P_SpawnMobjFromMobj // Spawns an object with offsets relative to the position of another object. @@ -12765,16 +12774,15 @@ mobj_t *P_SpawnMobjFromMobj(mobj_t *mobj, fixed_t xofs, fixed_t yofs, fixed_t zo if (!newmobj) return NULL; + newmobj->destscale = P_ScaleFromMap(mobj->destscale, newmobj->destscale); + P_SetScale(newmobj, P_ScaleFromMap(mobj->scale, newmobj->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; + newmobj->z = mobj->z + mobj->height - zofs - newmobj->height; } - newmobj->destscale = mobj->destscale; - P_SetScale(newmobj, mobj->scale); return newmobj; }