Tally in GP contexts: Recognise earned lives from other sources, not just Ring Total

- If owner->xtralife isn't 0...
    - For every 20 Rings we count up, increment livesAdded.
    - If at the end of the ring count livesAdded is less than owner->xtralife, set livesAdded to that value.
- Every time livesAdded is changed, play the sound and set the blink.
- Caps the number of added lives to the same as P_GivePlayerLives would permit.
This commit is contained in:
toaster 2023-10-25 16:11:57 +01:00
parent bd5fdb3b82
commit c50edc684c
3 changed files with 33 additions and 10 deletions

View file

@ -295,6 +295,7 @@ void level_tally_t::Init(player_t *player)
time = std::min(static_cast<INT32>(player->realtime), (100 * 60 * TICRATE) - 1);
ringPool = player->totalring;
livesAdded = 0;
position = numPlayers = 0;
rings = 0;
@ -567,7 +568,10 @@ boolean level_tally_t::IncrementLine(void)
}
value = &displayStat[i];
lives_check = (stats[i] == TALLY_STAT_TOTALRINGS);
lives_check = (
stats[i] == TALLY_STAT_TOTALRINGS // Rings also shows the Lives.
&& livesAdded < owner->xtralife // Don't check if we've maxxed out!
);
switch (stats[i])
{
@ -649,14 +653,30 @@ boolean level_tally_t::IncrementLine(void)
return true;
}
const boolean playSounds = P_IsDisplayPlayer(owner);
if (*value == dest)
{
// We've reached our destination
if (lives_check == true)
{
// This is only true if Rings alone aren't responsible for our added lives.
// Generally for Prison Break, but could be earned in custom contexts too.
livesAdded = owner->xtralife;
xtraBlink = TICRATE;
if (playSounds == true)
{
S_StopSoundByNum(sfx_cdfm73);
S_StartSound(NULL, sfx_cdfm73);
}
}
return true;
}
const INT32 prevVal = *value;
const boolean playSounds = P_IsDisplayPlayer(owner);
if (playSounds == true && tickSound == 0)
{
@ -693,6 +713,7 @@ boolean level_tally_t::IncrementLine(void)
// Handle extra life sound & blinking
if (extra > oldExtra)
{
livesAdded++;
xtraBlink = TICRATE;
if (playSounds == true)
@ -1190,13 +1211,8 @@ void level_tally_t::Draw(void)
.colormap(owner->skin, color)
.patch(faceprefix[owner->skin][r_splitscreen ? FACE_MINIMAP : FACE_RANK]);
const UINT8 lifethreshold = 20;
const UINT8 oldExtra = ringPool / lifethreshold;
const UINT8 extra = displayStat[i] / lifethreshold;
const INT32 increase = (extra - oldExtra);
UINT8 lives_num = owner->lives + increase;
if (xtraBlink > 0 && (xtraBlink & 1) == 0 && increase > 0)
UINT8 lives_num = std::min(owner->lives + livesAdded, 10);
if (xtraBlink > 0 && (xtraBlink & 1) == 0 && livesAdded > 0)
{
lives_num = 0;
}

View file

@ -72,6 +72,7 @@ struct level_tally_t
// Stats
INT32 time;
UINT16 ringPool;
UINT8 livesAdded;
tally_stat_e stats[TALLY_WINDOW_SIZE];
// Possible grade metrics

View file

@ -1364,6 +1364,12 @@ void P_DoAllPlayersExit(pflags_t flags, boolean trygivelife)
UINT8 i;
const boolean dofinishsound = (musiccountdown == 0);
if (grandprixinfo.gp == false
|| (flags & PF_NOCONTEST))
{
trygivelife = false;
}
for (i = 0; i < MAXPLAYERS; i++)
{
if (!playeringame[i] || players[i].spectator)
@ -1382,7 +1388,7 @@ void P_DoAllPlayersExit(pflags_t flags, boolean trygivelife)
continue;
}
P_GivePlayerLives(&players[i], 1);
players[i].xtralife++;
}
if (!dofinishsound)