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;
|
fixed_t x, y, z;
|
||||||
angle_t angle;
|
angle_t angle;
|
||||||
|
fixed_t scale;
|
||||||
boolean spawn_on_ceiling;
|
boolean spawn_on_ceiling;
|
||||||
boolean spawn_flipped;
|
boolean spawn_flipped;
|
||||||
} spawnpoint_t;
|
} spawnpoint_t;
|
||||||
|
|
|
@ -1190,8 +1190,11 @@ static void res_playerrespawn(Hook_State *hook)
|
||||||
fixed_t height_offset = 0;
|
fixed_t height_offset = 0;
|
||||||
boolean has_z = false;
|
boolean has_z = false;
|
||||||
|
|
||||||
spawnpoint_t spawnpoint;
|
spawnpoint_t spawnpoint = {
|
||||||
memset(&spawnpoint, 0, sizeof(spawnpoint));
|
.x = 0, .y = 0, .z = 0,
|
||||||
|
.angle = 0, .scale = FRACUNIT,
|
||||||
|
.spawn_on_ceiling = false, .spawn_flipped = false
|
||||||
|
};
|
||||||
|
|
||||||
if (lua_istable(gL, -a))
|
if (lua_istable(gL, -a))
|
||||||
{
|
{
|
||||||
|
@ -1239,8 +1242,9 @@ static void res_playerrespawn(Hook_State *hook)
|
||||||
GETNUMBEROPT(spawnpoint.z, "z", has_z);
|
GETNUMBEROPT(spawnpoint.z, "z", has_z);
|
||||||
GETNUMBER(height_offset, "height");
|
GETNUMBER(height_offset, "height");
|
||||||
GETNUMBER(spawnpoint.angle, "angle");
|
GETNUMBER(spawnpoint.angle, "angle");
|
||||||
GETBOOLEAN(spawnpoint.spawn_on_ceiling, "spawn_on_ceiling");
|
|
||||||
GETBOOLEAN(spawnpoint.spawn_flipped, "spawn_flipped");
|
GETBOOLEAN(spawnpoint.spawn_flipped, "spawn_flipped");
|
||||||
|
GETBOOLEAN(spawnpoint.spawn_on_ceiling, "spawn_on_ceiling");
|
||||||
|
GETNUMBER(spawnpoint.scale, "scale");
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef GETNUMBER
|
#undef GETNUMBER
|
||||||
|
@ -1296,6 +1300,7 @@ static void res_playerrespawn(Hook_State *hook)
|
||||||
GETBOOLEAN(spawnpoint.spawn_flipped, "spawn_flipped", -a + 4);
|
GETBOOLEAN(spawnpoint.spawn_flipped, "spawn_flipped", -a + 4);
|
||||||
GETBOOLEAN(spawnpoint.spawn_on_ceiling, "spawn_on_ceiling", -a + 5);
|
GETBOOLEAN(spawnpoint.spawn_on_ceiling, "spawn_on_ceiling", -a + 5);
|
||||||
GETBOOLEAN(height_is_relative, "height_is_relative", -a + 6);
|
GETBOOLEAN(height_is_relative, "height_is_relative", -a + 6);
|
||||||
|
GETNUMBER(spawnpoint.scale, "scale", -a + 7);
|
||||||
|
|
||||||
if (!height_is_relative)
|
if (!height_is_relative)
|
||||||
spawnpoint.z = height_offset;
|
spawnpoint.z = height_offset;
|
||||||
|
@ -1320,7 +1325,7 @@ spawnpoint_t *LUA_HookPlayerRespawn(player_t *player)
|
||||||
if (prepare_hook(&hook, -1, HOOK(PlayerRespawn)))
|
if (prepare_hook(&hook, -1, HOOK(PlayerRespawn)))
|
||||||
{
|
{
|
||||||
LUA_PushUserdata(gL, player, META_PLAYER);
|
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;
|
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;
|
fixed_t x, y, z;
|
||||||
angle_t angle;
|
angle_t angle;
|
||||||
|
fixed_t scale;
|
||||||
|
|
||||||
player_t *p = &players[playernum];
|
player_t *p = &players[playernum];
|
||||||
mobj_t *mobj = p->mo;
|
mobj_t *mobj = p->mo;
|
||||||
|
@ -11740,6 +11741,7 @@ void P_MovePlayerToSpawn(INT32 playernum, spawnpoint_t *spawnpoint)
|
||||||
x = spawnpoint->x;
|
x = spawnpoint->x;
|
||||||
y = spawnpoint->y;
|
y = spawnpoint->y;
|
||||||
angle = spawnpoint->angle;
|
angle = spawnpoint->angle;
|
||||||
|
scale = spawnpoint->scale;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -11747,13 +11749,18 @@ void P_MovePlayerToSpawn(INT32 playernum, spawnpoint_t *spawnpoint)
|
||||||
x = 0;
|
x = 0;
|
||||||
y = 0;
|
y = 0;
|
||||||
angle = 0;
|
angle = 0;
|
||||||
|
scale = FRACUNIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set scale
|
||||||
|
P_SetScale(mobj, scale);
|
||||||
|
mobj->destscale = scale;
|
||||||
|
|
||||||
// set Z height
|
// set Z height
|
||||||
sector_t *sector = R_PointInSubsector(x, y)->sector;
|
sector_t *sector = R_PointInSubsector(x, y)->sector;
|
||||||
fixed_t floor = P_GetSectorFloorZAt(sector, x, y);
|
fixed_t floor = P_GetSectorFloorZAt(sector, x, y);
|
||||||
fixed_t ceiling = P_GetSectorCeilingZAt(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)
|
if (spawnpoint)
|
||||||
{
|
{
|
||||||
|
@ -11858,6 +11865,7 @@ spawnpoint_t *P_MakeSpawnPointFromMapthing(mapthing_t *mthing)
|
||||||
spawnpoint->x = mthing->x << FRACBITS;
|
spawnpoint->x = mthing->x << FRACBITS;
|
||||||
spawnpoint->y = mthing->y << FRACBITS;
|
spawnpoint->y = mthing->y << FRACBITS;
|
||||||
spawnpoint->angle = FixedAngle(mthing->angle<<FRACBITS);
|
spawnpoint->angle = FixedAngle(mthing->angle<<FRACBITS);
|
||||||
|
spawnpoint->scale = FRACUNIT;
|
||||||
|
|
||||||
// Setting the spawnpoint's args[0] will make the player start on the ceiling
|
// Setting the spawnpoint's args[0] will make the player start on the ceiling
|
||||||
// Objectflip inverts
|
// Objectflip inverts
|
||||||
|
|
Loading…
Reference in a new issue