Function scale_cooldown_for_speed

Source
pub fn scale_cooldown_for_speed(
    base_cooldown_ticks: u64,
    speed: i64,
    baseline_speed: u64,
) -> u64
Expand description

Scales a base cooldown duration (in ticks, defined at baseline speed) by the entity’s current speed attribute. Returns the cooldown duration the entity actually experiences.

scaled = base * baseline_speed / max(speed, 1). A speed of 0 or negative is treated as baseline_speed, so unmigrated units keep working at 1×.

Floors at 1 tick when base > 0 so high speeds never collapse a cooldown to zero via integer truncation (which would change semantics from “very fast” to “off cooldown forever”).

baseline_speed is sourced from GameSettings.baseline_speed.