From 15f0e1634428cde98f8538cd8d8998cf31b7d55f Mon Sep 17 00:00:00 2001 From: TehRealSalt Date: Sat, 31 Mar 2018 14:48:49 -0400 Subject: [PATCH] Race lap linedef executor Set up similar to NiGHTS Mare linedef executors. Give a sector the "Race Lap" sector type, tag it, then set the frontside x-offset on the trigger line to the lap it should activate on minus 1. There are a few flags you can check on the trigger line to modify its behavior. - Normally the executor will only trigger if its exactly on the lap specified. Check Not Climbable to make it execute on laps equal to or greater than, or check Block Enemies to make it execute on laps equal to or less than. - By default, the executor will check current lap with the person in last's lap. Check E4 to instead find the current lap from the player who triggered it. This flag is better for triggering events ahead of the players, while the default effect is better for triggering events behind the players. --- src/k_kart.c | 2 +- src/p_local.h | 1 + src/p_spec.c | 42 ++++++++++++++++++++++++++---------------- src/p_user.c | 37 ++++++++++++++++++++++++++++++++++--- 4 files changed, 62 insertions(+), 20 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 54ae147f..67149294 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3438,7 +3438,7 @@ void K_CheckBalloons(void) if (playeringame[winnernum]) { P_AddPlayerScore(&players[winnernum], 1); - CONS_Printf(M_GetText("%s recieved a point for winning!\n")); + CONS_Printf(M_GetText("%s recieved a point for winning!\n"), player_names[winnernum]); } for (i = 0; i < MAXPLAYERS; i++) diff --git a/src/p_local.h b/src/p_local.h index 47cb545e..8a4bfa7b 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -182,6 +182,7 @@ void P_DoJump(player_t *player, boolean soundandstate); boolean P_AnalogMove(player_t *player); boolean P_TransferToNextMare(player_t *player); UINT8 P_FindLowestMare(void); +UINT8 P_FindLowestLap(void); void P_FindEmerald(void); void P_TransferToAxis(player_t *player, INT32 axisnum); boolean P_PlayerMoving(INT32 pnum); diff --git a/src/p_spec.c b/src/p_spec.c index 9a510fd0..b069736b 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1701,28 +1701,38 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller if (!(ALL7EMERALDS(emeralds))) return false; } - else if (GETSECSPECIAL(caller->special, 2) == 7) + else if (GETSECSPECIAL(caller->special, 2) == 7) // SRB2Kart: reusing for Race Lap executor { - UINT8 mare; + UINT8 lap; - if (!(maptol & TOL_NIGHTS)) - return false; - - mare = P_FindLowestMare(); - - if (triggerline->flags & ML_NOCLIMB) + if (actor && actor->player && triggerline->flags & ML_EFFECT4) { - if (!(mare <= dist)) - return false; - } - else if (triggerline->flags & ML_BLOCKMONSTERS) - { - if (!(mare >= dist)) - return false; + if (maptol & TOL_NIGHTS) + lap = actor->player->mare; + else + lap = actor->player->laps; } else { - if (!(mare == dist)) + if (maptol & TOL_NIGHTS) + lap = P_FindLowestMare(); + else + lap = P_FindLowestLap(); + } + + if (triggerline->flags & ML_NOCLIMB) // Need higher than or equal to + { + if (lap < (sides[triggerline->sidenum[0]].textureoffset >> FRACBITS)) + return false; + } + else if (triggerline->flags & ML_BLOCKMONSTERS) // Need lower than or equal to + { + if (lap > (sides[triggerline->sidenum[0]].textureoffset >> FRACBITS)) + return false; + } + else // Need equal to + { + if (lap != (sides[triggerline->sidenum[0]].textureoffset >> FRACBITS)) return false; } } diff --git a/src/p_user.c b/src/p_user.c index d11fbf1f..1245ed17 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -377,6 +377,35 @@ UINT8 P_FindLowestMare(void) return mare; } +// +// P_FindLowestLap +// +// SRB2Kart, a similar function as above for finding the lowest lap +// +UINT8 P_FindLowestLap(void) +{ + INT32 i; + UINT8 lowest = UINT8_MAX; + + if (!G_RaceGametype()) + return 0; + + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i] || players[i].spectator) + continue; + + if (lowest == 255) + lowest = players[i].laps; + else if (players[i].laps < lowest) + lowest = players[i].laps; + } + + CONS_Debug(DBG_GAMELOGIC, "Lowest laps found: %d\n", lowest); + + return lowest; +} + // // P_TransferToNextMare // @@ -8826,12 +8855,14 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall thiscam->momx = FixedMul(x - thiscam->x, camspeed); thiscam->momy = FixedMul(y - thiscam->y, camspeed); - if (GETSECSPECIAL(thiscam->subsector->sector->special, 1) == 6 + if ((GETSECSPECIAL(thiscam->subsector->sector->special, 1) == 6 && thiscam->z < thiscam->subsector->sector->floorheight + 256*FRACUNIT && FixedMul(z - thiscam->z, camspeed) < 0) - { +#if 0 + || player->kartstuff[k_feather] & 2 // SRB2Kart: don't follow while bouncing, experimental +#endif + ) thiscam->momz = 0; // Don't go down a death pit - } else thiscam->momz = FixedMul(z - thiscam->z, camspeed); }