From e2d95ae9c1545e059dc5883dd75f1ad92ee97697 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sat, 9 May 2020 23:08:11 -0400 Subject: [PATCH] Fake results for bots that didn't get to finish in time --- src/g_game.c | 41 +++++++++++++++---------------------- src/k_battle.c | 1 - src/k_grandprix.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++ src/k_grandprix.h | 1 + src/p_setup.c | 9 ++------ src/p_user.c | 2 -- 6 files changed, 71 insertions(+), 35 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index c3b561c1b..d4b328c76 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3646,10 +3646,21 @@ static void G_DoCompleted(void) // SRB2Kart: exitlevel shouldn't get you the points if (!players[i].exiting && !(players[i].pflags & PF_TIMEOVER)) { - players[i].pflags |= PF_TIMEOVER; - if (P_IsLocalPlayer(&players[i])) - j++; + if (players[i].bot) + { + K_FakeBotResults(&players[i]); + } + else + { + players[i].pflags |= PF_TIMEOVER; + + if (P_IsLocalPlayer(&players[i])) + { + j++; + } + } } + G_PlayerFinishLevel(i); // take away cards and stuff } @@ -3918,7 +3929,7 @@ static void G_DoContinued(void) token = 0; // Reset # of lives - pl->lives = (ultimatemode) ? 1 : 3; + pl->lives = 3; D_MapChange(gamemap, gametype, false, false, 0, false, false); @@ -4562,27 +4573,7 @@ void G_InitNew(UINT8 pencoremode, const char *mapname, boolean resetplayer, bool players[i].starpostangle = players[i].starpostnum = players[i].starposttime = 0; players[i].starpostx = players[i].starposty = players[i].starpostz = 0; -#if 0 - if (netgame || multiplayer) - { - players[i].lives = cv_startinglives.value; - players[i].continues = 0; - } - else if (pultmode) - { - players[i].lives = 1; - players[i].continues = 0; - } - else - { - players[i].lives = 3; - players[i].continues = 1; - } - - players[i].xtralife = 0; -#else - players[i].lives = 1; // SRB2Kart -#endif + players[i].lives = 3; // SRB2Kart // The latter two should clear by themselves, but just in case players[i].pflags &= ~(PF_TAGIT|PF_TAGGED|PF_FULLSTASIS); diff --git a/src/k_battle.c b/src/k_battle.c index fe727cee3..fc1141581 100644 --- a/src/k_battle.c +++ b/src/k_battle.c @@ -254,7 +254,6 @@ void K_CheckBumpers(void) for (i = 0; i < MAXPLAYERS; i++) { players[i].pflags |= PF_TIMEOVER; - //players[i].lives = 0; P_DoPlayerExit(&players[i]); } } diff --git a/src/k_grandprix.c b/src/k_grandprix.c index da78cb332..c3a4185cc 100644 --- a/src/k_grandprix.c +++ b/src/k_grandprix.c @@ -178,3 +178,55 @@ void K_InitGrandPrixBots(void) } } } + +void K_FakeBotResults(player_t *bot) +{ + const UINT32 distfactor = 32; + UINT32 worstdist = 0; + tic_t besttime = UINT32_MAX; + UINT8 numplayers = 0; + UINT8 i; + + for (i = 0; i < MAXPLAYERS; i++) + { + if (playeringame[i] && !players[i].spectator) + { + numplayers++; + + if (players[i].exiting && players[i].realtime < besttime) + { + besttime = players[i].realtime; + } + } + } + + if (besttime == UINT32_MAX) + { + // No one finished, so you don't finish either. + bot->pflags |= PF_TIMEOVER; + return; + } + + for (i = 0; i < MAXPLAYERS; i++) + { + if (playeringame[i] && !players[i].spectator) + { + if (players[i].distancetofinish > worstdist) + { + worstdist = players[i].distancetofinish; + } + } + } + + if (bot->distancetofinish >= worstdist) + { + // Last place, you aren't going to finish. + bot->pflags |= PF_TIMEOVER; + return; + } + + // hey, you "won" + bot->exiting = 2; + bot->realtime = bot->realtime + (bot->distancetofinish / distfactor); + bot->distancetofinish = 0; +} diff --git a/src/k_grandprix.h b/src/k_grandprix.h index 0eacf8ff9..d0734bc42 100644 --- a/src/k_grandprix.h +++ b/src/k_grandprix.h @@ -15,6 +15,7 @@ extern struct grandprixinfo } grandprixinfo; void K_InitGrandPrixBots(void); +void K_FakeBotResults(player_t *bot); #endif diff --git a/src/p_setup.c b/src/p_setup.c index dbb1769f7..a353314f8 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2352,15 +2352,10 @@ static void P_LevelInitStuff(void) for (i = 0; i < MAXPLAYERS; i++) { -#if 0 - if ((netgame || multiplayer) && (gametype == GT_COMPETITION || players[i].lives <= 0)) + if (grandprixinfo.roundnum == 0) { - // In Co-Op, replenish a user's lives if they are depleted. - players[i].lives = cv_startinglives.value; + players[i].lives = 3; } -#else - players[i].lives = 1; // SRB2Kart -#endif players[i].realtime = countdown = countdown2 = 0; curlap = bestlap = 0; // SRB2Kart diff --git a/src/p_user.c b/src/p_user.c index 7621542b0..05d96bec1 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -8023,8 +8023,6 @@ void P_DoTimeOver(player_t *player) P_DamageMobj(player->mo, NULL, NULL, 10000); } - player->lives = 0; - P_EndingMusic(player); if (!countdown2)