GTR_CHECKPOINTS: Players will now respawn at Starposts

In addition, tighten up the handling for player angle at spawn time
This commit is contained in:
toaster 2023-11-04 23:03:25 +00:00
parent d33fa75eb0
commit ce93667fce
4 changed files with 31 additions and 5 deletions

View file

@ -337,6 +337,7 @@ struct respawnvars_t
fixed_t pointx; // Respawn position coords to go towards fixed_t pointx; // Respawn position coords to go towards
fixed_t pointy; fixed_t pointy;
fixed_t pointz; fixed_t pointz;
angle_t pointangle; // Only used when wp is NULL
boolean flip; // Flip upside down or not boolean flip; // Flip upside down or not
tic_t timer; // Time left on respawn animation once you're there tic_t timer; // Time left on respawn animation once you're there
tic_t airtimer; // Time spent in the air before respawning tic_t airtimer; // Time spent in the air before respawning

View file

@ -2497,8 +2497,7 @@ void G_MovePlayerToSpawnOrCheatcheck(INT32 playernum)
rsp->pointx = pos.x; rsp->pointx = pos.x;
rsp->pointy = pos.y; rsp->pointy = pos.y;
rsp->pointz = pos.z; rsp->pointz = pos.z;
rsp->pointangle = Obj_GetCheckpointRespawnAngle(checkpoint);
players[playernum].mo->angle = Obj_GetCheckpointRespawnAngle(checkpoint);
Obj_ActivateCheckpointInstantly(checkpoint); Obj_ActivateCheckpointInstantly(checkpoint);

View file

@ -14,6 +14,7 @@
#include "d_player.h" #include "d_player.h"
#include "k_kart.h" #include "k_kart.h"
#include "k_battle.h" #include "k_battle.h"
#include "k_objects.h" // Obj_FindCheckpoint, etc
#include "g_game.h" #include "g_game.h"
#include "p_local.h" #include "p_local.h"
#include "p_tick.h" #include "p_tick.h"
@ -161,6 +162,9 @@ void K_DoIngameRespawn(player_t *player)
K_TumbleInterrupt(player); K_TumbleInterrupt(player);
P_ResetPlayer(player); P_ResetPlayer(player);
mobj_t *checkpoint;
vector3_t pos;
// Set up respawn position if invalid // Set up respawn position if invalid
if (player->respawn.manual == true) if (player->respawn.manual == true)
{ {
@ -192,6 +196,21 @@ void K_DoIngameRespawn(player_t *player)
K_RespawnAtWaypoint(player, player->respawn.wp); K_RespawnAtWaypoint(player, player->respawn.wp);
} }
} }
else if ((gametyperules & GTR_CHECKPOINTS)
&& player->checkpointId
&& (checkpoint = Obj_FindCheckpoint(player->checkpointId))
&& Obj_GetCheckpointRespawnPosition(checkpoint, &pos))
{
player->respawn.wp = NULL;
player->respawn.flip = (checkpoint->flags2 & MF2_OBJECTFLIP) ? true : false; // K_RespawnOffset wants a boolean!
player->respawn.pointx = pos.x;
player->respawn.pointy = pos.y;
player->respawn.pointz = pos.z + K_RespawnOffset(player, player->respawn.flip);
player->respawn.pointangle = Obj_GetCheckpointRespawnAngle(checkpoint);
player->respawn.distanceleft = 0;
}
else else
{ {
UINT32 bestdist = UINT32_MAX; UINT32 bestdist = UINT32_MAX;
@ -242,6 +261,7 @@ void K_DoIngameRespawn(player_t *player)
player->respawn.pointx = 0; player->respawn.pointx = 0;
player->respawn.pointy = 0; player->respawn.pointy = 0;
player->respawn.pointz = 0; player->respawn.pointz = 0;
player->respawn.pointangle = 0;
player->respawn.flip = false; player->respawn.flip = false;
} }
else else
@ -252,7 +272,7 @@ void K_DoIngameRespawn(player_t *player)
player->respawn.pointx = beststart->x << FRACBITS; player->respawn.pointx = beststart->x << FRACBITS;
player->respawn.pointy = beststart->y << FRACBITS; player->respawn.pointy = beststart->y << FRACBITS;
player->mo->angle = ( beststart->angle * ANG1 ); player->respawn.pointangle = ( beststart->angle * ANG1 );
s = R_PointInSubsector(beststart->x << FRACBITS, beststart->y << FRACBITS)->sector; s = R_PointInSubsector(beststart->x << FRACBITS, beststart->y << FRACBITS)->sector;
@ -474,6 +494,11 @@ static void K_MovePlayerToRespawnPoint(player_t *player)
else else
{ {
// We can now drop! // We can now drop!
if (gametyperules & GTR_CHECKPOINTS)
{
// Of course, in gametypes where there's a clear and intended progression, set our direction.
P_SetPlayerAngle(player, (player->drawangle = player->respawn.pointangle));
}
player->respawn.state = RESPAWNST_DROP; player->respawn.state = RESPAWNST_DROP;
return; return;
} }

View file

@ -12560,7 +12560,7 @@ void P_MovePlayerToSpawn(INT32 playernum, mapthing_t *mthing)
else if (mobj->z == mobj->floorz) else if (mobj->z == mobj->floorz)
mobj->eflags |= MFE_ONGROUND; mobj->eflags |= MFE_ONGROUND;
mobj->angle = angle; mobj->angle = p->drawangle = angle;
// FAULT // FAULT
if (gamestate == GS_LEVEL && leveltime > introtime && !p->spectator) if (gamestate == GS_LEVEL && leveltime > introtime && !p->spectator)
@ -12575,6 +12575,7 @@ void P_MovePlayerToSpawn(INT32 playernum, mapthing_t *mthing)
p->respawn.pointx = x; p->respawn.pointx = x;
p->respawn.pointy = y; p->respawn.pointy = y;
p->respawn.pointz = z; p->respawn.pointz = z;
p->respawn.pointangle = angle;
} }
P_AfterPlayerSpawn(playernum); P_AfterPlayerSpawn(playernum);
@ -12629,7 +12630,7 @@ void P_MovePlayerToCheatcheck(INT32 playernum)
} }
} }
else else
p->drawangle = mobj->angle; // default to the camera angle p->drawangle = mobj->angle = p->respawn.pointangle;
K_DoIngameRespawn(p); K_DoIngameRespawn(p);
p->respawn.truedeath = true; p->respawn.truedeath = true;