mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Refactor lives and rank increase to occur at level end transition, not when the player finishes
Fixes exploiting retries after finishing in good standing to farm lives and rank. These are now applied when you can no longer retry. Extra life sound effect still plays as soon as you finish the race.
This commit is contained in:
parent
312e847151
commit
f5f85cc3e4
5 changed files with 83 additions and 38 deletions
|
|
@ -3206,6 +3206,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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
@ -741,3 +742,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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -192,6 +192,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
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
47
src/p_user.c
47
src/p_user.c
|
|
@ -1334,46 +1334,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue