Fake results for bots that didn't get to finish in time

This commit is contained in:
Sally Coolatta 2020-05-09 23:08:11 -04:00
parent 8bb145e249
commit e2d95ae9c1
6 changed files with 71 additions and 35 deletions

View file

@ -3645,11 +3645,22 @@ static void G_DoCompleted(void)
{ {
// SRB2Kart: exitlevel shouldn't get you the points // SRB2Kart: exitlevel shouldn't get you the points
if (!players[i].exiting && !(players[i].pflags & PF_TIMEOVER)) if (!players[i].exiting && !(players[i].pflags & PF_TIMEOVER))
{
if (players[i].bot)
{
K_FakeBotResults(&players[i]);
}
else
{ {
players[i].pflags |= PF_TIMEOVER; players[i].pflags |= PF_TIMEOVER;
if (P_IsLocalPlayer(&players[i])) if (P_IsLocalPlayer(&players[i]))
{
j++; j++;
} }
}
}
G_PlayerFinishLevel(i); // take away cards and stuff G_PlayerFinishLevel(i); // take away cards and stuff
} }
@ -3918,7 +3929,7 @@ static void G_DoContinued(void)
token = 0; token = 0;
// Reset # of lives // Reset # of lives
pl->lives = (ultimatemode) ? 1 : 3; pl->lives = 3;
D_MapChange(gamemap, gametype, false, false, 0, false, false); 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].starpostangle = players[i].starpostnum = players[i].starposttime = 0;
players[i].starpostx = players[i].starposty = players[i].starpostz = 0; players[i].starpostx = players[i].starposty = players[i].starpostz = 0;
#if 0 players[i].lives = 3; // SRB2Kart
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
// The latter two should clear by themselves, but just in case // The latter two should clear by themselves, but just in case
players[i].pflags &= ~(PF_TAGIT|PF_TAGGED|PF_FULLSTASIS); players[i].pflags &= ~(PF_TAGIT|PF_TAGGED|PF_FULLSTASIS);

View file

@ -254,7 +254,6 @@ void K_CheckBumpers(void)
for (i = 0; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
{ {
players[i].pflags |= PF_TIMEOVER; players[i].pflags |= PF_TIMEOVER;
//players[i].lives = 0;
P_DoPlayerExit(&players[i]); P_DoPlayerExit(&players[i]);
} }
} }

View file

@ -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;
}

View file

@ -15,6 +15,7 @@ extern struct grandprixinfo
} grandprixinfo; } grandprixinfo;
void K_InitGrandPrixBots(void); void K_InitGrandPrixBots(void);
void K_FakeBotResults(player_t *bot);
#endif #endif

View file

@ -2352,15 +2352,10 @@ static void P_LevelInitStuff(void)
for (i = 0; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
{ {
#if 0 if (grandprixinfo.roundnum == 0)
if ((netgame || multiplayer) && (gametype == GT_COMPETITION || players[i].lives <= 0))
{ {
// In Co-Op, replenish a user's lives if they are depleted. players[i].lives = 3;
players[i].lives = cv_startinglives.value;
} }
#else
players[i].lives = 1; // SRB2Kart
#endif
players[i].realtime = countdown = countdown2 = 0; players[i].realtime = countdown = countdown2 = 0;
curlap = bestlap = 0; // SRB2Kart curlap = bestlap = 0; // SRB2Kart

View file

@ -8023,8 +8023,6 @@ void P_DoTimeOver(player_t *player)
P_DamageMobj(player->mo, NULL, NULL, 10000); P_DamageMobj(player->mo, NULL, NULL, 10000);
} }
player->lives = 0;
P_EndingMusic(player); P_EndingMusic(player);
if (!countdown2) if (!countdown2)