Merge branch 'failsafe-input-check' into 'master'

Failsafe fixes

See merge request KartKrew/Kart!1599
This commit is contained in:
Oni 2023-11-05 21:53:57 +00:00
commit ef8c472a51
5 changed files with 21 additions and 3 deletions

View file

@ -902,6 +902,8 @@ struct player_t
UINT8 instaWhipChargeLockout;
UINT8 guardCooldown;
UINT8 preventfailsafe; // Set when taking damage to prevent cheesing eggboxes
UINT8 handtimer;
angle_t besthanddirection;

View file

@ -8250,6 +8250,9 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd)
if (player->invincibilitytimer && onground == true)
player->invincibilitytimer--;
if (player->preventfailsafe)
player->preventfailsafe--;
if ((player->respawn.state == RESPAWNST_NONE) && player->growshrinktimer != 0)
{
if (player->growshrinktimer > 0 && onground == true)
@ -10783,7 +10786,8 @@ static void K_AirFailsafe(player_t *player)
const fixed_t thrustSpeed = 6*player->mo->scale; // 10*player->mo->scale
if (player->speed > maxSpeed // Above the max speed that you're allowed to use this technique.
|| player->respawn.state != RESPAWNST_NONE) // Respawning, you don't need this AND drop dash :V
|| player->respawn.state != RESPAWNST_NONE // Respawning, you don't need this AND drop dash :V
|| player->preventfailsafe) // You just got hit or interacted with something committal, no mashing for distance
{
player->pflags &= ~PF_AIRFAILSAFE;
return;
@ -10793,9 +10797,12 @@ static void K_AirFailsafe(player_t *player)
if (leveltime < introtime)
return;
if ((K_GetKartButtons(player) & BT_ACCELERATE) || K_GetForwardMove(player) != 0)
UINT8 buttons = K_GetKartButtons(player);
// Accel inputs queue air-failsafe for when they're released,
// as long as they're not part of a fastfall attempt.
if ((buttons & (BT_ACCELERATE|BT_BRAKE)) == BT_ACCELERATE || K_GetForwardMove(player) != 0)
{
// Queue up later
player->pflags |= PF_AIRFAILSAFE;
return;
}

View file

@ -337,6 +337,8 @@ static int player_get(lua_State *L)
lua_pushinteger(L, plr->instaWhipCooldown);
else if (fastcmp(field,"guardCooldown"))
lua_pushinteger(L, plr->guardCooldown);
else if (fastcmp(field,"preventfailsafe"))
lua_pushinteger(L, plr->preventfailsafe);
/*
else if (fastcmp(field,"itemroulette"))
lua_pushinteger(L, plr->itemroulette);
@ -819,6 +821,8 @@ static int player_set(lua_State *L)
plr->instaWhipCharge = luaL_checkinteger(L, 3);
else if (fastcmp(field,"guardCooldown"))
plr->guardCooldown = luaL_checkinteger(L, 3);
else if (fastcmp(field,"preventfailsafe"))
plr->preventfailsafe = luaL_checkinteger(L, 3);
/*
else if (fastcmp(field,"itemroulette"))
plr->itemroulette = luaL_checkinteger(L, 3);

View file

@ -3046,6 +3046,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da
player->fastfall = 0;
player->ringboost = 0;
player->glanceDir = 0;
player->preventfailsafe = TICRATE*3;
player->pflags &= ~PF_GAINAX;
if (player->spectator == false && !(player->charflags & SF_IRONMAN))

View file

@ -547,6 +547,8 @@ static void P_NetArchivePlayers(savebuffer_t *save)
WRITEUINT8(save->p, players[i].instaWhipCooldown);
WRITEUINT8(save->p, players[i].guardCooldown);
WRITEUINT8(save->p, players[i].preventfailsafe);
WRITEUINT8(save->p, players[i].handtimer);
WRITEANGLE(save->p, players[i].besthanddirection);
@ -1061,6 +1063,8 @@ static void P_NetUnArchivePlayers(savebuffer_t *save)
players[i].instaWhipCooldown = READUINT8(save->p);
players[i].guardCooldown = READUINT8(save->p);
players[i].preventfailsafe = READUINT8(save->p);
players[i].handtimer = READUINT8(save->p);
players[i].besthanddirection = READANGLE(save->p);