Reduce hitlag when rapidly punting hazards

This commit is contained in:
AJ Martinez 2023-12-30 23:53:33 -07:00
parent bce2cd55dd
commit 1fe6be9b75
4 changed files with 28 additions and 2 deletions

View file

@ -932,6 +932,8 @@ struct player_t
UINT8 wavedashdelay; // How long since the last sliptide? Only boost once you've been straightened out for a bit.
UINT16 wavedashboost; // The actual boost granted from wavedash.
UINT16 speedpunt;
UINT16 trickcharge; // Landed normally from a trick panel? Get the benefits package!
UINT16 infinitether; // Generic infinitether time, used for infinitether leniency.

View file

@ -3784,16 +3784,27 @@ void K_DoInstashield(player_t *player)
void K_DoPowerClash(mobj_t *t1, mobj_t *t2) {
mobj_t *clash;
UINT8 lag1 = 5;
UINT8 lag2 = 5;
// short-circuit instashield for vfx visibility
if (t1->player)
{
t1->player->instashield = 1;
t1->player->speedpunt += 20;
lag1 -= min(lag1, t1->player->speedpunt/10);
}
if (t2->player)
{
t2->player->instashield = 1;
t2->player->speedpunt += 20;
lag2 -= min(lag1, t2->player->speedpunt/10);
}
S_StartSound(t1, sfx_parry);
K_AddHitLag(t1, 6, false);
K_AddHitLag(t2, 6, false);
K_AddHitLag(t1, lag1+1, false);
K_AddHitLag(t2, lag2+1, false);
clash = P_SpawnMobj((t1->x/2) + (t2->x/2), (t1->y/2) + (t2->y/2), (t1->z/2) + (t2->z/2), MT_POWERCLASH);
@ -8551,6 +8562,13 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd)
player->wavedashboost--;
}
if (player->speedpunt)
player->speedpunt--;
// This timer can get out of control fast, clamp to match player expectations about "new" hazards
if (player->speedpunt > TICRATE*4)
player->speedpunt = TICRATE*4;
if (player->trickcharge > 0 && onground == true)
{
player->trickcharge--;

View file

@ -335,6 +335,8 @@ static int player_get(lua_State *L)
lua_pushinteger(L, plr->wavedashdelay);
else if (fastcmp(field,"wavedashboost"))
lua_pushinteger(L, plr->wavedashboost);
else if (fastcmp(field,"speedpunt"))
lua_pushinteger(L, plr->speedpunt);
else if (fastcmp(field,"trickcharge"))
lua_pushinteger(L, plr->trickcharge);
else if (fastcmp(field,"infinitether"))
@ -831,6 +833,8 @@ static int player_set(lua_State *L)
plr->wavedashdelay = luaL_checkinteger(L, 3);
else if (fastcmp(field,"wavedashboost"))
plr->wavedashboost = luaL_checkinteger(L, 3);
else if (fastcmp(field,"speedpunt"))
plr->speedpunt = luaL_checkinteger(L, 3);
else if (fastcmp(field,"trickcharge"))
plr->trickcharge = luaL_checkinteger(L, 3);
else if (fastcmp(field,"infinitether"))

View file

@ -561,6 +561,7 @@ static void P_NetArchivePlayers(savebuffer_t *save)
WRITEUINT16(save->p, players[i].wavedash);
WRITEUINT8(save->p, players[i].wavedashdelay);
WRITEUINT16(save->p, players[i].wavedashboost);
WRITEUINT16(save->p, players[i].speedpunt);
WRITEUINT16(save->p, players[i].trickcharge);
WRITEUINT16(save->p, players[i].infinitether);
@ -1114,6 +1115,7 @@ static void P_NetUnArchivePlayers(savebuffer_t *save)
players[i].wavedash = READUINT16(save->p);
players[i].wavedashdelay = READUINT8(save->p);
players[i].wavedashboost = READUINT16(save->p);
players[i].speedpunt = READUINT16(save->p);
players[i].trickcharge = READUINT16(save->p);
players[i].infinitether = READUINT16(save->p);