Merge branch 'gp-lives-steenky' into 'master'

Lives & Rings Cleanup (resolves #647)

Closes #647

See merge request KartKrew/Kart!1447
This commit is contained in:
toaster 2023-09-01 20:43:24 +00:00
commit fc075b24b4
6 changed files with 53 additions and 28 deletions

View file

@ -652,6 +652,7 @@ struct player_t
// player's ring count // player's ring count
SINT8 rings; SINT8 rings;
SINT8 hudrings; // The above is only updated during play, this is locked after finishing
UINT8 pickuprings; // Number of rings being picked up before added to the counter (prevents rings from being deleted forever over 20) UINT8 pickuprings; // Number of rings being picked up before added to the counter (prevents rings from being deleted forever over 20)
UINT8 ringdelay; // (0 to 3) - 3 tic delay between every ring usage UINT8 ringdelay; // (0 to 3) - 3 tic delay between every ring usage
UINT16 ringboost; // Ring boost timer UINT16 ringboost; // Ring boost timer

View file

@ -877,7 +877,7 @@ void K_PlayerFinishGrandPrix(player_t *player)
grandprixinfo.wonround = true; grandprixinfo.wonround = true;
// Increase your total rings // Increase your total rings
INT32 ringtotal = RINGTOTAL(player); INT32 ringtotal = player->hudrings;
if (ringtotal > 0) if (ringtotal > 0)
{ {
if (ringtotal > 20) if (ringtotal > 20)

View file

@ -2608,15 +2608,15 @@ static void K_drawRingCounter(boolean gametypeinfoshown)
boolean colorring = false; boolean colorring = false;
INT32 ringx = 0, fy = 0; INT32 ringx = 0, fy = 0;
rn[0] = ((abs(stplyr->rings) / 10) % 10); rn[0] = ((abs(stplyr->hudrings) / 10) % 10);
rn[1] = (abs(stplyr->rings) % 10); rn[1] = (abs(stplyr->hudrings) % 10);
if (stplyr->rings <= 0 && (leveltime/5 & 1)) // In debt if (stplyr->hudrings <= 0 && (leveltime/5 & 1)) // In debt
{ {
ringmap = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_CRIMSON, GTC_CACHE); ringmap = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_CRIMSON, GTC_CACHE);
colorring = true; colorring = true;
} }
else if (stplyr->rings >= 20) // Maxed out else if (stplyr->hudrings >= 20) // Maxed out
ringmap = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_YELLOW, GTC_CACHE); ringmap = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_YELLOW, GTC_CACHE);
if (stplyr->karthud[khud_ringframe] > RINGANIM_FLIPFRAME) if (stplyr->karthud[khud_ringframe] > RINGANIM_FLIPFRAME)
@ -2673,7 +2673,7 @@ static void K_drawRingCounter(boolean gametypeinfoshown)
V_DrawMappedPatch(fr+ringx, fy-3, V_HUDTRANS|V_SLIDEIN|splitflags|ringflip, kp_smallring[ringanim_realframe], (colorring ? ringmap : NULL)); V_DrawMappedPatch(fr+ringx, fy-3, V_HUDTRANS|V_SLIDEIN|splitflags|ringflip, kp_smallring[ringanim_realframe], (colorring ? ringmap : NULL));
if (stplyr->rings < 0) // Draw the minus for ring debt if (stplyr->hudrings < 0) // Draw the minus for ring debt
V_DrawMappedPatch(fr+7, fy, V_HUDTRANS|V_SLIDEIN|splitflags, kp_ringdebtminussmall, ringmap); V_DrawMappedPatch(fr+7, fy, V_HUDTRANS|V_SLIDEIN|splitflags, kp_ringdebtminussmall, ringmap);
V_DrawMappedPatch(fr+11, fy, V_HUDTRANS|V_SLIDEIN|splitflags, fontv[PINGNUM_FONT].font[rn[0]], ringmap); V_DrawMappedPatch(fr+11, fy, V_HUDTRANS|V_SLIDEIN|splitflags, fontv[PINGNUM_FONT].font[rn[0]], ringmap);
@ -2716,7 +2716,7 @@ static void K_drawRingCounter(boolean gametypeinfoshown)
V_DrawMappedPatch(LAPS_X+ringx+7, fy-5, V_HUDTRANS|V_SLIDEIN|splitflags|ringflip, kp_ring[ringanim_realframe], (colorring ? ringmap : NULL)); V_DrawMappedPatch(LAPS_X+ringx+7, fy-5, V_HUDTRANS|V_SLIDEIN|splitflags|ringflip, kp_ring[ringanim_realframe], (colorring ? ringmap : NULL));
if (stplyr->rings < 0) // Draw the minus for ring debt if (stplyr->hudrings < 0) // Draw the minus for ring debt
{ {
V_DrawMappedPatch(LAPS_X+23, fy, V_HUDTRANS|V_SLIDEIN|splitflags, kp_ringdebtminus, ringmap); V_DrawMappedPatch(LAPS_X+23, fy, V_HUDTRANS|V_SLIDEIN|splitflags, kp_ringdebtminus, ringmap);
V_DrawMappedPatch(LAPS_X+29, fy, V_HUDTRANS|V_SLIDEIN|splitflags, kp_facenum[rn[0]], ringmap); V_DrawMappedPatch(LAPS_X+29, fy, V_HUDTRANS|V_SLIDEIN|splitflags, kp_facenum[rn[0]], ringmap);
@ -2736,9 +2736,16 @@ static void K_drawRingCounter(boolean gametypeinfoshown)
if (uselives) if (uselives)
{ {
UINT8 *colormap = R_GetTranslationColormap(stplyr->skin, stplyr->skincolor, GTC_CACHE); UINT8 *colormap = R_GetTranslationColormap(stplyr->skin, stplyr->skincolor, GTC_CACHE);
V_DrawMappedPatch(LAPS_X+40, fy-5, V_HUDTRANS|V_SLIDEIN|splitflags, faceprefix[stplyr->skin][FACE_RANK], colormap); V_DrawMappedPatch(LAPS_X+46, fy-5, V_HUDTRANS|V_SLIDEIN|splitflags, faceprefix[stplyr->skin][FACE_RANK], colormap);
if (stplyr->lives >= 0) SINT8 livescount = 0;
K_DrawLivesDigits(LAPS_X + (stplyr->lives < 10 ? 60 : 57), fy, 6, V_HUDTRANS|V_SLIDEIN|splitflags, kp_facenum); if (stplyr->lives > 0)
{
livescount = stplyr->lives;
if (livescount > 10)
livescount = 10;
}
//K_DrawLivesDigits -- not using this because it messed with the FENG SHUI
V_DrawScaledPatch(LAPS_X+63, fy, V_HUDTRANS|V_SLIDEIN|splitflags, kp_facenum[livescount]);
} }
} }
} }

View file

@ -7414,6 +7414,8 @@ static void K_UpdateInvincibilitySounds(player_t *player)
#undef STOPTHIS #undef STOPTHIS
} }
// This function is not strictly for non-netsynced properties.
// It's just a convenient name for things that don't stop during hitlag.
void K_KartPlayerHUDUpdate(player_t *player) void K_KartPlayerHUDUpdate(player_t *player)
{ {
if (player->karthud[khud_lapanimation]) if (player->karthud[khud_lapanimation])
@ -7464,6 +7466,12 @@ void K_KartPlayerHUDUpdate(player_t *player)
if (!(gametyperules & GTR_SPHERES)) if (!(gametyperules & GTR_SPHERES))
{ {
if (!player->exiting
&& !(player->pflags & (PF_NOCONTEST|PF_ELIMINATED)))
{
player->hudrings = player->rings;
}
if (player->mo && player->mo->hitlag <= 0) if (player->mo && player->mo->hitlag <= 0)
{ {
// 0 is the fast spin animation, set at 30 tics of ring boost or higher! // 0 is the fast spin animation, set at 30 tics of ring boost or higher!
@ -7499,7 +7507,7 @@ void K_KartPlayerHUDUpdate(player_t *player)
if (player->karthud[khud_ringspblock] >= 14) // debt animation if (player->karthud[khud_ringspblock] >= 14) // debt animation
{ {
if ((player->rings > 0) // Get out of 0 ring animation if ((player->hudrings > 0) // Get out of 0 ring animation
&& (normalanim == 3 || normalanim == 10)) // on these transition frames. && (normalanim == 3 || normalanim == 10)) // on these transition frames.
player->karthud[khud_ringspblock] = normalanim; player->karthud[khud_ringspblock] = normalanim;
else else
@ -7507,7 +7515,7 @@ void K_KartPlayerHUDUpdate(player_t *player)
} }
else // normal animation else // normal animation
{ {
if ((player->rings <= 0) // Go into 0 ring animation if ((player->hudrings <= 0) // Go into 0 ring animation
&& (player->karthud[khud_ringspblock] == 1 || player->karthud[khud_ringspblock] == 8)) // on these transition frames. && (player->karthud[khud_ringspblock] == 1 || player->karthud[khud_ringspblock] == 8)) // on these transition frames.
player->karthud[khud_ringspblock] = debtanim; player->karthud[khud_ringspblock] = debtanim;
else else

View file

@ -457,6 +457,7 @@ static void P_NetArchivePlayers(savebuffer_t *save)
WRITEUINT8(save->p, players[i].sadtimer); WRITEUINT8(save->p, players[i].sadtimer);
WRITESINT8(save->p, players[i].rings); WRITESINT8(save->p, players[i].rings);
WRITESINT8(save->p, players[i].hudrings);
WRITEUINT8(save->p, players[i].pickuprings); WRITEUINT8(save->p, players[i].pickuprings);
WRITEUINT8(save->p, players[i].ringdelay); WRITEUINT8(save->p, players[i].ringdelay);
WRITEUINT16(save->p, players[i].ringboost); WRITEUINT16(save->p, players[i].ringboost);
@ -882,6 +883,7 @@ static void P_NetUnArchivePlayers(savebuffer_t *save)
players[i].sadtimer = READUINT8(save->p); players[i].sadtimer = READUINT8(save->p);
players[i].rings = READSINT8(save->p); players[i].rings = READSINT8(save->p);
players[i].hudrings = READSINT8(save->p);
players[i].pickuprings = READUINT8(save->p); players[i].pickuprings = READUINT8(save->p);
players[i].ringdelay = READUINT8(save->p); players[i].ringdelay = READUINT8(save->p);
players[i].ringboost = READUINT16(save->p); players[i].ringboost = READUINT16(save->p);

View file

@ -1290,6 +1290,29 @@ void P_DoPlayerExit(player_t *player, pflags_t flags)
{ {
ClearFakePlayerSkin(player); ClearFakePlayerSkin(player);
if (!(gametyperules & GTR_SPHERES))
{
player->hudrings = RINGTOTAL(player);
if (player->hudrings > 20)
player->hudrings = 20;
if (grandprixinfo.gp == true
&& grandprixinfo.eventmode == GPEVENT_NONE
&& player->bot == false && losing == false)
{
const UINT8 lifethreshold = 20;
const UINT8 oldExtra = player->totalring / lifethreshold;
const UINT8 extra = (player->totalring + player->hudrings) / lifethreshold;
if (extra > oldExtra)
{
S_StartSound(NULL, sfx_cdfm73);
player->xtralife = (extra - oldExtra);
}
}
}
if ((gametyperules & GTR_CIRCUIT)) // Special Race-like handling if ((gametyperules & GTR_CIRCUIT)) // Special Race-like handling
{ {
K_UpdateAllPlayerPositions(); K_UpdateAllPlayerPositions();
@ -1323,22 +1346,6 @@ void P_DoPlayerExit(player_t *player, pflags_t flags)
{ {
G_BeginLevelExit(); G_BeginLevelExit();
} }
if (grandprixinfo.gp == true
&& (roundqueue.size && roundqueue.position < roundqueue.size) // Not the last map of GP
&& player->bot == false && losing == false)
{
const UINT8 lifethreshold = 20;
const UINT8 oldExtra = player->totalring / lifethreshold;
const UINT8 extra = (player->totalring + RINGTOTAL(player)) / lifethreshold;
if (extra > oldExtra)
{
S_StartSound(NULL, sfx_cdfm73);
player->xtralife = (extra - oldExtra);
}
}
} }
if (demo.playback == false) if (demo.playback == false)