Add K_EndBattleRound, end the round and give a player 100 points if they won

This commit is contained in:
James R 2024-01-22 17:51:31 -08:00
parent 6197458ca4
commit 841827480b
3 changed files with 30 additions and 15 deletions

View file

@ -173,14 +173,9 @@ void K_CheckBumpers(void)
}
else if (eliminated >= numingame - 1)
{
if (kingofthehill != -1)
{
// If every other player is eliminated, the
// last player standing wins by default.
players[kingofthehill].roundscore = 100;
}
P_DoAllPlayersExit(0, false);
// If every other player is eliminated, the
// last player standing wins by default.
K_EndBattleRound(kingofthehill != -1 ? &players[kingofthehill] : NULL);
return;
}
@ -209,15 +204,11 @@ void K_CheckEmeralds(player_t *player)
return;
}
if (player->exiting)
if (!K_EndBattleRound(player))
{
return;
}
player->roundscore = 100; // lmao
P_DoAllPlayersExit(0, false);
// TODO: this would be better if the timing lived in
// Tally code. But I didn't do it that, so this just
// shittily approximates syncing up with Tally.
@ -969,3 +960,27 @@ boolean K_BattleOvertimeKiller(mobj_t *mobj)
return true;
}
boolean K_EndBattleRound(player_t *victor)
{
if (victor)
{
if (victor->exiting)
{
// In Battle, players always exit altogether.
// So it can be assumed that if this player is
// exiting, the round has already ended.
return false;
}
if (gametyperules & GTR_POINTLIMIT)
{
// Lock the winner in before the round ends.
victor->roundscore = 100;
}
}
P_DoAllPlayersExit(0, false);
return true;
}

View file

@ -53,6 +53,7 @@ void K_BattleInit(boolean singleplayercontext);
UINT8 K_Bumpers(player_t *player);
INT32 K_BumpersToHealth(UINT8 bumpers);
boolean K_BattleOvertimeKiller(mobj_t *mobj);
boolean K_EndBattleRound(player_t *victor);
#ifdef __cplusplus
} // extern "C"

View file

@ -3929,8 +3929,7 @@ void K_BattleAwardHit(player_t *player, player_t *victim, mobj_t *inflictor, UIN
// Check this before adding to player score
if ((gametyperules & GTR_BUMPERS) && finishOff && g_pointlimit <= player->roundscore)
{
player->roundscore = 100; // Make sure you win!
P_DoAllPlayersExit(0, false);
K_EndBattleRound(player);
mobj_t *source = !P_MobjWasRemoved(inflictor) ? inflictor : player->mo;