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())
{
if (player->exiting)
return;
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++;
if (player->exiting) // End of match standings
{
if (players[i].score > player->score) // Only score matters
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 camppos[MAXPLAYERS]; // who is the biggest camper
UINT8 ties = 0, nextcamppos = 0;
boolean setballoon = false;
UINT8 i, j;
if (!G_BattleGametype())
@ -3895,25 +3902,30 @@ void K_CalculateBattleWanted(void)
{
if (i+1 > numwanted) // Not enough players for this slot to be wanted!
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;
bestballoonplayer = -1; // Don't set twice
setballoon = true; // Don't set twice
}
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.
// (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
|| ties >= 2) // Already counted ties
|| ties >= (numwanted-i)) // Already counted ties
{
battlewanted[i] = -1;
continue;
}
if (ties < 2)
if (ties < (numwanted-i))
{
ties = 0; // Reset
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];
nextcamppos++;

View File

@ -4211,15 +4211,15 @@ DoneSection2:
{
// SRB2kart 200117
if (splitscreen)
S_ChangeMusicInternal("karwin", true);
S_ChangeMusicInternal("krok", true);
else
{
if (player->kartstuff[k_position] == 1)
S_ChangeMusicInternal("karwin", true);
S_ChangeMusicInternal("krwin", true);
else if (K_IsPlayerLosing(player))
S_ChangeMusicInternal("karlos", true);
S_ChangeMusicInternal("krlose", true);
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);
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
if (splitscreen != 0 && G_RaceGametype()
else if (splitscreen && G_RaceGametype()
&& (players[consoleplayer].exiting
|| players[secondarydisplayplayer].exiting
|| players[thirddisplayplayer].exiting
|| players[fourthdisplayplayer].exiting))
S_ChangeMusicInternal("karwin", true);
else if (splitscreen == 0 && G_RaceGametype() && player->exiting)
S_ChangeMusicInternal("krok", true);
else if (!splitscreen && G_RaceGametype() && player->exiting)
{
if (player->kartstuff[k_position] == 1)
S_ChangeMusicInternal("karwin", true);
S_ChangeMusicInternal("krwin", true);
else if (K_IsPlayerLosing(player))
S_ChangeMusicInternal("karlos", true);
S_ChangeMusicInternal("krlose", true);
else
S_ChangeMusicInternal("karok", true);
S_ChangeMusicInternal("krok", true);
}
else
{
@ -1642,27 +1670,24 @@ void P_DoPlayerExit(player_t *player)
countdown = cv_countdowntime.value*TICRATE + 1; // Use cv_countdowntime
if (circuitmap)
{
if (K_IsPlayerLosing(player))
S_StartSound(player->mo, sfx_klose);
else
S_StartSound(player->mo, sfx_kwin);
}
if (K_IsPlayerLosing(player))
S_StartSound(player->mo, sfx_klose);
else
S_StartSound(player->mo, sfx_kwin);
if (P_IsLocalPlayer(player) && cv_inttime.value > 0)
{
if (!splitscreen)
{
if (player->kartstuff[k_position] == 1)
S_ChangeMusicInternal("karwin", true);
S_ChangeMusicInternal("krwin", true);
else if (K_IsPlayerLosing(player))
S_ChangeMusicInternal("karlos", true);
S_ChangeMusicInternal("krlose", true);
else
S_ChangeMusicInternal("karok", true);
S_ChangeMusicInternal("krok", true);
}
else
S_ChangeMusicInternal("karok", true);
S_ChangeMusicInternal("krok", true);
}
player->exiting = 3*TICRATE;
@ -1676,8 +1701,40 @@ void P_DoPlayerExit(player_t *player)
if (P_CheckRacers())
player->exiting = (14*TICRATE)/5 + 1;
}
else if (G_BattleGametype())
player->exiting = 8*TICRATE + 1; // Battle Mode exiting
else if (G_BattleGametype()) // 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
player->exiting = (14*TICRATE)/5 + 2; // Accidental death safeguard???

View File

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