diff --git a/src/d_player.h b/src/d_player.h index cf7788101..d0995e4c2 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -791,6 +791,7 @@ struct player_t UINT8 tripwireState; // see tripwirestate_t UINT8 tripwirePass; // see tripwirepass_t UINT16 tripwireLeniency; // When reaching a state that lets you go thru tripwire, you get an extra second leniency after it ends to still go through it. + UINT8 tripwireAirLeniency; // Timer that elongates tripwire leniency when in midair. UINT8 fakeBoost; // Some items need to grant tripwire pass briefly, even when their effect is thrust/instathrust. This is a fake boost type to control that. itemroulette_t itemRoulette; // Item roulette data diff --git a/src/k_kart.c b/src/k_kart.c index aec2533c1..0f28eba7c 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -9297,17 +9297,34 @@ static void K_UpdateTripwire(player_t *player) { if (boostExists) { - player->tripwireLeniency--; - if (goodSpeed == false && player->tripwireLeniency > 0) + // If player is MOSTLY on the ground. + // Arbitrary number based on other code that claimed the player is often + // slightly aerial in ground-to-ground transitions and other such edge cases. + if (player->airtime < 2) { - // Decrease at double speed when your speed is bad. player->tripwireLeniency--; + if (goodSpeed == false && player->tripwireLeniency > 0) + { + // Decrease at double speed when your speed is bad. + player->tripwireLeniency--; + } + } + // ...Until they're NOT, in which case tripwire leniency is reduced at a decimal rate! + else + { + player->tripwireAirLeniency++; + if (player->tripwireAirLeniency >= 5) // Once every 5 tics + { + player->tripwireAirLeniency = 0; + player->tripwireLeniency--; + } } } if (player->tripwireLeniency <= 0 && triplevel == TRIPWIRE_NONE) { player->tripwirePass = TRIPWIRE_NONE; + player->tripwireAirLeniency = 0; } } } diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index 552742d4b..6cad86a53 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -378,6 +378,8 @@ static int player_get(lua_State *L) lua_pushinteger(L, plr->fakeBoost); else if (fastcmp(field,"tripwireleniency")) lua_pushinteger(L, plr->tripwireLeniency); + else if (fastcmp(field,"tripwireairleniency")) + lua_pushinteger(L, plr->tripwireAirLeniency); else if (fastcmp(field,"tripwirerebounddelay")) lua_pushinteger(L, plr->tripwireReboundDelay); else if (fastcmp(field,"eggmantransferdelay")) @@ -1021,6 +1023,8 @@ static int player_set(lua_State *L) plr->fakeBoost = luaL_checkinteger(L, 3); else if (fastcmp(field,"tripwireleniency")) plr->tripwireLeniency = luaL_checkinteger(L, 3); + else if (fastcmp(field,"tripwireairleniency")) + plr->tripwireAirLeniency = luaL_checkinteger(L, 3); else if (fastcmp(field,"tripwirerebounddelay")) plr->tripwireReboundDelay = luaL_checkinteger(L, 3); else if (fastcmp(field,"eggmantransferdelay")) diff --git a/src/p_saveg.cpp b/src/p_saveg.cpp index 040370163..3f80ce27c 100644 --- a/src/p_saveg.cpp +++ b/src/p_saveg.cpp @@ -520,6 +520,7 @@ static void P_NetArchivePlayers(savebuffer_t *save) WRITEUINT8(save->p, players[i].tripwireState); WRITEUINT8(save->p, players[i].tripwirePass); WRITEUINT16(save->p, players[i].tripwireLeniency); + WRITEUINT8(save->p, players[i].tripwireAirLeniency); WRITEUINT8(save->p, players[i].fakeBoost); WRITESINT8(save->p, players[i].itemtype); @@ -1182,6 +1183,7 @@ static void P_NetUnArchivePlayers(savebuffer_t *save) players[i].tripwireState = READUINT8(save->p); players[i].tripwirePass = READUINT8(save->p); players[i].tripwireLeniency = READUINT16(save->p); + players[i].tripwireAirLeniency = READUINT8(save->p); players[i].fakeBoost = READUINT8(save->p); players[i].itemtype = READSINT8(save->p);