Merge branch 'alt-drift-math-fix' into 'master'

drift math fixes

See merge request kart-krew-dev/ring-racers-internal!2520
This commit is contained in:
Oni VelocitOni 2025-05-10 03:45:25 +00:00
commit 27b6832e7b

View file

@ -3663,27 +3663,28 @@ static void K_GetKartBoostPower(player_t *player)
// Trying to emulate the old leniency timer being stat-based. // Trying to emulate the old leniency timer being stat-based.
// I dunno if this is overkill because turning is already stat-based. // I dunno if this is overkill because turning is already stat-based.
// Should this be a pure constant instead? // 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. // Even when not inputting a turn, drift prediction is hard.
// Turn solver will sometimes need to slightly turn to stay "aligned". // Turn solver will sometimes need to slightly turn to stay "aligned".
// Award full boost even if turn solver creates a fractional miniturn. // Award full boost even if turn solver creates a fractional miniturn.
const INT16 inner_deadzone = KART_FULLTURN / 100; 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); steering = max(steering - inner_deadzone, 0);
fixed_t frac = 0; fixed_t frac = 0;
if (steering < steer_threshold) 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. // Weaken the effect with drifts that were just started.
frac = (frac * abs(player->drift)) / 5; frac = (frac * abs(player->drift)) / 5;
fixed_t multiplier = 0;
if (frac > 0) if (frac > 0)
{ {
if (frac > FRACUNIT) if (frac > FRACUNIT)
@ -3694,7 +3695,7 @@ static void K_GetKartBoostPower(player_t *player)
// Get multiplier from easing function, to // Get multiplier from easing function, to
// heavily reward being near exactly 0. // heavily reward being near exactly 0.
fixed_t multiplier = Easing_InExpo(frac, 0, FRACUNIT); multiplier = Easing_InExpo(frac, 0, FRACUNIT);
if (multiplier > 0) if (multiplier > 0)
{ {
ADDBOOST( ADDBOOST(
@ -3705,6 +3706,14 @@ static void K_GetKartBoostPower(player_t *player)
numboosts--; // No afterimage! 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) if (player->trickcharge)