Battle finish music, fixed double-wanted bug

This commit is contained in:
TehRealSalt 2018-07-02 17:57:22 -04:00
parent 3184d2a7b0
commit 6698bb5772
4 changed files with 107 additions and 38 deletions

View File

@ -3200,12 +3200,18 @@ static void K_KartUpdatePosition(player_t *player)
} }
else if (G_BattleGametype()) else if (G_BattleGametype())
{ {
if (player->exiting) if (player->exiting) // End of match standings
return; {
if (players[i].kartstuff[k_balloon] == player->kartstuff[k_balloon] && players[i].score > player->score) if (players[i].score > player->score) // Only score matters
position++; position++;
else if (players[i].kartstuff[k_balloon] > player->kartstuff[k_balloon]) }
position++; else
{
if (players[i].kartstuff[k_balloon] == player->kartstuff[k_balloon] && players[i].score > player->score)
position++;
else if (players[i].kartstuff[k_balloon] > player->kartstuff[k_balloon])
position++;
}
} }
} }
@ -3829,6 +3835,7 @@ void K_CalculateBattleWanted(void)
SINT8 bestballoonplayer = -1, bestballoon = -1; SINT8 bestballoonplayer = -1, bestballoon = -1;
SINT8 camppos[MAXPLAYERS]; // who is the biggest camper SINT8 camppos[MAXPLAYERS]; // who is the biggest camper
UINT8 ties = 0, nextcamppos = 0; UINT8 ties = 0, nextcamppos = 0;
boolean setballoon = false;
UINT8 i, j; UINT8 i, j;
if (!G_BattleGametype()) if (!G_BattleGametype())
@ -3895,25 +3902,30 @@ void K_CalculateBattleWanted(void)
{ {
if (i+1 > numwanted) // Not enough players for this slot to be wanted! if (i+1 > numwanted) // Not enough players for this slot to be wanted!
battlewanted[i] = -1; battlewanted[i] = -1;
else if (bestballoonplayer != -1) // If there's a player who has a single-handed lead over everyone else, they are the first to be wanted. else if (bestballoonplayer != -1 && !setballoon) // If there's a player who has an untied balloon lead over everyone else, they are the first to be wanted.
{ {
battlewanted[i] = bestballoonplayer; battlewanted[i] = bestballoonplayer;
bestballoonplayer = -1; // Don't set twice setballoon = true; // Don't set twice
} }
else else
{ {
// Do not add *any* more people if there's more than 1 wanted times that are tied with others. // Don't accidentally set the same player, if the bestballoonplayer is also a huge camper.
while (bestballoonplayer != -1 && camppos[nextcamppos] != -1
&& bestballoonplayer == camppos[nextcamppos])
nextcamppos++;
// Do not add *any* more people if there's too many times that are tied with others.
// This could theoretically happen very easily if people don't hit each other for a while after the start of a match. // This could theoretically happen very easily if people don't hit each other for a while after the start of a match.
// (I will be sincerely impressed if more than 2 people tie after people start hitting each other though) // (I will be sincerely impressed if more than 2 people tie after people start hitting each other though)
if (camppos[nextcamppos] == -1 // Out of entries if (camppos[nextcamppos] == -1 // Out of entries
|| ties >= 2) // Already counted ties || ties >= (numwanted-i)) // Already counted ties
{ {
battlewanted[i] = -1; battlewanted[i] = -1;
continue; continue;
} }
if (ties < 2) if (ties < (numwanted-i))
{ {
ties = 0; // Reset ties = 0; // Reset
for (j = 0; j < 2; j++) for (j = 0; j < 2; j++)
@ -3925,7 +3937,7 @@ void K_CalculateBattleWanted(void)
} }
} }
if (ties < 2) // Is it still less than 2 after counting? if (ties < (numwanted-i)) // Is it still low enough after counting?
{ {
battlewanted[i] = camppos[nextcamppos]; battlewanted[i] = camppos[nextcamppos];
nextcamppos++; nextcamppos++;

View File

@ -4211,15 +4211,15 @@ DoneSection2:
{ {
// SRB2kart 200117 // SRB2kart 200117
if (splitscreen) if (splitscreen)
S_ChangeMusicInternal("karwin", true); S_ChangeMusicInternal("krok", true);
else else
{ {
if (player->kartstuff[k_position] == 1) if (player->kartstuff[k_position] == 1)
S_ChangeMusicInternal("karwin", true); S_ChangeMusicInternal("krwin", true);
else if (K_IsPlayerLosing(player)) else if (K_IsPlayerLosing(player))
S_ChangeMusicInternal("karlos", true); S_ChangeMusicInternal("krlose", true);
else else
S_ChangeMusicInternal("karok", true); S_ChangeMusicInternal("krok", true);
} }
} }

View File

@ -1122,21 +1122,49 @@ void P_RestoreMusic(player_t *player)
S_ChangeMusicInternal("kinvnc", false); S_ChangeMusicInternal("kinvnc", false);
else else
{ {
// Event - Battle Finish
if (G_BattleGametype() && player->exiting)
{
if (!splitscreen)
{
INT32 pos = 1;
UINT8 i;
for (i = 0; i < MAXPLAYERS; i++) // Calculate position to ensure what music to play
{
if (!playeringame[i] || players[i].spectator)
continue;
if (players[i].kartstuff[k_balloon] > player->kartstuff[k_balloon])
pos++;
else if (players[i].score > player->score)
pos++;
}
if (pos == 1)
S_ChangeMusicInternal("kbwin", false);
else if (pos <= 3)
S_ChangeMusicInternal("kbok", false);
else
S_ChangeMusicInternal("kblose", false);
}
else
S_ChangeMusicInternal("kbok", false);
}
// Event - Race Finish // Event - Race Finish
if (splitscreen != 0 && G_RaceGametype() else if (splitscreen && G_RaceGametype()
&& (players[consoleplayer].exiting && (players[consoleplayer].exiting
|| players[secondarydisplayplayer].exiting || players[secondarydisplayplayer].exiting
|| players[thirddisplayplayer].exiting || players[thirddisplayplayer].exiting
|| players[fourthdisplayplayer].exiting)) || players[fourthdisplayplayer].exiting))
S_ChangeMusicInternal("karwin", true); S_ChangeMusicInternal("krok", true);
else if (splitscreen == 0 && G_RaceGametype() && player->exiting) else if (!splitscreen && G_RaceGametype() && player->exiting)
{ {
if (player->kartstuff[k_position] == 1) if (player->kartstuff[k_position] == 1)
S_ChangeMusicInternal("karwin", true); S_ChangeMusicInternal("krwin", true);
else if (K_IsPlayerLosing(player)) else if (K_IsPlayerLosing(player))
S_ChangeMusicInternal("karlos", true); S_ChangeMusicInternal("krlose", true);
else else
S_ChangeMusicInternal("karok", true); S_ChangeMusicInternal("krok", true);
} }
else else
{ {
@ -1642,27 +1670,24 @@ void P_DoPlayerExit(player_t *player)
countdown = cv_countdowntime.value*TICRATE + 1; // Use cv_countdowntime countdown = cv_countdowntime.value*TICRATE + 1; // Use cv_countdowntime
if (circuitmap) if (K_IsPlayerLosing(player))
{ S_StartSound(player->mo, sfx_klose);
if (K_IsPlayerLosing(player)) else
S_StartSound(player->mo, sfx_klose); S_StartSound(player->mo, sfx_kwin);
else
S_StartSound(player->mo, sfx_kwin);
}
if (P_IsLocalPlayer(player) && cv_inttime.value > 0) if (P_IsLocalPlayer(player) && cv_inttime.value > 0)
{ {
if (!splitscreen) if (!splitscreen)
{ {
if (player->kartstuff[k_position] == 1) if (player->kartstuff[k_position] == 1)
S_ChangeMusicInternal("karwin", true); S_ChangeMusicInternal("krwin", true);
else if (K_IsPlayerLosing(player)) else if (K_IsPlayerLosing(player))
S_ChangeMusicInternal("karlos", true); S_ChangeMusicInternal("krlose", true);
else else
S_ChangeMusicInternal("karok", true); S_ChangeMusicInternal("krok", true);
} }
else else
S_ChangeMusicInternal("karok", true); S_ChangeMusicInternal("krok", true);
} }
player->exiting = 3*TICRATE; player->exiting = 3*TICRATE;
@ -1676,8 +1701,40 @@ void P_DoPlayerExit(player_t *player)
if (P_CheckRacers()) if (P_CheckRacers())
player->exiting = (14*TICRATE)/5 + 1; player->exiting = (14*TICRATE)/5 + 1;
} }
else if (G_BattleGametype()) else if (G_BattleGametype()) // Battle Mode exiting
player->exiting = 8*TICRATE + 1; // Battle Mode exiting {
//S_StopMusic();
if (P_IsLocalPlayer(player))
{
if (!splitscreen)
{
INT32 pos = 1;
UINT8 i;
for (i = 0; i < MAXPLAYERS; i++) // Calculate position to ensure what music to play
{
if (!playeringame[i] || players[i].spectator)
continue;
if (players[i].kartstuff[k_balloon] > player->kartstuff[k_balloon])
pos++;
else if (players[i].score > player->score)
pos++;
}
if (pos == 1)
S_ChangeMusicInternal("kbwin", false);
else if (pos <= 3)
S_ChangeMusicInternal("kbok", false);
else
S_ChangeMusicInternal("kblose", false);
}
else
S_ChangeMusicInternal("kbok", false);
}
player->exiting = 8*TICRATE + 1;
}
else else
player->exiting = (14*TICRATE)/5 + 2; // Accidental death safeguard??? player->exiting = (14*TICRATE)/5 + 2; // Accidental death safeguard???

View File

@ -833,9 +833,9 @@ void Y_Ticker(void)
/* // SRB2kart - removed temporarily. /* // SRB2kart - removed temporarily.
if (!intertic) { if (!intertic) {
if (!((music_playing == "karwin") // Mario Kart Win if (!((music_playing == "krwin") // Win
|| (music_playing == "karok") // Mario Kart Ok || (music_playing == "krok") // Ok
|| (music_playing == "karlos"))) // Mario Kart Lose || (music_playing == "krlose"))) // Lose
S_ChangeMusicInternal("racent", true); // Backup Plan S_ChangeMusicInternal("racent", true); // Backup Plan
}*/ }*/