Merge branch 'fault-starts' into 'master'

Add fault start things

Closes #187 and #1063

See merge request KartKrew/Kart!1949
This commit is contained in:
Eidolon 2024-02-25 05:05:11 +00:00
commit 9d6a03d7af
6 changed files with 59 additions and 4 deletions

View file

@ -871,6 +871,7 @@ extern tic_t gametic;
extern mapthing_t *playerstarts[MAXPLAYERS]; // Cooperative
extern mapthing_t *bluectfstarts[MAXPLAYERS]; // CTF
extern mapthing_t *redctfstarts[MAXPLAYERS]; // CTF
extern mapthing_t *faultstart; // Kart Fault
#define TUBEWAYPOINTSEQUENCESIZE 256
#define NUMTUBEWAYPOINTSEQUENCES 256

View file

@ -2821,6 +2821,18 @@ static inline mapthing_t *G_FindTeamStartOrFallback(INT32 playernum)
return spawnpoint;
}
static inline mapthing_t *G_FindTimeAttackStartOrFallback(INT32 playernum)
{
mapthing_t *spawnpoint = NULL;
if (!(spawnpoint = faultstart)
&& !(spawnpoint = G_FindRaceStart(playernum))
&& !(spawnpoint = G_FindBattleStart(playernum)))
{
spawnpoint = G_FindTeamStart(playernum);
}
return spawnpoint;
}
mapthing_t *G_FindMapStart(INT32 playernum)
{
extern consvar_t cv_battlespawn;
@ -2839,9 +2851,14 @@ mapthing_t *G_FindMapStart(INT32 playernum)
else if (K_PodiumSequence() == true)
spawnpoint = G_FindPodiumStart(playernum);
// -- Time Attack / Battle duels --
// -- Time Attack --
// Order: Fault->Race->DM->CTF
else if (K_TimeAttackRules() == true && modeattacking != ATTACKING_NONE)
spawnpoint = G_FindTimeAttackStartOrFallback(playernum);
// -- Battle duels --
// Order: Race->DM->CTF
else if (K_TimeAttackRules() == true || ((gametyperules & GTR_BATTLESTARTS) && inDuel))
else if (((gametyperules & GTR_BATTLESTARTS) && inDuel))
spawnpoint = G_FindRaceStartOrFallback(playernum);
// -- CTF --

View file

@ -128,6 +128,8 @@ void K_DoFault(player_t *player)
--------------------------------------------------*/
void K_DoIngameRespawn(player_t *player)
{
boolean faultstartfaulting = false;
if (!player->mo || P_MobjWasRemoved(player->mo))
{
return;
@ -149,7 +151,24 @@ void K_DoIngameRespawn(player_t *player)
{
const waypoint_t *finish = K_GetFinishLineWaypoint();
if (!(mapheaderinfo[gamemap-1]->levelflags & LF_SECTIONRACE) && finish != NULL)
if (numfaultstarts > 0 && faultstart)
{
subsector_t *subs;
if ((subs = R_PointInSubsectorOrNull(faultstart->x << FRACBITS, faultstart->y << FRACBITS)) != NULL)
{
faultstartfaulting = true;
player->respawn.wp = NULL;
player->respawn.flip = false;
player->respawn.pointx = faultstart->x << FRACBITS;
player->respawn.pointy = faultstart->y << FRACBITS;
player->respawn.pointz =
P_GetSectorFloorZAt(subs->sector, faultstart->x << FRACBITS, faultstart->y << FRACBITS)
+ (faultstart->z << FRACBITS)
+ K_RespawnOffset(player, player->respawn.flip);
player->respawn.pointangle = FixedAngle(faultstart->angle << FRACBITS);
}
}
else if (!(mapheaderinfo[gamemap-1]->levelflags & LF_SECTIONRACE) && finish != NULL)
player->respawn.wp = finish->prevwaypoints[0];
K_DoFault(player);
}
@ -198,6 +217,10 @@ void K_DoIngameRespawn(player_t *player)
K_RespawnAtWaypoint(player, player->respawn.wp);
}
}
else if (faultstartfaulting)
{
; // Do nothing, position was already set
}
else if ((gametyperules & GTR_CHECKPOINTS)
&& player->checkpointId
&& (checkpoint = Obj_FindCheckpoint(player->checkpointId))

View file

@ -12428,6 +12428,16 @@ static boolean P_SpawnNonMobjMapThing(mapthing_t *mthing)
}
return true;
}
else if (mthing->type == 36) // Kart fault start
{
if (numfaultstarts < MAXPLAYERS)
{
faultstart = mthing;
mthing->type = 0;
numfaultstarts++;
}
return true;
}
else if (mthing->type == 750 // Slope vertex point (formerly chaos spawn)
|| (mthing->type == FLOOR_SLOPE_THING || mthing->type == CEILING_SLOPE_THING) // Slope anchors
|| (mthing->type >= 600 && mthing->type <= 611) // Special placement patterns

View file

@ -187,11 +187,13 @@ UINT8 *rejectmatrix;
// Maintain single and multi player starting spots.
INT32 numdmstarts, numcoopstarts, numredctfstarts, numbluectfstarts;
INT32 numfaultstarts;
mapthing_t *deathmatchstarts[MAX_DM_STARTS];
mapthing_t *playerstarts[MAXPLAYERS];
mapthing_t *bluectfstarts[MAXPLAYERS];
mapthing_t *redctfstarts[MAXPLAYERS];
mapthing_t *faultstart;
// Global state for PartialAddWadFile/MultiSetupWadFiles
// Might be replacable with parameters, but non-trivial when the functions are called on separate tics
@ -7744,6 +7746,8 @@ static void P_ResetSpawnpoints(void)
UINT8 i;
numdmstarts = numredctfstarts = numbluectfstarts = 0;
numfaultstarts = 0;
faultstart = NULL;
// reset the player starts
for (i = 0; i < MAXPLAYERS; i++)

View file

@ -29,7 +29,7 @@ extern unsigned char mapmd5[16];
// Player spawn spots for deathmatch.
#define MAX_DM_STARTS 64
extern mapthing_t *deathmatchstarts[MAX_DM_STARTS];
extern INT32 numdmstarts, numcoopstarts, numredctfstarts, numbluectfstarts;
extern INT32 numdmstarts, numcoopstarts, numredctfstarts, numbluectfstarts, numfaultstarts;
extern boolean levelloading;
extern UINT8 levelfadecol;