* Restore player colour and colorization correctly when the Eggman Mark concludes its effect.

* Allow colorisation types to not completely crowd each other out.
    * For example, it's possible for invincibility + grow to flicker Invincibility, Eggman mark, and grow colours if the conditions for each type of flash are true on different frames!
This commit is contained in:
toaster 2022-05-23 22:04:14 +01:00
parent 14053a55cd
commit 17d007d418
6 changed files with 57 additions and 33 deletions

View file

@ -1447,8 +1447,7 @@ static void SendNameAndColor(UINT8 n)
player->skincolor = cv_playercolor[n].value; player->skincolor = cv_playercolor[n].value;
if (player->mo && !player->dye) K_KartResetPlayerColor(player);
player->mo->color = player->skincolor;
// Update follower for local games: // Update follower for local games:
if (cv_follower[n].value >= -1 && cv_follower[n].value != player->followerskin) if (cv_follower[n].value >= -1 && cv_follower[n].value != player->followerskin)

View file

@ -3548,8 +3548,7 @@ static void K_RemoveGrowShrink(player_t *player)
else if (player->growshrinktimer < 0) // Play Grow noise else if (player->growshrinktimer < 0) // Play Grow noise
S_StartSound(player->mo, sfx_kc5a); S_StartSound(player->mo, sfx_kc5a);
if (player->invincibilitytimer == 0) K_KartResetPlayerColor(player);
player->mo->color = player->skincolor;
player->mo->scalespeed = mapobjectscale/TICRATE; player->mo->scalespeed = mapobjectscale/TICRATE;
player->mo->destscale = mapobjectscale; player->mo->destscale = mapobjectscale;
@ -7571,6 +7570,9 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd)
if (player->eggmanexplode <= 0) if (player->eggmanexplode <= 0)
{ {
mobj_t *eggsexplode; mobj_t *eggsexplode;
K_KartResetPlayerColor(player);
//player->flashing = 0; //player->flashing = 0;
eggsexplode = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_SPBEXPLOSION); eggsexplode = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_SPBEXPLOSION);
if (player->eggmanblame >= 0 if (player->eggmanblame >= 0
@ -7650,37 +7652,45 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd)
K_HandleDelayedHitByEm(player); K_HandleDelayedHitByEm(player);
} }
void K_KartPlayerAfterThink(player_t *player) void K_KartResetPlayerColor(player_t *player)
{ {
boolean forcereset = false;
boolean fullbright = false; boolean fullbright = false;
if (player->playerstate == PST_DEAD || (player->respawn.state == RESPAWNST_MOVE)) // Ensure these are set correctly here if (!player->mo || P_MobjWasRemoved(player->mo)) // Can't do anything
return;
if (player->mo->health <= 0 || player->playerstate == PST_DEAD || (player->respawn.state == RESPAWNST_MOVE)) // Override everything
{ {
player->mo->colorized = (player->dye != 0); player->mo->colorized = (player->dye != 0);
player->mo->color = player->dye ? player->dye : player->skincolor; player->mo->color = player->dye ? player->dye : player->skincolor;
goto finalise;
} }
else if (player->eggmanexplode) // You're gonna diiiiie
if (player->eggmanexplode) // You're gonna diiiiie
{ {
const INT32 flashtime = 4<<(player->eggmanexplode/TICRATE); const INT32 flashtime = 4<<(player->eggmanexplode/TICRATE);
if (player->eggmanexplode == 1 || (player->eggmanexplode % (flashtime/2) != 0)) if (player->eggmanexplode == 1 || (player->eggmanexplode % (flashtime/2) != 0))
{ {
player->mo->colorized = (player->dye != 0); forcereset = true;
player->mo->color = player->dye ? player->dye : player->skincolor;
} }
else if (player->eggmanexplode % flashtime == 0) else if (player->eggmanexplode % flashtime == 0)
{ {
player->mo->colorized = true; player->mo->colorized = true;
player->mo->color = SKINCOLOR_BLACK; player->mo->color = SKINCOLOR_BLACK;
fullbright = true; fullbright = true;
goto finalise;
} }
else else
{ {
player->mo->colorized = true; player->mo->colorized = true;
player->mo->color = SKINCOLOR_CRIMSON; player->mo->color = SKINCOLOR_CRIMSON;
fullbright = true; fullbright = true;
goto finalise;
} }
} }
else if (player->invincibilitytimer)
if (player->invincibilitytimer) // You're gonna kiiiiill
{ {
const tic_t defaultTime = itemtime+(2*TICRATE); const tic_t defaultTime = itemtime+(2*TICRATE);
tic_t flicker = 2; tic_t flicker = 2;
@ -7691,45 +7701,57 @@ void K_KartPlayerAfterThink(player_t *player)
{ {
player->mo->color = K_RainbowColor(leveltime / 2); player->mo->color = K_RainbowColor(leveltime / 2);
player->mo->colorized = true; player->mo->colorized = true;
forcereset = false;
} }
else else
{ {
player->mo->color = player->skincolor;
player->mo->colorized = false;
flicker += (defaultTime - player->invincibilitytimer) / TICRATE / 2; flicker += (defaultTime - player->invincibilitytimer) / TICRATE / 2;
forcereset = true;
} }
if (leveltime % flicker == 0) if (leveltime % flicker == 0)
{ {
player->mo->color = SKINCOLOR_INVINCFLASH; player->mo->color = SKINCOLOR_INVINCFLASH;
player->mo->colorized = true; player->mo->colorized = true;
forcereset = false;
}
if (!forcereset)
{
goto finalise;
} }
} }
else if (player->growshrinktimer) // Ditto, for grow/shrink
if (player->growshrinktimer) // Ditto, for grow/shrink
{ {
if (player->growshrinktimer % 5 == 0) if (player->growshrinktimer % 5 == 0)
{ {
player->mo->colorized = true; player->mo->colorized = true;
player->mo->color = (player->growshrinktimer < 0 ? SKINCOLOR_CREAMSICLE : SKINCOLOR_PERIWINKLE); player->mo->color = (player->growshrinktimer < 0 ? SKINCOLOR_CREAMSICLE : SKINCOLOR_PERIWINKLE);
fullbright = true; fullbright = true;
goto finalise;
} }
else
{ forcereset = true;
player->mo->colorized = (player->dye != 0);
player->mo->color = player->dye ? player->dye : player->skincolor;
}
} }
else if (player->ringboost && (leveltime & 1)) // ring boosting
if (player->ringboost && (leveltime & 1)) // ring boosting
{ {
player->mo->colorized = true; player->mo->colorized = true;
fullbright = true; fullbright = true;
goto finalise;
} }
else else
{ {
player->mo->colorized = (player->dye != 0); player->mo->colorized = (player->dye != 0);
if (forcereset)
{
player->mo->color = player->dye ? player->dye : player->skincolor;
}
} }
finalise:
if (player->curshield) if (player->curshield)
{ {
fullbright = true; fullbright = true;
@ -7744,6 +7766,11 @@ void K_KartPlayerAfterThink(player_t *player)
if (!(player->mo->state->frame & FF_FULLBRIGHT)) if (!(player->mo->state->frame & FF_FULLBRIGHT))
player->mo->frame &= ~FF_FULLBRIGHT; player->mo->frame &= ~FF_FULLBRIGHT;
} }
}
void K_KartPlayerAfterThink(player_t *player)
{
K_KartResetPlayerColor(player);
// Move held objects (Bananas, Orbinaut, etc) // Move held objects (Bananas, Orbinaut, etc)
K_MoveHeldObjects(player); K_MoveHeldObjects(player);
@ -8859,6 +8886,8 @@ void K_StripOther(player_t *player)
{ {
player->eggmanexplode = 0; player->eggmanexplode = 0;
player->eggmanblame = -1; player->eggmanblame = -1;
K_KartResetPlayerColor(player);
} }
} }

View file

@ -61,6 +61,7 @@ void K_SpawnInvincibilitySpeedLines(mobj_t *mo);
void K_SpawnBumpEffect(mobj_t *mo); void K_SpawnBumpEffect(mobj_t *mo);
void K_KartMoveAnimation(player_t *player); void K_KartMoveAnimation(player_t *player);
void K_KartPlayerHUDUpdate(player_t *player); void K_KartPlayerHUDUpdate(player_t *player);
void K_KartResetPlayerColor(player_t *player);
void K_KartPlayerThink(player_t *player, ticcmd_t *cmd); void K_KartPlayerThink(player_t *player, ticcmd_t *cmd);
void K_KartPlayerAfterThink(player_t *player); void K_KartPlayerAfterThink(player_t *player);
angle_t K_MomentumAngle(mobj_t *mo); angle_t K_MomentumAngle(mobj_t *mo);

View file

@ -1767,8 +1767,7 @@ static boolean P_KillPlayer(player_t *player, mobj_t *inflictor, mobj_t *source,
player->carry = CR_NONE; player->carry = CR_NONE;
player->mo->color = player->skincolor; K_KartResetPlayerColor(player);
player->mo->colorized = false;
P_ResetPlayer(player); P_ResetPlayer(player);

View file

@ -1691,8 +1691,7 @@ static void P_CheckInvincibilityTimer(player_t *player)
// Resume normal music stuff. // Resume normal music stuff.
if (player->invincibilitytimer == 1) if (player->invincibilitytimer == 1)
{ {
player->mo->color = player->skincolor; //K_KartResetPlayerColor(player); -- this gets called every tic anyways
player->mo->colorized = false;
G_GhostAddColor((INT32) (player - players), GHC_NORMAL); G_GhostAddColor((INT32) (player - players), GHC_NORMAL);
P_RestoreMusic(player); P_RestoreMusic(player);
@ -2679,8 +2678,7 @@ static void P_DeathThink(player_t *player)
if (!player->mo) if (!player->mo)
return; return;
player->mo->colorized = false; //K_KartResetPlayerColor(player); -- called at death, don't think we need to re-establish
player->mo->color = player->skincolor;
P_CalcHeight(player); P_CalcHeight(player);
} }

View file

@ -27,6 +27,9 @@
#include "p_local.h" #include "p_local.h"
#include "dehacked.h" // get_number (for thok) #include "dehacked.h" // get_number (for thok)
#include "m_cond.h" #include "m_cond.h"
#if 0
#include "k_kart.h" // K_KartResetPlayerColor
#endif
#ifdef HWRENDER #ifdef HWRENDER
#include "hardware/hw_md2.h" #include "hardware/hw_md2.h"
#endif #endif
@ -285,7 +288,7 @@ void SetPlayerSkinByNum(INT32 playernum, INT32 skinnum)
{ {
player_t *player = &players[playernum]; player_t *player = &players[playernum];
skin_t *skin = &skins[skinnum]; skin_t *skin = &skins[skinnum];
UINT16 newcolor = 0; //UINT16 newcolor = 0;
//UINT8 i; //UINT8 i;
if (skinnum >= 0 && skinnum < numskins && R_SkinUsable(playernum, skinnum)) // Make sure it exists! if (skinnum >= 0 && skinnum < numskins && R_SkinUsable(playernum, skinnum)) // Make sure it exists!
@ -311,6 +314,7 @@ void SetPlayerSkinByNum(INT32 playernum, INT32 skinnum)
} }
player->skincolor = newcolor = skin->prefcolor; player->skincolor = newcolor = skin->prefcolor;
K_KartResetPlayerColor(player);
} }
#endif #endif
@ -323,12 +327,6 @@ void SetPlayerSkinByNum(INT32 playernum, INT32 skinnum)
if (player->mo) if (player->mo)
{ {
player->mo->skin = skin; player->mo->skin = skin;
if (newcolor)
{
player->mo->color = newcolor;
}
P_SetScale(player->mo, player->mo->scale); P_SetScale(player->mo, player->mo->scale);
P_SetPlayerMobjState(player->mo, player->mo->state-states); // Prevent visual errors when switching between skins with differing number of frames P_SetPlayerMobjState(player->mo, player->mo->state-states); // Prevent visual errors when switching between skins with differing number of frames
} }