Skip to main content

subtr_actor/domain/
boost_units.rs

1/// The maximum raw boost value stored in replay data.
2///
3/// Rocket League replays represent boost on a `0..=255` scale rather than a
4/// `0..=100` percentage scale.
5pub const BOOST_MAX_AMOUNT: f32 = u8::MAX as f32;
6
7/// The raw replay boost amount players spawn with at each standard kickoff.
8///
9/// Rocket League starts each kickoff with one third of a full tank, which maps
10/// cleanly to `85.0` on the replay's `0..=255` boost scale.
11pub const BOOST_KICKOFF_START_AMOUNT: f32 = BOOST_MAX_AMOUNT / 3.0;
12
13/// The rate at which boost drains while active, in raw replay units per second.
14pub const BOOST_USED_RAW_UNITS_PER_SECOND: f32 = 80.0 / 0.93;
15
16/// The rate at which boost drains while active, in percentage points per second.
17pub const BOOST_USED_PERCENT_PER_SECOND: f32 =
18    BOOST_USED_RAW_UNITS_PER_SECOND * 100.0 / BOOST_MAX_AMOUNT;
19
20/// Converts a raw replay boost amount (`0..=255`) to a percentage (`0..=100`).
21pub fn boost_amount_to_percent(boost_amount: f32) -> f32 {
22    boost_amount * 100.0 / BOOST_MAX_AMOUNT
23}
24
25/// Converts a boost percentage (`0..=100`) to a raw replay boost amount (`0..=255`).
26pub fn boost_percent_to_amount(boost_percent: f32) -> f32 {
27    boost_percent * BOOST_MAX_AMOUNT / 100.0
28}
29
30#[deprecated(
31    note = "BOOST_USED_PER_SECOND is measured in raw replay units. Use BOOST_USED_RAW_UNITS_PER_SECOND or BOOST_USED_PERCENT_PER_SECOND instead."
32)]
33pub const BOOST_USED_PER_SECOND: f32 = BOOST_USED_RAW_UNITS_PER_SECOND;