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

@ -172,15 +172,10 @@ void K_CheckBumpers(void)
} }
} }
else if (eliminated >= numingame - 1) else if (eliminated >= numingame - 1)
{
if (kingofthehill != -1)
{ {
// If every other player is eliminated, the // If every other player is eliminated, the
// last player standing wins by default. // last player standing wins by default.
players[kingofthehill].roundscore = 100; K_EndBattleRound(kingofthehill != -1 ? &players[kingofthehill] : NULL);
}
P_DoAllPlayersExit(0, false);
return; return;
} }
@ -209,15 +204,11 @@ void K_CheckEmeralds(player_t *player)
return; return;
} }
if (player->exiting) if (!K_EndBattleRound(player))
{ {
return; return;
} }
player->roundscore = 100; // lmao
P_DoAllPlayersExit(0, false);
// TODO: this would be better if the timing lived in // TODO: this would be better if the timing lived in
// Tally code. But I didn't do it that, so this just // Tally code. But I didn't do it that, so this just
// shittily approximates syncing up with Tally. // shittily approximates syncing up with Tally.
@ -969,3 +960,27 @@ boolean K_BattleOvertimeKiller(mobj_t *mobj)
return true; 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); UINT8 K_Bumpers(player_t *player);
INT32 K_BumpersToHealth(UINT8 bumpers); INT32 K_BumpersToHealth(UINT8 bumpers);
boolean K_BattleOvertimeKiller(mobj_t *mobj); boolean K_BattleOvertimeKiller(mobj_t *mobj);
boolean K_EndBattleRound(player_t *victor);
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } // 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 // Check this before adding to player score
if ((gametyperules & GTR_BUMPERS) && finishOff && g_pointlimit <= player->roundscore) if ((gametyperules & GTR_BUMPERS) && finishOff && g_pointlimit <= player->roundscore)
{ {
player->roundscore = 100; // Make sure you win! K_EndBattleRound(player);
P_DoAllPlayersExit(0, false);
mobj_t *source = !P_MobjWasRemoved(inflictor) ? inflictor : player->mo; mobj_t *source = !P_MobjWasRemoved(inflictor) ? inflictor : player->mo;