Skip to content

Commit

Permalink
fix reported issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Teero888 committed Nov 15, 2024
1 parent 4cfc69c commit 4f62400
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 30 deletions.
36 changes: 17 additions & 19 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,10 @@ <h1>Tune Calculator</h1>
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);
}
Expand Down Expand Up @@ -346,22 +350,22 @@ <h1>Tune Calculator</h1>
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)
);
}

Expand All @@ -388,8 +392,7 @@ <h1>Tune Calculator</h1>
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 = '';
Expand All @@ -400,16 +403,11 @@ <h1>Tune Calculator</h1>
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();
Expand Down
26 changes: 15 additions & 11 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
Expand Down Expand Up @@ -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),
}
}

Expand Down

0 comments on commit 4f62400

Please sign in to comment.