mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-02-02 14:32:22 +00:00
Add absolute z height flag for mapthings in UDMF
This commit is contained in:
parent
37223f13f1
commit
bed7e434e7
4 changed files with 16 additions and 9 deletions
|
@ -62,6 +62,10 @@ enum
|
|||
#define MTF_AMBUSH 8
|
||||
|
||||
// Do not use bit five or after, as they are used for object z-offsets.
|
||||
// Unless it's exclusive to UDMF.
|
||||
|
||||
// Flag to use Z as absolute spawn height, ignoring the floor and ceiling.
|
||||
#define MTF_ABSOLUTEZ 16
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma pack(1)
|
||||
|
|
17
src/p_mobj.c
17
src/p_mobj.c
|
@ -11812,7 +11812,7 @@ void P_MovePlayerToStarpost(INT32 playernum)
|
|||
mapthing_t *huntemeralds[MAXHUNTEMERALDS];
|
||||
INT32 numhuntemeralds;
|
||||
|
||||
fixed_t P_GetMobjSpawnHeight(const mobjtype_t mobjtype, const fixed_t x, const fixed_t y, const fixed_t dz, const fixed_t offset, const boolean flip, const fixed_t scale)
|
||||
fixed_t P_GetMobjSpawnHeight(const mobjtype_t mobjtype, const fixed_t x, const fixed_t y, const fixed_t dz, const fixed_t offset, const boolean flip, const fixed_t scale, const boolean absolutez)
|
||||
{
|
||||
const subsector_t *ss = R_PointInSubsector(x, y);
|
||||
|
||||
|
@ -11822,9 +11822,9 @@ fixed_t P_GetMobjSpawnHeight(const mobjtype_t mobjtype, const fixed_t x, const f
|
|||
|
||||
// Establish height.
|
||||
if (flip)
|
||||
return P_GetSectorCeilingZAt(ss->sector, x, y) - dz - FixedMul(scale, offset + mobjinfo[mobjtype].height);
|
||||
return (absolutez ? dz : P_GetSectorCeilingZAt(ss->sector, x, y) - dz) - FixedMul(scale, offset + mobjinfo[mobjtype].height);
|
||||
else
|
||||
return P_GetSectorFloorZAt(ss->sector, x, y) + dz + FixedMul(scale, offset);
|
||||
return (absolutez ? dz : P_GetSectorFloorZAt(ss->sector, x, y) + dz) + FixedMul(scale, offset);
|
||||
}
|
||||
|
||||
fixed_t P_GetMapThingSpawnHeight(const mobjtype_t mobjtype, const mapthing_t* mthing, const fixed_t x, const fixed_t y)
|
||||
|
@ -11832,6 +11832,7 @@ fixed_t P_GetMapThingSpawnHeight(const mobjtype_t mobjtype, const mapthing_t* mt
|
|||
fixed_t dz = mthing->z << FRACBITS; // Base offset from the floor.
|
||||
fixed_t offset = 0; // Specific scaling object offset.
|
||||
boolean flip = (!!(mobjinfo[mobjtype].flags & MF_SPAWNCEILING) ^ !!(mthing->options & MTF_OBJECTFLIP));
|
||||
boolean absolutez = !!(mthing->options & MTF_ABSOLUTEZ);
|
||||
|
||||
switch (mobjtype)
|
||||
{
|
||||
|
@ -11887,7 +11888,7 @@ fixed_t P_GetMapThingSpawnHeight(const mobjtype_t mobjtype, const mapthing_t* mt
|
|||
offset += mthing->args[0] ? 0 : 24*FRACUNIT;
|
||||
}
|
||||
|
||||
if (!(dz + offset)) // Snap to the surfaces when there's no offset set.
|
||||
if (!(dz + offset) && !absolutez) // Snap to the surfaces when there's no offset set.
|
||||
{
|
||||
if (flip)
|
||||
return ONCEILINGZ;
|
||||
|
@ -11895,7 +11896,7 @@ fixed_t P_GetMapThingSpawnHeight(const mobjtype_t mobjtype, const mapthing_t* mt
|
|||
return ONFLOORZ;
|
||||
}
|
||||
|
||||
return P_GetMobjSpawnHeight(mobjtype, x, y, dz, offset, flip, mthing->scale);
|
||||
return P_GetMobjSpawnHeight(mobjtype, x, y, dz, offset, flip, mthing->scale, absolutez);
|
||||
}
|
||||
|
||||
static boolean P_SpawnNonMobjMapThing(mapthing_t *mthing)
|
||||
|
@ -13389,7 +13390,7 @@ void P_SpawnHoop(mapthing_t *mthing)
|
|||
vector4_t v, res;
|
||||
fixed_t x = mthing->x << FRACBITS;
|
||||
fixed_t y = mthing->y << FRACBITS;
|
||||
fixed_t z = P_GetMobjSpawnHeight(MT_HOOP, x, y, mthing->z << FRACBITS, 0, false, mthing->scale);
|
||||
fixed_t z = P_GetMobjSpawnHeight(MT_HOOP, x, y, mthing->z << FRACBITS, 0, false, mthing->scale, !!(mthing->options & MTF_ABSOLUTEZ));
|
||||
|
||||
hoopcenter = P_SpawnMobj(x, y, z, MT_HOOPCENTER);
|
||||
hoopcenter->spawnpoint = mthing;
|
||||
|
@ -13516,7 +13517,7 @@ static void P_SpawnItemRow(mapthing_t *mthing, mobjtype_t *itemtypes, UINT8 numi
|
|||
itemtypes[r] = P_GetMobjtypeSubstitute(&dummything, itemtypes[r]);
|
||||
}
|
||||
}
|
||||
z = P_GetMobjSpawnHeight(itemtypes[0], x, y, z, 0, mthing->options & MTF_OBJECTFLIP, mthing->scale);
|
||||
z = P_GetMobjSpawnHeight(itemtypes[0], x, y, z, 0, mthing->options & MTF_OBJECTFLIP, mthing->scale, !!(mthing->options & MTF_ABSOLUTEZ));
|
||||
|
||||
for (r = 0; r < numitems; r++)
|
||||
{
|
||||
|
@ -13575,7 +13576,7 @@ static void P_SpawnItemCircle(mapthing_t *mthing, mobjtype_t *itemtypes, UINT8 n
|
|||
itemtypes[i] = P_GetMobjtypeSubstitute(&dummything, itemtypes[i]);
|
||||
}
|
||||
}
|
||||
z = P_GetMobjSpawnHeight(itemtypes[0], x, y, z, 0, false, mthing->scale);
|
||||
z = P_GetMobjSpawnHeight(itemtypes[0], x, y, z, 0, false, mthing->scale, !!(mthing->options & MTF_ABSOLUTEZ));
|
||||
|
||||
for (i = 0; i < numitems; i++)
|
||||
{
|
||||
|
|
|
@ -489,7 +489,7 @@ void P_MovePlayerToSpawn(INT32 playernum, mapthing_t *mthing);
|
|||
void P_MovePlayerToStarpost(INT32 playernum);
|
||||
void P_AfterPlayerSpawn(INT32 playernum);
|
||||
|
||||
fixed_t P_GetMobjSpawnHeight(const mobjtype_t mobjtype, const fixed_t x, const fixed_t y, const fixed_t dz, const fixed_t offset, const boolean flip, const fixed_t scale);
|
||||
fixed_t P_GetMobjSpawnHeight(const mobjtype_t mobjtype, const fixed_t x, const fixed_t y, const fixed_t dz, const fixed_t offset, const boolean flip, const fixed_t scale, const boolean absolutez);
|
||||
fixed_t P_GetMapThingSpawnHeight(const mobjtype_t mobjtype, const mapthing_t* mthing, const fixed_t x, const fixed_t y);
|
||||
|
||||
mobj_t *P_SpawnMapThing(mapthing_t *mthing);
|
||||
|
|
|
@ -1916,6 +1916,8 @@ static void ParseTextmapThingParameter(UINT32 i, const char *param, const char *
|
|||
// Flags
|
||||
else if (fastcmp(param, "flip") && fastcmp("true", val))
|
||||
mapthings[i].options |= MTF_OBJECTFLIP;
|
||||
else if (fastcmp(param, "absolutez") && fastcmp("true", val))
|
||||
mapthings[i].options |= MTF_ABSOLUTEZ;
|
||||
|
||||
else if (fastncmp(param, "stringarg", 9) && strlen(param) > 9)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue