diff --git a/src/doomstat.h b/src/doomstat.h index b8257ed667e021261c1f8b8ee9cde8062e245f2d..26b8697aa1faec69bc2f96f87a8bc48f5a90aa7f 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -641,6 +641,7 @@ typedef struct { fixed_t x, y, z; angle_t angle; + fixed_t scale; boolean spawn_on_ceiling; boolean spawn_flipped; } spawnpoint_t; diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index f2e80e2fa3a7ccf6edc4968856d7cfba559d8e62..2bfb8fa3c88049ea20704255b917c56a939d0119 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -1190,8 +1190,11 @@ static void res_playerrespawn(Hook_State *hook) fixed_t height_offset = 0; boolean has_z = false; - spawnpoint_t spawnpoint; - memset(&spawnpoint, 0, sizeof(spawnpoint)); + spawnpoint_t spawnpoint = { + .x = 0, .y = 0, .z = 0, + .angle = 0, .scale = FRACUNIT, + .spawn_on_ceiling = false, .spawn_flipped = false + }; if (lua_istable(gL, -a)) { @@ -1239,8 +1242,9 @@ static void res_playerrespawn(Hook_State *hook) GETNUMBEROPT(spawnpoint.z, "z", has_z); GETNUMBER(height_offset, "height"); GETNUMBER(spawnpoint.angle, "angle"); - GETBOOLEAN(spawnpoint.spawn_on_ceiling, "spawn_on_ceiling"); GETBOOLEAN(spawnpoint.spawn_flipped, "spawn_flipped"); + GETBOOLEAN(spawnpoint.spawn_on_ceiling, "spawn_on_ceiling"); + GETNUMBER(spawnpoint.scale, "scale"); } #undef GETNUMBER @@ -1296,6 +1300,7 @@ static void res_playerrespawn(Hook_State *hook) GETBOOLEAN(spawnpoint.spawn_flipped, "spawn_flipped", -a + 4); GETBOOLEAN(spawnpoint.spawn_on_ceiling, "spawn_on_ceiling", -a + 5); GETBOOLEAN(height_is_relative, "height_is_relative", -a + 6); + GETNUMBER(spawnpoint.scale, "scale", -a + 7); if (!height_is_relative) spawnpoint.z = height_offset; @@ -1320,7 +1325,7 @@ spawnpoint_t *LUA_HookPlayerRespawn(player_t *player) if (prepare_hook(&hook, -1, HOOK(PlayerRespawn))) { LUA_PushUserdata(gL, player, META_PLAYER); - call_hooks(&hook, 7, res_playerrespawn); + call_hooks(&hook, 8, res_playerrespawn); } return (spawnpoint_t *)hook.status.type_void_pointer; } diff --git a/src/p_mobj.c b/src/p_mobj.c index c6437f477ce39e71395319087b9735f75dd29f40..b6574a4fe7925a3728fcf5d7629ad66864e66cce 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -11751,6 +11751,7 @@ void P_MovePlayerToSpawn(INT32 playernum, spawnpoint_t *spawnpoint) { fixed_t x, y, z; angle_t angle; + fixed_t scale; player_t *p = &players[playernum]; mobj_t *mobj = p->mo; @@ -11761,6 +11762,7 @@ void P_MovePlayerToSpawn(INT32 playernum, spawnpoint_t *spawnpoint) x = spawnpoint->x; y = spawnpoint->y; angle = spawnpoint->angle; + scale = spawnpoint->scale; } else { @@ -11768,13 +11770,18 @@ void P_MovePlayerToSpawn(INT32 playernum, spawnpoint_t *spawnpoint) x = 0; y = 0; angle = 0; + scale = FRACUNIT; } + // Set scale + P_SetScale(mobj, scale); + mobj->destscale = scale; + // set Z height sector_t *sector = R_PointInSubsector(x, y)->sector; fixed_t floor = P_GetSectorFloorZAt(sector, x, y); fixed_t ceiling = P_GetSectorCeilingZAt(sector, x, y); - fixed_t ceilingspawn = ceiling - mobjinfo[MT_PLAYER].height; + fixed_t ceilingspawn = ceiling - FixedMul(mobjinfo[MT_PLAYER].height, scale); if (spawnpoint) { @@ -11879,6 +11886,7 @@ spawnpoint_t *P_MakeSpawnPointFromMapthing(mapthing_t *mthing) spawnpoint->x = mthing->x << FRACBITS; spawnpoint->y = mthing->y << FRACBITS; spawnpoint->angle = FixedAngle(mthing->angle<<FRACBITS); + spawnpoint->scale = FRACUNIT; // Setting the spawnpoint's args[0] will make the player start on the ceiling // Objectflip inverts