Add some helper functions for objects in reverse gravity

This commit is contained in:
James R 2021-02-16 04:42:27 -08:00
parent 0cf41dade0
commit 81d162d19c
2 changed files with 29 additions and 0 deletions

View file

@ -158,6 +158,7 @@ boolean P_IsObjectInGoop(mobj_t *mo);
boolean P_IsObjectOnGround(mobj_t *mo);
boolean P_IsObjectOnGroundIn(mobj_t *mo, sector_t *sec);
boolean P_IsObjectOnRealGround(mobj_t *mo, sector_t *sec); // SRB2Kart
#define P_IsObjectFlipped(o) ((o)->eflags & MFE_VERTICALFLIP)
boolean P_InQuicksand(mobj_t *mo);
boolean P_PlayerHitFloor(player_t *player, boolean dorollstuff);
@ -522,5 +523,8 @@ 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);
fixed_t P_GetMobjHead(const mobj_t *);
fixed_t P_GetMobjFeet(const mobj_t *);
fixed_t P_GetMobjGround(const mobj_t *);
#endif // __P_LOCAL__

View file

@ -12786,3 +12786,28 @@ mobj_t *P_SpawnMobjFromMobj(mobj_t *mobj, fixed_t xofs, fixed_t yofs, fixed_t zo
return newmobj;
}
//
// P_GetMobjHead & P_GetMobjFeet
// Returns the top and bottom of an object, follows appearance, not physics,
// in reverse gravity.
//
fixed_t P_GetMobjHead(const mobj_t *mobj)
{
return P_IsObjectFlipped(mobj) ? mobj->z : mobj->z + mobj->height;
}
fixed_t P_GetMobjFeet(const mobj_t *mobj)
{
return P_IsObjectFlipped(mobj) ? mobj->z + mobj->height : mobj->z;
}
//
// P_GetMobjGround
// Returns the object's floor, or ceiling in reverse gravity.
//
fixed_t P_GetMobjGround(const mobj_t *mobj)
{
return P_IsObjectFlipped(mobj) ? mobj->ceilingz : mobj->floorz;
}