Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: separate handling stat adds #22

Merged
merged 3 commits into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ pub fn get_scalar_response(_pvp: bool) -> Result<JsScalarResponse, JsValue> {
global_range_scalar: rmr.range_all_scale,
hipfire_range_scalar: rmr.range_hip_scale,
ads_scalar: hmr.ads_scale,
draw_scalar: hmr.draw_scale,
draw_scalar: hmr.ready_scale,
stow_scalar: hmr.stow_scale,
reload_scalar: rsmr.reload_time_scale,
mag_size_scalar: mmr.magazine_scale,
Expand Down
10 changes: 5 additions & 5 deletions src/perks/exotic_armor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,8 @@ pub fn exotic_armor() {
|_input: ModifierResponseInput| -> HandlingModifierResponse {
if _input.value > 0 && _input.calc_data.weapon_type == &WeaponType::HANDCANNON {
return HandlingModifierResponse {
stat_add: 100,
ads_scale: 1.0,
draw_scale: 0.6,
ready_add: 100,
ready_scale: 0.6,
..Default::default()
};
}
Expand Down Expand Up @@ -350,8 +349,9 @@ pub fn exotic_armor() {
return HandlingModifierResponse {
stat_add: 100,
ads_scale: 1.0,
draw_scale: 0.6,
ready_scale: 0.6,
stow_scale: 0.6,
..Default::default()
};
}
return HandlingModifierResponse::default();
Expand Down Expand Up @@ -399,7 +399,7 @@ pub fn exotic_armor() {
return HandlingModifierResponse::default();
}
HandlingModifierResponse {
stat_add: 100,
ready_add: 100,
..Default::default()
}
},
Expand Down
12 changes: 10 additions & 2 deletions src/perks/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,17 +226,25 @@ impl Default for FiringModifierResponse {
#[derive(Debug, Clone, PartialEq, Serialize)]
pub struct HandlingModifierResponse {
pub stat_add: i32,
//separated stats
pub stow_add: i32,
pub ready_add: i32,
pub ads_add: i32,

pub stow_scale: f64,
pub draw_scale: f64,
pub ready_scale: f64,
// pub handling_swap_scale: f64,
pub ads_scale: f64,
}
impl Default for HandlingModifierResponse {
fn default() -> Self {
Self {
stat_add: 0,
stow_add: 0,
ready_add: 0,
ads_add: 0,
stow_scale: 1.0,
draw_scale: 1.0,
ready_scale: 1.0,
ads_scale: 1.0,
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/perks/meta_perks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ pub fn meta_perks() {
};
HandlingModifierResponse {
stow_scale: swap_scale,
draw_scale: swap_scale,
ready_scale: swap_scale,
..Default::default()
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/perks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ pub fn get_handling_modifier(
});
handling_modifier.stat_add += tmp.stat_add;
handling_modifier.stow_scale *= tmp.stow_scale;
handling_modifier.draw_scale *= tmp.draw_scale;
handling_modifier.ready_scale *= tmp.ready_scale;
handling_modifier.ads_scale *= tmp.ads_scale;
}
handling_modifier
Expand Down
12 changes: 6 additions & 6 deletions src/perks/other_perks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ pub fn other_perks() {
Box::new(
|_input: ModifierResponseInput| -> HandlingModifierResponse {
HandlingModifierResponse {
draw_scale: 0.9,
ready_scale: 0.9,
stow_scale: 0.9,
..Default::default()
}
Expand All @@ -93,7 +93,7 @@ pub fn other_perks() {
Box::new(
|_input: ModifierResponseInput| -> HandlingModifierResponse {
HandlingModifierResponse {
draw_scale: 0.9,
ready_scale: 0.9,
stow_scale: 0.9,
..Default::default()
}
Expand All @@ -106,7 +106,7 @@ pub fn other_perks() {
Box::new(
|_input: ModifierResponseInput| -> HandlingModifierResponse {
HandlingModifierResponse {
draw_scale: 0.95,
ready_scale: 0.95,
..Default::default()
}
},
Expand Down Expand Up @@ -165,7 +165,7 @@ pub fn other_perks() {
if _input.value >= 1 {
HandlingModifierResponse {
stat_add: 100,
draw_scale: 0.7,
ready_scale: 0.7,
stow_scale: 0.7,
..Default::default()
}
Expand Down Expand Up @@ -205,7 +205,7 @@ pub fn other_perks() {
|_input: ModifierResponseInput| -> HandlingModifierResponse {
HandlingModifierResponse {
stat_add: 40,
draw_scale: 0.95,
ready_scale: 0.95,
stow_scale: 0.95,
..Default::default()
}
Expand Down Expand Up @@ -565,7 +565,7 @@ pub fn other_perks() {
if _input.value > 0 {
HandlingModifierResponse {
stat_add: 40,
draw_scale: 0.925,
ready_scale: 0.925,
stow_scale: 0.925,
..Default::default()
}
Expand Down
11 changes: 6 additions & 5 deletions src/perks/year_1_perks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@ pub fn year_1_perks() {
let time_scale = 0.9_f64.powi(val);
HandlingModifierResponse {
stat_add: stat,
draw_scale: time_scale,
ready_scale: time_scale,
stow_scale: time_scale,
ads_scale: time_scale,
..Default::default()
}
},
),
Expand Down Expand Up @@ -270,7 +271,7 @@ pub fn year_1_perks() {
if _input.value >= 1 {
HandlingModifierResponse {
stow_scale: 0.8,
draw_scale: 0.8,
ready_scale: 0.8,
..Default::default()
}
} else {
Expand Down Expand Up @@ -730,8 +731,8 @@ pub fn year_1_perks() {
|_input: ModifierResponseInput| -> HandlingModifierResponse {
if _input.value > 0 {
HandlingModifierResponse {
stat_add: 100,
draw_scale: 0.95,
ready_add: 100,
ready_scale: 0.95,
..Default::default()
}
} else {
Expand Down Expand Up @@ -761,7 +762,7 @@ pub fn year_1_perks() {
if _input.value > 0 {
HandlingModifierResponse {
stat_add: 50,
draw_scale: 0.95,
ready_scale: 0.95,
stow_scale: 0.95,
..Default::default()
}
Expand Down
11 changes: 6 additions & 5 deletions src/perks/year_5_perks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ pub fn year_5_perks() {
WeaponType::AUTORIFLE,
WeaponType::HANDCANNON,
WeaponType::BOW,
WeaponType::SCOUTRIFLE
WeaponType::SCOUTRIFLE,
];
let dmg_scale: f64;
let crit_scale: f64;
Expand Down Expand Up @@ -177,7 +177,7 @@ pub fn year_5_perks() {
HandlingModifierResponse {
stat_add: 100,
stow_scale: 1.0,
draw_scale: 0.95,
ready_scale: 0.95,
..Default::default()
}
},
Expand Down Expand Up @@ -294,7 +294,7 @@ pub fn year_5_perks() {
HandlingModifierResponse {
stat_add: handling,
stow_scale: handling_mult,
draw_scale: handling_mult,
ready_scale: handling_mult,
..Default::default()
}
},
Expand Down Expand Up @@ -496,9 +496,10 @@ pub fn year_5_perks() {
handling = 100;
};
HandlingModifierResponse {
stat_add: handling,
ready_add: handling,
stow_add: handling,
stow_scale: handling_mult,
draw_scale: handling_mult,
ready_scale: handling_mult,
..Default::default()
}
},
Expand Down
7 changes: 6 additions & 1 deletion src/types/rs_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::collections::HashMap;

use serde::{Deserialize, Serialize};

use crate::enemies::EnemyType;
use crate::{enemies::EnemyType, perks::clamp};

#[derive(Debug, Clone)]
pub struct DataPointers {
Expand Down Expand Up @@ -89,6 +89,11 @@ impl StatQuadraticFormula {
pub fn solve_at(&self, _x: f64) -> f64 {
self.evpp * _x * _x + self.vpp * _x + self.offset
}

pub fn solve_at_i(&self, x: i32) -> f64 {
let x = x.clamp(0, 100) as f64;
self.evpp * x * x + self.vpp * x + self.offset
}
}

#[derive(Debug, Clone, Default, Serialize)]
Expand Down
14 changes: 10 additions & 4 deletions src/weapons/stat_calc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,17 @@ impl HandlingFormula {
_handling_stat: i32,
_modifiers: HandlingModifierResponse,
) -> HandlingResponse {
let handling_stat = (_handling_stat + _modifiers.stat_add).clamp(0, 100) as f64;
let ready_time = self.ready.solve_at(handling_stat) * _modifiers.draw_scale;
let stow_time = (self.stow.solve_at(handling_stat) * _modifiers.stow_scale)
let handling_stat = _handling_stat + _modifiers.stat_add;

let ready_time =
self.ready.solve_at_i(handling_stat + _modifiers.ready_add) * _modifiers.ready_scale;

let stow_time = (self.stow.solve_at_i(handling_stat + _modifiers.stow_add)
* _modifiers.stow_scale)
.clamp(self.stow.solve_at(100.0), f64::INFINITY);
let ads_time = self.ads.solve_at(handling_stat) * _modifiers.ads_scale;

let ads_time =
self.ads.solve_at_i(handling_stat + _modifiers.ads_add) * _modifiers.ads_scale;

HandlingResponse {
ready_time,
Expand Down