diff --git a/index.html b/index.html index 3e71d77..713d460 100644 --- a/index.html +++ b/index.html @@ -317,6 +317,10 @@

Tune Calculator

hammer_hit_fire_delay: 0 }; + function physics_scaling_linear_invert(value, tick_speed) { + return value * (tick_speed / 50.0); + } + function physics_scaling_linear(value, tick_speed) { return value / (tick_speed / 50.0); } @@ -346,22 +350,22 @@

Tune Calculator

physics_scaling_linear(550.0, tick_speed), physics_scaling_linear(2000.0, tick_speed), physics_scaling_linear(2200.0, tick_speed), - physics_scaling_linear(2.0, tick_speed), + physics_scaling_linear_invert(2.0, tick_speed), physics_scaling_linear(1000.0, tick_speed), - physics_scaling_linear(2.0, tick_speed), - physics_scaling_linear(150.0, tick_speed), + physics_scaling_linear_invert(2.0, tick_speed), + physics_scaling_linear_invert(150.0, tick_speed), physics_scaling_linear(400.0, tick_speed), physics_scaling_linear(10.0, tick_speed), physics_scaling_linear(6.0, tick_speed), physics_scaling_linear(1.0, tick_speed), - physics_scaling_linear(1.25, tick_speed), - physics_scaling_linear(125.0, tick_speed), - physics_scaling_linear(125.0, tick_speed), - physics_scaling_linear(500.0, tick_speed), - physics_scaling_linear(500.0, tick_speed), - physics_scaling_linear(800.0, tick_speed), - physics_scaling_linear(800.0, tick_speed), - physics_scaling_linear(320.0, tick_speed) + physics_scaling_linear_invert(1.25, tick_speed), + physics_scaling_linear_invert(125.0, tick_speed), + physics_scaling_linear_invert(125.0, tick_speed), + physics_scaling_linear_invert(500.0, tick_speed), + physics_scaling_linear_invert(500.0, tick_speed), + physics_scaling_linear_invert(800.0, tick_speed), + physics_scaling_linear_invert(800.0, tick_speed), + physics_scaling_linear_invert(320.0, tick_speed) ); } @@ -388,8 +392,7 @@

Tune Calculator

const cell1 = row.insertCell(0); const cell2 = row.insertCell(1); cell1.innerText = formatKey(key); - const decimals = decimalPrecision[key] !== undefined ? decimalPrecision[key] : 4; - cell2.innerText = formatNumber(value, decimals); + cell2.innerText = value; } resultsDiv.innerHTML = ''; @@ -400,16 +403,11 @@

Tune Calculator

return key.replace(/_/g, ' ').replace(/\b\w/g, char => char.toUpperCase()); } - function formatNumber(value, decimals) { - return parseFloat(value.toFixed(decimals)).toString(); - } - function generateTuneCommands(tunes) { let commands = ''; for (const [key, value] of Object.entries(tunes)) { const decimals = decimalPrecision[key] !== undefined ? decimalPrecision[key] : 4; - const formattedValue = formatNumber(value, decimals); - commands += `tune ${key} ${formattedValue};`; + commands += `tune ${key} ${value};`; } commands += ''; return commands.trim(); diff --git a/src/main.rs b/src/main.rs index bc1e8f4..9367a96 100644 --- a/src/main.rs +++ b/src/main.rs @@ -34,6 +34,10 @@ struct Tunes { hammer_hit_fire_delay: f32, } +fn physics_scaling_linear_invert(value: f32, tick_speed: i32) -> f32 { + value * { tick_speed as f32 / 50.0 } +} + fn physics_scaling_linear(value: f32, tick_speed: i32) -> f32 { value / { tick_speed as f32 / 50.0 } } @@ -63,22 +67,22 @@ fn calculate_tunes(tick_speed: i32) -> Tunes { velramp_start: physics_scaling_linear(550.0, tick_speed), velramp_range: physics_scaling_linear(2000.0, tick_speed), gun_speed: physics_scaling_linear(2200.0, tick_speed), - gun_lifetime: physics_scaling_linear(2.0, tick_speed), + gun_lifetime: physics_scaling_linear_invert(2.0, tick_speed), grenade_speed: physics_scaling_linear(1000.0, tick_speed), - grenade_lifetime: physics_scaling_linear(2.0, tick_speed), - laser_bounce_delay: physics_scaling_linear(150.0, tick_speed), + grenade_lifetime: physics_scaling_linear_invert(2.0, tick_speed), + laser_bounce_delay: physics_scaling_linear_invert(150.0, tick_speed), jetpack_strength: physics_scaling_linear(400.0, tick_speed), shotgun_strength: physics_scaling_linear(10.0, tick_speed), explosion_strength: physics_scaling_linear(6.0, tick_speed), hammer_strength: physics_scaling_linear(1.0, tick_speed), - hook_duration: physics_scaling_linear(1.25, tick_speed), - hammer_fire_delay: physics_scaling_linear(125.0, tick_speed), - gun_fire_delay: physics_scaling_linear(125.0, tick_speed), - shotgun_fire_delay: physics_scaling_linear(500.0, tick_speed), - grenade_fire_delay: physics_scaling_linear(500.0, tick_speed), - laser_fire_delay: physics_scaling_linear(800.0, tick_speed), - ninja_fire_delay: physics_scaling_linear(800.0, tick_speed), - hammer_hit_fire_delay: physics_scaling_linear(320.0, tick_speed), + hook_duration: physics_scaling_linear_invert(1.25, tick_speed), + hammer_fire_delay: physics_scaling_linear_invert(125.0, tick_speed), + gun_fire_delay: physics_scaling_linear_invert(125.0, tick_speed), + shotgun_fire_delay: physics_scaling_linear_invert(500.0, tick_speed), + grenade_fire_delay: physics_scaling_linear_invert(500.0, tick_speed), + laser_fire_delay: physics_scaling_linear_invert(800.0, tick_speed), + ninja_fire_delay: physics_scaling_linear_invert(800.0, tick_speed), + hammer_hit_fire_delay: physics_scaling_linear_invert(320.0, tick_speed), } }