mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-12-18 17:01:20 +00:00
Add scale support to PlayerRespawn
This commit is contained in:
parent
3d9228aa9a
commit
03c080c07b
3 changed files with 19 additions and 5 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
10
src/p_mobj.c
10
src/p_mobj.c
|
@ -11730,6 +11730,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;
|
||||
|
@ -11740,6 +11741,7 @@ void P_MovePlayerToSpawn(INT32 playernum, spawnpoint_t *spawnpoint)
|
|||
x = spawnpoint->x;
|
||||
y = spawnpoint->y;
|
||||
angle = spawnpoint->angle;
|
||||
scale = spawnpoint->scale;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -11747,13 +11749,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)
|
||||
{
|
||||
|
@ -11858,6 +11865,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
|
||||
|
|
Loading…
Reference in a new issue