Merge branch 'blackhole-fault' into 'master'

Fault rework

See merge request KartKrew/Kart!910
This commit is contained in:
toaster 2023-02-13 23:23:07 +00:00
commit b2bd5ecccd
7 changed files with 87 additions and 9 deletions

View file

@ -107,6 +107,8 @@ typedef enum
PF_SHRINKME = 1<<28, // "Shrink me" cheat preference PF_SHRINKME = 1<<28, // "Shrink me" cheat preference
PF_SHRINKACTIVE = 1<<29, // "Shrink me" cheat is in effect. (Can't be disabled mid-race) PF_SHRINKACTIVE = 1<<29, // "Shrink me" cheat is in effect. (Can't be disabled mid-race)
PF_VOID = 1<<30, // Removed from reality! When leaving hitlag, reenable visibility+collision and kill speed.
// up to 1<<31 is free // up to 1<<31 is free
} pflags_t; } pflags_t;
@ -579,6 +581,8 @@ struct player_t
tic_t ebrakefor; // Ebrake timer, used for visuals. tic_t ebrakefor; // Ebrake timer, used for visuals.
UINT16 faultflash; // Used for misc FAULT visuals
UINT32 roundscore; // battle score this round UINT32 roundscore; // battle score this round
UINT8 emeralds; UINT8 emeralds;
UINT8 bumpers; UINT8 bumpers;

View file

@ -7788,6 +7788,37 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd)
player->superring--; player->superring--;
} }
if (player->pflags & PF_VOID) // Returning from FAULT VOID
{
player->pflags &= ~PF_VOID;
player->mo->renderflags &= ~RF_DONTDRAW;
player->mo->flags &= ~MF_NOCLIPTHING;
player->mo->momx = 0;
player->mo->momy = 0;
player->mo->momz = 0;
player->nocontrol = 0;
player->driftboost = 0;
player->strongdriftboost = 0;
player->tiregrease = 0;
player->sneakertimer = 0;
player->spindashboost = 0;
player->flashing = TICRATE/2;
player->ringboost = 0;
player->driftboost = player->strongdriftboost = 0;
player->gateBoost = 0;
}
if (player->pflags & PF_FAULT && player->nocontrol) // Hold player on respawn platform, no fair skipping long POSITION areas
{
if (rainbowstartavailable && ((leveltime <= starttime) || (leveltime - starttime < 10*TICRATE)))
{
player->nocontrol = 50;
player->mo->renderflags |= RF_DONTDRAW;
player->mo->flags |= MF_NOCLIPTHING;
}
}
if (player->stealingtimer == 0 if (player->stealingtimer == 0
&& player->rocketsneakertimer) && player->rocketsneakertimer)
player->rocketsneakertimer--; player->rocketsneakertimer--;

View file

@ -119,6 +119,8 @@ void K_DoFault(player_t *player)
S_StartSound(player->mo, sfx_s3k83); S_StartSound(player->mo, sfx_s3k83);
player->karthud[khud_fault] = 1; player->karthud[khud_fault] = 1;
player->pflags |= PF_FAULT; player->pflags |= PF_FAULT;
player->mo->renderflags |= RF_DONTDRAW;
player->mo->flags |= MF_NOCLIPTHING;
} }
} }
@ -147,7 +149,12 @@ void K_DoIngameRespawn(player_t *player)
// FAULT // FAULT
if (leveltime < starttime) if (leveltime < starttime)
{
if (!(mapheaderinfo[gamemap-1]->levelflags & LF_SECTIONRACE))
player->respawn.wp = K_GetFinishLineWaypoint()->prevwaypoints[0];
K_DoFault(player); K_DoFault(player);
}
player->ringboost = 0; player->ringboost = 0;
player->driftboost = player->strongdriftboost = 0; player->driftboost = player->strongdriftboost = 0;
@ -163,7 +170,7 @@ void K_DoIngameRespawn(player_t *player)
player->respawn.pointz += K_RespawnOffset(player, player->respawn.flip); player->respawn.pointz += K_RespawnOffset(player, player->respawn.flip);
player->respawn.manual = false; // one respawn only! player->respawn.manual = false; // one respawn only!
} }
else if (player->respawn.wp != NULL && leveltime >= starttime) else if (player->respawn.wp != NULL)
{ {
const UINT32 dist = RESPAWN_DIST + (player->airtime * 48); const UINT32 dist = RESPAWN_DIST + (player->airtime * 48);
player->respawn.distanceleft = (dist * mapobjectscale) / FRACUNIT; player->respawn.distanceleft = (dist * mapobjectscale) / FRACUNIT;
@ -272,7 +279,7 @@ void K_DoIngameRespawn(player_t *player)
player->respawn.init = true; player->respawn.init = true;
player->respawn.airtimer = player->airtime; player->respawn.airtimer = player->airtime;
player->respawn.truedeath = false; player->respawn.truedeath = !!(player->pflags & PF_FAULT);
} }
/*-------------------------------------------------- /*--------------------------------------------------
@ -612,6 +619,9 @@ static void K_DropDashWait(player_t *player)
if (player->nocontrol == 0) if (player->nocontrol == 0)
player->respawn.timer--; player->respawn.timer--;
if (player->pflags & PF_FAULT)
return;
if (leveltime % 8 == 0) if (leveltime % 8 == 0)
{ {
const UINT8 ns = 8; const UINT8 ns = 8;

View file

@ -9805,6 +9805,17 @@ void P_MobjThinker(mobj_t *mobj)
mobj->eflags |= MFE_PAUSED; mobj->eflags |= MFE_PAUSED;
mobj->hitlag--; mobj->hitlag--;
if (mobj->player != NULL && mobj->player->faultflash > 0)
{
ClearFakePlayerSkin(mobj->player);
if (mobj->player->faultflash & 1)
mobj->renderflags |= RF_DONTDRAW;
else
mobj->renderflags &= ~RF_DONTDRAW;
mobj->player->faultflash--;
}
if (mobj->type == MT_DROPTARGET && mobj->reactiontime > 0 && mobj->hitlag == 2) if (mobj->type == MT_DROPTARGET && mobj->reactiontime > 0 && mobj->hitlag == 2)
{ {
mobj->spritexscale = FRACUNIT; mobj->spritexscale = FRACUNIT;

View file

@ -1909,10 +1909,24 @@ static void K_HandleLapIncrement(player_t *player)
{ {
if (leveltime < starttime && !(gametyperules & GTR_ROLLINGSTART)) if (leveltime < starttime && !(gametyperules & GTR_ROLLINGSTART))
{ {
// Will fault the player // freeze 'em until fault penalty is over
K_DoIngameRespawn(player); player->mo->hitlag = starttime - leveltime + TICRATE*3;
P_ResetPlayer(player);
player->pflags |= PF_VOID;
player->mo->renderflags |= RF_DONTDRAW;
player->mo->flags |= MF_NOCLIPTHING;
player->nocontrol = UINT16_MAX;
player->hyudorotimer = UINT16_MAX;
player->speed = 0;
K_StripItems(player);
player->faultflash = TICRATE/3;
ClearFakePlayerSkin(player);
S_StartSound(player->mo, sfx_s3k8a);
P_MoveOrigin(player->mo, player->mo->old_x, player->mo->old_y, player->mo->z);
return;
} }
else if ((player->starpostnum == numstarposts) || (player->laps == 0))
if ((player->starpostnum == numstarposts) || (player->laps == 0))
{ {
size_t i = 0; size_t i = 0;
UINT8 nump = 0; UINT8 nump = 0;
@ -1948,7 +1962,7 @@ static void K_HandleLapIncrement(player_t *player)
player->karthud[khud_lapanimation] = 80; player->karthud[khud_lapanimation] = 80;
} }
if (rainbowstartavailable == true) if (rainbowstartavailable == true && player->mo->hitlag == 0)
{ {
S_StartSound(player->mo, sfx_s23c); S_StartSound(player->mo, sfx_s23c);
player->startboost = 125; player->startboost = 125;

View file

@ -4210,7 +4210,14 @@ void P_PlayerThink(player_t *player)
if (player->nocontrol && player->nocontrol < UINT16_MAX) if (player->nocontrol && player->nocontrol < UINT16_MAX)
{ {
if (!(--player->nocontrol)) if (!(--player->nocontrol))
player->pflags &= ~PF_FAULT; {
if (player->pflags & PF_FAULT)
{
player->pflags &= ~PF_FAULT;
player->mo->renderflags &= ~RF_DONTDRAW;
player->mo->flags &= ~MF_NOCLIPTHING;
}
}
} }
else else
player->nocontrol = 0; player->nocontrol = 0;

View file

@ -433,7 +433,7 @@ void SetRandomFakePlayerSkin(player_t* player, boolean fast)
SetFakePlayerSkin(player, i); SetFakePlayerSkin(player, i);
if (player->mo && player->spectator == false) if (player->mo && player->spectator == false && !(player->pflags & PF_VOID))
{ {
S_StartSound(player->mo, sfx_kc33); S_StartSound(player->mo, sfx_kc33);
S_StartSound(player->mo, sfx_cdfm44); S_StartSound(player->mo, sfx_cdfm44);
@ -448,6 +448,7 @@ void SetRandomFakePlayerSkin(player_t* player, boolean fast)
P_SetTarget(&box->target, parent); P_SetTarget(&box->target, parent);
box->angle = FixedAngle((baseangle + j*90) * FRACUNIT); box->angle = FixedAngle((baseangle + j*90) * FRACUNIT);
box->flags2 |= MF2_AMBUSH; box->flags2 |= MF2_AMBUSH;
box->renderflags |= parent->renderflags;
if (fast) if (fast)
{ {
box->extravalue1 = 10; // Rotation rate box->extravalue1 = 10; // Rotation rate
@ -500,7 +501,7 @@ void ClearFakePlayerSkin(player_t* player)
if ((flags & SF_IRONMAN) && !P_MobjWasRemoved(player->mo)) if ((flags & SF_IRONMAN) && !P_MobjWasRemoved(player->mo))
{ {
SetFakePlayerSkin(player, skinid); SetFakePlayerSkin(player, skinid);
if (player->spectator == false) if (player->spectator == false && player->mo->hitlag == 0)
{ {
S_StartSound(player->mo, sfx_s3k9f); S_StartSound(player->mo, sfx_s3k9f);
K_SpawnMagicianParticles(player->mo, 5); K_SpawnMagicianParticles(player->mo, 5);