drift math fixes

This commit is contained in:
Ashnal 2025-05-01 21:26:50 -04:00
parent 65c41cf6ce
commit 266c6d702e

View file

@ -3665,27 +3665,28 @@ static void K_GetKartBoostPower(player_t *player)
// Trying to emulate the old leniency timer being stat-based.
// I dunno if this is overkill because turning is already stat-based.
// Should this be a pure constant instead?
const INT16 max_steer_threshold = (KART_FULLTURN * 5) / 6;
const fixed_t max_steer_threshold = (FRACUNIT * KART_FULLTURN * 5) / 6;
// Even when not inputting a turn, drift prediction is hard.
// Turn solver will sometimes need to slightly turn to stay "aligned".
// Award full boost even if turn solver creates a fractional miniturn.
const INT16 inner_deadzone = KART_FULLTURN / 100;
INT32 steer_threshold = FixedMul((FRACUNIT * player->kartweight) / 9, max_steer_threshold);
INT16 steer_threshold = FixedMul((FRACUNIT * player->kartweight) / 9, max_steer_threshold)>>FRACBITS;
INT32 steering = abs(player->steering);
INT16 steering = abs(player->steering);
steering = max(steering - inner_deadzone, 0);
fixed_t frac = 0;
if (steering < steer_threshold)
{
frac = FixedDiv(steer_threshold - steering, steer_threshold);
frac = FixedDiv(FRACUNIT*(steer_threshold - steering), FRACUNIT*(steer_threshold));
}
// Weaken the effect with drifts that were just started.
frac = (frac * abs(player->drift)) / 5;
fixed_t multiplier = 0;
if (frac > 0)
{
if (frac > FRACUNIT)
@ -3696,7 +3697,7 @@ static void K_GetKartBoostPower(player_t *player)
// Get multiplier from easing function, to
// heavily reward being near exactly 0.
fixed_t multiplier = Easing_InExpo(frac, 0, FRACUNIT);
multiplier = Easing_InExpo(frac, 0, FRACUNIT);
if (multiplier > 0)
{
ADDBOOST(
@ -3707,6 +3708,14 @@ static void K_GetKartBoostPower(player_t *player)
numboosts--; // No afterimage!
}
}
// Debug print for neutral drift
// CONS_Printf("Drift debug: %d/%d = %f (speed +%.0f%%, accel +%.0f%%)\n",
// steering,
// steer_threshold,
// FIXED_TO_FLOAT(frac),
// FIXED_TO_FLOAT(FixedMul(multiplier, 4*FRACUNIT/10)*100),
// FIXED_TO_FLOAT(FixedMul(multiplier, FRACUNIT/3)*100));
}
if (player->trickcharge)