Store tripwire pass level on the player

Fixes tripwire leniency fadeout - previously broken two commits ago
This commit is contained in:
toaster 2022-08-30 21:22:26 +01:00
parent 6b8d729b2c
commit 2c91f83a02
9 changed files with 61 additions and 42 deletions

View file

@ -204,11 +204,19 @@ typedef enum
typedef enum
{
TRIP_NONE,
TRIP_PASSED,
TRIP_BLOCKED,
TRIPSTATE_NONE,
TRIPSTATE_PASSED,
TRIPSTATE_BLOCKED,
} tripwirestate_t;
typedef enum
{
TRIPWIRE_NONE,
TRIPWIRE_IGNORE,
TRIPWIRE_BOOST,
TRIPWIRE_BLASTER,
} tripwirepass_t;
typedef enum
{
// Unsynced, HUD or clientsided effects
@ -446,6 +454,8 @@ typedef struct player_s
UINT16 draftleeway; // Leniency timer before removing draft power
SINT8 lastdraft; // (-1 to 15) - Last player being drafted
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.
UINT16 itemroulette; // Used for the roulette when deciding what item to give you (was "pw_kartitem")
@ -515,8 +525,6 @@ typedef struct player_s
SINT8 glanceDir; // Direction the player is trying to look backwards in
UINT8 tripWireState; // see tripwirestate_t
//
SINT8 lives;

View file

@ -2410,7 +2410,6 @@ void G_PlayerReborn(INT32 player, boolean betweenmaps)
p->karthud[khud_fault] = khudfault;
p->nocontrol = nocontrol;
p->kickstartaccel = kickstartaccel;
p->tripWireState = TRIP_NONE;
p->botvars.rubberband = FRACUNIT;
p->botvars.controller = UINT16_MAX;

View file

@ -2944,7 +2944,7 @@ boolean K_SlopeResistance(player_t *player)
return false;
}
UINT8 K_TripwirePassConditions(player_t *player)
tripwirepass_t K_TripwirePassConditions(player_t *player)
{
if (
player->invincibilitytimer ||
@ -2969,7 +2969,7 @@ UINT8 K_TripwirePassConditions(player_t *player)
boolean K_TripwirePass(player_t *player)
{
return ((K_TripwirePassConditions(player) != TRIPWIRE_NONE) || (player->tripwireLeniency > 0));
return (player->tripwirePass != TRIPWIRE_NONE);
}
boolean K_WaterRun(player_t *player)
@ -3676,7 +3676,7 @@ void K_TumblePlayer(player_t *player, mobj_t *inflictor, mobj_t *source)
player->tumbleBounces = 1;
if (player->tripWireState == TRIP_PASSED)
if (player->tripwireState == TRIPSTATE_PASSED)
{
player->tumbleHeight = 50;
}
@ -3790,15 +3790,15 @@ void K_TumbleInterrupt(player_t *player)
void K_ApplyTripWire(player_t *player, tripwirestate_t state)
{
if (state == TRIP_PASSED)
if (state == TRIPSTATE_PASSED)
S_StartSound(player->mo, sfx_ssa015);
else if (state == TRIP_BLOCKED)
else if (state == TRIPSTATE_BLOCKED)
S_StartSound(player->mo, sfx_kc40);
player->tripWireState = state;
player->tripwireState = state;
K_AddHitLag(player->mo, 10, false);
if (state == TRIP_PASSED && player->spinouttimer &&
if (state == TRIPSTATE_PASSED && player->spinouttimer &&
player->speed > 2 * K_GetKartSpeed(player, false, true))
{
K_TumblePlayer(player, NULL, NULL);
@ -7219,18 +7219,9 @@ static void K_UpdateTripwire(player_t *player)
fixed_t speedThreshold = (3*K_GetKartSpeed(player, false, true))/4;
boolean goodSpeed = (player->speed >= speedThreshold);
boolean boostExists = (player->tripwireLeniency > 0); // can't be checked later because of subtractions...
tripwirepass_t triplevel = K_TripwirePassConditions(player);
if (boostExists)
{
player->tripwireLeniency--;
if (goodSpeed == false && player->tripwireLeniency > 0)
{
// Decrease at double speed when your speed is bad.
player->tripwireLeniency--;
}
}
if (K_TripwirePassConditions(player) != TRIPWIRE_NONE)
if (triplevel != TRIPWIRE_NONE)
{
if (!boostExists)
{
@ -7247,8 +7238,26 @@ static void K_UpdateTripwire(player_t *player)
P_SetMobjState(back, S_TRIPWIREBOOST_BOTTOM);
}
player->tripwirePass = triplevel;
player->tripwireLeniency = max(player->tripwireLeniency, TRIPWIRETIME);
}
else
{
if (boostExists)
{
player->tripwireLeniency--;
if (goodSpeed == false && player->tripwireLeniency > 0)
{
// Decrease at double speed when your speed is bad.
player->tripwireLeniency--;
}
}
if (player->tripwireLeniency <= 0)
{
player->tripwirePass = TRIPWIRE_NONE;
}
}
}
/** \brief Decreases various kart timers and powers per frame. Called in P_PlayerThink in p_user.c
@ -7718,14 +7727,14 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd)
// Handle invincibility sfx
K_UpdateInvincibilitySounds(player); // Also thanks, VAda!
if (player->tripWireState != TRIP_NONE)
if (player->tripwireState != TRIPSTATE_NONE)
{
if (player->tripWireState == TRIP_PASSED)
if (player->tripwireState == TRIPSTATE_PASSED)
S_StartSound(player->mo, sfx_cdfm63);
else if (player->tripWireState == TRIP_BLOCKED)
else if (player->tripwireState == TRIPSTATE_BLOCKED)
S_StartSound(player->mo, sfx_kc4c);
player->tripWireState = TRIP_NONE;
player->tripwireState = TRIPSTATE_NONE;
}
K_KartEbrakeVisuals(player);

View file

@ -121,13 +121,7 @@ void K_StripOther(player_t *player);
void K_MomentumToFacing(player_t *player);
boolean K_ApplyOffroad(player_t *player);
boolean K_SlopeResistance(player_t *player);
#define TRIPWIRE_BLASTER 0x03
#define TRIPWIRE_BOOST 0x02
#define TRIPWIRE_IGNORE 0x01
#define TRIPWIRE_NONE 0x00
UINT8 K_TripwirePassConditions(player_t *player);
tripwirepass_t K_TripwirePassConditions(player_t *player);
boolean K_TripwirePass(player_t *player);
boolean K_WaterRun(player_t *player);
void K_ApplyTripWire(player_t *player, tripwirestate_t state);

View file

@ -292,6 +292,10 @@ static int player_get(lua_State *L)
lua_pushinteger(L, plr->draftleeway);
else if (fastcmp(field,"lastdraft"))
lua_pushinteger(L, plr->lastdraft);
else if (fastcmp(field,"tripwireState"))
lua_pushinteger(L, plr->tripwireState);
else if (fastcmp(field,"tripwirePass"))
lua_pushinteger(L, plr->tripwirePass);
else if (fastcmp(field,"tripwireLeniency"))
lua_pushinteger(L, plr->tripwireLeniency);
else if (fastcmp(field,"itemroulette"))
@ -646,6 +650,10 @@ static int player_set(lua_State *L)
plr->draftleeway = luaL_checkinteger(L, 3);
else if (fastcmp(field,"lastdraft"))
plr->lastdraft = luaL_checkinteger(L, 3);
else if (fastcmp(field,"tripwireState"))
plr->tripwireState = luaL_checkinteger(L, 3);
else if (fastcmp(field,"tripwirePass"))
plr->tripwirePass = luaL_checkinteger(L, 3);
else if (fastcmp(field,"tripwireLeniency"))
plr->tripwireLeniency = luaL_checkinteger(L, 3);
else if (fastcmp(field,"itemroulette"))

View file

@ -3801,7 +3801,7 @@ void P_BouncePlayerMove(mobj_t *mo)
if (P_IsLineTripWire(bestslideline))
{
// TRIPWIRE CANNOT BE MADE NONBOUNCY
K_ApplyTripWire(mo->player, TRIP_BLOCKED);
K_ApplyTripWire(mo->player, TRIPSTATE_BLOCKED);
}
else
{

View file

@ -7184,7 +7184,6 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
{
fixed_t convSpeed = (mobj->target->player->speed * 100) / K_GetKartSpeed(mobj->target->player, false, true);
UINT8 trans = ((mobj->target->player->tripwireLeniency + 1) * (NUMTRANSMAPS+1)) / TRIPWIRETIME;
UINT8 triplevel = K_TripwirePassConditions(mobj->target->player);
if (trans > NUMTRANSMAPS)
trans = NUMTRANSMAPS;
@ -7193,14 +7192,14 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
if ((trans >= NUMTRANSMAPS) // not a valid visibility
|| (convSpeed < 150 && (leveltime & 1)) // < 150% flickering
|| (triplevel < TRIPWIRE_BOOST) // Not strong enough to make an aura
|| (mobj->target->player->tripwirePass < TRIPWIRE_BOOST) // Not strong enough to make an aura
|| mobj->target->player->flamedash) // Flameshield dash
{
mobj->renderflags |= RF_DONTDRAW;
}
else
{
boolean blastermode = (convSpeed >= 200) && (triplevel >= TRIPWIRE_BLASTER);
boolean blastermode = (convSpeed >= 200) && (mobj->target->player->tripwirePass >= TRIPWIRE_BLASTER);
mobj->renderflags &= ~(RF_TRANSMASK|RF_DONTDRAW);
if (trans != 0)

View file

@ -291,6 +291,8 @@ static void P_NetArchivePlayers(void)
WRITEUINT16(save_p, players[i].draftleeway);
WRITESINT8(save_p, players[i].lastdraft);
WRITEUINT8(save_p, players[i].tripwireState);
WRITEUINT8(save_p, players[i].tripwirePass);
WRITEUINT16(save_p, players[i].tripwireLeniency);
WRITEUINT16(save_p, players[i].itemroulette);
@ -355,7 +357,6 @@ static void P_NetArchivePlayers(void)
WRITEUINT32(save_p, players[i].spheredigestion);
WRITESINT8(save_p, players[i].glanceDir);
WRITEUINT8(save_p, players[i].tripWireState);
WRITEUINT8(save_p, players[i].typing_timer);
WRITEUINT8(save_p, players[i].typing_duration);
@ -575,6 +576,8 @@ static void P_NetUnArchivePlayers(void)
players[i].draftleeway = READUINT16(save_p);
players[i].lastdraft = READSINT8(save_p);
players[i].tripwireState = READUINT8(save_p);
players[i].tripwirePass = READUINT8(save_p);
players[i].tripwireLeniency = READUINT16(save_p);
players[i].itemroulette = READUINT16(save_p);
@ -639,7 +642,6 @@ static void P_NetUnArchivePlayers(void)
players[i].spheredigestion = READUINT32(save_p);
players[i].glanceDir = READSINT8(save_p);
players[i].tripWireState = READUINT8(save_p);
players[i].typing_timer = READUINT8(save_p);
players[i].typing_duration = READUINT8(save_p);

View file

@ -2070,7 +2070,7 @@ void P_CrossSpecialLine(line_t *line, INT32 side, mobj_t *thing)
if (P_IsLineTripWire(line))
{
K_ApplyTripWire(player, TRIP_PASSED);
K_ApplyTripWire(player, TRIPSTATE_PASSED);
}
switch (line->special)