mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Improve P_SpawnMobjFromMobj by factoring the scale from P_SpawnMobj in
This will copy the parent object's scale to the child, but scale it by the child's original scale relative to the map scale. Also uses the child's actual height, instead of the mobjinfo version. Might be useful if either the scale or height was changed in P_SpawnMobj. Say, from a Lua hook.
This commit is contained in:
parent
b77a67c085
commit
0cf41dade0
2 changed files with 14 additions and 5 deletions
|
|
@ -521,5 +521,6 @@ void P_Thrust(mobj_t *mo, angle_t angle, fixed_t move);
|
||||||
void P_ExplodeMissile(mobj_t *mo);
|
void P_ExplodeMissile(mobj_t *mo);
|
||||||
void P_CheckGravity(mobj_t *mo, boolean affect);
|
void P_CheckGravity(mobj_t *mo, boolean affect);
|
||||||
void P_SetPitchRollFromSlope(mobj_t *mo, pslope_t *slope);
|
void P_SetPitchRollFromSlope(mobj_t *mo, pslope_t *slope);
|
||||||
|
fixed_t P_ScaleFromMap(fixed_t, fixed_t scale);
|
||||||
|
|
||||||
#endif // __P_LOCAL__
|
#endif // __P_LOCAL__
|
||||||
|
|
|
||||||
18
src/p_mobj.c
18
src/p_mobj.c
|
|
@ -12748,6 +12748,15 @@ void P_FlashPal(player_t *pl, UINT16 type, UINT16 duration)
|
||||||
pl->flashpal = type;
|
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
|
// P_SpawnMobjFromMobj
|
||||||
// Spawns an object with offsets relative to the position of another object.
|
// 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)
|
if (!newmobj)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
newmobj->destscale = P_ScaleFromMap(mobj->destscale, newmobj->destscale);
|
||||||
|
P_SetScale(newmobj, P_ScaleFromMap(mobj->scale, newmobj->scale));
|
||||||
|
|
||||||
if (mobj->eflags & MFE_VERTICALFLIP)
|
if (mobj->eflags & MFE_VERTICALFLIP)
|
||||||
{
|
{
|
||||||
fixed_t elementheight = FixedMul(newmobj->info->height, mobj->scale);
|
|
||||||
|
|
||||||
newmobj->eflags |= MFE_VERTICALFLIP;
|
newmobj->eflags |= MFE_VERTICALFLIP;
|
||||||
newmobj->flags2 |= MF2_OBJECTFLIP;
|
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;
|
return newmobj;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue