zenno/mspeed: account for accelTime >= dur

This commit is contained in:
2026-05-22 23:39:17 -04:00
parent 9f8024d488
commit d0fa6ab15c

View File

@@ -283,6 +283,12 @@ export function speedGain(speedBonus: number, accel: number, decel: number, dur:
// and does not include the acceleration back to baseline after it ends.
const accelTime = speedBonus / accel;
const decelTime = -speedBonus / decel;
if (accelTime >= dur) {
// Acceleration is so low that the horse won't reach the boosted target
// speed before the effect ends. E.g., G surface aptitude.
const peakSpeed = accel * dur;
return 0.5 * (peakSpeed * dur - peakSpeed / decel);
}
// speedBonus*(dur-accelTime) + speedBonus*accelTime/2 + speedBonus*decelTime/2
return speedBonus * (dur + 0.5 * (decelTime - accelTime));
}