Merge branch 'fix-retry' into 'master'

Fix retry life/rank farming + fix buffered retry

Closes #475

See merge request KartKrew/Kart!1083
This commit is contained in:
Chromatian Keiske 2023-03-25 05:50:06 +00:00
commit 77117bbc9f
5 changed files with 85 additions and 38 deletions

View file

@ -3208,6 +3208,14 @@ void G_ExitLevel(void)
}
else if (grandprixinfo.gp == true && grandprixinfo.eventmode == GPEVENT_NONE)
{
for (i = 0; i < MAXPLAYERS; i++)
{
if (playeringame[i] && !players[i].spectator)
{
K_PlayerFinishGrandPrix(&players[i]);
}
}
doretry = (grandprixinfo.wonround != true);
}

View file

@ -18,6 +18,7 @@
#include "k_bot.h"
#include "k_kart.h"
#include "m_random.h"
#include "p_local.h"
#include "r_things.h"
struct grandprixinfo grandprixinfo;
@ -722,3 +723,51 @@ boolean K_CanChangeRules(boolean allowdemos)
return true;
}
/*--------------------------------------------------
void K_PlayerFinishGrandPrix(player_t *player);
See header file for description.
--------------------------------------------------*/
void K_PlayerFinishGrandPrix(player_t *player)
{
if (player->exiting == false)
{
// You did not finish
return;
}
if (player->bot)
{
// Bots are going to get harder... :)
K_IncreaseBotDifficulty(player);
return;
}
if (K_IsPlayerLosing(player))
{
return;
}
// YOU WIN
grandprixinfo.wonround = true;
// Increase your total rings
if (RINGTOTAL(player) > 0)
{
player->totalring += RINGTOTAL(player);
grandprixinfo.rank.rings += RINGTOTAL(player);
}
if (grandprixinfo.eventmode == GPEVENT_NONE)
{
grandprixinfo.rank.winPoints += K_CalculateGPRankPoints(player->position, grandprixinfo.rank.totalPlayers);
grandprixinfo.rank.laps += player->lapPoints;
}
else if (grandprixinfo.eventmode == GPEVENT_SPECIAL)
{
grandprixinfo.rank.specialWon = true;
}
P_GivePlayerLives(player, player->xtralife);
}

View file

@ -182,6 +182,21 @@ void K_PlayerLoseLife(player_t *player);
boolean K_CanChangeRules(boolean allowdemos);
/*--------------------------------------------------
void K_PlayerFinishGrandPrix(player_t *player);
Increases rank and bot difficulties, wins the round.
Input Arguments:-
player - Player to do this for.
Return:-
None
--------------------------------------------------*/
void K_PlayerFinishGrandPrix(player_t *player);
#ifdef __cplusplus
} // extern "C"
#endif

View file

@ -7402,6 +7402,8 @@ static void P_InitPlayers(void)
{
G_SpawnPlayer(i);
}
players[i].xtralife = 0; // extra lives do not ever carry over from the previous round
}
K_UpdateAllPlayerPositions();
@ -7474,6 +7476,8 @@ static void P_InitGametype(void)
lastLowestLap = 0;
spbplace = -1;
G_ClearRetryFlag();
// Start recording replay in multiplayer with a temp filename
//@TODO I'd like to fix dedis crashing when recording replays for the future too...
if (gamestate == GS_LEVEL && !demo.playback && multiplayer && !dedicated)

View file

@ -1349,46 +1349,17 @@ void P_DoPlayerExit(player_t *player)
exitcountdown = raceexittime+2;
}
if (grandprixinfo.gp == true)
if (grandprixinfo.gp == true && player->bot == false && losing == false)
{
if (player->bot)
const UINT8 lifethreshold = 20;
const UINT8 oldExtra = player->totalring / lifethreshold;
const UINT8 extra = (player->totalring + RINGTOTAL(player)) / lifethreshold;
if (extra > oldExtra)
{
// Bots are going to get harder... :)
K_IncreaseBotDifficulty(player);
}
else if (!losing)
{
const UINT8 lifethreshold = 20;
UINT8 extra = 0;
// YOU WIN
grandprixinfo.wonround = true;
// Increase your total rings
if (RINGTOTAL(player) > 0)
{
player->totalring += RINGTOTAL(player);
grandprixinfo.rank.rings += RINGTOTAL(player);
extra = player->totalring / lifethreshold;
if (extra > player->xtralife)
{
P_GivePlayerLives(player, extra - player->xtralife);
S_StartSound(NULL, sfx_cdfm73);
player->xtralife = extra;
}
}
if (grandprixinfo.eventmode == GPEVENT_NONE)
{
grandprixinfo.rank.winPoints += K_CalculateGPRankPoints(player->position, grandprixinfo.rank.totalPlayers);
grandprixinfo.rank.laps += player->lapPoints;
}
else if (grandprixinfo.eventmode == GPEVENT_SPECIAL)
{
grandprixinfo.rank.specialWon = true;
}
S_StartSound(NULL, sfx_cdfm73);
player->xtralife = (extra - oldExtra);
}
}
}