diff --git a/src/k_hud.c b/src/k_hud.c index 93d893b2d..53b25c167 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -4143,7 +4143,7 @@ static void K_drawDistributionDebugger(void) bestbumper = players[i].bumper; } - if (!(numbosswaypoints > 0)) + if (!(K_UsingLegacyCheckpoints())) { // lovely double loop...... for (i = 0; i < MAXPLAYERS; i++) @@ -4161,13 +4161,13 @@ static void K_drawDistributionDebugger(void) if (spbplace != -1 && stplyr->position == spbplace+1) { // SPB Rush Mode: It's 2nd place's job to catch-up items and make 1st place's job hell - if (!(numbosswaypoints > 0)) + if (!(K_UsingLegacyCheckpoints())) pdis = (3 * pdis) / 2; spbrush = true; } - if (!(numbosswaypoints > 0)) + if (!(K_UsingLegacyCheckpoints())) { pdis = K_ScaleItemDistance(pdis, pingame, spbrush); @@ -4179,7 +4179,7 @@ static void K_drawDistributionDebugger(void) } } - if (numbosswaypoints > 0) + if (K_UsingLegacyCheckpoints()) useodds = K_FindLegacyUseodds(stplyr, 0, pingame, bestbumper, spbrush, dontforcespb); else useodds = K_FindUseodds(stplyr, 0, pdis, bestbumper, spbrush); @@ -4207,7 +4207,7 @@ static void K_drawDistributionDebugger(void) - if (numbosswaypoints > 0) + if (K_UsingLegacyCheckpoints()) itemodds = K_KartGetLegacyItemOdds(useodds, i, 0, spbrush); else itemodds = K_KartGetItemOdds( @@ -4264,7 +4264,7 @@ static void K_drawDistributionDebugger(void) else V_DrawString(0, 0, V_SPLITSCREEN|V_HUDTRANS|V_SNAPTOTOP, va("USEODDS %d", useodds)); - if (numbosswaypoints > 0) + if (K_UsingLegacyCheckpoints()) V_DrawSmallString(70, 0, V_SPLITSCREEN|V_HUDTRANS|V_SNAPTOTOP, "Legacy Distance Mode"); } @@ -4274,7 +4274,7 @@ static void K_drawCheckpointDebugger(void) if (stplyr != &players[displayplayers[0]]) // only for p1 return; - if (numbosswaypoints > 0) + if (K_UsingLegacyCheckpoints()) { if (stplyr->starpostnum >= (numstarposts - (numstarposts/2))) V_DrawString(8, 184, 0, va("Checkpoint: %d / %d (Can finish)", stplyr->starpostnum, numstarposts)); diff --git a/src/k_kart.c b/src/k_kart.c index f08d74af3..3ad89e444 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -1428,7 +1428,7 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd) else if (!(player->itemroulette >= (TICRATE*3))) return; - if (!(numbosswaypoints > 0)) + if (!(K_UsingLegacyCheckpoints())) { for (i = 0; i < MAXPLAYERS; i++) { @@ -1455,12 +1455,12 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd) if (spbplace != -1 && player->position == spbplace+1) { // SPB Rush Mode: It's 2nd place's job to catch-up items and make 1st place's job hell - if (!(numbosswaypoints > 0)) + if (!(K_UsingLegacyCheckpoints())) pdis = (3 * pdis) / 2; spbrush = true; } - if (!(numbosswaypoints > 0)) + if (!(K_UsingLegacyCheckpoints())) { pdis = K_ScaleItemDistance(pdis, pingame, spbrush); @@ -1583,7 +1583,7 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd) } } - if (!(numbosswaypoints > 0)) + if (!(K_UsingLegacyCheckpoints())) { // SPECIAL CASE No. 6: // Force SPB onto 2nd if they get too far behind @@ -1609,7 +1609,7 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd) // Split into another function for a debug function below // Use a legacy version for maps not using waypoints. - if (numbosswaypoints > 0) + if (K_UsingLegacyCheckpoints()) useodds = K_FindLegacyUseodds(player, mashed, pingame, bestbumper, spbrush, dontforcespb); else useodds = K_FindUseodds(player, mashed, pdis, bestbumper, spbrush); @@ -1628,7 +1628,7 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd) for (i = 1; i < NUMKARTRESULTS; i++) { - if (numbosswaypoints > 0) + if (K_UsingLegacyCheckpoints()) { spawnchance[i] = (totalspawnchance += K_KartGetLegacyItemOdds(useodds, i, mashed, spbrush)); @@ -7073,7 +7073,7 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) } // Start at lap 1 when using old checkpoint system just to be safe. - if ((numbosswaypoints > 0) && (player->laps == 0) && (numlaps > 0)) + if ((K_UsingLegacyCheckpoints()) && (player->laps == 0) && (numlaps > 0)) player->laps = 1; if (player->stealingtimer == 0 && player->stolentimer == 0 @@ -8238,9 +8238,9 @@ static void K_UpdatePlayerWaypoints(player_t *const player) // While the player was in the "bigwaypointgap" state, laps did not change from crossing finish lines. // So reset the lap back to normal, in case they were able to get behind the line. - player->laps = player->lastsafelap; - if (numbosswaypoints == 0) + if (!K_UsingLegacyCheckpoints()) { + player->laps = player->lastsafelap; player->starpostnum = player->lastsafestarpost; } } @@ -8874,10 +8874,9 @@ void K_UpdateAllPlayerPositions(void) if (player->respawn > 0 && player->lastsafelap != player->laps) { - player->laps = player->lastsafelap; - - if (numbosswaypoints == 0) + if (!K_UsingLegacyCheckpoints()) { + player->laps = player->lastsafelap; player->starpostnum = player->lastsafestarpost; } } @@ -8890,7 +8889,7 @@ void K_UpdateAllPlayerPositions(void) { if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo)) { - if (numbosswaypoints > 0) + if (K_UsingLegacyCheckpoints()) K_KartLegacyUpdatePosition(&players[i]); else K_KartUpdatePosition(&players[i]); @@ -10170,6 +10169,17 @@ boolean K_RingsActive(void) return true; } +boolean K_UsingLegacyCheckpoints(void) +{ + if (numbosswaypoints > 0) + { + // We are using Kart V1 waypoints! + return true; + } + + return false; +} + void K_UpdateMobjItemOverlay(mobj_t *part, SINT8 itemType, UINT8 itemCount) { switch (itemType) diff --git a/src/k_kart.h b/src/k_kart.h index 7fa06f995..5651540d1 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -187,6 +187,7 @@ void K_UnsetItemOut(player_t *player); boolean K_SafeRespawnPosition(mobj_t * mo); boolean K_RingsActive(void); +boolean K_UsingLegacyCheckpoints(void); void K_UpdateMobjItemOverlay(mobj_t *part, SINT8 itemType, UINT8 itemCount); diff --git a/src/k_waypoint.cpp b/src/k_waypoint.cpp index ab110798f..9584b2b17 100644 --- a/src/k_waypoint.cpp +++ b/src/k_waypoint.cpp @@ -20,6 +20,7 @@ #include "z_zone.h" #include "g_game.h" #include "p_slopes.h" +#include "k_kart.h" #include "cxxutil.hpp" @@ -2779,7 +2780,7 @@ boolean K_SetupWaypointList(void) if (!waypointcap) { - if (numbosswaypoints == 0) + if (!K_UsingLegacyCheckpoints()) { CONS_Alert(CONS_ERROR, "No waypoints or legacy checkpoints in map.\n"); } @@ -2799,7 +2800,7 @@ boolean K_SetupWaypointList(void) if (firstwaypoint == NULL) { - if (numbosswaypoints == 0) + if (!K_UsingLegacyCheckpoints()) { CONS_Alert(CONS_ERROR, "No waypoints or legacy checkpoints in map.\n"); } diff --git a/src/lua_baselib.c b/src/lua_baselib.c index cdeb7f183..c54a4a09a 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -3974,7 +3974,21 @@ static int lib_kSafeRespawnPosition(lua_State *L) //HUDSAFE if (!mobj) return LUA_ErrInvalid(L, "mobj_t"); - lua_pushfixed(L, K_SafeRespawnPosition(mobj)); + lua_pushboolean(L, K_SafeRespawnPosition(mobj)); + return 1; +} + +// Checks if Rings are applicable. +static int lib_kRingsActive(lua_State *L) +{ + lua_pushboolean(L, K_RingsActive()); + return 1; +} + +// Checks if current map is using legacy boss3 bassed checkpoints. Useful for map compat. +static int lib_kUsingLegacyCheckpoints(lua_State *L) +{ + lua_pushboolean(L, K_UsingLegacyCheckpoints()); return 1; } @@ -4276,6 +4290,9 @@ static luaL_Reg lib[] = { {"K_GetCollideAngle",lib_kGetCollideAngle}, + {"K_RingsActive",lib_kRingsActive}, + {"K_UsingLegacyCheckpoints",lib_kUsingLegacyCheckpoints}, + // k_boss {"K_InitBossHealthBar", lib_kInitBossHealthBar}, {"K_UpdateBossHealthBar", lib_kUpdateBossHealthBar}, diff --git a/src/p_inter.c b/src/p_inter.c index d595ff85d..6259fe05e 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -849,7 +849,7 @@ void P_TouchStarPost(mobj_t *post, player_t *player, boolean snaptopost) (void)snaptopost; // Player must have touched all previous starposts - if ((post->health - player->starpostnum > 1) && (numbosswaypoints == 0)) + if ((post->health - player->starpostnum > 1) && (!K_UsingLegacyCheckpoints())) { if (!player->checkskip) { @@ -866,7 +866,7 @@ void P_TouchStarPost(mobj_t *post, player_t *player, boolean snaptopost) } // Going backwards triggers sound - if ((post->health >= ((numstarposts/2) + player->starpostnum)) && (numbosswaypoints > 0)) + if ((post->health >= ((numstarposts/2) + player->starpostnum)) && (K_UsingLegacyCheckpoints())) { if (!player->checkskip) S_StartSound(toucher, sfx_s26d); diff --git a/src/p_setup.c b/src/p_setup.c index 7dc990526..e801b8d3e 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -8689,7 +8689,7 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate) if ((K_SetupWaypointList() == false)) { - if (numbosswaypoints == 0) + if (!K_UsingLegacyCheckpoints()) { CONS_Alert(CONS_ERROR, "Waypoints were not able to be setup and legacy checkpoints do not exist! Player positions will not work correctly.\n"); } diff --git a/src/p_spec.c b/src/p_spec.c index f45338f8a..7bde16463 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1987,7 +1987,7 @@ static void K_HandleLapIncrement(player_t *player) { if (K_IgnoreFinishLine(player)) return; - if (((numbosswaypoints > 0) ? (player->starpostnum >= (numstarposts - (numstarposts/2))) : (player->starpostnum == numstarposts)) || (player->laps == 0)) + if (((K_UsingLegacyCheckpoints()) ? (player->starpostnum >= (numstarposts - (numstarposts/2))) : (player->starpostnum == numstarposts)) || (player->laps == 0)) { size_t i = 0; UINT8 nump = 0;