From c96e3b3cca89d6e66564d5d61e6bb2b88571e7cf Mon Sep 17 00:00:00 2001 From: Eidolon Date: Wed, 24 Sep 2025 21:45:14 -0500 Subject: [PATCH] Allow team victory by opposing team elimination in battle overtime --- src/k_battle.c | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/src/k_battle.c b/src/k_battle.c index d545a3fd4..790d886ca 100644 --- a/src/k_battle.c +++ b/src/k_battle.c @@ -133,8 +133,12 @@ void K_CheckBumpers(void) { UINT8 i; UINT8 numingame = 0; + UINT8 rednumingame = 0; + UINT8 bluenumingame = 0; UINT8 nobumpers = 0; UINT8 eliminated = 0; + UINT8 redeliminated = 0; + UINT8 blueeliminated = 0; SINT8 kingofthehill = -1; if (!(gametyperules & GTR_BUMPERS)) @@ -143,6 +147,8 @@ void K_CheckBumpers(void) if (gameaction == ga_completed) return; + boolean team = G_GametypeHasTeams(); + for (i = 0; i < MAXPLAYERS; i++) { if (!playeringame[i] || players[i].spectator) // not even in-game @@ -152,6 +158,11 @@ void K_CheckBumpers(void) return; numingame++; + if (team) + { + if (players[i].team == 1) rednumingame++; + if (players[i].team == 2) bluenumingame++; + } if (!P_MobjWasRemoved(players[i].mo) && players[i].mo->health <= 0) // if you don't have any bumpers, you're probably not a winner { @@ -161,6 +172,11 @@ void K_CheckBumpers(void) if (players[i].pflags & PF_ELIMINATED) { eliminated++; + if (team) + { + if (players[i].team == 1) redeliminated++; + else if (players[i].team == 2) blueeliminated++; + } } else { @@ -168,6 +184,12 @@ void K_CheckBumpers(void) } } + boolean teamwin = false; + if (team && (rednumingame - redeliminated == 0 || bluenumingame - blueeliminated == 0)) + { + teamwin = true; + } + if (numingame - eliminated == 2 && battleovertime.enabled && battleovertime.radius <= BARRIER_MIN_RADIUS) { Music_Stop("battle_overtime"); @@ -186,9 +208,28 @@ void K_CheckBumpers(void) { // If every other player is eliminated, the // last player standing wins by default. - if (eliminated >= numingame - 1) + // Or, if an entire team is eliminated. + if (eliminated >= numingame - 1 || teamwin) { - K_EndBattleRound(kingofthehill != -1 ? &players[kingofthehill] : NULL); + if (teamwin) + { + // Find the player with the highest individual score + UINT32 highestscore = 0; + UINT32 highestplayer = 0; + for (i = 0; i < MAXPLAYERS; i++) + { + if (playeringame[i] && players[i].score > highestscore) + { + highestplayer = i; + highestscore = players[i].score; + } + } + K_EndBattleRound(&players[highestplayer]); + } + else + { + K_EndBattleRound(kingofthehill != -1 ? &players[kingofthehill] : NULL); + } return; } }