P_SpawnMapThing, P_RaiseTaggedThingsToFakeFloor: save raised Z position for respawning later

P_RespawnSpecials just calls P_SpawnMapThing again, so
this works.
This commit is contained in:
James R. 2023-09-24 15:36:46 -07:00
parent 7dafacaf7d
commit c743af4d77
4 changed files with 16 additions and 1 deletions

View file

@ -278,6 +278,7 @@ struct mapthing_t
char *script_stringargs[NUM_SCRIPT_STRINGARGS];
UINT8 layer; // FOF layer to spawn on, see P_GetMobjSpawnHeight
mapUserProperties_t user; // UDMF user-defined custom properties.
fixed_t adjusted_z; // Z adjusted on map load, used for respawning
mobj_t *mobj;
};

View file

@ -13910,7 +13910,16 @@ mobj_t *P_SpawnMapThing(mapthing_t *mthing)
x = mthing->x << FRACBITS;
y = mthing->y << FRACBITS;
z = P_GetMapThingSpawnHeight(i, mthing, x, y);
if (mthing->adjusted_z != INT32_MAX)
{
z = mthing->adjusted_z;
}
else
{
z = P_GetMapThingSpawnHeight(i, mthing, x, y);
}
return P_SpawnMobjFromMapThing(mthing, x, y, z, i);
}

View file

@ -1356,6 +1356,8 @@ static void P_LoadThings(UINT8 *data)
else
mt->z = mt->options >> ZSHIFT;
mt->adjusted_z = INT32_MAX;
mt->mobj = NULL;
}
}
@ -3239,6 +3241,7 @@ static void P_LoadTextmap(void)
memset(mt->script_args, 0, NUM_SCRIPT_ARGS*sizeof(*mt->script_args));
memset(mt->script_stringargs, 0x00, NUM_SCRIPT_STRINGARGS*sizeof(*mt->script_stringargs));
mt->layer = 0;
mt->adjusted_z = INT32_MAX;
mt->mobj = NULL;
K_UserPropertiesClear(&mt->user);

View file

@ -6256,6 +6256,8 @@ P_RaiseTaggedThingsToFakeFloor (
offset = mo->z - mo->floorz;
mo->z = P_GetZAt(control->c_slope, mo->x, mo->y, control->ceilingheight) + offset;
}
mthing->adjusted_z = mo->z;
}
}
}