From 706b91d5e3720f69a12918a14cbdce5ea559ef76 Mon Sep 17 00:00:00 2001 From: Harm Brammer Date: Tue, 29 Aug 2023 13:42:01 -0400 Subject: [PATCH 01/38] chore: bump cached_build --- build_resources/cached_build.ron | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/build_resources/cached_build.ron b/build_resources/cached_build.ron index eb57ef12..4ed94ab9 100644 --- a/build_resources/cached_build.ron +++ b/build_resources/cached_build.ron @@ -1,5 +1,5 @@ ( - last_manifest_version: "117696.23.08.01.1700-1-bnet.51271", + last_manifest_version: "118365.23.08.23.1700-1-bnet.51829", dim_perk_mappings: [ (23371658, 2551157718), (64866129, 3038247973), @@ -12,6 +12,7 @@ (254337357, 1427256713), (288411554, 3425386926), (331667533, 3751912585), + (332733060, 555281244), (344235611, 2978966579), (395388285, 1771339417), (402033656, 1631667848), @@ -22,11 +23,13 @@ (494941759, 4071163871), (509594246, 2846385770), (536173722, 691659142), + (561986700, 1119449540), (573122728, 3400784728), (595108252, 671806388), (598607952, 2396489472), (617966211, 2652708987), (624891305, 3047969693), + (639190697, 31345821), (706172244, 4252909580), (711234314, 3511092054), (711628886, 2272927194), @@ -73,6 +76,7 @@ (1720528630, 2173046394), (1738338041, 3526486541), (1748774930, 2387244414), + (1771736209, 3828510309), (1905598698, 2888557110), (1906147653, 3523296417), (1926441324, 2048641572), @@ -84,6 +88,7 @@ (2037312142, 2594592626), (2091001077, 1275731761), (2139363611, 744594675), + (2140591236, 2319119708), (2216471363, 1683379515), (2217963031, 2586829431), (2241043034, 1782407750), @@ -149,9 +154,11 @@ (4085959009, 1749209109), (4100396181, 3018146897), (4116820839, 957782887), + (4175584682, 1451849462), (4183521337, 2590710093), (4200236906, 1365187766), (4207509907, 2450788523), + (4223976499, 3017780555), (4245865861, 1820235745), (4274613598, 4274614370), (4290541820, 2610012052), @@ -222,7 +229,6 @@ (1326668122, 904), (1338909520, 903), (1361856293, 904), - (1370384437, 907), (1395789926, 908), (1447716563, 903), (1451602450, 901), @@ -276,13 +282,11 @@ (2178772051, 903), (2189829540, 903), (2213377102, 905), - (2213429699, 907), (2260949877, 902), (2263539715, 902), (2305599261, 906), (2353477480, 902), (2409208302, 906), - (2444870733, 907), (2458294492, 906), (2470575005, 905), (2490530085, 903), @@ -319,7 +323,6 @@ (3252839262, 906), (3272152575, 905), (3274444880, 906), - (3291480605, 907), (3320257055, 904), (3332480988, 911), (3355499393, 903), @@ -352,7 +355,6 @@ (3841661468, 902), (3913106382, 906), (3920852688, 902), - (3923638944, 907), (3983457027, 904), (4000302358, 906), (4008973208, 905), From 22929dcd9a92b9758a5d4f4b1948a5aab22d55a1 Mon Sep 17 00:00:00 2001 From: Harm Brammer Date: Tue, 29 Aug 2023 13:39:38 -0400 Subject: [PATCH 02/38] fix: clippy compile --- build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.rs b/build.rs index 767c0f2f..5ffbfad1 100644 --- a/build.rs +++ b/build.rs @@ -355,7 +355,7 @@ fn write_variable( ) { let res = writeln!( writer, - "#[doc=r#\"{}\"#]\n#[allow(dead_code)]\npub const {}: {} = {};", + "#[doc=r#\"{}\"#]\n#[allow(dead_code)]\n#[allow(clippy::approx_constant)]\npub const {}: {} = {};", doc, name, datatype, value ); if res.is_err() { From 0f52e554f18f3d68e8473c42e69c0e60fd68b93d Mon Sep 17 00:00:00 2001 From: Harm Brammer Date: Tue, 29 Aug 2023 13:39:49 -0400 Subject: [PATCH 03/38] chore: set clippy as default linter --- .vscode/settings.json | 1 + 1 file changed, 1 insertion(+) diff --git a/.vscode/settings.json b/.vscode/settings.json index 0b935fbf..33442c22 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,4 +3,5 @@ "rust-analyzer.cargo.extraEnv": { "IS_RA": "true" }, + "rust-analyzer.check.command": "clippy", } \ No newline at end of file From d406c3ff03c442d1773fc16dfc48e1a924b28b7f Mon Sep 17 00:00:00 2001 From: Harm Brammer Date: Tue, 29 Aug 2023 13:49:48 -0400 Subject: [PATCH 04/38] chore: clippy cleanup --- build.rs | 30 +++++++++++++----------------- src/abilities/mod.rs | 8 +++----- src/activity/damage_calc.rs | 10 ++++------ src/activity/mod.rs | 10 ++++------ src/d2_enums.rs | 6 +++--- src/enemies/mod.rs | 8 +++----- src/lib.rs | 2 +- src/logging.rs | 8 +++----- src/types/js_types.rs | 12 ++++++------ src/types/rs_types.rs | 6 +++--- src/weapons/dps_calc.rs | 24 +++++++++++------------- src/weapons/mod.rs | 4 ++-- src/weapons/reserve_calc.rs | 5 ++--- src/weapons/stat_calc.rs | 8 ++++---- src/weapons/weapon_constructor.rs | 2 +- 15 files changed, 63 insertions(+), 80 deletions(-) diff --git a/build.rs b/build.rs index 5ffbfad1..edac65d9 100644 --- a/build.rs +++ b/build.rs @@ -23,13 +23,13 @@ impl CachedBuildData { fn get_timestamp(&mut self, formula: &impl UuidTimestamp) -> u64 { // get current unix time - let uuid = (formula.uuid() * 10.0).to_bits() as u64; + let uuid = (formula.uuid() * 10.0).to_bits(); let now = std::time::SystemTime::now() .duration_since(std::time::UNIX_EPOCH) .unwrap() .as_secs(); - if !self.perk_formula_timestamps.contains_key(&uuid) { - self.perk_formula_timestamps.insert(uuid, now); + if let std::collections::btree_map::Entry::Vacant(e) = self.perk_formula_timestamps.entry(uuid) { + e.insert(now); now } else { *self.perk_formula_timestamps.get(&uuid).unwrap() @@ -416,11 +416,9 @@ fn main() { //check if being run by rust-analyzer let is_rust_analyzer = std::env::var("IS_RA"); - if is_rust_analyzer.is_ok() { - if is_rust_analyzer.unwrap() == "true" { - println!("cargo:warning=running in rust-analyzer"); - return; - } + if is_rust_analyzer.is_ok() && is_rust_analyzer.unwrap() == "true" { + println!("cargo:warning=running in rust-analyzer"); + return; } let file_res = std::fs::File::create("./build_resources/cached_build.ron"); @@ -698,10 +696,10 @@ fn construct_weapon_formulas(formula_file: &mut File, cached: &mut CachedBuildDa firing_data.push(firing); } - if err_list.len() > 0 { + if !err_list.is_empty() { return Err(err_list); } - return Ok(()); + Ok(()) }; let set_data_res = set_data(inner_values.clone()); if set_data_res.is_err() { @@ -804,14 +802,12 @@ fn construct_enhance_perk_mapping(formula_file: &mut File, cached: &mut CachedBu println!("cargo:warning=dim enhanced mapping not found"); return; } + } else if cached.has_data() { + println!("cargo:warning=using cached dim enhanced mapping"); + let mut dim_mappings = cached.dim_perk_mappings.clone(); + perk_mappings.append(&mut dim_mappings); } else { - if cached.has_data() { - println!("cargo:warning=using cached dim enhanced mapping"); - let mut dim_mappings = cached.dim_perk_mappings.clone(); - perk_mappings.append(&mut dim_mappings); - } else { - panic!("cargo:warning=no cached dim enhanced mapping found"); - } + panic!("cargo:warning=no cached dim enhanced mapping found"); } if has_internet { diff --git a/src/abilities/mod.rs b/src/abilities/mod.rs index f5f7e5ba..eaa7b554 100644 --- a/src/abilities/mod.rs +++ b/src/abilities/mod.rs @@ -1,4 +1,5 @@ #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +#[derive(Default)] pub enum AbilityType { GRENADE, MELEE, @@ -9,13 +10,10 @@ pub enum AbilityType { WEAPON, ARMOR, MISC, + #[default] UNKNOWN, } -impl Default for AbilityType { - fn default() -> Self { - AbilityType::UNKNOWN - } -} + #[derive(Debug, Clone, Default)] pub struct AbilityDamageProfile { diff --git a/src/activity/damage_calc.rs b/src/activity/damage_calc.rs index f9ff2b63..7bc92b98 100644 --- a/src/activity/damage_calc.rs +++ b/src/activity/damage_calc.rs @@ -14,16 +14,14 @@ pub struct DifficultyData { const WEAPON_DELTA_EXPONENT: f64 = 0.00672; #[derive(Debug, Clone)] +#[derive(Default)] pub enum DifficultyOptions { + #[default] NORMAL = 1, RAID = 2, MASTER = 3, } -impl Default for DifficultyOptions { - fn default() -> Self { - DifficultyOptions::NORMAL - } -} + impl DifficultyOptions { pub fn get_difficulty_data(&self) -> DifficultyData { match self { @@ -96,7 +94,7 @@ impl From for DifficultyOptions { } pub(super) fn rpl_mult(_rpl: f64) -> f64 { - return (1.0 + ((1.0 / 30.0) * _rpl)) / (4.0 / 3.0); + (1.0 + ((1.0 / 30.0) * _rpl)) / (4.0 / 3.0) } pub(super) fn get_gear_delta_mult(_activity: &Activity) -> f64 { diff --git a/src/activity/mod.rs b/src/activity/mod.rs index 3b5508ea..91a47bde 100644 --- a/src/activity/mod.rs +++ b/src/activity/mod.rs @@ -3,17 +3,15 @@ use self::damage_calc::{get_gear_delta_mult, rpl_mult, DifficultyOptions, get_we pub mod damage_calc; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +#[derive(Default)] pub enum PlayerClass { + #[default] Unknown = 0, Titan = 1, Hunter = 2, Warlock = 3, } -impl Default for PlayerClass { - fn default() -> Self { - PlayerClass::Unknown - } -} + #[derive(Debug, Clone, Default)] pub struct Player { @@ -48,7 +46,7 @@ impl Default for Activity { } impl Activity { pub fn get_pl_delta(&self) -> f64 { - get_gear_delta_mult(&self)*get_wep_delta_mult(&self) + get_gear_delta_mult(self)*get_wep_delta_mult(self) } pub fn get_rpl_mult(&self) -> f64 { rpl_mult(self.rpl as f64) diff --git a/src/d2_enums.rs b/src/d2_enums.rs index cf34bb2d..0b7c9313 100644 --- a/src/d2_enums.rs +++ b/src/d2_enums.rs @@ -142,9 +142,9 @@ impl From for StatHashes { } } } -impl Into for StatHashes { - fn into(self) -> u32 { - match self { +impl From for u32 { + fn from(val: StatHashes) -> Self { + match val { StatHashes::ACCURACY => 1591432999, StatHashes::AIM_ASSIST => 1345609583, StatHashes::AIRBORNE => 2714457168, diff --git a/src/enemies/mod.rs b/src/enemies/mod.rs index c268b587..0b4e73ce 100644 --- a/src/enemies/mod.rs +++ b/src/enemies/mod.rs @@ -1,21 +1,19 @@ use crate::activity::Activity; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +#[derive(Default)] pub enum EnemyType { MINOR, ELITE, MINIBOSS, BOSS, VEHICLE, + #[default] ENCLAVE, PLAYER, CHAMPION, } -impl Default for EnemyType { - fn default() -> Self { - EnemyType::ENCLAVE - } -} + #[derive(Debug, Clone, Default)] pub struct Enemy { diff --git a/src/lib.rs b/src/lib.rs index d7e9084c..571aa04e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -80,7 +80,7 @@ extern "C" { #[macro_export] macro_rules! console_log { - ($($t:tt)*) => (crate::log(&format_args!($($t)*).to_string())) + ($($t:tt)*) => ($crate::log(&format_args!($($t)*).to_string())) } #[wasm_bindgen(start)] diff --git a/src/logging.rs b/src/logging.rs index 6a42cbb0..814d9885 100644 --- a/src/logging.rs +++ b/src/logging.rs @@ -1,6 +1,8 @@ #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(Default)] pub enum LogLevel { Error, + #[default] Warning, Info, Debug, @@ -26,11 +28,7 @@ impl From for usize { } } } -impl Default for LogLevel { - fn default() -> Self { - LogLevel::Warning - } -} + fn get_log_level() -> LogLevel { crate::PERS_DATA.with(|perm_data| perm_data.borrow().log_level) diff --git a/src/types/js_types.rs b/src/types/js_types.rs index a4e5f0e1..1a65a6f4 100644 --- a/src/types/js_types.rs +++ b/src/types/js_types.rs @@ -343,9 +343,9 @@ pub enum JsDifficultyOptions { RAID = 2, MASTER = 3, } -impl Into for JsDifficultyOptions { - fn into(self) -> DifficultyOptions { - match self { +impl From for DifficultyOptions { + fn from(val: JsDifficultyOptions) -> Self { + match val { JsDifficultyOptions::NORMAL => DifficultyOptions::NORMAL, JsDifficultyOptions::RAID => DifficultyOptions::RAID, JsDifficultyOptions::MASTER => DifficultyOptions::MASTER, @@ -365,9 +365,9 @@ pub enum JsEnemyType { PLAYER, CHAMPION, } -impl Into for JsEnemyType { - fn into(self) -> EnemyType { - match self { +impl From for EnemyType { + fn from(val: JsEnemyType) -> Self { + match val { JsEnemyType::MINOR => EnemyType::MINOR, JsEnemyType::ELITE => EnemyType::ELITE, JsEnemyType::MINIBOSS => EnemyType::MINIBOSS, diff --git a/src/types/rs_types.rs b/src/types/rs_types.rs index e868470e..5ca87fd4 100644 --- a/src/types/rs_types.rs +++ b/src/types/rs_types.rs @@ -56,7 +56,8 @@ impl Default for DamageMods { } impl DamageMods { pub fn get_mod(&self, _type: &EnemyType) -> f64 { - let combatant_scale = match _type { + + match _type { &EnemyType::MINOR => self.minor, &EnemyType::ELITE => self.elite, &EnemyType::MINIBOSS => self.miniboss, @@ -64,8 +65,7 @@ impl DamageMods { &EnemyType::BOSS => self.boss, &EnemyType::VEHICLE => self.vehicle, _ => 1.0, - }; - combatant_scale + } } } diff --git a/src/weapons/dps_calc.rs b/src/weapons/dps_calc.rs index 41c8497e..139ce5e1 100644 --- a/src/weapons/dps_calc.rs +++ b/src/weapons/dps_calc.rs @@ -19,7 +19,7 @@ pub fn calc_refund(_shots_hit_this_mag: i32, _refunds: Vec) -> ( refund_ammount.1 += refund.refund_reserves; } } - return refund_ammount; + refund_ammount } #[derive(Debug, Clone)] @@ -74,7 +74,7 @@ pub fn calc_extra_dmg( }; extra_time_dmg.push((_total_time + entry.time_for_additive_damage, bonus_dmg)); extra_hits += entry.times_to_hit; - } else if entry.is_dot == false { + } else if !entry.is_dot { for i in 0..entry.times_to_hit { let mut bonus_dmg = entry.additive_damage; bonus_dmg *= _dmg_buffs.get_buff_amount(&entry); @@ -117,8 +117,8 @@ pub fn calc_extra_dmg( pub fn complex_dps_calc(_weapon: Weapon, _enemy: Enemy, _pl_dmg_mult: f64) -> DpsResponse { let weapon = Rc::new(_weapon.clone()); let stats = weapon.stats.clone(); - let weapon_type = weapon.weapon_type.clone(); - let ammo_type = weapon.ammo_type.clone(); + let weapon_type = weapon.weapon_type; + let ammo_type = weapon.ammo_type; let tmp_dmg_prof = weapon.get_damage_profile(); let impact_dmg = tmp_dmg_prof.0; @@ -129,7 +129,7 @@ pub fn complex_dps_calc(_weapon: Weapon, _enemy: Enemy, _pl_dmg_mult: f64) -> Dp let base_mag = weapon.calc_ammo_sizes(None, None, false).mag_size; let maximum_shots = if base_mag * 5 < 15 { 15 } else { base_mag * 5 }; - let firing_settings = _weapon.firing_data.clone(); + let firing_settings = _weapon.firing_data; let perks = weapon.list_perks(); let burst_size = firing_settings.burst_size as f64; @@ -175,7 +175,7 @@ pub fn complex_dps_calc(_weapon: Weapon, _enemy: Enemy, _pl_dmg_mult: f64) -> Dp let handling_data = weapon.calc_handling_times(Some(handling_calc_input), Some(&mut pers_calc_data), false); /////////////////////////////// - let mut start_time = total_time.clone(); + let mut start_time = total_time; while mag > 0 { //DMG MODIFIERS//////////////// let before_shot_input_data = CalculationInput { @@ -196,7 +196,7 @@ pub fn complex_dps_calc(_weapon: Weapon, _enemy: Enemy, _pl_dmg_mult: f64) -> Dp time_total: total_time, time_this_mag: (total_time - start_time), damage_type: &weapon.damage_type, - handling_data: handling_data, + handling_data, num_reloads: num_reloads as f64, has_overshield: false, }; @@ -298,7 +298,7 @@ pub fn complex_dps_calc(_weapon: Weapon, _enemy: Enemy, _pl_dmg_mult: f64) -> Dp time_total: total_time, time_this_mag: (total_time - start_time), damage_type: &weapon.damage_type, - handling_data: handling_data, + handling_data, num_reloads: num_reloads as f64, has_overshield: false, }; @@ -375,11 +375,9 @@ pub fn complex_dps_calc(_weapon: Weapon, _enemy: Enemy, _pl_dmg_mult: f64) -> Dp reserve = 0; break; } - } else { - if total_shots_fired > base_mag * 8 + 20 { - reserve = 0; - break; - } + } else if total_shots_fired > base_mag * 8 + 20 { + reserve = 0; + break; } if reserve <= 0 { break; diff --git a/src/weapons/mod.rs b/src/weapons/mod.rs index c0653145..606a82cb 100644 --- a/src/weapons/mod.rs +++ b/src/weapons/mod.rs @@ -209,10 +209,10 @@ impl Weapon { let a = static_stats.get(key); let b = dynamic_stats.get(key); if a.is_some() { - stat.part_value = a.unwrap().clone(); + stat.part_value = *a.unwrap(); } if b.is_some() { - stat.perk_value = b.unwrap().clone(); + stat.perk_value = *b.unwrap(); } } } diff --git a/src/weapons/reserve_calc.rs b/src/weapons/reserve_calc.rs index ab5ae6a2..502144be 100644 --- a/src/weapons/reserve_calc.rs +++ b/src/weapons/reserve_calc.rs @@ -79,9 +79,8 @@ pub fn calc_reserves(_mag_size: f64, _mag_stat: i32, _inv_stat: i32, _id: u32, _ fn small_machinegun(_mag_size: f64, _mag_stat: i32, _inv_stat: i32) -> f64 { let round_amount = _mag_size.ceil() - _mag_size; let offset = (-0.875 + round_amount * 2.0) * (2.0 - ((100.0 - _mag_stat as f64) / 100.0)); - let reserves = - 225.0 + offset + _inv_stat as f64 * ((225.0 + offset) * 2.0 - (225.0 + offset)) / 100.0; - reserves + + 225.0 + offset + _inv_stat as f64 * ((225.0 + offset) * 2.0 - (225.0 + offset)) / 100.0 } fn trace_rifle(_mag_size: f64, _mag_stat: i32, _inv_stat: i32) -> f64 { diff --git a/src/weapons/stat_calc.rs b/src/weapons/stat_calc.rs index 668a73a6..39ddde64 100644 --- a/src/weapons/stat_calc.rs +++ b/src/weapons/stat_calc.rs @@ -208,7 +208,7 @@ impl AmmoFormula { if _calc_inv { reserve_size = calc_reserves( raw_mag_size, - _mag_stat as i32, + _mag_stat, inv_stat as i32, _inv_id, _inv_modifiers.inv_scale, @@ -347,7 +347,8 @@ impl Weapon { } else { rpm = raw_rpm }; - let out = FiringResponse { + + FiringResponse { pvp_impact_damage: impact_dmg * pvp_damage_modifiers.impact_dmg_scale, pvp_explosion_damage: explosion_dmg * pvp_damage_modifiers.explosive_dmg_scale, pvp_crit_mult: crit_mult * pvp_damage_modifiers.crit_scale, @@ -363,8 +364,7 @@ impl Weapon { rpm, timestamp: fd.timestamp, - }; - out + } } } diff --git a/src/weapons/weapon_constructor.rs b/src/weapons/weapon_constructor.rs index ef2f5efd..97fb0ed5 100644 --- a/src/weapons/weapon_constructor.rs +++ b/src/weapons/weapon_constructor.rs @@ -47,7 +47,7 @@ impl Weapon { let damage_mods: DamageMods = database::SCALAR_DATA[data_pointer.s].clone(); - let firing_data: FiringData = database::FIRING_DATA[data_pointer.f].clone(); + let firing_data: FiringData = database::FIRING_DATA[data_pointer.f]; let ammo_formula: AmmoFormula = database::AMMO_DATA[data_pointer.a].clone(); From 5157c3f41858f5826204e3604f00b62113db5900 Mon Sep 17 00:00:00 2001 From: Harm Brammer Date: Tue, 29 Aug 2023 13:58:20 -0400 Subject: [PATCH 05/38] chore: add Copy trait to Formula types --- src/types/rs_types.rs | 13 ++++++------- src/weapons/weapon_constructor.rs | 10 +++++----- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/types/rs_types.rs b/src/types/rs_types.rs index 5ca87fd4..896b2cfd 100644 --- a/src/types/rs_types.rs +++ b/src/types/rs_types.rs @@ -29,7 +29,7 @@ pub struct FiringData { pub timestamp: u64, } -#[derive(Debug, Clone, Serialize)] +#[derive(Debug, Clone, Copy, Serialize)] pub struct DamageMods { pub pve: f64, pub minor: f64, @@ -56,7 +56,6 @@ impl Default for DamageMods { } impl DamageMods { pub fn get_mod(&self, _type: &EnemyType) -> f64 { - match _type { &EnemyType::MINOR => self.minor, &EnemyType::ELITE => self.elite, @@ -69,7 +68,7 @@ impl DamageMods { } } -#[derive(Debug, Clone, Default, Serialize)] +#[derive(Debug, Clone, Copy, Default, Serialize)] pub struct RangeFormula { pub start: StatQuadraticFormula, pub end: StatQuadraticFormula, @@ -79,7 +78,7 @@ pub struct RangeFormula { } //even if just linear use this -#[derive(Debug, Clone, Default, Serialize)] +#[derive(Debug, Clone, Copy, Default, Serialize)] pub struct StatQuadraticFormula { pub evpp: f64, pub vpp: f64, @@ -96,14 +95,14 @@ impl StatQuadraticFormula { } } -#[derive(Debug, Clone, Default, Serialize)] +#[derive(Debug, Clone, Copy, Default, Serialize)] pub struct ReloadFormula { pub reload_data: StatQuadraticFormula, pub ammo_percent: f64, pub timestamp: u64, } -#[derive(Debug, Clone, Default, Serialize)] +#[derive(Debug, Clone, Copy, Default, Serialize)] pub struct HandlingFormula { pub ready: StatQuadraticFormula, pub stow: StatQuadraticFormula, @@ -111,7 +110,7 @@ pub struct HandlingFormula { pub timestamp: u64, } -#[derive(Debug, Clone, Default, Serialize)] +#[derive(Debug, Clone, Copy, Default, Serialize)] pub struct AmmoFormula { pub mag: StatQuadraticFormula, pub round_to: i32, diff --git a/src/weapons/weapon_constructor.rs b/src/weapons/weapon_constructor.rs index 97fb0ed5..cebd2d0d 100644 --- a/src/weapons/weapon_constructor.rs +++ b/src/weapons/weapon_constructor.rs @@ -39,17 +39,17 @@ impl Weapon { } let data_pointer = data_pointer_result.unwrap(); - let range_formula: RangeFormula = database::RANGE_DATA[data_pointer.r].clone(); + let range_formula: RangeFormula = database::RANGE_DATA[data_pointer.r]; - let handling_formula: HandlingFormula = database::HANDLING_DATA[data_pointer.h].clone(); + let handling_formula: HandlingFormula = database::HANDLING_DATA[data_pointer.h]; - let reload_formula: ReloadFormula = database::RELOAD_DATA[data_pointer.rl].clone(); + let reload_formula: ReloadFormula = database::RELOAD_DATA[data_pointer.rl]; - let damage_mods: DamageMods = database::SCALAR_DATA[data_pointer.s].clone(); + let damage_mods: DamageMods = database::SCALAR_DATA[data_pointer.s]; let firing_data: FiringData = database::FIRING_DATA[data_pointer.f]; - let ammo_formula: AmmoFormula = database::AMMO_DATA[data_pointer.a].clone(); + let ammo_formula: AmmoFormula = database::AMMO_DATA[data_pointer.a]; let weapon_type = WeaponType::from(_weapon_type_id as u32); let ammo_type = AmmoType::from(_ammo_type_id); From 47cce25b0ef7cce8e3a9ddc6c95d5237ede4cdae Mon Sep 17 00:00:00 2001 From: Harm Brammer Date: Tue, 29 Aug 2023 14:02:07 -0400 Subject: [PATCH 06/38] chore: is_weapon_stat to use matches! --- src/d2_enums.rs | 54 ++++++++++++++++++++++++------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/src/d2_enums.rs b/src/d2_enums.rs index 0b7c9313..f87d7b16 100644 --- a/src/d2_enums.rs +++ b/src/d2_enums.rs @@ -183,33 +183,33 @@ impl From for u32 { } impl StatHashes { pub fn is_weapon_stat(&self) -> bool { - match self { - StatHashes::ACCURACY => true, - StatHashes::AIM_ASSIST => true, - StatHashes::AIRBORNE => true, - StatHashes::AMMO_CAPACITY => true, - StatHashes::ZOOM => true, - StatHashes::RANGE => true, - StatHashes::STABILITY => true, - StatHashes::RELOAD => true, - StatHashes::MAGAZINE => true, - StatHashes::HANDLING => true, - StatHashes::VELOCITY => true, - StatHashes::BLAST_RADIUS => true, - StatHashes::CHARGE_TIME => true, - StatHashes::INVENTORY_SIZE => true, - StatHashes::RECOIL_DIR => true, - StatHashes::RPM => true, - StatHashes::GUARD_EFFICIENCY => true, - StatHashes::GUARD_ENDURANCE => true, - StatHashes::GUARD_RESISTANCE => true, - StatHashes::DRAW_TIME => true, - StatHashes::SWING_SPEED => true, - StatHashes::SHIELD_DURATION => true, - StatHashes::IMPACT => true, - StatHashes::CHARGE_RATE => true, - _ => false, - } + matches!( + self, + StatHashes::ACCURACY + | StatHashes::AIM_ASSIST + | StatHashes::AIRBORNE + | StatHashes::AMMO_CAPACITY + | StatHashes::ZOOM + | StatHashes::RANGE + | StatHashes::STABILITY + | StatHashes::RELOAD + | StatHashes::MAGAZINE + | StatHashes::HANDLING + | StatHashes::VELOCITY + | StatHashes::BLAST_RADIUS + | StatHashes::CHARGE_TIME + | StatHashes::INVENTORY_SIZE + | StatHashes::RECOIL_DIR + | StatHashes::RPM + | StatHashes::GUARD_EFFICIENCY + | StatHashes::GUARD_ENDURANCE + | StatHashes::GUARD_RESISTANCE + | StatHashes::DRAW_TIME + | StatHashes::SWING_SPEED + | StatHashes::SHIELD_DURATION + | StatHashes::IMPACT + | StatHashes::CHARGE_RATE + ) } } From 7ced3fb0e5422ee743ed80916cd9d3a6b275ed6a Mon Sep 17 00:00:00 2001 From: Harm Brammer Date: Tue, 29 Aug 2023 14:02:22 -0400 Subject: [PATCH 07/38] chore: Default trait for Stat --- src/weapons/mod.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/weapons/mod.rs b/src/weapons/mod.rs index 606a82cb..ddd19646 100644 --- a/src/weapons/mod.rs +++ b/src/weapons/mod.rs @@ -44,6 +44,13 @@ impl Stat { (self.base_value + self.part_value + self.perk_value).clamp(0, 100) } } + +impl Default for Stat { + fn default() -> Self { + Self::new() + } +} + impl From for Stat { fn from(_val: i32) -> Self { Stat { From 1baaf3c769d318568c115adef01b79a3bac08f5c Mon Sep 17 00:00:00 2001 From: Harm Brammer Date: Tue, 29 Aug 2023 14:05:34 -0400 Subject: [PATCH 08/38] chore: perk_value_map_update iterate over values --- src/weapons/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/weapons/mod.rs b/src/weapons/mod.rs index ddd19646..33eaabf3 100644 --- a/src/weapons/mod.rs +++ b/src/weapons/mod.rs @@ -107,7 +107,7 @@ impl Weapon { } pub fn perk_value_map_update(&self) -> HashMap { let mut perk_map: HashMap = HashMap::new(); - for (_key, perk) in &self.perks { + for perk in self.perks.values() { perk_map.insert(perk.hash, perk.value); } perk_map From 298b5d14b520618df41fb839ca74743635b5f0bd Mon Sep 17 00:00:00 2001 From: Harm Brammer Date: Tue, 29 Aug 2023 14:06:00 -0400 Subject: [PATCH 09/38] chore: get_mod deref --- src/types/rs_types.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/types/rs_types.rs b/src/types/rs_types.rs index 896b2cfd..98363358 100644 --- a/src/types/rs_types.rs +++ b/src/types/rs_types.rs @@ -56,13 +56,13 @@ impl Default for DamageMods { } impl DamageMods { pub fn get_mod(&self, _type: &EnemyType) -> f64 { - match _type { - &EnemyType::MINOR => self.minor, - &EnemyType::ELITE => self.elite, - &EnemyType::MINIBOSS => self.miniboss, - &EnemyType::CHAMPION => self.champion, - &EnemyType::BOSS => self.boss, - &EnemyType::VEHICLE => self.vehicle, + match *_type { + EnemyType::MINOR => self.minor, + EnemyType::ELITE => self.elite, + EnemyType::MINIBOSS => self.miniboss, + EnemyType::CHAMPION => self.champion, + EnemyType::BOSS => self.boss, + EnemyType::VEHICLE => self.vehicle, _ => 1.0, } } From f0782da605ae98aca64979ab2521a6282541d2be Mon Sep 17 00:00:00 2001 From: Harm Brammer Date: Tue, 29 Aug 2023 14:52:33 -0400 Subject: [PATCH 10/38] chore: clean up set_weapon() --- src/lib.rs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 571aa04e..b7c424e3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -133,17 +133,20 @@ pub fn set_weapon( _ammo_type_id, _damage_type_id, ); - if new_weapon.is_err() { - console_log!( - "Could not find weapon data for type: {}, intrinsic: {}, Err: {:?}", - _weapon_type_id, - _intrinsic_hash, - new_weapon + + if let Ok(weapon) = new_weapon { + perm_data.borrow_mut().weapon = weapon; + } else { + logging::log( + format!( + "Could not find weapon data for type: {}, intrinsic: {}, Err: {:?}", + _weapon_type_id, _intrinsic_hash, new_weapon + ) + .as_str(), + LogLevel::Error.into(), ); perm_data.borrow_mut().weapon = Weapon::default(); - } else { - perm_data.borrow_mut().weapon = new_weapon.unwrap(); - }; + } }); Ok(()) } From 71581243d991d1b40af4f0a1ab31a79972c4e967 Mon Sep 17 00:00:00 2001 From: Harm Brammer Date: Tue, 29 Aug 2023 15:18:34 -0400 Subject: [PATCH 11/38] chore: remove an allow all lint tag --- src/perks/mod.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/perks/mod.rs b/src/perks/mod.rs index 99356aa5..4107595a 100644 --- a/src/perks/mod.rs +++ b/src/perks/mod.rs @@ -1,5 +1,3 @@ -#![allow(clippy::all)] - pub mod buff_perks; pub mod exotic_armor; pub mod exotic_perks; From 9ebc3d1d0a99a8af82376fedc79aef3dedba53da Mon Sep 17 00:00:00 2001 From: Harm Brammer Date: Tue, 29 Aug 2023 15:20:21 -0400 Subject: [PATCH 12/38] chore: clean up tricksleeves dmr --- src/perks/exotic_armor.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/perks/exotic_armor.rs b/src/perks/exotic_armor.rs index c4297822..e05808db 100644 --- a/src/perks/exotic_armor.rs +++ b/src/perks/exotic_armor.rs @@ -33,14 +33,16 @@ pub fn exotic_armor() { add_dmr( Perks::MechaneersTricksleeves, Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { - let mut dmr = DamageModifierResponse::default(); - if _input.value <= 0 || _input.calc_data.weapon_type != &WeaponType::SIDEARM { - return dmr; + if _input.value == 0 || *_input.calc_data.weapon_type != WeaponType::SIDEARM { + return DamageModifierResponse::default(); }; + let damage_mult = if _input.pvp { 1.35 } else { 2.0 }; - dmr.explosive_dmg_scale = damage_mult; - dmr.impact_dmg_scale = damage_mult; - dmr + DamageModifierResponse { + explosive_dmg_scale: damage_mult, + impact_dmg_scale: damage_mult, + ..Default::default() + } }), ); From abc330e8d10c69c63025f133b860183faf766fb0 Mon Sep 17 00:00:00 2001 From: Harm Brammer Date: Tue, 29 Aug 2023 15:20:55 -0400 Subject: [PATCH 13/38] chore: remove is_err in generate_weapon --- src/weapons/weapon_constructor.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/weapons/weapon_constructor.rs b/src/weapons/weapon_constructor.rs index cebd2d0d..6719102d 100644 --- a/src/weapons/weapon_constructor.rs +++ b/src/weapons/weapon_constructor.rs @@ -34,10 +34,8 @@ impl Weapon { _damage_type_id: u32, ) -> Result { let data_pointer_result = get_data_pointers(_weapon_type_id, _intrinsic_hash); - if data_pointer_result.is_err() { - return Err(data_pointer_result.unwrap_err()); - } - let data_pointer = data_pointer_result.unwrap(); + + let data_pointer = data_pointer_result?; let range_formula: RangeFormula = database::RANGE_DATA[data_pointer.r]; From 0808a3af44f149a345336deae8de7211c0e30084 Mon Sep 17 00:00:00 2001 From: Harm Brammer Date: Tue, 29 Aug 2023 15:23:40 -0400 Subject: [PATCH 14/38] chore: clippy auto clean after lint tag removal --- src/perks/buff_perks.rs | 12 +++++----- src/perks/exotic_armor.rs | 12 +++++----- src/perks/exotic_perks.rs | 12 +++++----- src/perks/lib.rs | 38 +++++++------------------------ src/perks/meta_perks.rs | 2 +- src/perks/mod.rs | 28 +++++++++++------------ src/perks/origin_perks.rs | 6 ++--- src/perks/other_perks.rs | 8 +++---- src/perks/perk_options_handler.rs | 8 +++---- src/perks/year_1_perks.rs | 8 +++---- src/perks/year_2_perks.rs | 10 ++++---- src/perks/year_3_perks.rs | 2 +- src/perks/year_5_perks.rs | 4 ++-- src/perks/year_6_perks.rs | 4 ++-- 14 files changed, 64 insertions(+), 90 deletions(-) diff --git a/src/perks/buff_perks.rs b/src/perks/buff_perks.rs index 11328a47..25e06c6b 100644 --- a/src/perks/buff_perks.rs +++ b/src/perks/buff_perks.rs @@ -15,10 +15,10 @@ use super::{ fn emp_buff(_cached_data: &mut HashMap, _desired_buff: f64) -> f64 { let current_buff = _cached_data.get("empowering").unwrap_or(&1.0).to_owned(); if current_buff >= _desired_buff { - return 1.0; + 1.0 } else { _cached_data.insert("empowering".to_string(), _desired_buff); - return _desired_buff / current_buff; + _desired_buff / current_buff } } @@ -37,20 +37,20 @@ fn surge_buff(_cached_data: &mut HashMap, _value: u32, _pvp: bool) let current_buff = _cached_data.get("surge").unwrap_or(&1.0).to_owned(); if current_buff >= desired_buff { - return 1.0; + 1.0 } else { _cached_data.insert("surge".to_string(), desired_buff); - return desired_buff / current_buff; + desired_buff / current_buff } } fn gbl_debuff(_cached_data: &mut HashMap, _desired_buff: f64) -> f64 { let current_buff = _cached_data.get("debuff").unwrap_or(&1.0).to_owned(); if current_buff >= _desired_buff { - return 1.0; + 1.0 } else { _cached_data.insert("debuff".to_string(), _desired_buff); - return _desired_buff / current_buff; + _desired_buff / current_buff } } diff --git a/src/perks/exotic_armor.rs b/src/perks/exotic_armor.rs index e05808db..f441dfd7 100644 --- a/src/perks/exotic_armor.rs +++ b/src/perks/exotic_armor.rs @@ -26,7 +26,7 @@ pub fn exotic_armor() { modifier.impact_dmg_scale = value; modifier.explosive_dmg_scale = value; } - return modifier; + modifier }), ); @@ -112,16 +112,16 @@ pub fn exotic_armor() { add_dmr( Perks::Foetracer, Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { - let health_percent = _input.cached_data.get("health%").unwrap_or(&1.0).clone(); + let health_percent = *_input.cached_data.get("health%").unwrap_or(&1.0); if health_percent >= 0.3 || _input.value == 0 { return DamageModifierResponse::default(); } let modifier = 1.0 + (0.3 - health_percent); - return DamageModifierResponse { + DamageModifierResponse { impact_dmg_scale: modifier, explosive_dmg_scale: modifier, crit_scale: 1.0, - }; + } }), ); @@ -256,7 +256,7 @@ pub fn exotic_armor() { ..Default::default() }; } - return HandlingModifierResponse::default(); + HandlingModifierResponse::default() }, ), ); @@ -356,7 +356,7 @@ pub fn exotic_armor() { ..Default::default() }; } - return HandlingModifierResponse::default(); + HandlingModifierResponse::default() }, ), ); diff --git a/src/perks/exotic_perks.rs b/src/perks/exotic_perks.rs index 14331620..a8a27466 100644 --- a/src/perks/exotic_perks.rs +++ b/src/perks/exotic_perks.rs @@ -871,7 +871,7 @@ pub fn exotic_perks() { add_fmr( Perks::RideTheBull, Box::new(|_input: ModifierResponseInput| -> FiringModifierResponse { - let extra_value = _input.calc_data.shots_fired_this_mag as f64 / 10.0; + let extra_value = _input.calc_data.shots_fired_this_mag / 10.0; let val = clamp(_input.value + extra_value as u32, 0, 2); FiringModifierResponse { burst_delay_add: val as f64 * (-0.25 / 30.0), @@ -883,7 +883,7 @@ pub fn exotic_perks() { add_fmr( Perks::SpinningUp, Box::new(|_input: ModifierResponseInput| -> FiringModifierResponse { - let extra_value = _input.calc_data.shots_fired_this_mag as f64 / 12.0; + let extra_value = _input.calc_data.shots_fired_this_mag / 12.0; let val = clamp(_input.value + extra_value as u32, 0, 2); FiringModifierResponse { burst_delay_add: val as f64 * (-0.5 / 30.0), @@ -1139,11 +1139,11 @@ pub fn exotic_perks() { let crit_scale = (impact_damage * crit_mult + broadhead_damage) / (impact_damage * impact_dmg_scale * crit_mult); - return DamageModifierResponse { - impact_dmg_scale: impact_dmg_scale, - crit_scale: crit_scale, + DamageModifierResponse { + impact_dmg_scale, + crit_scale, ..Default::default() - }; + } }), ) } diff --git a/src/perks/lib.rs b/src/perks/lib.rs index c3e9bd8a..5910c576 100644 --- a/src/perks/lib.rs +++ b/src/perks/lib.rs @@ -48,7 +48,7 @@ impl<'a> CalculationInput<'a> { ) -> Self { Self { intrinsic_hash: _intrinsic_hash, - curr_firing_data: &_firing_data, + curr_firing_data: _firing_data, base_crit_mult: _base_crit_mult, shots_fired_this_mag: 0.0, total_shots_fired: _total_shots_hit as f64, @@ -58,10 +58,10 @@ impl<'a> CalculationInput<'a> { reserves_left: 100.0, time_total: _total_time, time_this_mag: -1.0, - stats: &_stats, - weapon_type: &_weapon_type, + stats: _stats, + weapon_type: _weapon_type, damage_type: _damage_type, - ammo_type: &_ammo_type, + ammo_type: _ammo_type, handling_data: HandlingResponse::default(), num_reloads: 0.0, enemy_type: &EnemyType::BOSS, @@ -269,22 +269,14 @@ impl Default for RangeModifierResponse { } #[derive(Debug, Clone, PartialEq)] +#[derive(Default)] pub struct RefundResponse { pub crit: bool, pub requirement: i32, pub refund_mag: i32, pub refund_reserves: i32, } -impl Default for RefundResponse { - fn default() -> Self { - Self { - crit: false, - requirement: 0, - refund_mag: 0, - refund_reserves: 0, - } - } -} + #[derive(Debug, Clone, PartialEq, Serialize)] pub struct MagazineModifierResponse { pub magazine_stat_add: i32, @@ -398,6 +390,7 @@ impl Default for DamageResistModifierResponse { } #[derive(Debug, Clone, PartialEq, Serialize)] +#[derive(Default)] pub struct ModifierResponseSummary { pub rmr: Option, pub dmr: Option, @@ -411,19 +404,4 @@ pub struct ModifierResponseSummary { pub statbump: Option>, } -impl Default for ModifierResponseSummary { - fn default() -> Self { - Self { - rmr: None, - dmr: None, - hmr: None, - fmr: None, - flmr: None, - rsmr: None, - mmr: None, - imr: None, - drmr: None, - statbump: None, - } - } -} + diff --git a/src/perks/meta_perks.rs b/src/perks/meta_perks.rs index 1ca68e54..b0f7bbcb 100644 --- a/src/perks/meta_perks.rs +++ b/src/perks/meta_perks.rs @@ -38,7 +38,7 @@ pub fn meta_perks() { if *_input.calc_data.ammo_type == AmmoType::PRIMARY && _input.calc_data.intrinsic_hash > 1000 && *_input.calc_data.enemy_type == EnemyType::MINOR - && _input.pvp == false + && !_input.pvp { dmg_scale *= 1.4; } diff --git a/src/perks/mod.rs b/src/perks/mod.rs index 4107595a..c9c587b5 100644 --- a/src/perks/mod.rs +++ b/src/perks/mod.rs @@ -684,7 +684,7 @@ pub fn get_stat_bumps( *entry += value; } for (key, value) in perk.stat_buffs { - let entry = static_stats.entry(key.clone()).or_insert(0); + let entry = static_stats.entry(key).or_insert(0); *entry += value; } } @@ -703,7 +703,7 @@ pub fn get_dmg_modifier( let inp = ModifierResponseInput { is_enhanced: perk.enhanced, value: perk.value, - calc_data: &_input_data, + calc_data: _input_data, pvp: _pvp, cached_data: _cached_data, }; @@ -728,7 +728,7 @@ pub fn get_reload_modifier( let inp = ModifierResponseInput { is_enhanced: perk.enhanced, value: perk.value, - calc_data: &_input_data, + calc_data: _input_data, pvp: _pvp, cached_data: _cached_data, }; @@ -752,7 +752,7 @@ pub fn get_firing_modifier( let inp = ModifierResponseInput { is_enhanced: perk.enhanced, value: perk.value, - calc_data: &_input_data, + calc_data: _input_data, pvp: _pvp, cached_data: _cached_data, }; @@ -778,7 +778,7 @@ pub fn get_handling_modifier( let inp = ModifierResponseInput { is_enhanced: perk.enhanced, value: perk.value, - calc_data: &_input_data, + calc_data: _input_data, pvp: _pvp, cached_data: _cached_data, }; @@ -807,7 +807,7 @@ pub fn get_magazine_modifier( let inp = ModifierResponseInput { is_enhanced: perk.enhanced, value: perk.value, - calc_data: &_input_data, + calc_data: _input_data, pvp: _pvp, cached_data: _cached_data, }; @@ -832,7 +832,7 @@ pub fn get_reserve_modifier( let inp = ModifierResponseInput { is_enhanced: perk.enhanced, value: perk.value, - calc_data: &_input_data, + calc_data: _input_data, pvp: _pvp, cached_data: _cached_data, }; @@ -857,7 +857,7 @@ pub fn get_range_modifier( let inp = ModifierResponseInput { is_enhanced: perk.enhanced, value: perk.value, - calc_data: &_input_data, + calc_data: _input_data, pvp: _pvp, cached_data: _cached_data, }; @@ -883,7 +883,7 @@ pub fn get_refund_modifier( let inp = ModifierResponseInput { is_enhanced: perk.enhanced, value: perk.value, - calc_data: &_input_data, + calc_data: _input_data, pvp: _pvp, cached_data: _cached_data, }; @@ -908,7 +908,7 @@ pub fn get_extra_damage( let inp = ModifierResponseInput { is_enhanced: perk.enhanced, value: perk.value, - calc_data: &_input_data, + calc_data: _input_data, pvp: _pvp, cached_data: _cached_data, }; @@ -957,7 +957,7 @@ pub fn get_explosion_data( let inp = ModifierResponseInput { is_enhanced: perk.enhanced, value: perk.value, - calc_data: &_input_data, + calc_data: _input_data, pvp: _pvp, cached_data: &mut HashMap::new(), }; @@ -982,7 +982,7 @@ pub fn get_flinch_modifier( let inp = ModifierResponseInput { is_enhanced: perk.enhanced, value: perk.value, - calc_data: &_input_data, + calc_data: _input_data, pvp: _pvp, cached_data: _cached_data, }; @@ -1005,7 +1005,7 @@ pub fn get_velocity_modifier( let inp = ModifierResponseInput { is_enhanced: perk.enhanced, value: perk.value, - calc_data: &_input_data, + calc_data: _input_data, pvp: _pvp, cached_data: _cached_data, }; @@ -1153,7 +1153,7 @@ impl Weapon { .or_insert(value); } mod_response.statbump = Some(stat_buffer); - return mod_response; + mod_response }); buffer.insert(perk.raw_hash, mod_buffer); } diff --git a/src/perks/origin_perks.rs b/src/perks/origin_perks.rs index 8570f1ba..def069c3 100644 --- a/src/perks/origin_perks.rs +++ b/src/perks/origin_perks.rs @@ -17,7 +17,7 @@ pub fn origin_perks() { add_rr( Perks::VeistStinger, Box::new(|_input: ModifierResponseInput| -> RefundResponse { - if !(_input.value > 0) { + if _input.value <= 0 { return RefundResponse::default(); }; let data = _input.cached_data.get("veist_stinger"); @@ -36,12 +36,12 @@ pub fn origin_perks() { .cached_data .insert("veist_stinger".to_string(), _input.calc_data.time_total); let final_refund_ammount = clamp(refund_amount, 0, max_refund as i32); - return RefundResponse { + RefundResponse { requirement: 1, crit: false, refund_mag: refund_amount, refund_reserves: -final_refund_ammount, - }; + } } else { RefundResponse::default() } diff --git a/src/perks/other_perks.rs b/src/perks/other_perks.rs index b8409c0a..7d4d2e61 100644 --- a/src/perks/other_perks.rs +++ b/src/perks/other_perks.rs @@ -341,7 +341,7 @@ pub fn other_perks() { Perks::BossSpec, Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { let damage_mult = - if *_input.calc_data.enemy_type == EnemyType::BOSS && _input.pvp == false { + if *_input.calc_data.enemy_type == EnemyType::BOSS && !_input.pvp { 1.077 } else { 1.0 @@ -361,7 +361,7 @@ pub fn other_perks() { if (*_input.calc_data.enemy_type == EnemyType::MINIBOSS || *_input.calc_data.enemy_type == EnemyType::ELITE || *_input.calc_data.enemy_type == EnemyType::CHAMPION) - && _input.pvp == false + && !_input.pvp { damage_mult = 1.077; } else { @@ -383,7 +383,7 @@ pub fn other_perks() { || *_input.calc_data.enemy_type == EnemyType::ELITE || *_input.calc_data.enemy_type == EnemyType::CHAMPION || *_input.calc_data.enemy_type == EnemyType::BOSS) - && _input.pvp == false + && !_input.pvp { damage_mult = 1.077; } else { @@ -401,7 +401,7 @@ pub fn other_perks() { Perks::MinorSpec, Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { let damage_mult = - if _input.calc_data.enemy_type == &EnemyType::MINOR && _input.pvp == false { + if _input.calc_data.enemy_type == &EnemyType::MINOR && !_input.pvp { 1.077 } else { 1.0 diff --git a/src/perks/perk_options_handler.rs b/src/perks/perk_options_handler.rs index a71b36bc..58becc42 100644 --- a/src/perks/perk_options_handler.rs +++ b/src/perks/perk_options_handler.rs @@ -5,17 +5,15 @@ use serde::Serialize; use super::{enhanced_check, Perk, Perks}; #[derive(Debug, Clone, Serialize)] +#[derive(Default)] pub enum PerkValueVariant { + #[default] STATIC, TOGGLE, SLIDER, OPTIONS, } -impl Default for PerkValueVariant { - fn default() -> Self { - PerkValueVariant::STATIC - } -} + #[derive(Debug, Clone, Serialize)] pub struct PerkOptionData { diff --git a/src/perks/year_1_perks.rs b/src/perks/year_1_perks.rs index 0b542140..b2d3e122 100644 --- a/src/perks/year_1_perks.rs +++ b/src/perks/year_1_perks.rs @@ -289,8 +289,8 @@ pub fn year_1_perks() { let mut handling = if _input.is_enhanced { 35 } else { 30 }; let mut stabiltiy = if _input.is_enhanced { 25 } else { 20 }; if *_input.calc_data.weapon_type == WeaponType::FUSIONRIFLE { - handling = handling / 2; - stabiltiy = stabiltiy / 2; + handling /= 2; + stabiltiy /= 2; }; let mut out = HashMap::new(); if _input.value > 0 { @@ -308,7 +308,7 @@ pub fn year_1_perks() { |_input: ModifierResponseInput| -> HandlingModifierResponse { let mut handling = if _input.is_enhanced { 35 } else { 30 }; if *_input.calc_data.weapon_type == WeaponType::FUSIONRIFLE { - handling = handling / 2; + handling /= 2; }; if _input.value > 0 { HandlingModifierResponse { @@ -565,7 +565,7 @@ pub fn year_1_perks() { |_input: ModifierResponseInput| -> HashMap { let mut stability = if _input.is_enhanced { 44 } else { 40 }; if *_input.calc_data.weapon_type == WeaponType::FUSIONRIFLE { - stability = stability / 4; + stability /= 4; } let mut out = HashMap::new(); if _input.value > 0 { diff --git a/src/perks/year_2_perks.rs b/src/perks/year_2_perks.rs index b9ea7001..7d861fd8 100644 --- a/src/perks/year_2_perks.rs +++ b/src/perks/year_2_perks.rs @@ -200,14 +200,12 @@ pub fn year_2_perks() { add_rsmr( Perks::RapidHit, Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { - let values = vec![ - (0, 1.0), + let values = [(0, 1.0), (5, 0.99), (30, 0.97), (35, 0.96), (45, 0.94), - (60, 0.93), - ]; + (60, 0.93)]; let entry_to_get = clamp( _input.value + _input.calc_data.shots_fired_this_mag as u32, 0, @@ -223,8 +221,8 @@ pub fn year_2_perks() { add_sbr( Perks::RapidHit, Box::new(|_input: ModifierResponseInput| -> HashMap { - let rel_values = vec![0, 5, 30, 35, 45, 60]; - let stab_values = vec![0, 2, 12, 14, 18, 25]; + let rel_values = [0, 5, 30, 35, 45, 60]; + let stab_values = [0, 2, 12, 14, 18, 25]; let entry_to_get = clamp( _input.value + _input.calc_data.shots_fired_this_mag as u32, 0, diff --git a/src/perks/year_3_perks.rs b/src/perks/year_3_perks.rs index cbd9fb89..1ab3abe9 100644 --- a/src/perks/year_3_perks.rs +++ b/src/perks/year_3_perks.rs @@ -147,7 +147,7 @@ pub fn year_3_perks() { || *_input.calc_data.enemy_type == EnemyType::MINIBOSS || *_input.calc_data.enemy_type == EnemyType::CHAMPION || *_input.calc_data.enemy_type == EnemyType::VEHICLE) - && _input.pvp == false + && !_input.pvp { buff = match *_input.calc_data.ammo_type { AmmoType::HEAVY => 1.1, diff --git a/src/perks/year_5_perks.rs b/src/perks/year_5_perks.rs index 546f1a85..958af7d8 100644 --- a/src/perks/year_5_perks.rs +++ b/src/perks/year_5_perks.rs @@ -66,7 +66,7 @@ pub fn year_5_perks() { Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { let mut dmg_boost = 1.0; let shots_needed; - if _input.calc_data.curr_firing_data.one_ammo == false + if !_input.calc_data.curr_firing_data.one_ammo || _input.calc_data.curr_firing_data.burst_size == 1 { shots_needed = _input.calc_data.base_mag / 2.0; @@ -123,7 +123,7 @@ pub fn year_5_perks() { ]; let dmg_scale: f64; let crit_scale: f64; - if high_weapons.contains(&_input.calc_data.weapon_type) { + if high_weapons.contains(_input.calc_data.weapon_type) { dmg_scale = 1.2; crit_scale = 1.0 / 1.2; } else { diff --git a/src/perks/year_6_perks.rs b/src/perks/year_6_perks.rs index de32afff..78205205 100644 --- a/src/perks/year_6_perks.rs +++ b/src/perks/year_6_perks.rs @@ -192,11 +192,11 @@ pub fn year_6_perks() { add_dmr( Perks::Bipod, Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { - return DamageModifierResponse { + DamageModifierResponse { impact_dmg_scale: 0.75, explosive_dmg_scale: 0.75, ..Default::default() - }; + } }), ); From 95e38672dd7c8214c73ca6ac3773f7628e9d2511 Mon Sep 17 00:00:00 2001 From: Harmon Brammer Date: Tue, 29 Aug 2023 17:14:13 -0400 Subject: [PATCH 15/38] chore: clean up veist stinger --- src/perks/origin_perks.rs | 46 +++++++++++++++------------------------ 1 file changed, 18 insertions(+), 28 deletions(-) diff --git a/src/perks/origin_perks.rs b/src/perks/origin_perks.rs index def069c3..f8f9e239 100644 --- a/src/perks/origin_perks.rs +++ b/src/perks/origin_perks.rs @@ -17,36 +17,26 @@ pub fn origin_perks() { add_rr( Perks::VeistStinger, Box::new(|_input: ModifierResponseInput| -> RefundResponse { - if _input.value <= 0 { - return RefundResponse::default(); - }; let data = _input.cached_data.get("veist_stinger"); - let last_proc; - if data.is_none() { - last_proc = 0.0; - } else { - last_proc = *data.unwrap(); - }; + let last_proc = *data.unwrap_or(&1.0); let time_since_last_proc = _input.calc_data.time_total - last_proc; - if time_since_last_proc >= 4.0 && _input.value > 0 { - let max_refund = _input.calc_data.base_mag - _input.calc_data.curr_mag; - let refund_amount = (_input.calc_data.base_mag / 4.0).ceil() as i32; - if max_refund > 0.0 { - _input - .cached_data - .insert("veist_stinger".to_string(), _input.calc_data.time_total); - let final_refund_ammount = clamp(refund_amount, 0, max_refund as i32); - RefundResponse { - requirement: 1, - crit: false, - refund_mag: refund_amount, - refund_reserves: -final_refund_ammount, - } - } else { - RefundResponse::default() - } - } else { - RefundResponse::default() + let max_refund = _input.calc_data.base_mag - _input.calc_data.curr_mag; + + + if _input.value == 0 || time_since_last_proc < 4.0 || max_refund == 0.0 { + return RefundResponse::default(); + }; + + _input + .cached_data + .insert("veist_stinger".to_string(), _input.calc_data.time_total); + let refund_amount = (_input.calc_data.base_mag / 4.0).ceil() as i32; + let final_refund_ammount = refund_amount.clamp(0, max_refund as i32); + RefundResponse { + requirement: 1, + crit: false, + refund_mag: refund_amount, + refund_reserves: -final_refund_ammount, } }), ); From 8065f325008b831e6ceba2742ea30827aae65da0 Mon Sep 17 00:00:00 2001 From: Harmon Brammer Date: Tue, 29 Aug 2023 21:12:34 -0400 Subject: [PATCH 16/38] chore: enumerate resil values in ttk --- src/weapons/ttk_calc.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/weapons/ttk_calc.rs b/src/weapons/ttk_calc.rs index 35f90c43..9e005c8c 100644 --- a/src/weapons/ttk_calc.rs +++ b/src/weapons/ttk_calc.rs @@ -56,9 +56,7 @@ pub fn calc_ttk(_weapon: &Weapon, _overshield: f64) -> Vec { crit_mult = 1.0; // shawty has no crits } - for i in 0..RESILIENCE_VALUES.len() { - let health = RESILIENCE_VALUES[i] + _overshield; - + for (i, health) in RESILIENCE_VALUES.iter().enumerate() { let mut opt_damage_dealt = 0.0_f64; let mut opt_time_taken = 0.0_f64; let mut opt_bullets_fired = 0.0_f64; @@ -154,7 +152,7 @@ pub fn calc_ttk(_weapon: &Weapon, _overshield: f64) -> Vec { opt_bullet_timeline.push((body_damage, head_diff)); // assume all headshots for first pass - if (opt_damage_dealt + body_damage + head_diff) >= health { + if (opt_damage_dealt + body_damage + head_diff) >= *health { opt_headshots += 1; opt_damage_dealt += body_damage + head_diff; break; @@ -173,7 +171,7 @@ pub fn calc_ttk(_weapon: &Weapon, _overshield: f64) -> Vec { let _body_damage = timeline_snapshot.0; let headshot_diff = timeline_snapshot.1; - if opt_timeline_damage_dealt - headshot_diff >= health { + if opt_timeline_damage_dealt - headshot_diff >= *health { opt_timeline_bodyshots += 1; opt_timeline_headshots -= 1; opt_timeline_damage_dealt -= headshot_diff; @@ -274,7 +272,7 @@ pub fn calc_ttk(_weapon: &Weapon, _overshield: f64) -> Vec { bdy_bullets_hit += 1.0; }; - if (bdy_damage_dealt + body_damage) >= health { + if (bdy_damage_dealt + body_damage) >= *health { break; } else { bdy_damage_dealt += body_damage; From f1873c7e49355ffb573379e74cfe3e77b39d4db3 Mon Sep 17 00:00:00 2001 From: Harmon Brammer Date: Tue, 29 Aug 2023 21:15:47 -0400 Subject: [PATCH 17/38] chore: stat_calcs cleanup --- src/weapons/stat_calc.rs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/weapons/stat_calc.rs b/src/weapons/stat_calc.rs index 39ddde64..c1c45600 100644 --- a/src/weapons/stat_calc.rs +++ b/src/weapons/stat_calc.rs @@ -347,7 +347,7 @@ impl Weapon { } else { rpm = raw_rpm }; - + FiringResponse { pvp_impact_damage: impact_dmg * pvp_damage_modifiers.impact_dmg_scale, pvp_explosion_damage: explosion_dmg * pvp_damage_modifiers.explosive_dmg_scale, @@ -444,11 +444,9 @@ impl Weapon { .clamp(0, 100) .into(); total_scaler *= 1.0 - ((total_stability - 20.0) / 80.0 * stability_percent); - - if _calc_input.is_some() { + if let Some(calc_input) = _calc_input { total_scaler *= - get_flinch_modifier(self.list_perks(), &_calc_input.unwrap(), _pvp, cached_data) - .flinch_scale; + get_flinch_modifier(self.list_perks(), &calc_input, _pvp, cached_data).flinch_scale; } total_scaler @@ -549,10 +547,9 @@ impl Weapon { _ => 0.0, }; - if _calc_input.is_some() { - velocity *= - get_velocity_modifier(self.list_perks(), &_calc_input.unwrap(), _pvp, cached_data) - .velocity_scaler; + if let Some(calc_input) = _calc_input { + velocity *= get_velocity_modifier(self.list_perks(), &calc_input, _pvp, cached_data) + .velocity_scaler; } velocity } From 64a9fc858e1f451eef0e1997d42b2d6c3d95e782 Mon Sep 17 00:00:00 2001 From: Harmon Brammer Date: Tue, 29 Aug 2023 21:17:25 -0400 Subject: [PATCH 18/38] chore: exotic_perks --- src/perks/exotic_perks.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/perks/exotic_perks.rs b/src/perks/exotic_perks.rs index a8a27466..3284e6de 100644 --- a/src/perks/exotic_perks.rs +++ b/src/perks/exotic_perks.rs @@ -842,12 +842,11 @@ pub fn exotic_perks() { add_fmr( Perks::RatPack, Box::new(|_input: ModifierResponseInput| -> FiringModifierResponse { - let val; - if _input.value > 0 { - val = clamp(_input.value - 1, 0, 4); - } else { - val = 0; + if _input.value == 0 { + return FiringModifierResponse::default(); } + let val = clamp(_input.value - 1, 0, 4); + FiringModifierResponse { burst_delay_add: val as f64 * (-0.625 / 30.0), ..Default::default() From e5a0bd3b65d541149e8dad04884ba7c50ac21eba Mon Sep 17 00:00:00 2001 From: Harmon Brammer Date: Tue, 29 Aug 2023 21:43:04 -0400 Subject: [PATCH 19/38] fix: explosive light? it has been bugged for a long time? --- src/perks/year_2_perks.rs | 46 ++++++++++----------------------------- 1 file changed, 11 insertions(+), 35 deletions(-) diff --git a/src/perks/year_2_perks.rs b/src/perks/year_2_perks.rs index 7d861fd8..1a81cd05 100644 --- a/src/perks/year_2_perks.rs +++ b/src/perks/year_2_perks.rs @@ -200,12 +200,14 @@ pub fn year_2_perks() { add_rsmr( Perks::RapidHit, Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { - let values = [(0, 1.0), + let values = [ + (0, 1.0), (5, 0.99), (30, 0.97), (35, 0.96), (45, 0.94), - (60, 0.93)]; + (60, 0.93), + ]; let entry_to_get = clamp( _input.value + _input.calc_data.shots_fired_this_mag as u32, 0, @@ -332,41 +334,15 @@ pub fn year_2_perks() { if shots_left <= 0.0 { return DamageModifierResponse::default(); }; - if _input.calc_data.weapon_type == &WeaponType::GRENADELAUNCHER { - let blast_radius_struct = - _input.calc_data.stats.get(&StatHashes::BLAST_RADIUS.into()); - let blast_radius; - if blast_radius_struct.is_none() { - blast_radius = 0; - } else { - blast_radius = blast_radius_struct.unwrap().val(); - }; - if _input.calc_data.ammo_type == &AmmoType::HEAVY { - let expl_percent = 0.7 + 0.00175 * blast_radius as f64; - let impt_percent = 1.0 - expl_percent; - let expl_mult = 0.875 / expl_percent * 1.6; - let impt_mult = 0.125 / impt_percent; - return DamageModifierResponse { - impact_dmg_scale: impt_mult, - explosive_dmg_scale: expl_mult, - crit_scale: 1.0, - }; - } - if _input.calc_data.ammo_type == &AmmoType::SPECIAL { - let expl_percent = 0.5 + 0.0025 * blast_radius as f64; - let impt_percent = 1.0 - expl_percent; - let expl_mult = 0.75 / expl_percent * 1.6; - let impt_mult = 0.25 / impt_percent; - return DamageModifierResponse { - impact_dmg_scale: impt_mult, - explosive_dmg_scale: expl_mult, - crit_scale: 1.0, - }; - } + + let mult = match _input.calc_data.weapon_type { + WeaponType::ROCKET => (1.25, 1.25), + WeaponType::GRENADELAUNCHER => (1.6, 1.0), + _ => (1.0, 1.0), }; DamageModifierResponse { - explosive_dmg_scale: 1.25, - impact_dmg_scale: 1.25, + explosive_dmg_scale: mult.0, + impact_dmg_scale: mult.1, crit_scale: 1.0, } }), From d5671c421741dc3bde514d8350d7852313e2799c Mon Sep 17 00:00:00 2001 From: Harmon Brammer Date: Tue, 29 Aug 2023 23:32:45 -0400 Subject: [PATCH 20/38] chore: add lint allow tags for CalcInput --- src/perks/lib.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/perks/lib.rs b/src/perks/lib.rs index 5910c576..ba98a68e 100644 --- a/src/perks/lib.rs +++ b/src/perks/lib.rs @@ -32,6 +32,7 @@ pub struct CalculationInput<'a> { } impl<'a> CalculationInput<'a> { //stuff like mag size can use this, not reload, damage, etc. + #[allow(clippy::too_many_arguments)] pub fn construct_pve_sparse( _intrinsic_hash: u32, _firing_data: &'a FiringData, @@ -69,6 +70,7 @@ impl<'a> CalculationInput<'a> { has_overshield: false, } } + #[allow(clippy::too_many_arguments)] pub fn construct_pvp( _intrinsic_hash: u32, _firing_data: &'a FiringData, @@ -105,6 +107,7 @@ impl<'a> CalculationInput<'a> { has_overshield: _has_overshield, } } + #[allow(clippy::too_many_arguments)] pub fn construct_static( _intrinsic_hash: u32, _firing_data: &'a FiringData, @@ -268,8 +271,7 @@ impl Default for RangeModifierResponse { } } -#[derive(Debug, Clone, PartialEq)] -#[derive(Default)] +#[derive(Debug, Clone, PartialEq, Default)] pub struct RefundResponse { pub crit: bool, pub requirement: i32, @@ -389,8 +391,7 @@ impl Default for DamageResistModifierResponse { } } -#[derive(Debug, Clone, PartialEq, Serialize)] -#[derive(Default)] +#[derive(Debug, Clone, PartialEq, Serialize, Default)] pub struct ModifierResponseSummary { pub rmr: Option, pub dmr: Option, @@ -403,5 +404,3 @@ pub struct ModifierResponseSummary { pub drmr: Option, pub statbump: Option>, } - - From 1cbc81a740598b64949ceb8647195c502d5768d0 Mon Sep 17 00:00:00 2001 From: Harmon Brammer Date: Tue, 29 Aug 2023 23:33:07 -0400 Subject: [PATCH 21/38] chore: clean epr builtIn --- src/perks/meta_perks.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/perks/meta_perks.rs b/src/perks/meta_perks.rs index b0f7bbcb..568a2efa 100644 --- a/src/perks/meta_perks.rs +++ b/src/perks/meta_perks.rs @@ -127,12 +127,9 @@ pub fn meta_perks() { if *_input.calc_data.weapon_type == WeaponType::GRENADELAUNCHER { let blast_radius_struct = _input.calc_data.stats.get(&StatHashes::BLAST_RADIUS.into()); - let blast_radius; - if blast_radius_struct.is_none() { - blast_radius = 0; - } else { - blast_radius = blast_radius_struct.unwrap().perk_val(); - }; + + let blast_radius = blast_radius_struct.cloned().unwrap_or_default().perk_val(); + if _input.calc_data.ammo_type == &AmmoType::SPECIAL { return ExplosivePercentResponse { percent: 0.5 + 0.003 * blast_radius as f64, From d7a83b231fc38c6ec64a5328c7d18c1f5c35bd21 Mon Sep 17 00:00:00 2001 From: Harmon Brammer Date: Tue, 29 Aug 2023 23:33:28 -0400 Subject: [PATCH 22/38] chore: add type defs for modifier functions --- src/perks/mod.rs | 56 ++++++++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/src/perks/mod.rs b/src/perks/mod.rs index c9c587b5..9fd4a7c1 100644 --- a/src/perks/mod.rs +++ b/src/perks/mod.rs @@ -456,21 +456,25 @@ pub struct ModifierResponseInput<'a> { pvp: bool, cached_data: &'a mut HashMap, } +type ModifierFunction = Box T>; +type StatMap = HashMap; +type ModifierMap = HashMap>; + #[derive(Default)] pub struct PersistentModifierResponses { - pub sbr: HashMap HashMap>>, - pub dmr: HashMap DamageModifierResponse>>, - pub hmr: HashMap HandlingModifierResponse>>, - pub rmr: HashMap RangeModifierResponse>>, - pub rsmr: HashMap ReloadModifierResponse>>, - pub fmr: HashMap FiringModifierResponse>>, - pub flmr: HashMap FlinchModifierResponse>>, - pub edr: HashMap ExtraDamageResponse>>, - pub rr: HashMap RefundResponse>>, - pub vmr: HashMap VelocityModifierResponse>>, - pub epr: HashMap ExplosivePercentResponse>>, - pub mmr: HashMap MagazineModifierResponse>>, - pub imr: HashMap InventoryModifierResponse>>, + pub sbr: ModifierMap, + pub dmr: ModifierMap, + pub hmr: ModifierMap, + pub rmr: ModifierMap, + pub rsmr: ModifierMap, + pub fmr: ModifierMap, + pub flmr: ModifierMap, + pub edr: ModifierMap, + pub rr: ModifierMap, + pub vmr: ModifierMap, + pub epr: ModifierMap, + pub mmr: ModifierMap, + pub imr: ModifierMap, } impl PersistentModifierResponses { fn is_empty(&self) -> bool { @@ -594,67 +598,67 @@ impl PersistentModifierResponses { } } -fn add_sbr(perk: Perks, func: Box HashMap>) { +fn add_sbr(perk: Perks, func: ModifierFunction) { PERK_FUNC_MAP.with(|map| { map.borrow_mut().sbr.insert(perk, func); }); } -fn add_dmr(perk: Perks, func: Box DamageModifierResponse>) { +fn add_dmr(perk: Perks, func: ModifierFunction) { PERK_FUNC_MAP.with(|map| { map.borrow_mut().dmr.insert(perk, func); }); } -fn add_hmr(perk: Perks, func: Box HandlingModifierResponse>) { +fn add_hmr(perk: Perks, func: ModifierFunction) { PERK_FUNC_MAP.with(|map| { map.borrow_mut().hmr.insert(perk, func); }); } -fn add_rmr(perk: Perks, func: Box RangeModifierResponse>) { +fn add_rmr(perk: Perks, func: ModifierFunction) { PERK_FUNC_MAP.with(|map| { map.borrow_mut().rmr.insert(perk, func); }); } -fn add_rsmr(perk: Perks, func: Box ReloadModifierResponse>) { +fn add_rsmr(perk: Perks, func: ModifierFunction) { PERK_FUNC_MAP.with(|map| { map.borrow_mut().rsmr.insert(perk, func); }); } -fn add_fmr(perk: Perks, func: Box FiringModifierResponse>) { +fn add_fmr(perk: Perks, func: ModifierFunction) { PERK_FUNC_MAP.with(|map| { map.borrow_mut().fmr.insert(perk, func); }); } -fn add_flmr(perk: Perks, func: Box FlinchModifierResponse>) { +fn add_flmr(perk: Perks, func: ModifierFunction) { PERK_FUNC_MAP.with(|map| { map.borrow_mut().flmr.insert(perk, func); }); } -fn add_edr(perk: Perks, func: Box ExtraDamageResponse>) { +fn add_edr(perk: Perks, func: ModifierFunction) { PERK_FUNC_MAP.with(|map| { map.borrow_mut().edr.insert(perk, func); }); } -fn add_rr(perk: Perks, func: Box RefundResponse>) { +fn add_rr(perk: Perks, func: ModifierFunction) { PERK_FUNC_MAP.with(|map| { map.borrow_mut().rr.insert(perk, func); }); } -fn add_vmr(perk: Perks, func: Box VelocityModifierResponse>) { +fn add_vmr(perk: Perks, func: ModifierFunction) { PERK_FUNC_MAP.with(|map| { map.borrow_mut().vmr.insert(perk, func); }); } -fn add_epr(perk: Perks, func: Box ExplosivePercentResponse>) { +fn add_epr(perk: Perks, func: ModifierFunction) { PERK_FUNC_MAP.with(|map| { map.borrow_mut().epr.insert(perk, func); }); } -fn add_mmr(perk: Perks, func: Box MagazineModifierResponse>) { +fn add_mmr(perk: Perks, func: ModifierFunction) { PERK_FUNC_MAP.with(|map| { map.borrow_mut().mmr.insert(perk, func); }); } -fn add_imr(perk: Perks, func: Box InventoryModifierResponse>) { +fn add_imr(perk: Perks, func: ModifierFunction) { PERK_FUNC_MAP.with(|map| { map.borrow_mut().imr.insert(perk, func); }); From 235f842897d259d33ac22d32b62404636416982f Mon Sep 17 00:00:00 2001 From: Harmon Brammer Date: Tue, 29 Aug 2023 23:34:02 -0400 Subject: [PATCH 23/38] chore: remove redundant Default() --- src/perks/origin_perks.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/perks/origin_perks.rs b/src/perks/origin_perks.rs index f8f9e239..5c4b791d 100644 --- a/src/perks/origin_perks.rs +++ b/src/perks/origin_perks.rs @@ -384,7 +384,6 @@ pub fn origin_perks() { ReloadModifierResponse { reload_stat_add: 20, reload_time_scale: 0.9, - ..Default::default() } } else { ReloadModifierResponse::default() @@ -453,7 +452,6 @@ pub fn origin_perks() { ReloadModifierResponse { reload_stat_add: stat_bump, reload_time_scale: 0.95, - ..Default::default() } } else { ReloadModifierResponse::default() From 4491e9e1565c21b2f37d5baab420b7dc0ea2a37f Mon Sep 17 00:00:00 2001 From: Harmon Brammer Date: Tue, 29 Aug 2023 23:34:27 -0400 Subject: [PATCH 24/38] chore: clean up major and bigones spec --- src/perks/other_perks.rs | 61 +++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 35 deletions(-) diff --git a/src/perks/other_perks.rs b/src/perks/other_perks.rs index 7d4d2e61..46b2ccf3 100644 --- a/src/perks/other_perks.rs +++ b/src/perks/other_perks.rs @@ -1,7 +1,5 @@ use std::collections::{btree_map::Range, HashMap}; -use serde::de::value; - use crate::{ d2_enums::{AmmoType, BungieHash, DamageType, StatBump, StatHashes, WeaponType}, enemies::EnemyType, @@ -340,12 +338,11 @@ pub fn other_perks() { add_dmr( Perks::BossSpec, Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { - let damage_mult = - if *_input.calc_data.enemy_type == EnemyType::BOSS && !_input.pvp { - 1.077 - } else { - 1.0 - }; + let damage_mult = if *_input.calc_data.enemy_type == EnemyType::BOSS && !_input.pvp { + 1.077 + } else { + 1.0 + }; DamageModifierResponse { impact_dmg_scale: damage_mult, explosive_dmg_scale: damage_mult, @@ -357,20 +354,18 @@ pub fn other_perks() { add_dmr( Perks::MajorSpec, Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { - let damage_mult; - if (*_input.calc_data.enemy_type == EnemyType::MINIBOSS - || *_input.calc_data.enemy_type == EnemyType::ELITE - || *_input.calc_data.enemy_type == EnemyType::CHAMPION) - && !_input.pvp + if !matches!( + *_input.calc_data.enemy_type, + EnemyType::ELITE | EnemyType::MINIBOSS | EnemyType::CHAMPION + ) || _input.pvp { - damage_mult = 1.077; - } else { - damage_mult = 1.0; - }; + return DamageModifierResponse::default(); + } + let damage_mult = 1.077; DamageModifierResponse { impact_dmg_scale: damage_mult, explosive_dmg_scale: damage_mult, - crit_scale: 1.0, + ..Default::default() } }), ); @@ -378,21 +373,18 @@ pub fn other_perks() { add_dmr( Perks::BigOnesSpec, Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { - let damage_mult; - if (*_input.calc_data.enemy_type == EnemyType::MINIBOSS - || *_input.calc_data.enemy_type == EnemyType::ELITE - || *_input.calc_data.enemy_type == EnemyType::CHAMPION - || *_input.calc_data.enemy_type == EnemyType::BOSS) - && !_input.pvp + if !matches!( + *_input.calc_data.enemy_type, + EnemyType::ELITE | EnemyType::MINIBOSS | EnemyType::CHAMPION | EnemyType::BOSS + ) || _input.pvp { - damage_mult = 1.077; - } else { - damage_mult = 1.0; - }; + return DamageModifierResponse::default(); + } + let damage_mult = 1.077; DamageModifierResponse { impact_dmg_scale: damage_mult, explosive_dmg_scale: damage_mult, - crit_scale: 1.0, + ..Default::default() } }), ); @@ -400,12 +392,11 @@ pub fn other_perks() { add_dmr( Perks::MinorSpec, Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { - let damage_mult = - if _input.calc_data.enemy_type == &EnemyType::MINOR && !_input.pvp { - 1.077 - } else { - 1.0 - }; + let damage_mult = if _input.calc_data.enemy_type == &EnemyType::MINOR && !_input.pvp { + 1.077 + } else { + 1.0 + }; DamageModifierResponse { impact_dmg_scale: damage_mult, explosive_dmg_scale: damage_mult, From cb19d71681ae6691494818dea81073135620e1fb Mon Sep 17 00:00:00 2001 From: Harmon Brammer Date: Tue, 29 Aug 2023 23:35:29 -0400 Subject: [PATCH 25/38] chore: remove redundant Default() year 1 --- src/perks/year_1_perks.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/perks/year_1_perks.rs b/src/perks/year_1_perks.rs index b2d3e122..7ccf8b36 100644 --- a/src/perks/year_1_perks.rs +++ b/src/perks/year_1_perks.rs @@ -795,7 +795,6 @@ pub fn year_1_perks() { ReloadModifierResponse { reload_stat_add: 100, reload_time_scale: 0.9, - ..Default::default() } } else { ReloadModifierResponse::default() From e1bd5f7d1d9a142191bee7a5d44e71e44f405b00 Mon Sep 17 00:00:00 2001 From: Harmon Brammer Date: Tue, 29 Aug 2023 23:37:01 -0400 Subject: [PATCH 26/38] chore!: Display trait instead of toString may be breaking? needs testing --- src/types/js_types.rs | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/types/js_types.rs b/src/types/js_types.rs index 1a65a6f4..dfaaf8de 100644 --- a/src/types/js_types.rs +++ b/src/types/js_types.rs @@ -1,4 +1,7 @@ -use std::collections::HashMap; +use std::{ + collections::HashMap, + fmt::{self, write}, +}; use crate::{ activity::damage_calc::DifficultyOptions, @@ -131,10 +134,6 @@ pub struct JsDpsResponse { } #[wasm_bindgen(js_class = "DpsResponse")] impl JsDpsResponse { - #[wasm_bindgen(js_name = "toString")] - pub fn to_string(self) -> String { - format!("{:?}", self) - } #[wasm_bindgen(js_name = "toJSON")] pub fn to_json(self) -> String { serde_wasm_bindgen::to_value(&self) @@ -153,6 +152,11 @@ impl JsDpsResponse { serde_wasm_bindgen::to_value(&self.dps_per_mag).unwrap() } } +impl fmt::Display for JsDpsResponse { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{:?}", self) + } +} impl From for JsDpsResponse { fn from(dps: DpsResponse) -> Self { JsDpsResponse { @@ -283,13 +287,13 @@ pub struct JsStat { #[serde(rename = "traitValue")] pub trait_value: i32, } -#[wasm_bindgen(js_class = "Stat")] -impl JsStat { - #[wasm_bindgen(js_name = "toString")] - pub fn to_string(self) -> String { - format!("{:?}", self) + +impl fmt::Display for JsStat { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{:?}", self) } } + impl From for JsStat { fn from(stat: Stat) -> Self { JsStat { From b73506981f7fb45d313d9a3c4edac5260e651059 Mon Sep 17 00:00:00 2001 From: Harmon Brammer Date: Tue, 29 Aug 2023 23:37:23 -0400 Subject: [PATCH 27/38] chore: clean focused fury --- src/perks/year_5_perks.rs | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/perks/year_5_perks.rs b/src/perks/year_5_perks.rs index 958af7d8..48bcb545 100644 --- a/src/perks/year_5_perks.rs +++ b/src/perks/year_5_perks.rs @@ -64,20 +64,17 @@ pub fn year_5_perks() { add_dmr( Perks::FocusedFury, Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { - let mut dmg_boost = 1.0; - let shots_needed; - if !_input.calc_data.curr_firing_data.one_ammo - || _input.calc_data.curr_firing_data.burst_size == 1 - { - shots_needed = _input.calc_data.base_mag / 2.0; - } else { - shots_needed = (_input.calc_data.base_mag - * (_input.calc_data.curr_firing_data.burst_size as f64)) - / 2.0; - } - if _input.calc_data.total_shots_fired >= shots_needed || _input.value > 0 { - dmg_boost = 1.2; - } + + let shots_needed = (_input.calc_data.base_mag + * (_input.calc_data.curr_firing_data.burst_size as f64)) + / 2.0; + + let dmg_boost = + if _input.calc_data.total_shots_fired >= shots_needed || _input.value > 0 { + 1.2 + } else { + 1.0 + }; DamageModifierResponse { impact_dmg_scale: dmg_boost, explosive_dmg_scale: dmg_boost, From 6085b67ec2d3f866a93d2d610d23a73624157687 Mon Sep 17 00:00:00 2001 From: Harmon Brammer Date: Tue, 29 Aug 2023 23:38:24 -0400 Subject: [PATCH 28/38] chore: clippy clean --- src/perks/perk_options_handler.rs | 8 ++--- src/perks/year_4_perks.rs | 49 +++++++++++++++++++------------ src/weapons/mod.rs | 14 ++++----- src/weapons/stat_calc.rs | 7 ++--- 4 files changed, 43 insertions(+), 35 deletions(-) diff --git a/src/perks/perk_options_handler.rs b/src/perks/perk_options_handler.rs index 58becc42..1757e54b 100644 --- a/src/perks/perk_options_handler.rs +++ b/src/perks/perk_options_handler.rs @@ -4,8 +4,7 @@ use serde::Serialize; use super::{enhanced_check, Perk, Perks}; -#[derive(Debug, Clone, Serialize)] -#[derive(Default)] +#[derive(Debug, Clone, Serialize, Default)] pub enum PerkValueVariant { #[default] STATIC, @@ -14,7 +13,6 @@ pub enum PerkValueVariant { OPTIONS, } - #[derive(Debug, Clone, Serialize)] pub struct PerkOptionData { stacks: (u32, u32), @@ -428,8 +426,8 @@ pub fn get_perk_options(_perks: Vec) -> HashMap { for perk in _perks { // let data = if _input._is_enhanced {enh_hash_to_perk_option_data(perk)} else {hash_to_perk_option_data(perk)}; let data = hash_to_perk_option_data(perk); - if data.is_some() { - options.insert(perk, data.unwrap()); + if let Some(value) = data { + options.insert(perk, value); } } options diff --git a/src/perks/year_4_perks.rs b/src/perks/year_4_perks.rs index c6520e8f..a637a325 100644 --- a/src/perks/year_4_perks.rs +++ b/src/perks/year_4_perks.rs @@ -67,14 +67,12 @@ pub fn year_4_perks() { add_rmr( Perks::Adagio, Box::new(|_input: ModifierResponseInput| -> RangeModifierResponse { - let range_boost: i32; - if _input.value > 0 { - range_boost = 10; - } else { - range_boost = 0; - }; + if _input.value == 0 { + return RangeModifierResponse::default(); + } + RangeModifierResponse { - range_stat_add: range_boost, + range_stat_add: 10, ..Default::default() } }), @@ -269,7 +267,11 @@ pub fn year_4_perks() { Perks::ImpulseAmplifier, Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { let reload = if _input.is_enhanced { 25 } else { 20 }; - let reload_mult = if *_input.calc_data.weapon_type == WeaponType::ROCKET { 0.8 } else { 0.85 }; + let reload_mult = if *_input.calc_data.weapon_type == WeaponType::ROCKET { + 0.8 + } else { + 0.85 + }; ReloadModifierResponse { reload_stat_add: reload, reload_time_scale: reload_mult, @@ -456,7 +458,7 @@ pub fn year_4_perks() { add_rsmr( Perks::FireFly, Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { - if _input.value > 0 { + if _input.value > 0 { ReloadModifierResponse { reload_stat_add: 50, reload_time_scale: 1.0, @@ -659,20 +661,29 @@ pub fn year_4_perks() { ); add_dmr( - Perks::Recombination, + Perks::Recombination, Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { //to make sure it doesn't go over the max stacks - let val = if _input.is_enhanced {clamp(_input.value, 0, 8) as f64 } else { clamp(_input.value, 0, 10) as f64}; + let val = if _input.is_enhanced { + clamp(_input.value, 0, 8) as f64 + } else { + clamp(_input.value, 0, 10) as f64 + }; //dmg buff per stack depends on enhancement and pvp - let buff = 1.0 + if _input.calc_data.total_shots_fired == 0.0 { match (_input.is_enhanced, _input.pvp) { - (false, false) => 0.1 * val, - (false, true) => 0.05 * val, - (true, false) => 0.125 * val, - (true, true) => 0.0625 * val, - } } else { 0.0 }; - DamageModifierResponse { + let buff = 1.0 + + if _input.calc_data.total_shots_fired == 0.0 { + match (_input.is_enhanced, _input.pvp) { + (false, false) => 0.1 * val, + (false, true) => 0.05 * val, + (true, false) => 0.125 * val, + (true, true) => 0.0625 * val, + } + } else { + 0.0 + }; + DamageModifierResponse { impact_dmg_scale: buff, - ..Default::default() + ..Default::default() } }), ); diff --git a/src/weapons/mod.rs b/src/weapons/mod.rs index 33eaabf3..b844087d 100644 --- a/src/weapons/mod.rs +++ b/src/weapons/mod.rs @@ -100,7 +100,7 @@ impl Weapon { } pub fn list_perks(&self) -> Vec { let mut perk_list: Vec = Vec::new(); - for (_key, perk) in &self.perks { + for perk in self.perks.values() { perk_list.push(perk.clone()); } perk_list @@ -114,8 +114,8 @@ impl Weapon { } pub fn change_perk_val(&mut self, _perk_hash: u32, _val: u32) { let perk_opt = self.perks.get_mut(&_perk_hash); - if perk_opt.is_some() { - perk_opt.unwrap().value = _val; + if let Some(perk) = perk_opt { + perk.value = _val; } self.update_stats(); } @@ -215,11 +215,11 @@ impl Weapon { for (key, stat) in &mut self.stats { let a = static_stats.get(key); let b = dynamic_stats.get(key); - if a.is_some() { - stat.part_value = *a.unwrap(); + if let Some(value) = a { + stat.part_value = *value; } - if b.is_some() { - stat.perk_value = *b.unwrap(); + if let Some(value) = b { + stat.perk_value = *value; } } } diff --git a/src/weapons/stat_calc.rs b/src/weapons/stat_calc.rs index c1c45600..4418210a 100644 --- a/src/weapons/stat_calc.rs +++ b/src/weapons/stat_calc.rs @@ -341,11 +341,10 @@ impl Weapon { + (inner_burst_delay * (burst_size as f64 - 1.0)) + extra_charge_delay) / burst_size as f64); - let rpm: f64; - if self.firing_data.one_ammo { - rpm = raw_rpm / burst_size as f64 + let rpm = if self.firing_data.one_ammo { + raw_rpm / burst_size as f64 } else { - rpm = raw_rpm + raw_rpm }; FiringResponse { From d79464fe9b3d5e4c2aa6644b1cd0c2e12da95de0 Mon Sep 17 00:00:00 2001 From: Harmon Brammer Date: Tue, 29 Aug 2023 23:40:08 -0400 Subject: [PATCH 29/38] chore: don't lint build script we will be changing weapons_formula soon --- build.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build.rs b/build.rs index edac65d9..cba73e9c 100644 --- a/build.rs +++ b/build.rs @@ -1,3 +1,4 @@ +#![allow(clippy::all)] use serde::{Deserialize, Serialize}; use serde_json::{Map, Number, Value}; use std::collections::{BTreeMap, HashMap}; @@ -28,7 +29,9 @@ impl CachedBuildData { .duration_since(std::time::UNIX_EPOCH) .unwrap() .as_secs(); - if let std::collections::btree_map::Entry::Vacant(e) = self.perk_formula_timestamps.entry(uuid) { + if let std::collections::btree_map::Entry::Vacant(e) = + self.perk_formula_timestamps.entry(uuid) + { e.insert(now); now } else { From 5cd86357315765d85114ca63a04f2132f2a0eea6 Mon Sep 17 00:00:00 2001 From: oh-yes-0-fps Date: Wed, 13 Sep 2023 20:08:59 -0400 Subject: [PATCH 30/38] =?UTF-8?q?chore:=20cleaned=20up=20some=20code=20for?= =?UTF-8?q?=20harm=F0=9F=A5=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 11 +- .vscode/settings.json | 1 + Cargo.lock | 25 +- Cargo.toml | 8 +- build.rs | 34 +- src/abilities/mod.rs | 5 +- src/activity/damage_calc.rs | 6 +- src/activity/mod.rs | 8 +- src/enemies/mod.rs | 19 +- src/lib.rs | 17 +- src/logging.rs | 4 +- src/perks/buff_perks.rs | 96 ++-- src/perks/exotic_armor.rs | 494 ++++++++++----------- src/perks/exotic_perks.rs | 389 ++++++++--------- src/perks/lib.rs | 14 +- src/perks/meta_perks.rs | 178 ++++---- src/perks/mod.rs | 14 +- src/perks/origin_perks.rs | 233 +++++----- src/perks/other_perks.rs | 290 ++++++------- src/perks/year_1_perks.rs | 700 ++++++++++++++---------------- src/perks/year_2_perks.rs | 142 +++--- src/perks/year_3_perks.rs | 114 +++-- src/perks/year_4_perks.rs | 346 +++++++-------- src/perks/year_5_perks.rs | 255 ++++++----- src/perks/year_6_perks.rs | 282 ++++++------ src/test.rs | 1 + src/types/formula_types.rs | 124 ++++++ src/types/js_types.rs | 13 +- src/types/mod.rs | 7 + src/types/rs_types.rs | 134 +----- src/weapons/dps_calc.rs | 4 +- src/weapons/mod.rs | 33 +- src/weapons/reserve_calc.rs | 2 +- src/weapons/stat_calc.rs | 17 +- src/weapons/ttk_calc.rs | 10 +- src/weapons/weapon_constructor.rs | 11 +- 36 files changed, 1911 insertions(+), 2130 deletions(-) create mode 100644 src/types/formula_types.rs diff --git a/.gitignore b/.gitignore index 639b63ab..9a21ee71 100644 --- a/.gitignore +++ b/.gitignore @@ -8,13 +8,4 @@ *.zip *.ts !*.d.ts -database/weapon_formulas.rs -!database/compactor.py -!database/perk_rerouter.py -zdata.json -database/weapon.json -database/weapon_test.json -database/enhanced_handler.rs -/zPythonStuff -/zPveReverser -data.json \ No newline at end of file +/boboswaggins_kitchen \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 33442c22..0bd1f9e3 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -4,4 +4,5 @@ "IS_RA": "true" }, "rust-analyzer.check.command": "clippy", + "rust-analyzer.cargo.target": "wasm32-unknown-unknown", } \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index b0a77cd8..76bda9d1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -769,6 +769,7 @@ dependencies = [ "serde", "serde-wasm-bindgen", "serde_json", + "thiserror", "wasm-bindgen", ] @@ -992,9 +993,9 @@ dependencies = [ [[package]] name = "serde-wasm-bindgen" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3b143e2833c57ab9ad3ea280d21fd34e285a42837aeb0ee301f4f41890fa00e" +checksum = "30c9933e5689bd420dc6c87b7a1835701810cbc10cd86a26e4da45b73e6b1d78" dependencies = [ "js-sys", "serde", @@ -1129,6 +1130,26 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "thiserror" +version = "1.0.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d6d7a740b8a666a7e828dd00da9c0dc290dff53154ea77ac109281de90589b7" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49922ecae66cc8a249b77e68d1d0623c1b2c514f0060c27cdc68bd62a1219d35" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.29", +] + [[package]] name = "threadpool" version = "1.8.1" diff --git a/Cargo.toml b/Cargo.toml index 8335b983..ef368ade 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,7 @@ edition = "2021" version = "1.0.2" rust-version = "1.65" repository = "https://github.com/d2foundry/oracle_engine/" +# build = "build-script-src/main.rs" build = "build.rs" [build-dependencies] @@ -12,6 +13,7 @@ serde = { version = "^1.0", features = ["derive"]} reqwest = { version = "^0.11", features = ["json", "blocking"] } serde_json = "^1.0" ron = "^0.8" +thiserror = "1.0.48" [dev-dependencies] num-traits = "0.2" @@ -20,13 +22,14 @@ num-traits = "0.2" [dependencies] serde = { version = "^1.0", features = ["derive"]} -serde-wasm-bindgen = { version = "^0.5"} +serde-wasm-bindgen = { version = "^0.6"} console_error_panic_hook = { version = "0.1.7"} wasm-bindgen = { version = "^0.2"} num_enum = "0.7.0" -lol_alloc = "0.4.0" +lol_alloc = { version = "0.4.0", default-features = false} piecewise-linear = "0.1.0" +thiserror = "1.0.48" [lib] @@ -34,4 +37,5 @@ crate-type = ["cdylib"] [profile.release] lto = true +strip = true opt-level = "z" diff --git a/build.rs b/build.rs index cba73e9c..6f973e73 100644 --- a/build.rs +++ b/build.rs @@ -99,7 +99,7 @@ impl UuidTimestamp for StatQuadraticFormula { } #[derive(Debug, Clone, Serialize, Default)] -pub struct DamageMods { +pub struct DamageModFormula { pub pve: f64, pub minor: f64, pub elite: f64, @@ -109,9 +109,9 @@ pub struct DamageMods { pub vehicle: f64, pub timestamp: u64, } -impl From<&Map> for DamageMods { +impl From<&Map> for DamageModFormula { fn from(_val: &Map) -> Self { - DamageMods { + DamageModFormula { pve: 1.0, minor: _val .get("minor") @@ -147,10 +147,10 @@ impl From<&Map> for DamageMods { } } } -impl DamageMods { +impl DamageModFormula { pub fn add_pve_mult(self, mult: f64) -> Self { // not super memory efficient but it works - DamageMods { + DamageModFormula { pve: mult, minor: self.minor, elite: self.elite, @@ -162,7 +162,7 @@ impl DamageMods { } } } -impl UuidTimestamp for DamageMods { +impl UuidTimestamp for DamageModFormula { fn uuid(&self) -> f64 { (self.pve - 12.0) * 6729.0 + self.minor * 18342.0 @@ -294,7 +294,7 @@ impl UuidTimestamp for AmmoFormula { } #[derive(Debug, Clone, Serialize, Default)] -pub struct FiringData { +pub struct FiringDataFormula { pub damage: f64, pub crit_mult: f64, pub burst_delay: f64, @@ -304,9 +304,9 @@ pub struct FiringData { pub charge: bool, pub timestamp: u64, } -impl From<&Map> for FiringData { +impl From<&Map> for FiringDataFormula { fn from(_val: &Map) -> Self { - FiringData { + FiringDataFormula { damage: _val["damage"].as_f64().unwrap_or_default(), crit_mult: _val["crit_mult"].as_f64().unwrap_or_default(), burst_delay: _val["burst_delay"].as_f64().unwrap_or_default(), @@ -326,7 +326,7 @@ impl From<&Map> for FiringData { } } } -impl UuidTimestamp for FiringData { +impl UuidTimestamp for FiringDataFormula { fn uuid(&self) -> f64 { (self.damage * 821.88 + self.crit_mult * 388.1 @@ -382,7 +382,7 @@ fn main() { //write imports in file let res = writeln!( formula_file, - "use crate::types::rs_types::{{StatQuadraticFormula, RangeFormula, HandlingFormula, ReloadFormula, DamageMods, AmmoFormula, DataPointers, FiringData, WeaponPath}};"); + "use crate::types::prelude::*;"); if res.is_err() { panic!("cargo:warning=error writing imports"); } @@ -496,8 +496,8 @@ fn construct_weapon_formulas(formula_file: &mut File, cached: &mut CachedBuildDa let mut range_data: Vec = vec![RangeFormula::default()]; let mut reload_data: Vec = vec![ReloadFormula::default()]; let mut ammo_data: Vec = vec![AmmoFormula::default()]; - let mut firing_data: Vec = vec![FiringData::default()]; - let mut scalar_data: Vec = vec![DamageMods::default()]; + let mut firing_data: Vec = vec![FiringDataFormula::default()]; + let mut scalar_data: Vec = vec![DamageModFormula::default()]; let mut updated_weapon_defs: Vec<(WeaponPath, DataPointers)> = Vec::new(); for (weapon_id, inner_values) in new_jdata.as_object().unwrap() { @@ -647,7 +647,7 @@ fn construct_weapon_formulas(formula_file: &mut File, cached: &mut CachedBuildDa handling_data.push(handling); } - let b_scalar: DamageMods = cat + let b_scalar: DamageModFormula = cat .get("combatant_scalars") .unwrap_or_else(|| { err_list.push(format!( @@ -686,7 +686,7 @@ fn construct_weapon_formulas(formula_file: &mut File, cached: &mut CachedBuildDa ammo_data.push(ammo); } - let mut firing: FiringData = (&fam).into(); + let mut firing: FiringDataFormula = (&fam).into(); firing.burst_delay *= 1.0 / 30.0; firing.inner_burst_delay *= 1.0 / 30.0; firing.crit_mult = 1.5 + (firing.crit_mult / 51.0); @@ -752,14 +752,14 @@ fn construct_weapon_formulas(formula_file: &mut File, cached: &mut CachedBuildDa write_variable( formula_file, "SCALAR_DATA", - &format!("[DamageMods; {}]", scalar_data.len()), + &format!("[DamageModFormula; {}]", scalar_data.len()), format!("{:?}", scalar_data), "Array of combatant scalar formulas", ); write_variable( formula_file, "FIRING_DATA", - &format!("[FiringData; {}]", firing_data.len()), + &format!("[FiringDataFormula; {}]", firing_data.len()), format!("{:?}", firing_data), "Array of firing data formulas", ); diff --git a/src/abilities/mod.rs b/src/abilities/mod.rs index eaa7b554..02cd3aee 100644 --- a/src/abilities/mod.rs +++ b/src/abilities/mod.rs @@ -1,5 +1,4 @@ -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] -#[derive(Default)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)] pub enum AbilityType { GRENADE, MELEE, @@ -14,7 +13,7 @@ pub enum AbilityType { UNKNOWN, } - +#[allow(dead_code)] #[derive(Debug, Clone, Default)] pub struct AbilityDamageProfile { impact: f64, diff --git a/src/activity/damage_calc.rs b/src/activity/damage_calc.rs index 7bc92b98..43f2d212 100644 --- a/src/activity/damage_calc.rs +++ b/src/activity/damage_calc.rs @@ -1,8 +1,7 @@ #![allow(dead_code)] use super::Activity; -use crate::{enemies::EnemyType, logging, types::rs_types::DamageMods}; +use crate::logging; use piecewise_linear::PiecewiseLinearFunction; -use serde::{Deserialize, Serialize}; #[derive(Debug, Clone)] pub struct DifficultyData { @@ -13,8 +12,7 @@ pub struct DifficultyData { const WEAPON_DELTA_EXPONENT: f64 = 0.00672; -#[derive(Debug, Clone)] -#[derive(Default)] +#[derive(Debug, Clone, Default)] pub enum DifficultyOptions { #[default] NORMAL = 1, diff --git a/src/activity/mod.rs b/src/activity/mod.rs index 91a47bde..53ff0a5f 100644 --- a/src/activity/mod.rs +++ b/src/activity/mod.rs @@ -1,9 +1,8 @@ -use self::damage_calc::{get_gear_delta_mult, rpl_mult, DifficultyOptions, get_wep_delta_mult}; +use self::damage_calc::{get_gear_delta_mult, get_wep_delta_mult, rpl_mult, DifficultyOptions}; pub mod damage_calc; -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] -#[derive(Default)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)] pub enum PlayerClass { #[default] Unknown = 0, @@ -12,7 +11,6 @@ pub enum PlayerClass { Warlock = 3, } - #[derive(Debug, Clone, Default)] pub struct Player { pub power: u32, @@ -46,7 +44,7 @@ impl Default for Activity { } impl Activity { pub fn get_pl_delta(&self) -> f64 { - get_gear_delta_mult(self)*get_wep_delta_mult(self) + get_gear_delta_mult(self) * get_wep_delta_mult(self) } pub fn get_rpl_mult(&self) -> f64 { rpl_mult(self.rpl as f64) diff --git a/src/enemies/mod.rs b/src/enemies/mod.rs index 0b4e73ce..5295b52f 100644 --- a/src/enemies/mod.rs +++ b/src/enemies/mod.rs @@ -1,7 +1,6 @@ use crate::activity::Activity; -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] -#[derive(Default)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)] pub enum EnemyType { MINOR, ELITE, @@ -14,7 +13,6 @@ pub enum EnemyType { CHAMPION, } - #[derive(Debug, Clone, Default)] pub struct Enemy { pub health: f64, @@ -28,3 +26,18 @@ impl Enemy { self.health * (1.0 - self.damage_resistance) } } + +//is here to sanitize the formulas_types.rs file for build script +impl crate::types::formula_types::DamageModFormula { + pub fn get_mod(&self, _type: &EnemyType) -> f64 { + match *_type { + EnemyType::MINOR => self.minor, + EnemyType::ELITE => self.elite, + EnemyType::MINIBOSS => self.miniboss, + EnemyType::CHAMPION => self.champion, + EnemyType::BOSS => self.boss, + EnemyType::VEHICLE => self.vehicle, + _ => 1.0, + } + } +} \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index b7c424e3..9dd42a51 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,3 @@ -#![allow(dead_code)] -#![allow(unused_imports)] extern crate alloc; use logging::LogLevel; @@ -15,24 +13,25 @@ mod test; pub mod types; pub mod weapons; -use crate::perks::{Perk, Perks}; +use crate::perks::Perk; use crate::weapons::{Stat, Weapon}; use abilities::Ability; use activity::Activity; -use d2_enums::StatHashes; use enemies::Enemy; use std::cell::RefCell; use std::collections::HashMap; use std::panic; -#[cfg(target_arch = "wasm32")] -use lol_alloc::{AssumeSingleThreaded, FreeListAllocator}; // SAFETY: This application is single threaded, so using AssumeSingleThreaded is allowed. #[cfg(target_arch = "wasm32")] +use lol_alloc::{AssumeSingleThreaded, FreeListAllocator}; +#[cfg(target_arch = "wasm32")] #[global_allocator] static ALLOCATOR: AssumeSingleThreaded = unsafe { AssumeSingleThreaded::new(FreeListAllocator::new()) }; + + mod built_info { include!(concat!(env!("OUT_DIR"), "/built.rs")); } @@ -43,11 +42,7 @@ mod database { //JavaScript -use crate::types::js_types::{ - JsAmmoResponse, JsDifficultyOptions, JsDpsResponse, JsEnemyType, JsFiringResponse, - JsHandlingResponse, JsMetaData, JsRangeResponse, JsReloadResponse, JsResillienceSummary, - JsStat, -}; +use crate::types::prelude::*; use wasm_bindgen::prelude::*; diff --git a/src/logging.rs b/src/logging.rs index 814d9885..6eb0bc83 100644 --- a/src/logging.rs +++ b/src/logging.rs @@ -1,5 +1,4 @@ -#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] -#[derive(Default)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] pub enum LogLevel { Error, #[default] @@ -29,7 +28,6 @@ impl From for usize { } } - fn get_log_level() -> LogLevel { crate::PERS_DATA.with(|perm_data| perm_data.borrow().log_level) } diff --git a/src/perks/buff_perks.rs b/src/perks/buff_perks.rs index 44dcb5fd..97f90e44 100644 --- a/src/perks/buff_perks.rs +++ b/src/perks/buff_perks.rs @@ -62,19 +62,19 @@ fn gbl_debuff(_cached_data: &mut HashMap, _desired_buff: f64) -> f6 pub fn buff_perks() { add_dmr( Perks::WellOfRadiance, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let buff = emp_buff(_input.cached_data, 1.25); DamageModifierResponse { impact_dmg_scale: buff, explosive_dmg_scale: buff, ..Default::default() } - }), + }, ); add_dmr( Perks::NobleRounds, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { if _input.value == 0 { return DamageModifierResponse::default(); } @@ -85,12 +85,12 @@ pub fn buff_perks() { explosive_dmg_scale: buff, ..Default::default() } - }), + }, ); add_dmr( Perks::Radiant, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let des_buff = if _input.pvp { 1.1 } else { 1.25 }; let buff = emp_buff(_input.cached_data, des_buff); _input.cached_data.insert("radiant".to_string(), 1.0); @@ -99,24 +99,24 @@ pub fn buff_perks() { explosive_dmg_scale: buff, ..Default::default() } - }), + }, ); add_dmr( Perks::PathOfTheBurningSteps, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let buff = surge_buff(_input.cached_data, _input.value, _input.pvp); DamageModifierResponse { impact_dmg_scale: buff, explosive_dmg_scale: buff, ..Default::default() } - }), + }, ); add_dmr( Perks::BannerShield, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let des_buff = if _input.pvp { 1.35 } else { 1.4 }; let buff = emp_buff(_input.cached_data, des_buff); DamageModifierResponse { @@ -124,12 +124,12 @@ pub fn buff_perks() { explosive_dmg_scale: buff, ..Default::default() } - }), + }, ); add_dmr( Perks::EmpRift, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let des_buff = if _input.pvp { 1.15 } else { 1.2 }; let buff = emp_buff(_input.cached_data, des_buff); DamageModifierResponse { @@ -137,24 +137,24 @@ pub fn buff_perks() { explosive_dmg_scale: buff, ..Default::default() } - }), + }, ); add_dmr( Perks::WardOfDawn, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let buff = emp_buff(_input.cached_data, 1.25); DamageModifierResponse { impact_dmg_scale: buff, explosive_dmg_scale: buff, ..Default::default() } - }), + }, ); add_dmr( Perks::Gyrfalcon, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let des_buff = if _input.pvp { 1.0 } else { 1.35 }; let buff = emp_buff(_input.cached_data, des_buff); DamageModifierResponse { @@ -162,12 +162,12 @@ pub fn buff_perks() { explosive_dmg_scale: buff, ..Default::default() } - }), + }, ); add_dmr( Perks::AeonInsight, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { if _input.value > 0 { let des_buff = if _input.pvp { 1.0 } else { 1.35 }; let buff = emp_buff(_input.cached_data, des_buff); @@ -179,12 +179,12 @@ pub fn buff_perks() { } else { DamageModifierResponse::default() } - }), + }, ); add_dmr( Perks::UmbralSharpening, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let pve_values = [1.2, 1.25, 1.35, 1.4]; let des_buff = if _input.pvp { 1.0 @@ -197,12 +197,12 @@ pub fn buff_perks() { explosive_dmg_scale: buff, ..Default::default() } - }), + }, ); add_dmr( Perks::WormByproduct, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { if _input.value > 0 { DamageModifierResponse { impact_dmg_scale: 1.15, @@ -212,7 +212,7 @@ pub fn buff_perks() { } else { DamageModifierResponse::default() } - }), + }, ); // @@ -221,7 +221,7 @@ pub fn buff_perks() { add_dmr( Perks::Weaken, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let des_debuff = if _input.pvp { 1.075 } else { 1.15 }; let debuff = gbl_debuff(_input.cached_data, des_debuff); DamageModifierResponse { @@ -229,12 +229,12 @@ pub fn buff_perks() { explosive_dmg_scale: debuff, ..Default::default() } - }), + }, ); add_dmr( Perks::TractorCannon, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let des_debuff = if _input.pvp { 1.5 } else { 1.3 }; let debuff = gbl_debuff(_input.cached_data, des_debuff); DamageModifierResponse { @@ -242,12 +242,12 @@ pub fn buff_perks() { explosive_dmg_scale: debuff, ..Default::default() } - }), + }, ); add_dmr( Perks::MoebiusQuiver, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let des_debuff = if _input.pvp { 1.5 } else { 1.3 }; let debuff = gbl_debuff(_input.cached_data, des_debuff); DamageModifierResponse { @@ -255,11 +255,11 @@ pub fn buff_perks() { explosive_dmg_scale: debuff, ..Default::default() } - }), + }, ); add_dmr( Perks::DeadFall, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let des_debuff = if _input.pvp { 1.5 } else { 1.3 }; let debuff = gbl_debuff(_input.cached_data, des_debuff); DamageModifierResponse { @@ -267,11 +267,11 @@ pub fn buff_perks() { explosive_dmg_scale: debuff, ..Default::default() } - }), + }, ); add_dmr( Perks::Felwinters, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { if _input.value > 0 { let debuff = gbl_debuff(_input.cached_data, 1.3); DamageModifierResponse { @@ -282,12 +282,12 @@ pub fn buff_perks() { } else { DamageModifierResponse::default() } - }), + }, ); add_dmr( Perks::EnhancedScannerAugment, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let pve_values = [1.08, 1.137, 1.173, 1.193, 1.2]; let des_debuff = if _input.pvp { 1.0 @@ -300,34 +300,34 @@ pub fn buff_perks() { explosive_dmg_scale: debuff, ..Default::default() } - }), + }, ); add_dmr( Perks::SurgeMod, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let damage_mod = surge_buff(_input.cached_data, _input.value, _input.pvp); DamageModifierResponse { explosive_dmg_scale: damage_mod, impact_dmg_scale: damage_mod, ..Default::default() } - }), + }, ); add_dmr( Perks::EternalWarrior, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let damage_mod = surge_buff(_input.cached_data, _input.value, _input.pvp); DamageModifierResponse { explosive_dmg_scale: damage_mod, impact_dmg_scale: damage_mod, ..Default::default() } - }), + }, ); add_dmr( Perks::MantleOfBattleHarmony, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let buff = if _input.value > 0 { surge_buff(_input.cached_data, 4, _input.pvp) } else { @@ -338,11 +338,11 @@ pub fn buff_perks() { explosive_dmg_scale: buff, ..Default::default() } - }), + }, ); add_dmr( Perks::MaskOfBakris, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let buff = if _input.value > 0 && matches!( _input.calc_data.damage_type, @@ -357,11 +357,11 @@ pub fn buff_perks() { explosive_dmg_scale: buff, ..Default::default() } - }), + }, ); add_dmr( Perks::SanguineAlchemy, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { if _input.value == 0 || *_input.calc_data.damage_type == DamageType::KINETIC { return DamageModifierResponse::default(); } @@ -373,11 +373,11 @@ pub fn buff_perks() { explosive_dmg_scale: buff, ..Default::default() } - }), + }, ); add_dmr( Perks::Foetracers, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { if _input.value == 0 { return DamageModifierResponse::default(); } @@ -387,11 +387,11 @@ pub fn buff_perks() { explosive_dmg_scale: mult, ..Default::default() } - }), + }, ); add_dmr( Perks::GlacialGuard, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { if _input.value == 0 { return DamageModifierResponse::default(); } @@ -401,6 +401,6 @@ pub fn buff_perks() { explosive_dmg_scale: mult, ..Default::default() } - }), + }, ); } diff --git a/src/perks/exotic_armor.rs b/src/perks/exotic_armor.rs index cafe41e8..72d3c498 100644 --- a/src/perks/exotic_armor.rs +++ b/src/perks/exotic_armor.rs @@ -19,7 +19,7 @@ use super::{ pub fn exotic_armor() { add_dmr( Perks::BallindorseWrathweavers, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let mut modifier = DamageModifierResponse::default(); let value = if _input.pvp { 1.05 } else { 1.15 }; if _input.calc_data.damage_type == &DamageType::STASIS && _input.value >= 1 { @@ -27,12 +27,12 @@ pub fn exotic_armor() { modifier.explosive_dmg_scale = value; } modifier - }), + }, ); add_dmr( Perks::MechaneersTricksleeves, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { if _input.value == 0 || *_input.calc_data.weapon_type != WeaponType::SIDEARM { return DamageModifierResponse::default(); }; @@ -43,13 +43,13 @@ pub fn exotic_armor() { impact_dmg_scale: damage_mult, ..Default::default() } - }), + }, ); //doesnt work for sturm overcharge, (maybe) memento add_dmr( Perks::LuckyPants, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let perks = _input.calc_data.perk_value_map.clone(); let perk_check = @@ -73,45 +73,41 @@ pub fn exotic_armor() { impact_dmg_scale: 1.0 + mult * _input.value.clamp(0, 10) as f64, ..Default::default() } - }), + }, ); add_sbr( Perks::TomeOfDawn, - Box::new( - |_input: ModifierResponseInput| -> HashMap { - let mut stats = HashMap::new(); - if _input.value > 0 { - stats.insert(StatHashes::AIRBORNE.into(), 50); - } - stats - }, - ), + |_input: ModifierResponseInput| -> HashMap { + let mut stats = HashMap::new(); + if _input.value > 0 { + stats.insert(StatHashes::AIRBORNE.into(), 50); + } + stats + }, ); add_flmr( Perks::TomeOfDawn, - Box::new(|_input: ModifierResponseInput| -> FlinchModifierResponse { + |_input: ModifierResponseInput| -> FlinchModifierResponse { if _input.value > 0 { FlinchModifierResponse { flinch_scale: 0.80 } } else { FlinchModifierResponse::default() } - }), + }, ); add_sbr( Perks::KnuckleheadRadar, - Box::new( - |_input: ModifierResponseInput| -> HashMap { - HashMap::from([(StatHashes::AIRBORNE.into(), 20)]) - }, - ), + |_input: ModifierResponseInput| -> HashMap { + HashMap::from([(StatHashes::AIRBORNE.into(), 20)]) + }, ); add_dmr( Perks::KnuckleheadRadar, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let health_percent = *_input.cached_data.get("health%").unwrap_or(&1.0); if health_percent >= 0.3 || _input.value == 0 { return DamageModifierResponse::default(); @@ -122,44 +118,40 @@ pub fn exotic_armor() { explosive_dmg_scale: modifier, crit_scale: 1.0, } - }), + }, ); //TODO: MECHANEER'S TRICKSLEEVES AUTORELOAD add_sbr( Perks::MechaneersTricksleeves, - Box::new( - |_input: ModifierResponseInput| -> HashMap { - let mut stats = HashMap::new(); - if _input.calc_data.weapon_type == &WeaponType::SIDEARM { - stats.insert(StatHashes::AIRBORNE.into(), 50); - stats.insert(StatHashes::HANDLING.into(), 100); - stats.insert(StatHashes::RELOAD.into(), 100); - }; - stats - }, - ), + |_input: ModifierResponseInput| -> HashMap { + let mut stats = HashMap::new(); + if _input.calc_data.weapon_type == &WeaponType::SIDEARM { + stats.insert(StatHashes::AIRBORNE.into(), 50); + stats.insert(StatHashes::HANDLING.into(), 100); + stats.insert(StatHashes::RELOAD.into(), 100); + }; + stats + }, ); add_hmr( Perks::MechaneersTricksleeves, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - if _input.calc_data.weapon_type == &WeaponType::SIDEARM { - HandlingModifierResponse { - stat_add: 100, - ..Default::default() - } - } else { - HandlingModifierResponse::default() + |_input: ModifierResponseInput| -> HandlingModifierResponse { + if _input.calc_data.weapon_type == &WeaponType::SIDEARM { + HandlingModifierResponse { + stat_add: 100, + ..Default::default() } - }, - ), + } else { + HandlingModifierResponse::default() + } + }, ); add_rsmr( Perks::MechaneersTricksleeves, - Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { + |_input: ModifierResponseInput| -> ReloadModifierResponse { if _input.calc_data.weapon_type == &WeaponType::SIDEARM { ReloadModifierResponse { reload_stat_add: 100, @@ -168,12 +160,12 @@ pub fn exotic_armor() { } else { ReloadModifierResponse::default() } - }), + }, ); add_dmr( Perks::MechaneersTricksleeves, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let mult = if _input.pvp { 1.35 } else { 2.0 }; if _input.value > 0 && _input.calc_data.weapon_type == &WeaponType::SIDEARM { DamageModifierResponse { @@ -184,26 +176,24 @@ pub fn exotic_armor() { } else { DamageModifierResponse::default() } - }), + }, ); add_sbr( Perks::Oathkeeper, - Box::new( - |_input: ModifierResponseInput| -> HashMap { - let mut stats = HashMap::new(); - if _input.calc_data.weapon_type == &WeaponType::BOW { - stats.insert(StatHashes::AIRBORNE.into(), 40); - stats.insert(StatHashes::DRAW_TIME.into(), 10); - }; - stats - }, - ), + |_input: ModifierResponseInput| -> HashMap { + let mut stats = HashMap::new(); + if _input.calc_data.weapon_type == &WeaponType::BOW { + stats.insert(StatHashes::AIRBORNE.into(), 40); + stats.insert(StatHashes::DRAW_TIME.into(), 10); + }; + stats + }, ); /*add_fmr( Perks::Oathkeeper, - Box::new(|_input: ModifierResponsInput| -> FiringModifierResponse { + |_input: ModifierResponsInput| -> FiringModifierResponse { FiringModifierResponse { burst_delay_add: match _input.calc_data.intrinsic_hash { 906 => -36.0 / 1100.0, @@ -212,20 +202,18 @@ pub fn exotic_armor() { }, ..Default::default() } - }), + }, );*/ add_sbr( Perks::SealedAhamkaraGrasps, - Box::new( - |_input: ModifierResponseInput| -> HashMap { - let mut stats = HashMap::new(); - if _input.value > 0 { - stats.insert(StatHashes::AIRBORNE.into(), 50); - }; - stats - }, - ), + |_input: ModifierResponseInput| -> HashMap { + let mut stats = HashMap::new(); + if _input.value > 0 { + stats.insert(StatHashes::AIRBORNE.into(), 50); + }; + stats + }, ); //TODO: AUTORELOAD FOR SEALED AHAMKARA GRASPS @@ -233,50 +221,44 @@ pub fn exotic_armor() { //LUCKY PANTS ONLY WORKS FOR READY ?!?!?! crazy :( add_sbr( Perks::LuckyPants, - Box::new( - |_input: ModifierResponseInput| -> HashMap { - let mut stat = HashMap::new(); - if _input.value > 0 && _input.calc_data.weapon_type == &WeaponType::HANDCANNON { - stat.insert(StatHashes::AIRBORNE.into(), 20); - stat.insert(StatHashes::HANDLING.into(), 100); - }; - stat - }, - ), + |_input: ModifierResponseInput| -> HashMap { + let mut stat = HashMap::new(); + if _input.value > 0 && _input.calc_data.weapon_type == &WeaponType::HANDCANNON { + stat.insert(StatHashes::AIRBORNE.into(), 20); + stat.insert(StatHashes::HANDLING.into(), 100); + }; + stat + }, ); add_hmr( Perks::LuckyPants, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - if _input.value > 0 && _input.calc_data.weapon_type == &WeaponType::HANDCANNON { - return HandlingModifierResponse { - draw_add: 100, - draw_scale: 0.6, - ..Default::default() - }; - } - HandlingModifierResponse::default() - }, - ), + |_input: ModifierResponseInput| -> HandlingModifierResponse { + if _input.value > 0 && _input.calc_data.weapon_type == &WeaponType::HANDCANNON { + return HandlingModifierResponse { + draw_add: 100, + draw_scale: 0.6, + ..Default::default() + }; + } + HandlingModifierResponse::default() + }, ); add_sbr( Perks::NoBackupPlans, - Box::new( - |_input: ModifierResponseInput| -> HashMap { - let mut stats = HashMap::new(); - if _input.calc_data.weapon_type == &WeaponType::SHOTGUN { - stats.insert(StatHashes::AIRBORNE.into(), 30); - }; - stats - }, - ), + |_input: ModifierResponseInput| -> HashMap { + let mut stats = HashMap::new(); + if _input.calc_data.weapon_type == &WeaponType::SHOTGUN { + stats.insert(StatHashes::AIRBORNE.into(), 30); + }; + stats + }, ); add_dmr( Perks::NoBackupPlans, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { if *_input.calc_data.weapon_type != WeaponType::SHOTGUN || _input.value == 0 { return DamageModifierResponse::default(); } @@ -287,220 +269,192 @@ pub fn exotic_armor() { explosive_dmg_scale: buff, ..Default::default() } - }), + }, ); add_sbr( Perks::ActiumWarRig, - Box::new( - |_input: ModifierResponseInput| -> HashMap { - let mut stats = HashMap::new(); - if _input.calc_data.weapon_type == &WeaponType::AUTORIFLE - || _input.calc_data.weapon_type == &WeaponType::MACHINEGUN - { - stats.insert(StatHashes::AIRBORNE.into(), 30); - } - stats - }, - ), + |_input: ModifierResponseInput| -> HashMap { + let mut stats = HashMap::new(); + if _input.calc_data.weapon_type == &WeaponType::AUTORIFLE + || _input.calc_data.weapon_type == &WeaponType::MACHINEGUN + { + stats.insert(StatHashes::AIRBORNE.into(), 30); + } + stats + }, ); //TODO: AUTORELOAD ON ACTIUM WAR RIG add_sbr( Perks::HallowfireHeart, - Box::new( - |_input: ModifierResponseInput| -> HashMap { - HashMap::from([(StatHashes::AIRBORNE.into(), 20)]) - }, - ), + |_input: ModifierResponseInput| -> HashMap { + HashMap::from([(StatHashes::AIRBORNE.into(), 20)]) + }, ); add_sbr( Perks::LionRampart, - Box::new( - |_input: ModifierResponseInput| -> HashMap { - let mut stats = HashMap::new(); - if _input.value > 0 { - stats.insert(StatHashes::AIRBORNE.into(), 50); - }; - stats - }, - ), + |_input: ModifierResponseInput| -> HashMap { + let mut stats = HashMap::new(); + if _input.value > 0 { + stats.insert(StatHashes::AIRBORNE.into(), 50); + }; + stats + }, ); add_sbr( Perks::Peacekeepers, - Box::new( - |_input: ModifierResponseInput| -> HashMap { - let mut stats = HashMap::new(); - if _input.calc_data.weapon_type == &WeaponType::SUBMACHINEGUN { - stats.insert(StatHashes::AIRBORNE.into(), 40); - stats.insert(StatHashes::HANDLING.into(), 100); - }; - stats - }, - ), + |_input: ModifierResponseInput| -> HashMap { + let mut stats = HashMap::new(); + if _input.calc_data.weapon_type == &WeaponType::SUBMACHINEGUN { + stats.insert(StatHashes::AIRBORNE.into(), 40); + stats.insert(StatHashes::HANDLING.into(), 100); + }; + stats + }, ); add_hmr( Perks::Peacekeepers, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - if _input.calc_data.weapon_type == &WeaponType::SUBMACHINEGUN { - return HandlingModifierResponse { - stat_add: 100, - ads_scale: 1.0, - draw_scale: 0.6, - stow_scale: 0.6, - ..Default::default() - }; - } - HandlingModifierResponse::default() - }, - ), + |_input: ModifierResponseInput| -> HandlingModifierResponse { + if _input.calc_data.weapon_type == &WeaponType::SUBMACHINEGUN { + return HandlingModifierResponse { + stat_add: 100, + ads_scale: 1.0, + draw_scale: 0.6, + stow_scale: 0.6, + ..Default::default() + }; + } + HandlingModifierResponse::default() + }, ); add_sbr( Perks::PeregrineGreaves, - Box::new( - |_input: ModifierResponseInput| -> HashMap { - HashMap::from([(StatHashes::AIRBORNE.into(), 20)]) - }, - ), + |_input: ModifierResponseInput| -> HashMap { + HashMap::from([(StatHashes::AIRBORNE.into(), 20)]) + }, ); add_sbr( Perks::EyeOfAnotherWorld, - Box::new( - |_input: ModifierResponseInput| -> HashMap { - HashMap::from([(StatHashes::AIRBORNE.into(), 15)]) - }, - ), + |_input: ModifierResponseInput| -> HashMap { + HashMap::from([(StatHashes::AIRBORNE.into(), 15)]) + }, ); add_sbr( Perks::AstrocyteVerse, - Box::new( - |_input: ModifierResponseInput| -> HashMap { - let mut stats = HashMap::new(); - stats.insert(StatHashes::AIRBORNE.into(), 30); - if _input.value > 0 { - stats.insert(StatHashes::HANDLING.into(), 100); - } - stats - }, - ), + |_input: ModifierResponseInput| -> HashMap { + let mut stats = HashMap::new(); + stats.insert(StatHashes::AIRBORNE.into(), 30); + if _input.value > 0 { + stats.insert(StatHashes::HANDLING.into(), 100); + } + stats + }, ); add_hmr( Perks::AstrocyteVerse, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - if _input.value == 0 { - return HandlingModifierResponse::default(); - } - HandlingModifierResponse { - draw_add: 100, - ..Default::default() - } - }, - ), + |_input: ModifierResponseInput| -> HandlingModifierResponse { + if _input.value == 0 { + return HandlingModifierResponse::default(); + } + HandlingModifierResponse { + draw_add: 100, + ..Default::default() + } + }, ); add_sbr( Perks::NecroticGrips, - Box::new( - |_input: ModifierResponseInput| -> HashMap { - let mut stats = HashMap::new(); - if _input.calc_data.intrinsic_hash == 1863355414 - || _input.calc_data.intrinsic_hash == 2965975126 - || _input.calc_data.intrinsic_hash == 2724693746 - { - //Thorn, Osteo Striga, Touch of Malice - stats.insert(StatHashes::AIRBORNE.into(), 30); - }; - stats - }, - ), + |_input: ModifierResponseInput| -> HashMap { + let mut stats = HashMap::new(); + if _input.calc_data.intrinsic_hash == 1863355414 + || _input.calc_data.intrinsic_hash == 2965975126 + || _input.calc_data.intrinsic_hash == 2724693746 + { + //Thorn, Osteo Striga, Touch of Malice + stats.insert(StatHashes::AIRBORNE.into(), 30); + }; + stats + }, ); add_sbr( Perks::BootsOfTheAssembler, - Box::new( - |_input: ModifierResponseInput| -> HashMap { - let mut stats = HashMap::new(); - if _input.calc_data.intrinsic_hash == 2144092201 { - //Lumina - stats.insert(StatHashes::AIRBORNE.into(), 30); - }; - stats - }, - ), + |_input: ModifierResponseInput| -> HashMap { + let mut stats = HashMap::new(); + if _input.calc_data.intrinsic_hash == 2144092201 { + //Lumina + stats.insert(StatHashes::AIRBORNE.into(), 30); + }; + stats + }, ); add_sbr( Perks::RainOfFire, - Box::new( - |_input: ModifierResponseInput| -> HashMap { - let mut stats = HashMap::new(); - if _input.calc_data.weapon_type == &WeaponType::FUSIONRIFLE - || _input.calc_data.weapon_type == &WeaponType::LINEARFUSIONRIFLE - { - stats.insert(StatHashes::AIRBORNE.into(), 30); - } - stats - }, - ), + |_input: ModifierResponseInput| -> HashMap { + let mut stats = HashMap::new(); + if _input.calc_data.weapon_type == &WeaponType::FUSIONRIFLE + || _input.calc_data.weapon_type == &WeaponType::LINEARFUSIONRIFLE + { + stats.insert(StatHashes::AIRBORNE.into(), 30); + } + stats + }, ); add_sbr( Perks::SpeedloaderSlacks, - Box::new( - |_input: ModifierResponseInput| -> HashMap { - let modifiers = match _input.value { - 0 => (0, 0, 0), - 1 => (40, 40, 30), - 2 => (40, 40, 35), - 3 => (45, 45, 40), - 4 => (50, 50, 45), - 5 => (55, 55, 50), - _ => (55, 55, 50), - }; + |_input: ModifierResponseInput| -> HashMap { + let modifiers = match _input.value { + 0 => (0, 0, 0), + 1 => (40, 40, 30), + 2 => (40, 40, 35), + 3 => (45, 45, 40), + 4 => (50, 50, 45), + 5 => (55, 55, 50), + _ => (55, 55, 50), + }; - HashMap::from([ - (StatHashes::RELOAD.into(), modifiers.0), - (StatHashes::HANDLING.into(), modifiers.1), //? - (StatHashes::AIRBORNE.into(), modifiers.2), - ]) - }, - ), + HashMap::from([ + (StatHashes::RELOAD.into(), modifiers.0), + (StatHashes::HANDLING.into(), modifiers.1), //? + (StatHashes::AIRBORNE.into(), modifiers.2), + ]) + }, ); add_hmr( Perks::SpeedloaderSlacks, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - let handling = match _input.value { - 0 => 0, - 1 => 40, - 2 => 40, - 3 => 45, - 4 => 50, - 5 => 55, - _ => 55, - }; - HandlingModifierResponse { - stat_add: handling, - ..Default::default() - } - }, - ), + |_input: ModifierResponseInput| -> HandlingModifierResponse { + let handling = match _input.value { + 0 => 0, + 1 => 40, + 2 => 40, + 3 => 45, + 4 => 50, + 5 => 55, + _ => 55, + }; + HandlingModifierResponse { + stat_add: handling, + ..Default::default() + } + }, ); add_rsmr( Perks::SpeedloaderSlacks, - Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { + |_input: ModifierResponseInput| -> ReloadModifierResponse { let modifiers = match _input.value { 0 => (0, 1.0), 1 => (40, 1.0), @@ -515,25 +469,23 @@ pub fn exotic_armor() { reload_stat_add: modifiers.0, reload_time_scale: modifiers.1, } - }), + }, ); add_sbr( Perks::LunaFaction, - Box::new( - |_input: ModifierResponseInput| -> HashMap { - let mut stat = HashMap::new(); - if _input.value >= 1 { - stat.insert(StatHashes::RELOAD.into(), 100); - } - stat - }, - ), + |_input: ModifierResponseInput| -> HashMap { + let mut stat = HashMap::new(); + if _input.value >= 1 { + stat.insert(StatHashes::RELOAD.into(), 100); + } + stat + }, ); add_rsmr( Perks::LunaFaction, - Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { + |_input: ModifierResponseInput| -> ReloadModifierResponse { if _input.value >= 1 { ReloadModifierResponse { reload_stat_add: 100, @@ -542,12 +494,12 @@ pub fn exotic_armor() { } else { ReloadModifierResponse::default() } - }), + }, ); add_rmr( Perks::LunaFaction, - Box::new(|_input: ModifierResponseInput| -> RangeModifierResponse { + |_input: ModifierResponseInput| -> RangeModifierResponse { if _input.value >= 2 { return RangeModifierResponse { range_all_scale: 2.0, @@ -555,16 +507,16 @@ pub fn exotic_armor() { }; } RangeModifierResponse::default() - }), + }, ); add_sbr( Perks::TritonVice, - Box::new(|_input| -> HashMap { + |_input| -> HashMap { let mut stats = HashMap::new(); if _input.value > 0 && *_input.calc_data.weapon_type == WeaponType::GLAIVE { stats.insert(StatHashes::RELOAD.into(), 50); } stats - }), - ) + }, + ); } diff --git a/src/perks/exotic_perks.rs b/src/perks/exotic_perks.rs index 639b9d2b..0f6ca889 100644 --- a/src/perks/exotic_perks.rs +++ b/src/perks/exotic_perks.rs @@ -1,8 +1,6 @@ //This also includes intrinsic perks, not just exotic use std::collections::HashMap; -use serde::__private::de; - use crate::{d2_enums::StatHashes, enemies::EnemyType, weapons::Stat}; use super::{ @@ -19,7 +17,7 @@ use super::{ pub fn exotic_perks() { add_dmr( Perks::ParacausalShot, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let bufflist_pve = vec![1.0, 3.92, 4.0, 4.4, 5.25, 7.67, 11.71, 18.36]; let bufflist_pvp = vec![1.0, 1.01, 1.03, 1.13, 1.41, 1.96, 3.0, 4.73]; let mut damage_buff = 1.0; @@ -46,12 +44,12 @@ pub fn exotic_perks() { explosive_dmg_scale: damage_buff, crit_scale: 1.0, } - }), + }, ); add_sbr( Perks::HuntersTrance, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut out = HashMap::new(); let inter_val = *_input .calc_data @@ -63,12 +61,12 @@ pub fn exotic_perks() { out.insert(StatHashes::RANGE.into(), buff_val); out.insert(StatHashes::HANDLING.into(), buff_val); out - }), + }, ); add_rsmr( Perks::HuntersTrance, - Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { + |_input: ModifierResponseInput| -> ReloadModifierResponse { let inter_val = *_input .calc_data .perk_value_map @@ -79,12 +77,12 @@ pub fn exotic_perks() { reload_stat_add: buff_val, ..Default::default() } - }), + }, ); add_rmr( Perks::HuntersTrance, - Box::new(|_input: ModifierResponseInput| -> RangeModifierResponse { + |_input: ModifierResponseInput| -> RangeModifierResponse { let inter_val = *_input .calc_data .perk_value_map @@ -95,41 +93,39 @@ pub fn exotic_perks() { range_stat_add: buff_val, ..Default::default() } - }), + }, ); add_hmr( Perks::HuntersTrance, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - let inter_val = *_input - .calc_data - .perk_value_map - .get(&213689231) - .unwrap_or(&0); - let buff_val = (clamp(inter_val, 0, 7) * 5) as i32; - HandlingModifierResponse { - stat_add: buff_val, - ..Default::default() - } - }, - ), + |_input: ModifierResponseInput| -> HandlingModifierResponse { + let inter_val = *_input + .calc_data + .perk_value_map + .get(&213689231) + .unwrap_or(&0); + let buff_val = (clamp(inter_val, 0, 7) * 5) as i32; + HandlingModifierResponse { + stat_add: buff_val, + ..Default::default() + } + }, ); add_rmr( Perks::HuntersTrace, - Box::new(|_input: ModifierResponseInput| -> RangeModifierResponse { + |_input: ModifierResponseInput| -> RangeModifierResponse { let range_ads_scale = if _input.value > 0 { 4.5 / 1.7 } else { 1.0 }; RangeModifierResponse { range_zoom_scale: range_ads_scale, ..Default::default() } - }), + }, ); add_dmr( Perks::MementoMori, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let mut damage_buff = 1.0; if _input.value > 0 && _input.calc_data.total_shots_fired < 7.0 { damage_buff = if _input.pvp { 1.285 } else { 1.5 }; @@ -139,12 +135,12 @@ pub fn exotic_perks() { explosive_dmg_scale: damage_buff, crit_scale: 1.0, } - }), + }, ); add_rmr( Perks::MementoMori, - Box::new(|_input: ModifierResponseInput| -> RangeModifierResponse { + |_input: ModifierResponseInput| -> RangeModifierResponse { let range_all_scale = if _input.value > 0 && _input.calc_data.total_shots_fired < 7.0 { 0.85 } else { @@ -154,24 +150,24 @@ pub fn exotic_perks() { range_all_scale, ..Default::default() } - }), + }, ); add_sbr( Perks::Roadborn, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut out = HashMap::new(); if _input.value > 0 { out.insert(StatHashes::HANDLING.into(), 20); out.insert(StatHashes::RELOAD.into(), 40); }; out - }), + }, ); add_dmr( Perks::Roadborn, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let mut crit_mult = 1.0; if _input.value > 0 { crit_mult = 1.17; @@ -181,12 +177,12 @@ pub fn exotic_perks() { explosive_dmg_scale: 1.0, impact_dmg_scale: 1.0, } - }), + }, ); add_fmr( Perks::Roadborn, - Box::new(|_input: ModifierResponseInput| -> FiringModifierResponse { + |_input: ModifierResponseInput| -> FiringModifierResponse { let mut delay_mult = 1.0; if _input.value > 0 { delay_mult = 0.583; @@ -197,12 +193,12 @@ pub fn exotic_perks() { inner_burst_scale: 1.0, burst_size_add: 0.0, } - }), + }, ); add_rmr( Perks::Roadborn, - Box::new(|_input: ModifierResponseInput| -> RangeModifierResponse { + |_input: ModifierResponseInput| -> RangeModifierResponse { let mut range_scale = 1.05; if _input.value > 0 { range_scale = 1.15; //roughly @@ -213,12 +209,12 @@ pub fn exotic_perks() { range_hip_scale: 1.0, range_zoom_scale: 1.0, } - }), + }, ); add_rsmr( Perks::Roadborn, - Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { + |_input: ModifierResponseInput| -> ReloadModifierResponse { let mut reload = 0; if _input.value > 0 { reload = 40; @@ -227,12 +223,12 @@ pub fn exotic_perks() { reload_stat_add: reload, reload_time_scale: 1.0, } - }), + }, ); add_fmr( Perks::ReignHavoc, - Box::new(|_input: ModifierResponseInput| -> FiringModifierResponse { + |_input: ModifierResponseInput| -> FiringModifierResponse { let mut delay_mult = 1.0; if _input.calc_data.shots_fired_this_mag >= _input.calc_data.base_mag * 0.2 { delay_mult = 0.75; @@ -246,12 +242,12 @@ pub fn exotic_perks() { inner_burst_scale: 1.0, burst_size_add: 0.0, } - }), + }, ); add_edr( Perks::ReignHavoc, - Box::new(|_input: ModifierResponseInput| -> ExtraDamageResponse { + |_input: ModifierResponseInput| -> ExtraDamageResponse { let dmg = if _input.pvp { 65.0 } else { 65.0 * 1.3 }; ExtraDamageResponse { additive_damage: dmg, @@ -264,24 +260,24 @@ pub fn exotic_perks() { crit_scale: false, combatant_scale: true, } - }), + }, ); add_dmr( Perks::WormsHunger, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let val = clamp(_input.value, 0, 20); DamageModifierResponse { impact_dmg_scale: 1.0 + (val as f64) * 0.1, explosive_dmg_scale: 1.0 + (val as f64) * 0.1, crit_scale: 1.0, } - }), + }, ); add_dmr( Perks::LagragianSight, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let mut damage_buff = 1.0; if _input.value > 0 && _input.calc_data.time_total < 30.0 { damage_buff = 1.4; @@ -291,12 +287,12 @@ pub fn exotic_perks() { explosive_dmg_scale: damage_buff, crit_scale: 1.0, } - }), + }, ); add_dmr( Perks::ToM, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let mut damage_buff = 1.0; if _input.calc_data.curr_mag == 1.0 { damage_buff = if _input.pvp { 2.0 } else { 2.4 }; @@ -306,12 +302,12 @@ pub fn exotic_perks() { explosive_dmg_scale: damage_buff, crit_scale: 1.0, } - }), + }, ); add_rr( Perks::ToM, - Box::new(|_input: ModifierResponseInput| -> RefundResponse { + |_input: ModifierResponseInput| -> RefundResponse { RefundResponse { refund_mag: if _input.calc_data.curr_mag == 0.0 { 1 @@ -322,12 +318,12 @@ pub fn exotic_perks() { crit: false, requirement: 1, } - }), + }, ); add_edr( Perks::RocketTracers, - Box::new(|_input: ModifierResponseInput| -> ExtraDamageResponse { + |_input: ModifierResponseInput| -> ExtraDamageResponse { let dmg = if _input.pvp { 24.0 } else { 105.0 }; ExtraDamageResponse { additive_damage: dmg, @@ -340,7 +336,7 @@ pub fn exotic_perks() { crit_scale: false, combatant_scale: true, } - }), + }, ); // add_edr_guidance_ring( @@ -395,29 +391,29 @@ pub fn exotic_perks() { add_fmr( Perks::HakkeHeavyBurst, - Box::new(|_input: ModifierResponseInput| -> FiringModifierResponse { + |_input: ModifierResponseInput| -> FiringModifierResponse { FiringModifierResponse { burst_size_add: -2.0, ..Default::default() } - }), + }, ); add_dmr( Perks::HakkeHeavyBurst, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let crit_scale = (1.5 + 5.0 / 51.0) / _input.calc_data.base_crit_mult; DamageModifierResponse { explosive_dmg_scale: 1.48, impact_dmg_scale: 1.48, crit_scale, } - }), + }, ); add_dmr( Perks::SwoopingTalons, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let mut dmg_mult = 1.0; if _input.value > 0 { dmg_mult = 1.4; @@ -429,11 +425,12 @@ pub fn exotic_perks() { explosive_dmg_scale: dmg_mult, crit_scale: 1.0, } - }), + }, ); + add_dmr( Perks::IgnitionTrigger, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let mut dmg_mult = 1.0; if _input.value > 0 || _input.calc_data.total_shots_fired > 20.0 { dmg_mult = if _input.pvp { 1.55 } else { 1.99 }; @@ -443,12 +440,12 @@ pub fn exotic_perks() { explosive_dmg_scale: dmg_mult, crit_scale: 1.0, } - }), + }, ); add_dmr( Perks::CalculatedBalance, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let mut damage_mult = if _input.value > 0 { 0.2 } else { 0.0 }; let duration = 5.0; if _input.calc_data.time_total > duration { @@ -459,12 +456,12 @@ pub fn exotic_perks() { explosive_dmg_scale: 1.0 + damage_mult, crit_scale: 1.0, } - }), + }, ); add_fmr( Perks::RavenousBeast, - Box::new(|_input: ModifierResponseInput| -> FiringModifierResponse { + |_input: ModifierResponseInput| -> FiringModifierResponse { if _input.value > 0 { FiringModifierResponse { burst_delay_scale: 0.8, @@ -473,12 +470,12 @@ pub fn exotic_perks() { } else { FiringModifierResponse::default() } - }), + }, ); add_dmr( Perks::RavenousBeast, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let mut damage_mult = 1.0; let mut crit_mult = 1.0; if _input.value > 0 { @@ -494,12 +491,12 @@ pub fn exotic_perks() { explosive_dmg_scale: damage_mult, crit_scale: crit_mult, } - }), + }, ); add_sbr( Perks::ReleaseTheWolves, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let has_cat = _input.calc_data.perk_value_map.contains_key(&431220296); let mut out = HashMap::new(); if has_cat { @@ -510,12 +507,12 @@ pub fn exotic_perks() { } } out - }), + }, ); add_rsmr( Perks::ReleaseTheWolves, - Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { + |_input: ModifierResponseInput| -> ReloadModifierResponse { let has_cat = _input.calc_data.perk_value_map.contains_key(&431220296); if _input.value == 1 && has_cat { ReloadModifierResponse { @@ -525,12 +522,12 @@ pub fn exotic_perks() { } else { ReloadModifierResponse::default() } - }), + }, ); add_fmr( Perks::ReleaseTheWolves, - Box::new(|_input: ModifierResponseInput| -> FiringModifierResponse { + |_input: ModifierResponseInput| -> FiringModifierResponse { if _input.value > 0 { FiringModifierResponse { burst_delay_scale: 0.4, @@ -539,24 +536,24 @@ pub fn exotic_perks() { } else { FiringModifierResponse::default() } - }), + }, ); add_dmr( Perks::ReleaseTheWolves, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let damage_mult = if _input.value > 0 { 1.4 } else { 1.0 }; DamageModifierResponse { impact_dmg_scale: damage_mult, explosive_dmg_scale: damage_mult, crit_scale: 1.0, } - }), + }, ); add_sbr( Perks::Fundamentals, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut stats = HashMap::new(); if _input.value == 1 { stats.insert(StatHashes::STABILITY.into(), 20); @@ -569,28 +566,26 @@ pub fn exotic_perks() { stats.insert(StatHashes::HANDLING.into(), 25); }; stats - }), + }, ); add_hmr( Perks::Fundamentals, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - let mut handling = 0; - if _input.value == 3 { - handling = 25; - } - HandlingModifierResponse { - stat_add: handling, - ..Default::default() - } - }, - ), + |_input: ModifierResponseInput| -> HandlingModifierResponse { + let mut handling = 0; + if _input.value == 3 { + handling = 25; + } + HandlingModifierResponse { + stat_add: handling, + ..Default::default() + } + }, ); add_rsmr( Perks::Fundamentals, - Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { + |_input: ModifierResponseInput| -> ReloadModifierResponse { let mut reload = 0; if _input.value == 2 { reload = 35; @@ -599,12 +594,12 @@ pub fn exotic_perks() { reload_stat_add: reload, ..Default::default() } - }), + }, ); add_rmr( Perks::Fundamentals, - Box::new(|_input: ModifierResponseInput| -> RangeModifierResponse { + |_input: ModifierResponseInput| -> RangeModifierResponse { let mut range = 0; if _input.value == 3 { range = 5; @@ -613,23 +608,23 @@ pub fn exotic_perks() { range_stat_add: range, ..Default::default() } - }), + }, ); add_sbr( Perks::ThinTheHerd, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut out = HashMap::new(); if _input.value > 0 { out.insert(StatHashes::RELOAD.into(), 70); } out - }), + }, ); add_rsmr( Perks::ThinTheHerd, - Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { + |_input: ModifierResponseInput| -> ReloadModifierResponse { if _input.value > 0 { ReloadModifierResponse { reload_stat_add: 70, @@ -638,39 +633,37 @@ pub fn exotic_perks() { } else { ReloadModifierResponse::default() } - }), + }, ); add_hmr( Perks::Chimera, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - if _input.value > 0 { - HandlingModifierResponse { - stat_add: 100, - ..Default::default() - } - } else { - HandlingModifierResponse::default() + |_input: ModifierResponseInput| -> HandlingModifierResponse { + if _input.value > 0 { + HandlingModifierResponse { + stat_add: 100, + ..Default::default() } - }, - ), + } else { + HandlingModifierResponse::default() + } + }, ); add_sbr( Perks::Chimera, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut out = HashMap::new(); if _input.value > 0 { out.insert(StatHashes::RELOAD.into(), 100); } out - }), + }, ); add_dmr( Perks::FirstGlance, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let mut damage_mult = 1.0; let mut crit_mult = 1.0; if _input.value > 0 { @@ -685,12 +678,12 @@ pub fn exotic_perks() { impact_dmg_scale: damage_mult, crit_scale: crit_mult, } - }), + }, ); add_dmr( Perks::FateOfAllFools, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let mut damage_mult = 1.0; let mut crit_mult = 1.0; if _input.value as f64 > _input.calc_data.total_shots_fired { @@ -703,12 +696,12 @@ pub fn exotic_perks() { impact_dmg_scale: damage_mult, crit_scale: crit_mult, } - }), + }, ); add_dmr( Perks::HonedEdge, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let mut damage_mult = 1.0; let has_cat = _input.calc_data.perk_value_map.contains_key(&529188544); if _input.value == 2 { @@ -725,12 +718,12 @@ pub fn exotic_perks() { impact_dmg_scale: damage_mult, crit_scale: 1.0, } - }), + }, ); add_dmr( Perks::TakenPredator, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let mut damage_mult = 1.0; if _input.value == 1 || _input.value == 2 { damage_mult = 1.25; @@ -742,12 +735,12 @@ pub fn exotic_perks() { impact_dmg_scale: damage_mult, crit_scale: 1.0, } - }), + }, ); add_dmr( Perks::MarkovChain, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let val = clamp(_input.value, 0, 5); let damage_mult = (1.0 / 15.0) * val as f64 * if _input.pvp { 1.0 } else { 2.0 }; DamageModifierResponse { @@ -755,12 +748,12 @@ pub fn exotic_perks() { impact_dmg_scale: 1.0 + damage_mult, crit_scale: 1.0, } - }), + }, ); add_dmr( Perks::StringofCurses, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let val = clamp(_input.value, 0, 5); let mut damage_mult = 0.2 * val as f64; if _input.pvp { @@ -775,12 +768,12 @@ pub fn exotic_perks() { explosive_dmg_scale: 1.0 + damage_mult, crit_scale: 1.0, } - }), + }, ); add_dmr( Perks::StormAndStress, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { if _input.value == 0 { return DamageModifierResponse::default(); } @@ -791,12 +784,12 @@ pub fn exotic_perks() { impact_dmg_scale: damage_mult, ..Default::default() } - }), + }, ); add_rmr( Perks::DualSpeedReceiver, - Box::new(|_input: ModifierResponseInput| -> RangeModifierResponse { + |_input: ModifierResponseInput| -> RangeModifierResponse { if _input.value == 0 { return RangeModifierResponse::default(); } @@ -804,35 +797,35 @@ pub fn exotic_perks() { range_stat_add: 30, ..Default::default() } - }), + }, ); add_sbr( Perks::DualSpeedReceiver, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut out = HashMap::new(); if _input.value > 0 { out.insert(StatHashes::ZOOM.into(), 3); out.insert(StatHashes::RANGE.into(), 30); } out - }), + }, ); add_dmr( Perks::FullStop, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { DamageModifierResponse { explosive_dmg_scale: 1.0, impact_dmg_scale: 1.0, crit_scale: if !_input.pvp { 2.9 } else { 1.0 }, } - }), + }, ); add_fmr( Perks::RatPack, - Box::new(|_input: ModifierResponseInput| -> FiringModifierResponse { + |_input: ModifierResponseInput| -> FiringModifierResponse { if _input.value == 0 { return FiringModifierResponse::default(); } @@ -842,83 +835,81 @@ pub fn exotic_perks() { burst_delay_add: val as f64 * (-0.625 / 30.0), ..Default::default() } - }), + }, ); add_mmr( Perks::RatPack, - Box::new( - |_input: ModifierResponseInput| -> MagazineModifierResponse { - let val = clamp(_input.value - 1, 0, 4); - MagazineModifierResponse { - magazine_add: val as f64 * if val == 4 { 2.25 } else { 2.0 }, - ..Default::default() - } - }, - ), + |_input: ModifierResponseInput| -> MagazineModifierResponse { + let val = clamp(_input.value - 1, 0, 4); + MagazineModifierResponse { + magazine_add: val as f64 * if val == 4 { 2.25 } else { 2.0 }, + ..Default::default() + } + }, ); add_fmr( Perks::RideTheBull, - Box::new(|_input: ModifierResponseInput| -> FiringModifierResponse { + |_input: ModifierResponseInput| -> FiringModifierResponse { let extra_value = _input.calc_data.shots_fired_this_mag / 10.0; let val = clamp(_input.value + extra_value as u32, 0, 2); FiringModifierResponse { burst_delay_add: val as f64 * (-0.25 / 30.0), ..Default::default() } - }), + }, ); add_fmr( Perks::SpinningUp, - Box::new(|_input: ModifierResponseInput| -> FiringModifierResponse { + |_input: ModifierResponseInput| -> FiringModifierResponse { let extra_value = _input.calc_data.shots_fired_this_mag / 12.0; let val = clamp(_input.value + extra_value as u32, 0, 2); FiringModifierResponse { burst_delay_add: val as f64 * (-0.5 / 30.0), ..Default::default() } - }), + }, ); add_sbr( Perks::CranialSpike, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut out = HashMap::new(); let val = clamp(_input.value, 0, 5) as i32; out.insert(StatHashes::RANGE.into(), 8 * val); out.insert(StatHashes::AIM_ASSIST.into(), 4 * val); out - }), + }, ); add_rsmr( Perks::CranialSpike, - Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { + |_input: ModifierResponseInput| -> ReloadModifierResponse { let val = clamp(_input.value, 0, 5) as i32; let rel = 0.97_f64.powi(val); ReloadModifierResponse { reload_time_scale: rel, ..Default::default() } - }), + }, ); add_rmr( Perks::CranialSpike, - Box::new(|_input: ModifierResponseInput| -> RangeModifierResponse { + |_input: ModifierResponseInput| -> RangeModifierResponse { let val = clamp(_input.value, 0, 5) as i32; RangeModifierResponse { range_stat_add: 8 * val, ..Default::default() } - }), + }, ); add_fmr( Perks::DarkForgedTrigger, - Box::new(|_input: ModifierResponseInput| -> FiringModifierResponse { + |_input: ModifierResponseInput| -> FiringModifierResponse { if _input.value == 0 { if _input .calc_data @@ -940,12 +931,12 @@ pub fn exotic_perks() { } else { FiringModifierResponse::default() } - }), + }, ); add_dmr( Perks::HarmonicLaser, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let buff = match (_input.value, _input.pvp) { (0, _) => 1.0, (1, true) => 1.03, @@ -957,12 +948,12 @@ pub fn exotic_perks() { impact_dmg_scale: buff, ..Default::default() } - }), + }, ); add_dmr( Perks::AgersScepterCatalyst, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { if _input.value > 0 { return DamageModifierResponse { impact_dmg_scale: 1.8, @@ -970,61 +961,59 @@ pub fn exotic_perks() { }; } DamageModifierResponse::default() - }), + }, ); add_mmr( Perks::AgersScepterCatalyst, - Box::new( - |_input: ModifierResponseInput| -> MagazineModifierResponse { - let mag_buff = if _input.value > 0 && _input.calc_data.total_shots_fired == 0.0 { - 2.0 - } else { - 1.0 - }; - MagazineModifierResponse { - magazine_scale: mag_buff, - ..Default::default() - } - }, - ), + |_input: ModifierResponseInput| -> MagazineModifierResponse { + let mag_buff = if _input.value > 0 && _input.calc_data.total_shots_fired == 0.0 { + 2.0 + } else { + 1.0 + }; + MagazineModifierResponse { + magazine_scale: mag_buff, + ..Default::default() + } + }, ); add_dmr( Perks::ColdFusion, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let buff = 0.0195 * clamp(_input.calc_data.total_shots_hit, 0.0, 41.0); DamageModifierResponse { impact_dmg_scale: 1.0 + buff, ..Default::default() } - }), + }, ); //Queenbreaker's sights add_dmr( Perks::MarksmanSights, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { DamageModifierResponse { impact_dmg_scale: 1.38, ..Default::default() } - }), + }, ); add_fmr( Perks::MarksmanSights, - Box::new(|_input: ModifierResponseInput| -> FiringModifierResponse { + |_input: ModifierResponseInput| -> FiringModifierResponse { FiringModifierResponse { burst_delay_add: (1800.0 / (60000.0 / 333.0)), // 300 + 333 = 633 , ..Default::default() } - }), + }, ); add_dmr( Perks::Broadside, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let buff = match _input.value { 0 => 1.0, 1 => 1.18, @@ -1036,12 +1025,12 @@ pub fn exotic_perks() { impact_dmg_scale: buff, ..Default::default() } - }), + }, ); add_fmr( Perks::TemporalUnlimiter, - Box::new(|_input: ModifierResponseInput| -> FiringModifierResponse { + |_input: ModifierResponseInput| -> FiringModifierResponse { if _input.value > 0 { return FiringModifierResponse { burst_delay_add: 0.366, @@ -1049,12 +1038,12 @@ pub fn exotic_perks() { }; } FiringModifierResponse::default() - }), + }, ); add_dmr( Perks::TemporalUnlimiter, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let buff = if _input.pvp { 7.545 } else { 14.0 }; if _input.value > 0 { return DamageModifierResponse { @@ -1064,24 +1053,22 @@ pub fn exotic_perks() { }; } DamageModifierResponse::default() - }), + }, ); add_mmr( Perks::FourthHorsemanCatalyst, - Box::new( - |_input: ModifierResponseInput| -> MagazineModifierResponse { - MagazineModifierResponse { - magazine_add: 1.0, - ..Default::default() - } - }, - ), + |_input: ModifierResponseInput| -> MagazineModifierResponse { + MagazineModifierResponse { + magazine_add: 1.0, + ..Default::default() + } + }, ); add_dmr( Perks::BlackHole, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let buff = if _input.calc_data.total_shots_hit % 2.0 == 1.0 { 1.35 } else { @@ -1091,12 +1078,12 @@ pub fn exotic_perks() { impact_dmg_scale: buff, ..Default::default() } - }), + }, ); add_dmr( Perks::Impetus, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { if _input.value > 0 { return DamageModifierResponse { impact_dmg_scale: 1.5, @@ -1104,22 +1091,22 @@ pub fn exotic_perks() { }; } DamageModifierResponse::default() - }), + }, ); add_fmr( Perks::MarksmanSights, - Box::new(|_input: ModifierResponseInput| -> FiringModifierResponse { + |_input: ModifierResponseInput| -> FiringModifierResponse { FiringModifierResponse { burst_delay_add: 0.333, // 300 + 333 = 633 , ..Default::default() } - }), + }, ); add_dmr( Perks::Broadhead, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let broadhead_damage = if _input.pvp { 30.0 } else { 60.0 }; let impact_damage = _input.calc_data.curr_firing_data.damage; let crit_mult = _input.calc_data.curr_firing_data.crit_mult; @@ -1134,11 +1121,11 @@ pub fn exotic_perks() { crit_scale, ..Default::default() } - }), + }, ); add_fmr( Perks::Desperation, - Box::new(|_input: ModifierResponseInput| -> FiringModifierResponse { + |_input: ModifierResponseInput| -> FiringModifierResponse { let duration = 7.0; if _input.value == 0 || _input.calc_data.time_total > duration { return FiringModifierResponse::default(); @@ -1147,6 +1134,6 @@ pub fn exotic_perks() { burst_delay_scale: 0.8, ..Default::default() } - }), + }, ); } diff --git a/src/perks/lib.rs b/src/perks/lib.rs index ba98a68e..aa792b90 100644 --- a/src/perks/lib.rs +++ b/src/perks/lib.rs @@ -1,16 +1,16 @@ use crate::{ - d2_enums::{AmmoType, BungieHash, DamageSource, DamageType, StatBump, StatHashes, WeaponType}, + d2_enums::{AmmoType, BungieHash, DamageSource, DamageType, StatBump, WeaponType}, enemies::EnemyType, - types::rs_types::{FiringData, HandlingResponse}, + types::{rs_types::HandlingResponse, formula_types::FiringDataFormula}, weapons::Stat, }; use serde::Serialize; -use std::{cell::RefCell, collections::HashMap, ops::Mul}; +use std::collections::HashMap; #[derive(Debug, Clone)] pub struct CalculationInput<'a> { pub intrinsic_hash: u32, - pub curr_firing_data: &'a FiringData, + pub curr_firing_data: &'a FiringDataFormula, pub base_crit_mult: f64, pub shots_fired_this_mag: f64, pub total_shots_fired: f64, @@ -35,7 +35,7 @@ impl<'a> CalculationInput<'a> { #[allow(clippy::too_many_arguments)] pub fn construct_pve_sparse( _intrinsic_hash: u32, - _firing_data: &'a FiringData, + _firing_data: &'a FiringDataFormula, _stats: &'a HashMap, _perk_value_map: &'a HashMap, _weapon_type: &'a WeaponType, @@ -73,7 +73,7 @@ impl<'a> CalculationInput<'a> { #[allow(clippy::too_many_arguments)] pub fn construct_pvp( _intrinsic_hash: u32, - _firing_data: &'a FiringData, + _firing_data: &'a FiringDataFormula, _stats: &'a HashMap, _perk_value_map: &'a HashMap, _weapon_type: &'a WeaponType, @@ -110,7 +110,7 @@ impl<'a> CalculationInput<'a> { #[allow(clippy::too_many_arguments)] pub fn construct_static( _intrinsic_hash: u32, - _firing_data: &'a FiringData, + _firing_data: &'a FiringDataFormula, _stats: &'a HashMap, _perk_value_map: &'a HashMap, _weapon_type: &'a WeaponType, diff --git a/src/perks/meta_perks.rs b/src/perks/meta_perks.rs index c89fec7c..b00c461d 100644 --- a/src/perks/meta_perks.rs +++ b/src/perks/meta_perks.rs @@ -21,7 +21,7 @@ use super::{ pub fn meta_perks() { add_dmr( Perks::BuiltIn, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let mut crit_scale = 1.0; let mut dmg_scale = 1.0; if *_input.calc_data.weapon_type == WeaponType::LINEARFUSIONRIFLE && !_input.pvp { @@ -64,12 +64,12 @@ pub fn meta_perks() { impact_dmg_scale: dmg_scale, explosive_dmg_scale: dmg_scale, } - }), + }, ); add_fmr( Perks::BuiltIn, - Box::new(|_input: ModifierResponseInput| -> FiringModifierResponse { + |_input: ModifierResponseInput| -> FiringModifierResponse { #[allow(unused_mut)] let mut delay_add = 0.0; @@ -116,85 +116,79 @@ pub fn meta_perks() { burst_delay_add: delay_add, ..Default::default() } - }), + }, ); add_epr( Perks::BuiltIn, - Box::new( - |_input: ModifierResponseInput| -> ExplosivePercentResponse { - if *_input.calc_data.weapon_type == WeaponType::GRENADELAUNCHER { - let blast_radius_struct = - _input.calc_data.stats.get(&StatHashes::BLAST_RADIUS.into()); - - let blast_radius = blast_radius_struct.cloned().unwrap_or_default().perk_val(); + |_input: ModifierResponseInput| -> ExplosivePercentResponse { + if *_input.calc_data.weapon_type == WeaponType::GRENADELAUNCHER { + let blast_radius_struct = + _input.calc_data.stats.get(&StatHashes::BLAST_RADIUS.into()); - if _input.calc_data.ammo_type == &AmmoType::SPECIAL { - return ExplosivePercentResponse { - percent: 0.5 + 0.003 * blast_radius as f64, - delyed: 0.0, - retain_base_total: true, - }; - } else if _input.calc_data.ammo_type == &AmmoType::HEAVY { - return ExplosivePercentResponse { - percent: 0.7 + 0.00175 * blast_radius as f64, - delyed: 0.0, - retain_base_total: true, - }; + let blast_radius = blast_radius_struct.cloned().unwrap_or_default().perk_val(); + + if _input.calc_data.ammo_type == &AmmoType::SPECIAL { + return ExplosivePercentResponse { + percent: 0.5 + 0.003 * blast_radius as f64, + delyed: 0.0, + retain_base_total: true, }; - } - if *_input.calc_data.weapon_type == WeaponType::ROCKET - && _input.calc_data.intrinsic_hash < 1000 - //ensures not exotic - { + } else if _input.calc_data.ammo_type == &AmmoType::HEAVY { return ExplosivePercentResponse { - percent: 0.778, + percent: 0.7 + 0.00175 * blast_radius as f64, delyed: 0.0, retain_base_total: true, }; - } - ExplosivePercentResponse { - percent: 0.0, + }; + } + if *_input.calc_data.weapon_type == WeaponType::ROCKET + && _input.calc_data.intrinsic_hash < 1000 + //ensures not exotic + { + return ExplosivePercentResponse { + percent: 0.778, delyed: 0.0, retain_base_total: true, - } - }, - ), + }; + } + ExplosivePercentResponse { + percent: 0.0, + delyed: 0.0, + retain_base_total: true, + } + }, ); add_hmr( Perks::DexterityMod, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - let swap_scale = if _input.value > 0 { - 0.85 - clamp(_input.value, 1, 3) as f64 * 0.05 - } else { - 1.0 - }; - HandlingModifierResponse { - stow_scale: swap_scale, - draw_scale: swap_scale, - ..Default::default() - } - }, - ), + |_input: ModifierResponseInput| -> HandlingModifierResponse { + let swap_scale = if _input.value > 0 { + 0.85 - clamp(_input.value, 1, 3) as f64 * 0.05 + } else { + 1.0 + }; + HandlingModifierResponse { + stow_scale: swap_scale, + draw_scale: swap_scale, + ..Default::default() + } + }, ); add_hmr( Perks::TargetingMod, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - HandlingModifierResponse { - ads_scale: if _input.value > 0 { 0.75 } else { 1.0 }, - ..Default::default() - } - }, - ), + |_input: ModifierResponseInput| -> HandlingModifierResponse { + HandlingModifierResponse { + ads_scale: if _input.value > 0 { 0.75 } else { 1.0 }, + ..Default::default() + } + }, ); add_sbr( Perks::TargetingMod, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut stats = HashMap::new(); if _input.value == 1 { stats.insert(StatHashes::AIM_ASSIST.into(), 5); @@ -204,32 +198,30 @@ pub fn meta_perks() { stats.insert(StatHashes::AIM_ASSIST.into(), 10); } stats - }), + }, ); add_imr( Perks::ReserveMod, - Box::new( - |_input: ModifierResponseInput| -> InventoryModifierResponse { - let mut inv_buff = if _input.value > 0 { 20 } else { 0 }; - if _input.value == 2 { - inv_buff += 20; - } - if _input.value > 2 { - inv_buff += 30; - } - InventoryModifierResponse { - inv_stat_add: inv_buff, - inv_scale: 1.0, - ..Default::default() - } - }, - ), + |_input: ModifierResponseInput| -> InventoryModifierResponse { + let mut inv_buff = if _input.value > 0 { 20 } else { 0 }; + if _input.value == 2 { + inv_buff += 20; + } + if _input.value > 2 { + inv_buff += 30; + } + InventoryModifierResponse { + inv_stat_add: inv_buff, + inv_scale: 1.0, + ..Default::default() + } + }, ); add_sbr( Perks::ReserveMod, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut inv_buff = if _input.value > 0 { 20 } else { 0 }; if _input.value == 2 { inv_buff += 15; @@ -240,12 +232,12 @@ pub fn meta_perks() { let mut stats = HashMap::new(); stats.insert(StatHashes::INVENTORY_SIZE.into(), inv_buff); stats - }), + }, ); add_rsmr( Perks::LoaderMod, - Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { + |_input: ModifierResponseInput| -> ReloadModifierResponse { let stat = match _input.value { 0 => 0, 1 => 10, @@ -258,12 +250,12 @@ pub fn meta_perks() { reload_stat_add: stat, reload_time_scale: mult, } - }), + }, ); add_sbr( Perks::LoaderMod, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut stats = HashMap::new(); let buff = match _input.value { 0 => 0, @@ -273,12 +265,12 @@ pub fn meta_perks() { }; stats.insert(StatHashes::RELOAD.into(), buff); stats - }), + }, ); add_flmr( Perks::UnflinchingMod, - Box::new(|_input: ModifierResponseInput| -> FlinchModifierResponse { + |_input: ModifierResponseInput| -> FlinchModifierResponse { if _input.value > 2 { FlinchModifierResponse { flinch_scale: 0.6 } } else if _input.value == 2 { @@ -288,48 +280,48 @@ pub fn meta_perks() { } else { FlinchModifierResponse::default() } - }), + }, ); add_sbr( Perks::RallyBarricade, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut stats = HashMap::new(); stats.insert(StatHashes::STABILITY.into(), 30); stats.insert(StatHashes::RELOAD.into(), 100); stats - }), + }, ); add_flmr( Perks::RallyBarricade, - Box::new(|_input: ModifierResponseInput| -> FlinchModifierResponse { + |_input: ModifierResponseInput| -> FlinchModifierResponse { FlinchModifierResponse { flinch_scale: 0.5 } - }), + }, ); add_rsmr( Perks::RallyBarricade, - Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { + |_input: ModifierResponseInput| -> ReloadModifierResponse { ReloadModifierResponse { reload_stat_add: 100, reload_time_scale: 0.9, } - }), + }, ); add_rmr( Perks::RallyBarricade, - Box::new(|_input: ModifierResponseInput| -> RangeModifierResponse { + |_input: ModifierResponseInput| -> RangeModifierResponse { RangeModifierResponse { range_all_scale: 1.1, ..Default::default() } - }), + }, ); add_fmr( Perks::AdeptChargeTime, - Box::new(|_input: ModifierResponseInput| -> FiringModifierResponse { + |_input: ModifierResponseInput| -> FiringModifierResponse { FiringModifierResponse { burst_delay_add: match *_input.calc_data.weapon_type { WeaponType::FUSIONRIFLE => -0.040, @@ -338,6 +330,6 @@ pub fn meta_perks() { }, ..Default::default() } - }), + }, ); } diff --git a/src/perks/mod.rs b/src/perks/mod.rs index 3057f174..88722e06 100644 --- a/src/perks/mod.rs +++ b/src/perks/mod.rs @@ -1,3 +1,9 @@ +//quiet rust analyzer while refactoring +#![allow(unused_imports)] + +//is because the people who make num enum dont know how to make macros +#![allow(non_upper_case_globals)] + pub mod buff_perks; pub mod exotic_armor; pub mod exotic_perks; @@ -13,13 +19,12 @@ pub mod year_4_perks; pub mod year_5_perks; pub mod year_6_perks; -use std::borrow::BorrowMut; use std::collections::HashMap; use num_enum::{FromPrimitive, IntoPrimitive}; -use serde::{Deserialize, Serialize}; +use serde::Serialize; -use crate::d2_enums::{BungieHash, StatBump, StatHashes, WeaponType}; +use crate::d2_enums::{BungieHash, StatBump}; use crate::database; use self::{ @@ -83,7 +88,6 @@ pub fn enhanced_check(_hash: u32) -> (u32, bool) { } // all armor pekrs are for the future but wanted to started to compile them now - #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, FromPrimitive, IntoPrimitive)] #[repr(u32)] pub enum Perks { @@ -466,7 +470,7 @@ pub struct ModifierResponseInput<'a> { pvp: bool, cached_data: &'a mut HashMap, } -type ModifierFunction = Box T>; +type ModifierFunction = fn(ModifierResponseInput) -> T; type StatMap = HashMap; type ModifierMap = HashMap>; diff --git a/src/perks/origin_perks.rs b/src/perks/origin_perks.rs index 5c4b791d..797ac0da 100644 --- a/src/perks/origin_perks.rs +++ b/src/perks/origin_perks.rs @@ -16,12 +16,11 @@ use super::{ pub fn origin_perks() { add_rr( Perks::VeistStinger, - Box::new(|_input: ModifierResponseInput| -> RefundResponse { + |_input: ModifierResponseInput| -> RefundResponse { let data = _input.cached_data.get("veist_stinger"); let last_proc = *data.unwrap_or(&1.0); let time_since_last_proc = _input.calc_data.time_total - last_proc; let max_refund = _input.calc_data.base_mag - _input.calc_data.curr_mag; - if _input.value == 0 || time_since_last_proc < 4.0 || max_refund == 0.0 { return RefundResponse::default(); @@ -38,12 +37,12 @@ pub fn origin_perks() { refund_mag: refund_amount, refund_reserves: -final_refund_ammount, } - }), + }, ); add_fmr( Perks::VeistStinger, - Box::new(|_input: ModifierResponseInput| -> FiringModifierResponse { + |_input: ModifierResponseInput| -> FiringModifierResponse { FiringModifierResponse { burst_delay_scale: if _input.calc_data.weapon_type == &WeaponType::BOW && _input.value > 0 @@ -54,46 +53,46 @@ pub fn origin_perks() { }, ..Default::default() } - }), + }, ); add_dmr( Perks::HakkeBreach, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let damage_mult = if _input.value > 0 { 0.3 } else { 0.0 }; DamageModifierResponse { impact_dmg_scale: 1.0 + damage_mult, explosive_dmg_scale: 1.0 + damage_mult, crit_scale: 1.0, } - }), + }, ); add_rmr( Perks::Alacrity, - Box::new(|_input: ModifierResponseInput| -> RangeModifierResponse { + |_input: ModifierResponseInput| -> RangeModifierResponse { let range_add = if _input.value > 0 { 20 } else { 0 }; RangeModifierResponse { range_stat_add: range_add, ..Default::default() } - }), + }, ); add_rsmr( Perks::Alacrity, - Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { + |_input: ModifierResponseInput| -> ReloadModifierResponse { let reload_add = if _input.value > 0 { 50 } else { 0 }; ReloadModifierResponse { reload_stat_add: reload_add, ..Default::default() } - }), + }, ); add_sbr( Perks::Alacrity, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut map = HashMap::new(); let range = if _input.value > 0 { 20 } else { 0 }; let reload = if _input.value > 0 { 50 } else { 0 }; @@ -104,12 +103,12 @@ pub fn origin_perks() { map.insert(StatHashes::STABILITY.into(), stability); map.insert(StatHashes::AIM_ASSIST.into(), aim_assist); map - }), + }, ); add_sbr( Perks::Ambush, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut map = HashMap::new(); let range = if _input.is_enhanced { 30 } else { 20 }; let handling = if _input.is_enhanced { 40 } else { 20 }; @@ -118,12 +117,12 @@ pub fn origin_perks() { map.insert(StatHashes::HANDLING.into(), handling); } map - }), + }, ); add_rmr( Perks::Ambush, - Box::new(|_input: ModifierResponseInput| -> RangeModifierResponse { + |_input: ModifierResponseInput| -> RangeModifierResponse { let range_add = if _input.is_enhanced { 30 } else { 20 }; if _input.calc_data.time_total < 2.0 && _input.value > 0 { RangeModifierResponse { @@ -133,29 +132,27 @@ pub fn origin_perks() { } else { RangeModifierResponse::default() } - }), + }, ); add_hmr( Perks::Ambush, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - let handling_add = if _input.is_enhanced { 40 } else { 20 }; - if _input.calc_data.time_total < 2.0 && _input.value > 0 { - HandlingModifierResponse { - stat_add: handling_add, - ..Default::default() - } - } else { - HandlingModifierResponse::default() + |_input: ModifierResponseInput| -> HandlingModifierResponse { + let handling_add = if _input.is_enhanced { 40 } else { 20 }; + if _input.calc_data.time_total < 2.0 && _input.value > 0 { + HandlingModifierResponse { + stat_add: handling_add, + ..Default::default() } - }, - ), + } else { + HandlingModifierResponse::default() + } + }, ); add_dmr( Perks::Ambush, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { if _input.value == 0 || _input.pvp { return DamageModifierResponse::default(); } @@ -170,12 +167,12 @@ pub fn origin_perks() { explosive_dmg_scale: damage_mult, crit_scale: 1.0, } - }), + }, ); add_fmr( Perks::Ambush, - Box::new(|_input: ModifierResponseInput| -> FiringModifierResponse { + |_input: ModifierResponseInput| -> FiringModifierResponse { FiringModifierResponse { burst_delay_scale: if _input.calc_data.weapon_type == &WeaponType::BOW && _input.value > 0 @@ -186,29 +183,27 @@ pub fn origin_perks() { }, ..Default::default() } - }), + }, ); add_hmr( Perks::HotSwap, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - let handling_add = if _input.is_enhanced { 60 } else { 30 }; - if _input.value > 0 { - HandlingModifierResponse { - stat_add: handling_add, - ..Default::default() - } - } else { - HandlingModifierResponse::default() + |_input: ModifierResponseInput| -> HandlingModifierResponse { + let handling_add = if _input.is_enhanced { 60 } else { 30 }; + if _input.value > 0 { + HandlingModifierResponse { + stat_add: handling_add, + ..Default::default() } - }, - ), + } else { + HandlingModifierResponse::default() + } + }, ); add_rsmr( Perks::FluidDynamics, - Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { + |_input: ModifierResponseInput| -> ReloadModifierResponse { let reload_add = if _input.is_enhanced { 35 } else { 30 }; if _input.calc_data.shots_fired_this_mag <= _input.calc_data.base_mag / 2.0 { ReloadModifierResponse { @@ -218,12 +213,12 @@ pub fn origin_perks() { } else { ReloadModifierResponse::default() } - }), + }, ); add_sbr( Perks::FluidDynamics, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut map = HashMap::new(); let reload = if _input.is_enhanced { 35 } else { 30 }; let stability = if _input.is_enhanced { 25 } else { 20 }; @@ -234,12 +229,12 @@ pub fn origin_perks() { map.insert(StatHashes::STABILITY.into(), stability); } map - }), + }, ); add_rsmr( Perks::QuietMoment, - Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { + |_input: ModifierResponseInput| -> ReloadModifierResponse { if _input.value > 0 { ReloadModifierResponse { reload_stat_add: 40, @@ -248,23 +243,23 @@ pub fn origin_perks() { } else { ReloadModifierResponse::default() } - }), + }, ); add_sbr( Perks::QuietMoment, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut map = HashMap::new(); if _input.value > 0 { map.insert(StatHashes::RELOAD.into(), 40); } map - }), + }, ); add_rsmr( Perks::BitterSpite, - Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { + |_input: ModifierResponseInput| -> ReloadModifierResponse { let val = clamp(_input.value, 0, 5) as i32; let mult = match val { 0 => 1.0, @@ -279,22 +274,22 @@ pub fn origin_perks() { reload_stat_add: val * 10, reload_time_scale: mult, } - }), + }, ); add_sbr( Perks::BitterSpite, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut map = HashMap::new(); let val = clamp(_input.value, 0, 5) as i32; map.insert(StatHashes::RELOAD.into(), val * 10); map - }), + }, ); add_rmr( Perks::RightHook, - Box::new(|_input: ModifierResponseInput| -> RangeModifierResponse { + |_input: ModifierResponseInput| -> RangeModifierResponse { let range_add = if _input.is_enhanced { 20 } else { 10 }; if _input.value > 0 { RangeModifierResponse { @@ -304,12 +299,12 @@ pub fn origin_perks() { } else { RangeModifierResponse::default() } - }), + }, ); add_sbr( Perks::RightHook, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut map = HashMap::new(); let stat_bump = if _input.is_enhanced { 20 } else { 10 }; if _input.value > 0 { @@ -317,69 +312,63 @@ pub fn origin_perks() { map.insert(StatHashes::RANGE.into(), stat_bump); } map - }), + }, ); add_hmr( Perks::SearchParty, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - if _input.value > 0 { - HandlingModifierResponse { - ads_scale: 0.85, - ..Default::default() - } - } else { - HandlingModifierResponse::default() + |_input: ModifierResponseInput| -> HandlingModifierResponse { + if _input.value > 0 { + HandlingModifierResponse { + ads_scale: 0.85, + ..Default::default() } - }, - ), + } else { + HandlingModifierResponse::default() + } + }, ); add_mmr( Perks::RunnethOver, - Box::new( - |_input: ModifierResponseInput| -> MagazineModifierResponse { - let val = clamp(_input.value, 0, 5) as f64; - MagazineModifierResponse { - magazine_scale: 1.0 + val * 0.1, - ..Default::default() - } - }, - ), + |_input: ModifierResponseInput| -> MagazineModifierResponse { + let val = clamp(_input.value, 0, 5) as f64; + MagazineModifierResponse { + magazine_scale: 1.0 + val * 0.1, + ..Default::default() + } + }, ); add_sbr( Perks::TexBalancedStock, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut map = HashMap::new(); if _input.value > 0 { map.insert(StatHashes::HANDLING.into(), 20); map.insert(StatHashes::RELOAD.into(), 20); } map - }), + }, ); add_hmr( Perks::TexBalancedStock, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - if _input.value > 0 { - HandlingModifierResponse { - stat_add: 50, - ..Default::default() - } - } else { - HandlingModifierResponse::default() + |_input: ModifierResponseInput| -> HandlingModifierResponse { + if _input.value > 0 { + HandlingModifierResponse { + stat_add: 50, + ..Default::default() } - }, - ), + } else { + HandlingModifierResponse::default() + } + }, ); add_rsmr( Perks::TexBalancedStock, - Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { + |_input: ModifierResponseInput| -> ReloadModifierResponse { if _input.value > 0 { ReloadModifierResponse { reload_stat_add: 20, @@ -388,50 +377,48 @@ pub fn origin_perks() { } else { ReloadModifierResponse::default() } - }), + }, ); add_sbr( Perks::SurosSynergy, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut out = HashMap::new(); if _input.value > 0 { out.insert(StatHashes::HANDLING.into(), 40); } out - }), + }, ); add_hmr( Perks::SurosSynergy, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - if _input.value > 0 { - HandlingModifierResponse { - stat_add: 40, - ..Default::default() - } - } else { - HandlingModifierResponse::default() + |_input: ModifierResponseInput| -> HandlingModifierResponse { + if _input.value > 0 { + HandlingModifierResponse { + stat_add: 40, + ..Default::default() } - }, - ), + } else { + HandlingModifierResponse::default() + } + }, ); add_flmr( Perks::SurosSynergy, - Box::new(|_input: ModifierResponseInput| -> FlinchModifierResponse { + |_input: ModifierResponseInput| -> FlinchModifierResponse { if _input.value > 0 { FlinchModifierResponse { flinch_scale: 0.80 } } else { FlinchModifierResponse::default() } - }), + }, ); add_sbr( Perks::HarmonicResonance, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut out = HashMap::new(); if _input.value == 1 { out.insert(StatHashes::HANDLING.into(), 10); @@ -441,12 +428,12 @@ pub fn origin_perks() { out.insert(StatHashes::HANDLING.into(), 20); } out - }), + }, ); add_rsmr( Perks::HarmonicResonance, - Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { + |_input: ModifierResponseInput| -> ReloadModifierResponse { let stat_bump = if _input.value > 1 { 20 } else { 0 }; if _input.value > 0 { ReloadModifierResponse { @@ -456,19 +443,17 @@ pub fn origin_perks() { } else { ReloadModifierResponse::default() } - }), + }, ); add_hmr( Perks::HarmonicResonance, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - let stat_bump = 10 * clamp(_input.value, 0, 2); - HandlingModifierResponse { - stat_add: stat_bump as i32, - ..Default::default() - } - }, - ), + |_input: ModifierResponseInput| -> HandlingModifierResponse { + let stat_bump = 10 * clamp(_input.value, 0, 2); + HandlingModifierResponse { + stat_add: stat_bump as i32, + ..Default::default() + } + }, ); } diff --git a/src/perks/other_perks.rs b/src/perks/other_perks.rs index 46b2ccf3..05817f5e 100644 --- a/src/perks/other_perks.rs +++ b/src/perks/other_perks.rs @@ -20,7 +20,7 @@ use super::{ pub fn other_perks() { add_rsmr( Perks::AlloyMag, - Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { + |_input: ModifierResponseInput| -> ReloadModifierResponse { if _input.value > 0 { ReloadModifierResponse { reload_stat_add: 0, @@ -29,12 +29,12 @@ pub fn other_perks() { } else { ReloadModifierResponse::default() } - }), + }, ); add_rsmr( Perks::RapidFireFrame, - Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { + |_input: ModifierResponseInput| -> ReloadModifierResponse { if _input.value > 0 || _input.calc_data.weapon_type == &WeaponType::SHOTGUN { ReloadModifierResponse { reload_stat_add: 0, @@ -43,140 +43,128 @@ pub fn other_perks() { } else { ReloadModifierResponse::default() } - }), + }, ); add_imr( Perks::RapidFireFrame, - Box::new( - |_input: ModifierResponseInput| -> InventoryModifierResponse { - if _input.calc_data.weapon_type == &WeaponType::SNIPER { - InventoryModifierResponse { - inv_scale: 1.3, - ..Default::default() - } - } else { - InventoryModifierResponse::default() + |_input: ModifierResponseInput| -> InventoryModifierResponse { + if _input.calc_data.weapon_type == &WeaponType::SNIPER { + InventoryModifierResponse { + inv_scale: 1.3, + ..Default::default() } - }, - ), + } else { + InventoryModifierResponse::default() + } + }, ); add_sbr( Perks::PrecisionFrame, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut stats = HashMap::new(); if _input.calc_data.weapon_type == &WeaponType::HANDCANNON { stats.insert(StatHashes::AIRBORNE.into(), 25); } stats - }), + }, ); add_hmr( Perks::SwapMag, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - HandlingModifierResponse { - draw_scale: 0.9, - stow_scale: 0.9, - ..Default::default() - } - }, - ), + |_input: ModifierResponseInput| -> HandlingModifierResponse { + HandlingModifierResponse { + draw_scale: 0.9, + stow_scale: 0.9, + ..Default::default() + } + }, ); add_hmr( Perks::QuickAccessSling, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - HandlingModifierResponse { - draw_scale: 0.9, - stow_scale: 0.9, - ..Default::default() - } - }, - ), + |_input: ModifierResponseInput| -> HandlingModifierResponse { + HandlingModifierResponse { + draw_scale: 0.9, + stow_scale: 0.9, + ..Default::default() + } + }, ); add_hmr( Perks::FreehandGrip, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - HandlingModifierResponse { - draw_scale: 0.95, - ..Default::default() - } - }, - ), + |_input: ModifierResponseInput| -> HandlingModifierResponse { + HandlingModifierResponse { + draw_scale: 0.95, + ..Default::default() + } + }, ); add_hmr( Perks::OphidianAspect, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - HandlingModifierResponse { - stat_add: 35, - ..Default::default() - } - }, - ), + |_input: ModifierResponseInput| -> HandlingModifierResponse { + HandlingModifierResponse { + stat_add: 35, + ..Default::default() + } + }, ); add_rsmr( Perks::OphidianAspect, - Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { + |_input: ModifierResponseInput| -> ReloadModifierResponse { ReloadModifierResponse { reload_stat_add: 35, reload_time_scale: 1.0, } - }), + }, ); add_sbr( Perks::OphidianAspect, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut stats = HashMap::new(); stats.insert(StatHashes::HANDLING.into(), 35); stats.insert(StatHashes::RELOAD.into(), 35); stats.insert(StatHashes::AIRBORNE.into(), 10); stats - }), + }, ); add_sbr( Perks::DragonShadow, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut stats = HashMap::new(); if _input.value >= 1 { stats.insert(StatHashes::HANDLING.into(), 100); stats.insert(StatHashes::RELOAD.into(), 100); } stats - }), + }, ); add_hmr( Perks::DragonShadow, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - if _input.value >= 1 { - HandlingModifierResponse { - stat_add: 100, - draw_scale: 0.7, - stow_scale: 0.7, - ..Default::default() - } - } else { - HandlingModifierResponse::default() + |_input: ModifierResponseInput| -> HandlingModifierResponse { + if _input.value >= 1 { + HandlingModifierResponse { + stat_add: 100, + draw_scale: 0.7, + stow_scale: 0.7, + ..Default::default() } - }, - ), + } else { + HandlingModifierResponse::default() + } + }, ); add_rsmr( Perks::DragonShadow, - Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { + |_input: ModifierResponseInput| -> ReloadModifierResponse { if _input.value >= 1 { ReloadModifierResponse { reload_stat_add: 100, @@ -185,35 +173,33 @@ pub fn other_perks() { } else { ReloadModifierResponse::default() } - }), + }, ); add_sbr( Perks::Amplified, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut stats = HashMap::new(); stats.insert(StatHashes::HANDLING.into(), 40); stats - }), + }, ); add_hmr( Perks::Amplified, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - HandlingModifierResponse { - stat_add: 40, - draw_scale: 0.95, - stow_scale: 0.95, - ..Default::default() - } - }, - ), + |_input: ModifierResponseInput| -> HandlingModifierResponse { + HandlingModifierResponse { + stat_add: 40, + draw_scale: 0.95, + stow_scale: 0.95, + ..Default::default() + } + }, ); add_rsmr( Perks::Frequency, - Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { + |_input: ModifierResponseInput| -> ReloadModifierResponse { if _input.value > 0 { ReloadModifierResponse { reload_stat_add: 50, @@ -222,23 +208,23 @@ pub fn other_perks() { } else { ReloadModifierResponse::default() } - }), + }, ); add_sbr( Perks::Tempering, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut stats = HashMap::new(); if _input.value > 0 { stats.insert(StatHashes::RELOAD.into(), 50); }; stats - }), + }, ); add_rsmr( Perks::FlowState, - Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { + |_input: ModifierResponseInput| -> ReloadModifierResponse { if _input.value > 0 { ReloadModifierResponse { reload_stat_add: 50, @@ -247,34 +233,34 @@ pub fn other_perks() { } else { ReloadModifierResponse::default() } - }), + }, ); add_sbr( Perks::FlowState, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut stats = HashMap::new(); if _input.value > 0 { stats.insert(StatHashes::RELOAD.into(), 50); }; stats - }), + }, ); add_sbr( Perks::Tempering, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut stats = HashMap::new(); if _input.value > 0 { stats.insert(StatHashes::AIRBORNE.into(), 20); }; stats - }), + }, ); add_sbr( Perks::OnYourMark, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut stats = HashMap::new(); let val = clamp(_input.value, 0, 3) as i32; if _input.value > 0 { @@ -282,36 +268,34 @@ pub fn other_perks() { stats.insert(StatHashes::RELOAD.into(), 20 * val); }; stats - }), + }, ); add_hmr( Perks::OnYourMark, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - let val = clamp(_input.value, 0, 3) as i32; - HandlingModifierResponse { - stat_add: 20 * val, - ..Default::default() - } - }, - ), + |_input: ModifierResponseInput| -> HandlingModifierResponse { + let val = clamp(_input.value, 0, 3) as i32; + HandlingModifierResponse { + stat_add: 20 * val, + ..Default::default() + } + }, ); add_rsmr( Perks::OnYourMark, - Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { + |_input: ModifierResponseInput| -> ReloadModifierResponse { let val = clamp(_input.value, 0, 3) as i32; ReloadModifierResponse { reload_stat_add: 20 * val, reload_time_scale: if _input.value > 0 { 0.93 } else { 1.0 }, } - }), + }, ); add_sbr( Perks::HeatRises, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut stats = HashMap::new(); let mut buff = 20; if _input.value > 0 { @@ -319,12 +303,12 @@ pub fn other_perks() { }; stats.insert(StatHashes::AIRBORNE.into(), buff); stats - }), + }, ); add_sbr( Perks::Hedrons, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut stats = HashMap::new(); if _input.value > 0 { stats.insert(StatHashes::AIRBORNE.into(), 20); @@ -332,12 +316,12 @@ pub fn other_perks() { stats.insert(StatHashes::STABILITY.into(), 30); }; stats - }), + }, ); add_dmr( Perks::BossSpec, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let damage_mult = if *_input.calc_data.enemy_type == EnemyType::BOSS && !_input.pvp { 1.077 } else { @@ -348,12 +332,12 @@ pub fn other_perks() { explosive_dmg_scale: damage_mult, crit_scale: 1.0, } - }), + }, ); add_dmr( Perks::MajorSpec, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { if !matches!( *_input.calc_data.enemy_type, EnemyType::ELITE | EnemyType::MINIBOSS | EnemyType::CHAMPION @@ -367,12 +351,12 @@ pub fn other_perks() { explosive_dmg_scale: damage_mult, ..Default::default() } - }), + }, ); add_dmr( Perks::BigOnesSpec, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { if !matches!( *_input.calc_data.enemy_type, EnemyType::ELITE | EnemyType::MINIBOSS | EnemyType::CHAMPION | EnemyType::BOSS @@ -386,12 +370,12 @@ pub fn other_perks() { explosive_dmg_scale: damage_mult, ..Default::default() } - }), + }, ); add_dmr( Perks::MinorSpec, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let damage_mult = if _input.calc_data.enemy_type == &EnemyType::MINOR && !_input.pvp { 1.077 } else { @@ -402,12 +386,12 @@ pub fn other_perks() { explosive_dmg_scale: damage_mult, crit_scale: 1.0, } - }), + }, ); add_dmr( Perks::TakenSpec, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let damage_mult = if _input.value > 0 && !_input.pvp { 1.1 } else { @@ -418,34 +402,34 @@ pub fn other_perks() { explosive_dmg_scale: damage_mult, crit_scale: 1.0, } - }), + }, ); add_dmr( Perks::SpikeGrenades, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { DamageModifierResponse { impact_dmg_scale: 1.5, explosive_dmg_scale: 1.0, crit_scale: 1.0, } - }), + }, ); add_dmr( Perks::DisorientingGrenades, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { DamageModifierResponse { impact_dmg_scale: 0.75, explosive_dmg_scale: 0.75, crit_scale: 1.0, } - }), + }, ); add_dmr( Perks::FullChoke, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { if _input.calc_data.weapon_type == &WeaponType::SHOTGUN && _input.calc_data.base_crit_mult < 1.15 { @@ -457,12 +441,12 @@ pub fn other_perks() { } else { DamageModifierResponse::default() } - }), + }, ); add_fmr( Perks::AcceleratedCoils, - Box::new(|_input: ModifierResponseInput| -> FiringModifierResponse { + |_input: ModifierResponseInput| -> FiringModifierResponse { if _input.calc_data.weapon_type == &WeaponType::LINEARFUSIONRIFLE { return FiringModifierResponse { burst_delay_add: -0.033, @@ -473,12 +457,12 @@ pub fn other_perks() { burst_delay_add: -0.040, ..Default::default() } - }), + }, ); add_fmr( Perks::LiquidCoils, - Box::new(|_input: ModifierResponseInput| -> FiringModifierResponse { + |_input: ModifierResponseInput| -> FiringModifierResponse { if _input.calc_data.weapon_type == &WeaponType::LINEARFUSIONRIFLE { return FiringModifierResponse { burst_delay_add: 0.033, @@ -489,34 +473,34 @@ pub fn other_perks() { burst_delay_add: 0.040, ..Default::default() } - }), + }, ); add_dmr( Perks::LiquidCoils, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { DamageModifierResponse { impact_dmg_scale: 1.02, explosive_dmg_scale: 1.02, crit_scale: 1.0, } - }), + }, ); add_dmr( Perks::AcceleratedCoils, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { DamageModifierResponse { impact_dmg_scale: 0.98, explosive_dmg_scale: 0.98, ..Default::default() } - }), + }, ); add_fmr( Perks::AssaultMag, - Box::new(|_input: ModifierResponseInput| -> FiringModifierResponse { + |_input: ModifierResponseInput| -> FiringModifierResponse { let hash = _input.calc_data.intrinsic_hash; let tick_amount = if hash == 904 { 3.0 @@ -533,12 +517,12 @@ pub fn other_perks() { } else { FiringModifierResponse::default() } - }), + }, ); add_sbr( Perks::ThreadOfAscent, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut map = HashMap::new(); if _input.value > 0 { map.insert(StatHashes::AIRBORNE.into(), 30); @@ -546,29 +530,27 @@ pub fn other_perks() { map.insert(StatHashes::HANDLING.into(), 40); } map - }), + }, ); add_hmr( Perks::ThreadOfAscent, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - if _input.value > 0 { - HandlingModifierResponse { - stat_add: 40, - draw_scale: 0.925, - stow_scale: 0.925, - ..Default::default() - } - } else { - HandlingModifierResponse::default() + |_input: ModifierResponseInput| -> HandlingModifierResponse { + if _input.value > 0 { + HandlingModifierResponse { + stat_add: 40, + draw_scale: 0.925, + stow_scale: 0.925, + ..Default::default() } - }, - ), + } else { + HandlingModifierResponse::default() + } + }, ); add_rsmr( Perks::ThreadOfAscent, - Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { + |_input: ModifierResponseInput| -> ReloadModifierResponse { if _input.value > 0 { ReloadModifierResponse { reload_time_scale: 0.925, @@ -577,6 +559,6 @@ pub fn other_perks() { } else { ReloadModifierResponse::default() } - }), + }, ); } diff --git a/src/perks/year_1_perks.rs b/src/perks/year_1_perks.rs index 7ccf8b36..73a28b1f 100644 --- a/src/perks/year_1_perks.rs +++ b/src/perks/year_1_perks.rs @@ -21,25 +21,23 @@ use super::{ pub fn year_1_perks() { add_sbr( Perks::ThreatDetector, - Box::new( - |_input: ModifierResponseInput| -> HashMap { - let stats = match _input.value { - 0 => (0, 0, 0), - 1 => (15, 15, 25), - _ => (40, 55, 100), - }; - let mut out = HashMap::new(); - out.insert(StatHashes::STABILITY.into(), stats.0); - out.insert(StatHashes::RELOAD.into(), stats.1); - out.insert(StatHashes::HANDLING.into(), stats.2); - out - }, - ), + |_input: ModifierResponseInput| -> HashMap { + let stats = match _input.value { + 0 => (0, 0, 0), + 1 => (15, 15, 25), + _ => (40, 55, 100), + }; + let mut out = HashMap::new(); + out.insert(StatHashes::STABILITY.into(), stats.0); + out.insert(StatHashes::RELOAD.into(), stats.1); + out.insert(StatHashes::HANDLING.into(), stats.2); + out + }, ); add_dmr( Perks::HighImpactReserves, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let mut out_dmg_scale = 1.0; let base = if _input.pvp { 0.03 } else { 0.121 }; let max = if _input.pvp { 0.06 } else { 0.256 }; @@ -57,36 +55,34 @@ pub fn year_1_perks() { explosive_dmg_scale: out_dmg_scale, crit_scale: 1.0, } - }), + }, ); //Confirmed by harm <3 add_hmr( Perks::ThreatDetector, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - let val = clamp(_input.value, 0, 2) as i32; - let stat = match val { - 0 => 0, - 1 => 25, - 2 => 100, - _ => 100, - }; - let time_scale = 0.9_f64.powi(val); - HandlingModifierResponse { - stat_add: stat, - draw_scale: time_scale, - stow_scale: time_scale, - ads_scale: time_scale, - ..Default::default() - } - }, - ), + |_input: ModifierResponseInput| -> HandlingModifierResponse { + let val = clamp(_input.value, 0, 2) as i32; + let stat = match val { + 0 => 0, + 1 => 25, + 2 => 100, + _ => 100, + }; + let time_scale = 0.9_f64.powi(val); + HandlingModifierResponse { + stat_add: stat, + draw_scale: time_scale, + stow_scale: time_scale, + ads_scale: time_scale, + ..Default::default() + } + }, ); add_rsmr( Perks::ThreatDetector, - Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { + |_input: ModifierResponseInput| -> ReloadModifierResponse { let mut reload = 0; if _input.value == 1 { reload = 15; @@ -97,39 +93,37 @@ pub fn year_1_perks() { reload_stat_add: reload, reload_time_scale: 1.0, } - }), + }, ); add_mmr( Perks::AmbitiousAssassin, - Box::new( - |_input: ModifierResponseInput| -> MagazineModifierResponse { - let val = clamp(_input.value, 0, 15) as f64; - if _input.calc_data.total_shots_fired == 0.0 { - let mut mag_mult = 1.0; - if *_input.calc_data.ammo_type == AmmoType::PRIMARY { - mag_mult += 0.2 * val; - } else { - mag_mult += 0.1 * val; - }; - return MagazineModifierResponse { - magazine_stat_add: 0, - magazine_scale: clamp(mag_mult, 1.0, 2.5), - magazine_add: 0.0, - }; + |_input: ModifierResponseInput| -> MagazineModifierResponse { + let val = clamp(_input.value, 0, 15) as f64; + if _input.calc_data.total_shots_fired == 0.0 { + let mut mag_mult = 1.0; + if *_input.calc_data.ammo_type == AmmoType::PRIMARY { + mag_mult += 0.2 * val; + } else { + mag_mult += 0.1 * val; }; - MagazineModifierResponse { + return MagazineModifierResponse { magazine_stat_add: 0, - magazine_scale: 1.0, + magazine_scale: clamp(mag_mult, 1.0, 2.5), magazine_add: 0.0, - } - }, - ), + }; + }; + MagazineModifierResponse { + magazine_stat_add: 0, + magazine_scale: 1.0, + magazine_add: 0.0, + } + }, ); add_dmr( Perks::BoxBreathing, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { if _input.calc_data.total_shots_fired == 0.0 && _input.value > 0 { let mut crit_mult = (_input.calc_data.base_crit_mult + 1.0) / _input.calc_data.base_crit_mult; @@ -143,12 +137,12 @@ pub fn year_1_perks() { }; }; DamageModifierResponse::default() - }), + }, ); add_fmr( Perks::Desperado, - Box::new(|_input: ModifierResponseInput| -> FiringModifierResponse { + |_input: ModifierResponseInput| -> FiringModifierResponse { let mut delay_mult = 1.0; let duration = if _input.is_enhanced { 7.0 } else { 6.0 }; if _input.calc_data.time_total < duration && _input.value > 0 { @@ -158,12 +152,12 @@ pub fn year_1_perks() { burst_delay_scale: delay_mult, ..Default::default() } - }), + }, ); add_dmr( Perks::ExplosivePayload, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { if _input.pvp { DamageModifierResponse::default() } else { @@ -173,25 +167,23 @@ pub fn year_1_perks() { crit_scale: 1.0, } } - }), + }, ); add_epr( Perks::ExplosivePayload, - Box::new( - |_input: ModifierResponseInput| -> ExplosivePercentResponse { - ExplosivePercentResponse { - percent: 0.5, - delyed: 0.0, - retain_base_total: true, - } - }, - ), + |_input: ModifierResponseInput| -> ExplosivePercentResponse { + ExplosivePercentResponse { + percent: 0.5, + delyed: 0.0, + retain_base_total: true, + } + }, ); add_dmr( Perks::TimedPayload, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { if _input.pvp { DamageModifierResponse::default() } else { @@ -202,44 +194,40 @@ pub fn year_1_perks() { crit_scale: 1.0, } } - }), + }, ); add_epr( Perks::TimedPayload, - Box::new( - |_input: ModifierResponseInput| -> ExplosivePercentResponse { - ExplosivePercentResponse { - percent: 0.5, - delyed: 0.6, - retain_base_total: true, - } - }, - ), + |_input: ModifierResponseInput| -> ExplosivePercentResponse { + ExplosivePercentResponse { + percent: 0.5, + delyed: 0.6, + retain_base_total: true, + } + }, ); add_sbr( Perks::FieldPrep, - Box::new( - |_input: ModifierResponseInput| -> HashMap { - let mut out = HashMap::new(); - if _input.value > 0 { - let reload = if _input.is_enhanced { 55 } else { 50 }; - out.insert(StatHashes::RELOAD.into(), reload); - }; - let mut reserves = if _input.is_enhanced { 40 } else { 30 }; - if *_input.calc_data.weapon_type == WeaponType::GRENADELAUNCHER { - reserves -= 10; - }; - out.insert(StatHashes::INVENTORY_SIZE.into(), reserves); - out - }, - ), + |_input: ModifierResponseInput| -> HashMap { + let mut out = HashMap::new(); + if _input.value > 0 { + let reload = if _input.is_enhanced { 55 } else { 50 }; + out.insert(StatHashes::RELOAD.into(), reload); + }; + let mut reserves = if _input.is_enhanced { 40 } else { 30 }; + if *_input.calc_data.weapon_type == WeaponType::GRENADELAUNCHER { + reserves -= 10; + }; + out.insert(StatHashes::INVENTORY_SIZE.into(), reserves); + out + }, ); add_rsmr( Perks::FieldPrep, - Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { + |_input: ModifierResponseInput| -> ReloadModifierResponse { let mut reload = 0; let mut reload_mult = 1.0; if _input.value > 0 { @@ -250,81 +238,73 @@ pub fn year_1_perks() { reload_stat_add: reload, reload_time_scale: reload_mult, } - }), + }, ); add_imr( Perks::FieldPrep, - Box::new( - |_input: ModifierResponseInput| -> InventoryModifierResponse { - InventoryModifierResponse { - inv_stat_add: if _input.is_enhanced { 40 } else { 30 }, - ..Default::default() - } - }, - ), + |_input: ModifierResponseInput| -> InventoryModifierResponse { + InventoryModifierResponse { + inv_stat_add: if _input.is_enhanced { 40 } else { 30 }, + ..Default::default() + } + }, ); add_hmr( Perks::FieldPrep, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - if _input.value >= 1 { - HandlingModifierResponse { - stow_scale: 0.8, - draw_scale: 0.8, - ..Default::default() - } - } else { - HandlingModifierResponse::default() + |_input: ModifierResponseInput| -> HandlingModifierResponse { + if _input.value >= 1 { + HandlingModifierResponse { + stow_scale: 0.8, + draw_scale: 0.8, + ..Default::default() } - }, - ), + } else { + HandlingModifierResponse::default() + } + }, ); add_sbr( Perks::FirmlyPlanted, - Box::new( - |_input: ModifierResponseInput| -> HashMap { - let mut handling = if _input.is_enhanced { 35 } else { 30 }; - let mut stabiltiy = if _input.is_enhanced { 25 } else { 20 }; - if *_input.calc_data.weapon_type == WeaponType::FUSIONRIFLE { - handling /= 2; - stabiltiy /= 2; - }; - let mut out = HashMap::new(); - if _input.value > 0 { - out.insert(StatHashes::HANDLING.into(), handling); - out.insert(StatHashes::STABILITY.into(), stabiltiy); - } - out - }, - ), + |_input: ModifierResponseInput| -> HashMap { + let mut handling = if _input.is_enhanced { 35 } else { 30 }; + let mut stabiltiy = if _input.is_enhanced { 25 } else { 20 }; + if *_input.calc_data.weapon_type == WeaponType::FUSIONRIFLE { + handling /= 2; + stabiltiy /= 2; + }; + let mut out = HashMap::new(); + if _input.value > 0 { + out.insert(StatHashes::HANDLING.into(), handling); + out.insert(StatHashes::STABILITY.into(), stabiltiy); + } + out + }, ); add_hmr( Perks::FirmlyPlanted, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - let mut handling = if _input.is_enhanced { 35 } else { 30 }; - if *_input.calc_data.weapon_type == WeaponType::FUSIONRIFLE { - handling /= 2; - }; - if _input.value > 0 { - HandlingModifierResponse { - stat_add: handling, - ..Default::default() - } - } else { - HandlingModifierResponse::default() + |_input: ModifierResponseInput| -> HandlingModifierResponse { + let mut handling = if _input.is_enhanced { 35 } else { 30 }; + if *_input.calc_data.weapon_type == WeaponType::FUSIONRIFLE { + handling /= 2; + }; + if _input.value > 0 { + HandlingModifierResponse { + stat_add: handling, + ..Default::default() } - }, - ), + } else { + HandlingModifierResponse::default() + } + }, ); add_fmr( Perks::FullAutoTrigger, - Box::new(|_input: ModifierResponseInput| -> FiringModifierResponse { + |_input: ModifierResponseInput| -> FiringModifierResponse { let mut delay_mult = 1.0; if *_input.calc_data.weapon_type == WeaponType::SHOTGUN { delay_mult = 0.91; @@ -335,38 +315,36 @@ pub fn year_1_perks() { inner_burst_scale: 1.0, burst_size_add: 0.0, } - }), + }, ); add_rr( Perks::TripleTap, - Box::new(|_input: ModifierResponseInput| -> RefundResponse { + |_input: ModifierResponseInput| -> RefundResponse { RefundResponse { crit: true, requirement: 3, refund_mag: 1, refund_reserves: 0, } - }), + }, ); add_sbr( Perks::HipFireGrip, - Box::new( - |_input: ModifierResponseInput| -> HashMap { - let mut out = HashMap::new(); - if _input.value > 0 { - out.insert(StatHashes::AIM_ASSIST.into(), 15); - out.insert(StatHashes::STABILITY.into(), 25); - }; - out - }, - ), + |_input: ModifierResponseInput| -> HashMap { + let mut out = HashMap::new(); + if _input.value > 0 { + out.insert(StatHashes::AIM_ASSIST.into(), 15); + out.insert(StatHashes::STABILITY.into(), 25); + }; + out + }, ); add_rmr( Perks::HipFireGrip, - Box::new(|_input: ModifierResponseInput| -> RangeModifierResponse { + |_input: ModifierResponseInput| -> RangeModifierResponse { let mut hf_range_scale = 1.2; if *_input.calc_data.weapon_type == WeaponType::FUSIONRIFLE || *_input.calc_data.weapon_type == WeaponType::SHOTGUN @@ -381,53 +359,49 @@ pub fn year_1_perks() { range_hip_scale: hf_range_scale, range_zoom_scale: 1.0, } - }), + }, ); add_dmr( Perks::ImpactCasing, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { DamageModifierResponse { impact_dmg_scale: 1.1, explosive_dmg_scale: 1.0, crit_scale: 1.0, } - }), + }, ); add_sbr( Perks::MovingTarget, - Box::new( - |_input: ModifierResponseInput| -> HashMap { - let aim_assist = if _input.is_enhanced { 11 } else { 10 }; - let mut out = HashMap::new(); - if _input.value >= 1 { - out.insert(StatHashes::AIM_ASSIST.into(), aim_assist); - } - out - }, - ), + |_input: ModifierResponseInput| -> HashMap { + let aim_assist = if _input.is_enhanced { 11 } else { 10 }; + let mut out = HashMap::new(); + if _input.value >= 1 { + out.insert(StatHashes::AIM_ASSIST.into(), aim_assist); + } + out + }, ); add_sbr( Perks::OpeningShot, - Box::new( - |_input: ModifierResponseInput| -> HashMap { - let aim_assist = if _input.is_enhanced { 25 } else { 20 }; - let range = if _input.is_enhanced { 30 } else { 25 }; - let mut out = HashMap::new(); - if _input.value > 0 { - out.insert(StatHashes::AIM_ASSIST.into(), aim_assist); - out.insert(StatHashes::RANGE.into(), range); - } - out - }, - ), + |_input: ModifierResponseInput| -> HashMap { + let aim_assist = if _input.is_enhanced { 25 } else { 20 }; + let range = if _input.is_enhanced { 30 } else { 25 }; + let mut out = HashMap::new(); + if _input.value > 0 { + out.insert(StatHashes::AIM_ASSIST.into(), aim_assist); + out.insert(StatHashes::RANGE.into(), range); + } + out + }, ); add_rmr( Perks::OpeningShot, - Box::new(|_input: ModifierResponseInput| -> RangeModifierResponse { + |_input: ModifierResponseInput| -> RangeModifierResponse { let mut range = if _input.is_enhanced { 30 } else { 25 }; if _input.calc_data.total_shots_fired != 0.0 || _input.value == 0 { range = 0; @@ -438,25 +412,23 @@ pub fn year_1_perks() { range_hip_scale: 1.0, range_zoom_scale: 1.0, } - }), + }, ); add_sbr( Perks::Outlaw, - Box::new( - |_input: ModifierResponseInput| -> HashMap { - let mut out = HashMap::new(); - if _input.value > 0 { - out.insert(StatHashes::RELOAD.into(), 70); - } - out - }, - ), + |_input: ModifierResponseInput| -> HashMap { + let mut out = HashMap::new(); + if _input.value > 0 { + out.insert(StatHashes::RELOAD.into(), 70); + } + out + }, ); add_rsmr( Perks::Outlaw, - Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { + |_input: ModifierResponseInput| -> ReloadModifierResponse { let duration = if _input.is_enhanced { 7.0 } else { 6.0 }; if _input.value > 0 && _input.calc_data.time_total < duration { ReloadModifierResponse { @@ -466,39 +438,35 @@ pub fn year_1_perks() { } else { ReloadModifierResponse::default() } - }), + }, ); add_vmr( Perks::RangeFinder, - Box::new( - |_input: ModifierResponseInput| -> VelocityModifierResponse { - VelocityModifierResponse { - velocity_scaler: 1.05, - } - }, - ), + |_input: ModifierResponseInput| -> VelocityModifierResponse { + VelocityModifierResponse { + velocity_scaler: 1.05, + } + }, ); add_sbr( Perks::SlideShot, - Box::new( - |_input: ModifierResponseInput| -> HashMap { - let stability = if _input.is_enhanced { 35 } else { 30 }; - let range = if _input.is_enhanced { 25 } else { 20 }; - let mut out = HashMap::new(); - if _input.value > 0 { - out.insert(StatHashes::STABILITY.into(), stability); - out.insert(StatHashes::RANGE.into(), range); - } - out - }, - ), + |_input: ModifierResponseInput| -> HashMap { + let stability = if _input.is_enhanced { 35 } else { 30 }; + let range = if _input.is_enhanced { 25 } else { 20 }; + let mut out = HashMap::new(); + if _input.value > 0 { + out.insert(StatHashes::STABILITY.into(), stability); + out.insert(StatHashes::RANGE.into(), range); + } + out + }, ); add_rmr( Perks::SlideShot, - Box::new(|_input: ModifierResponseInput| -> RangeModifierResponse { + |_input: ModifierResponseInput| -> RangeModifierResponse { let range; if *_input.calc_data.weapon_type == WeaponType::FUSIONRIFLE { range = 0; //only applies to first proj so like should do alot less @@ -511,74 +479,66 @@ pub fn year_1_perks() { range_stat_add: range, ..Default::default() } - }), + }, ); add_sbr( Perks::SlideWays, - Box::new( - |_input: ModifierResponseInput| -> HashMap { - let stability = if _input.is_enhanced { 25 } else { 20 }; - let handling = if _input.is_enhanced { 25 } else { 20 }; - let mut out = HashMap::new(); - if _input.value > 0 { - out.insert(StatHashes::STABILITY.into(), stability); - out.insert(StatHashes::HANDLING.into(), handling); - } - out - }, - ), + |_input: ModifierResponseInput| -> HashMap { + let stability = if _input.is_enhanced { 25 } else { 20 }; + let handling = if _input.is_enhanced { 25 } else { 20 }; + let mut out = HashMap::new(); + if _input.value > 0 { + out.insert(StatHashes::STABILITY.into(), stability); + out.insert(StatHashes::HANDLING.into(), handling); + } + out + }, ); add_hmr( Perks::SlideWays, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - let handling = if _input.value > 0 { 20 } else { 0 }; - HandlingModifierResponse { - stat_add: handling, - ..Default::default() - } - }, - ), + |_input: ModifierResponseInput| -> HandlingModifierResponse { + let handling = if _input.value > 0 { 20 } else { 0 }; + HandlingModifierResponse { + stat_add: handling, + ..Default::default() + } + }, ); add_hmr( Perks::Snapshot, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - let mut ads_mult = 0.5; - if *_input.calc_data.ammo_type == AmmoType::SPECIAL { - ads_mult = 0.8; //its 0.8 from my testing idk - }; - HandlingModifierResponse { - ads_scale: ads_mult, - ..Default::default() - } - }, - ), + |_input: ModifierResponseInput| -> HandlingModifierResponse { + let mut ads_mult = 0.5; + if *_input.calc_data.ammo_type == AmmoType::SPECIAL { + ads_mult = 0.8; //its 0.8 from my testing idk + }; + HandlingModifierResponse { + ads_scale: ads_mult, + ..Default::default() + } + }, ); add_sbr( Perks::TapTheTrigger, - Box::new( - |_input: ModifierResponseInput| -> HashMap { - let mut stability = if _input.is_enhanced { 44 } else { 40 }; - if *_input.calc_data.weapon_type == WeaponType::FUSIONRIFLE { - stability /= 4; - } - let mut out = HashMap::new(); - if _input.value > 0 { - out.insert(StatHashes::STABILITY.into(), stability); - } - out - }, - ), + |_input: ModifierResponseInput| -> HashMap { + let mut stability = if _input.is_enhanced { 44 } else { 40 }; + if *_input.calc_data.weapon_type == WeaponType::FUSIONRIFLE { + stability /= 4; + } + let mut out = HashMap::new(); + if _input.value > 0 { + out.insert(StatHashes::STABILITY.into(), stability); + } + out + }, ); add_dmr( Perks::Rampage, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let val = clamp(_input.value, 0, 3); let mut damage_mult = 1.1_f64.powi(val as i32) - 1.0; let duration = if _input.is_enhanced { 5.0 } else { 4.0 }; @@ -594,12 +554,12 @@ pub fn year_1_perks() { explosive_dmg_scale: 1.0 + damage_mult, crit_scale: 1.0, } - }), + }, ); add_dmr( Perks::KillClip, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let mut damage_mult = if _input.value > 0 { 0.25 } else { 0.0 }; let duration = if _input.is_enhanced { 5.0 } else { 4.0 }; if _input.calc_data.time_total > duration { @@ -610,12 +570,12 @@ pub fn year_1_perks() { explosive_dmg_scale: 1.0 + damage_mult, crit_scale: 1.0, } - }), + }, ); add_dmr( Perks::BackupPlan, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let mut damage_mult = if _input.value > 0 { 0.2 } else { 0.0 }; let duration = if _input.is_enhanced { 2.2 } else { 2.0 }; if _input.calc_data.time_total > duration { @@ -626,12 +586,12 @@ pub fn year_1_perks() { explosive_dmg_scale: 1.0 - damage_mult, crit_scale: 1.0, } - }), + }, ); add_fmr( Perks::BackupPlan, - Box::new(|_input: ModifierResponseInput| -> FiringModifierResponse { + |_input: ModifierResponseInput| -> FiringModifierResponse { let mut firing_mult = if _input.value > 0 { 0.7 } else { 1.0 }; let duration = if _input.is_enhanced { 2.2 } else { 2.0 }; if _input.calc_data.time_total > duration { @@ -641,47 +601,43 @@ pub fn year_1_perks() { burst_delay_scale: firing_mult, ..Default::default() } - }), + }, ); add_hmr( Perks::BackupPlan, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - let mut handling_add = if _input.value > 0 { 100 } else { 0 }; - let duration = if _input.is_enhanced { 2.2 } else { 2.0 }; - if _input.calc_data.time_total > duration { - handling_add = 0; - }; - HandlingModifierResponse { - stat_add: handling_add, - ..Default::default() - } - }, - ), + |_input: ModifierResponseInput| -> HandlingModifierResponse { + let mut handling_add = if _input.value > 0 { 100 } else { 0 }; + let duration = if _input.is_enhanced { 2.2 } else { 2.0 }; + if _input.calc_data.time_total > duration { + handling_add = 0; + }; + HandlingModifierResponse { + stat_add: handling_add, + ..Default::default() + } + }, ); add_sbr( Perks::BackupPlan, - Box::new( - |_input: ModifierResponseInput| -> HashMap { - let mut handling = if _input.value > 0 { 100 } else { 0 }; - let duration = if _input.is_enhanced { 2.2 } else { 2.0 }; - if _input.calc_data.time_total > duration { - handling = 0; - }; - let mut out = HashMap::new(); - if _input.value > 0 { - out.insert(StatHashes::HANDLING.into(), handling); - } - out - }, - ), + |_input: ModifierResponseInput| -> HashMap { + let mut handling = if _input.value > 0 { 100 } else { 0 }; + let duration = if _input.is_enhanced { 2.2 } else { 2.0 }; + if _input.calc_data.time_total > duration { + handling = 0; + }; + let mut out = HashMap::new(); + if _input.value > 0 { + out.insert(StatHashes::HANDLING.into(), handling); + } + out + }, ); add_edr( Perks::ClusterBomb, - Box::new(|_input: ModifierResponseInput| -> ExtraDamageResponse { + |_input: ModifierResponseInput| -> ExtraDamageResponse { ExtraDamageResponse { additive_damage: 350.0 * 0.04, combatant_scale: true, @@ -693,12 +649,12 @@ pub fn year_1_perks() { hit_at_same_time: true, is_dot: false, } - }), + }, ); add_dmr( Perks::DisruptionBreak, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let mut damage_mult = if _input.value > 0 { 0.5 } else { 0.0 }; let duration = if _input.is_enhanced { 5.0 } else { 4.0 }; if _input.calc_data.time_total > duration @@ -711,86 +667,76 @@ pub fn year_1_perks() { explosive_dmg_scale: 1.0 + damage_mult, crit_scale: 1.0, } - }), + }, ); add_hmr( Perks::QuickDraw, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - if _input.value > 0 { - HandlingModifierResponse { - draw_add: 100, - draw_scale: 0.95, - ..Default::default() - } - } else { - HandlingModifierResponse::default() + |_input: ModifierResponseInput| -> HandlingModifierResponse { + if _input.value > 0 { + HandlingModifierResponse { + draw_add: 100, + draw_scale: 0.95, + ..Default::default() } - }, - ), + } else { + HandlingModifierResponse::default() + } + }, ); add_sbr( Perks::QuickDraw, - Box::new( - |_input: ModifierResponseInput| -> HashMap { - let mut map = HashMap::new(); - if _input.value > 0 { - map.insert(StatHashes::HANDLING.into(), 100); - } - map - }, - ), + |_input: ModifierResponseInput| -> HashMap { + let mut map = HashMap::new(); + if _input.value > 0 { + map.insert(StatHashes::HANDLING.into(), 100); + } + map + }, ); add_hmr( Perks::PulseMonitor, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - if _input.value > 0 { - HandlingModifierResponse { - stat_add: 50, - draw_scale: 0.95, - stow_scale: 0.95, - ..Default::default() - } - } else { - HandlingModifierResponse::default() + |_input: ModifierResponseInput| -> HandlingModifierResponse { + if _input.value > 0 { + HandlingModifierResponse { + stat_add: 50, + draw_scale: 0.95, + stow_scale: 0.95, + ..Default::default() } - }, - ), + } else { + HandlingModifierResponse::default() + } + }, ); add_sbr( Perks::PulseMonitor, - Box::new( - |_input: ModifierResponseInput| -> HashMap { - let mut map = HashMap::new(); - if _input.value > 0 { - map.insert(StatHashes::HANDLING.into(), 50); - } - map - }, - ), + |_input: ModifierResponseInput| -> HashMap { + let mut map = HashMap::new(); + if _input.value > 0 { + map.insert(StatHashes::HANDLING.into(), 50); + } + map + }, ); add_sbr( Perks::UnderDog, - Box::new( - |_input: ModifierResponseInput| -> HashMap { - let mut map = HashMap::new(); - if _input.value > 0 { - map.insert(StatHashes::RELOAD.into(), 100); - } - map - }, - ), + |_input: ModifierResponseInput| -> HashMap { + let mut map = HashMap::new(); + if _input.value > 0 { + map.insert(StatHashes::RELOAD.into(), 100); + } + map + }, ); add_rsmr( Perks::UnderDog, - Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { + |_input: ModifierResponseInput| -> ReloadModifierResponse { if _input.value > 0 { ReloadModifierResponse { reload_stat_add: 100, @@ -799,35 +745,33 @@ pub fn year_1_perks() { } else { ReloadModifierResponse::default() } - }), + }, ); add_sbr( Perks::UnderPressure, - Box::new( - |_input: ModifierResponseInput| -> HashMap { - let mut map = HashMap::new(); - let buff = if _input.is_enhanced { 35 } else { 30 }; - if _input.value > 0 { - map.insert(StatHashes::STABILITY.into(), buff); - } - map - }, - ), + |_input: ModifierResponseInput| -> HashMap { + let mut map = HashMap::new(); + let buff = if _input.is_enhanced { 35 } else { 30 }; + if _input.value > 0 { + map.insert(StatHashes::STABILITY.into(), buff); + } + map + }, ); add_fmr( Perks::PhaseMag, - Box::new(|_input: ModifierResponseInput| -> FiringModifierResponse { + |_input: ModifierResponseInput| -> FiringModifierResponse { FiringModifierResponse { burst_delay_add: 1.0 / 30.0, ..Default::default() } - }), + }, ); add_dmr( Perks::PhaseMag, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { //set up precision smg to get damage values from let precision = Weapon::generate_weapon( 0, 24, //smg @@ -849,6 +793,6 @@ pub fn year_1_perks() { explosive_dmg_scale: precision_body / lightweight_body, crit_scale: precision_crit / lightweight_crit, } - }), + }, ); } diff --git a/src/perks/year_2_perks.rs b/src/perks/year_2_perks.rs index 1a81cd05..e7f65869 100644 --- a/src/perks/year_2_perks.rs +++ b/src/perks/year_2_perks.rs @@ -19,18 +19,18 @@ use super::{ pub fn year_2_perks() { add_sbr( Perks::AirAssault, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut stats = HashMap::new(); let ae_per_stack = if _input.is_enhanced { 35 } else { 30 }; let ae = ae_per_stack * _input.value as i32; stats.insert(StatHashes::AIRBORNE.into(), ae); stats - }), + }, ); add_fmr( Perks::ArchersTempo, - Box::new(|_input: ModifierResponseInput| -> FiringModifierResponse { + |_input: ModifierResponseInput| -> FiringModifierResponse { let delay = match (_input.value, _input.calc_data.intrinsic_hash) { (0, _) => 1.0, (1.., 1699724249) => 0.5625, //levi breath @@ -40,12 +40,12 @@ pub fn year_2_perks() { burst_delay_scale: delay, ..Default::default() } - }), + }, ); add_dmr( Perks::ExplosiveHead, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { if _input.pvp { DamageModifierResponse::default() } else { @@ -55,25 +55,23 @@ pub fn year_2_perks() { crit_scale: 1.0, } } - }), + }, ); add_epr( Perks::ExplosiveHead, - Box::new( - |_input: ModifierResponseInput| -> ExplosivePercentResponse { - ExplosivePercentResponse { - percent: 0.5, - delyed: if _input.pvp { 0.0 } else { 0.2 }, - retain_base_total: true, - } - }, - ), + |_input: ModifierResponseInput| -> ExplosivePercentResponse { + ExplosivePercentResponse { + percent: 0.5, + delyed: if _input.pvp { 0.0 } else { 0.2 }, + retain_base_total: true, + } + }, ); add_rsmr( Perks::FeedingFrenzy, - Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { + |_input: ModifierResponseInput| -> ReloadModifierResponse { let val = clamp(_input.value, 0, 5); let duration = 3.5; let mut reload_mult = 1.0; @@ -102,12 +100,12 @@ pub fn year_2_perks() { reload_stat_add: reload, reload_time_scale: reload_mult, } - }), + }, ); add_sbr( Perks::FeedingFrenzy, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut stats = HashMap::new(); let val = clamp(_input.value, 0, 5); let duration = 3.5; @@ -128,12 +126,12 @@ pub fn year_2_perks() { }; stats.insert(StatHashes::RELOAD.into(), reload); stats - }), + }, ); add_dmr( Perks::FiringLine, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let mut crit_mult = 1.0; if _input.value > 0 { crit_mult = 1.2; @@ -143,24 +141,24 @@ pub fn year_2_perks() { explosive_dmg_scale: 1.0, impact_dmg_scale: 1.0, } - }), + }, ); add_rr( Perks::FourthTimesTheCharm, - Box::new(|_input: ModifierResponseInput| -> RefundResponse { + |_input: ModifierResponseInput| -> RefundResponse { RefundResponse { crit: true, requirement: 4, refund_mag: 2, refund_reserves: 0, } - }), + }, ); add_dmr( Perks::KillingTally, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let val = clamp(_input.value, 0, 3); let mut damage_mult = 0.1 * val as f64; if _input.pvp { @@ -174,32 +172,30 @@ pub fn year_2_perks() { explosive_dmg_scale: 1.0 + damage_mult, crit_scale: 1.0, } - }), + }, ); add_mmr( Perks::OverFlow, - Box::new( - |_input: ModifierResponseInput| -> MagazineModifierResponse { - let mut mag_scale = if _input.value > 0 { 2.0 } else { 1.0 }; - if _input.is_enhanced && _input.value > 0 { - mag_scale *= 1.1; - }; - if _input.calc_data.total_shots_fired > 0.0 { - mag_scale = 1.0; - }; - MagazineModifierResponse { - magazine_stat_add: 0, - magazine_scale: mag_scale, - magazine_add: 0.0, - } - }, - ), + |_input: ModifierResponseInput| -> MagazineModifierResponse { + let mut mag_scale = if _input.value > 0 { 2.0 } else { 1.0 }; + if _input.is_enhanced && _input.value > 0 { + mag_scale *= 1.1; + }; + if _input.calc_data.total_shots_fired > 0.0 { + mag_scale = 1.0; + }; + MagazineModifierResponse { + magazine_stat_add: 0, + magazine_scale: mag_scale, + magazine_add: 0.0, + } + }, ); add_rsmr( Perks::RapidHit, - Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { + |_input: ModifierResponseInput| -> ReloadModifierResponse { let values = [ (0, 1.0), (5, 0.99), @@ -217,12 +213,12 @@ pub fn year_2_perks() { reload_stat_add: values[entry_to_get as usize].0, reload_time_scale: values[entry_to_get as usize].1, } - }), + }, ); add_sbr( Perks::RapidHit, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let rel_values = [0, 5, 30, 35, 45, 60]; let stab_values = [0, 2, 12, 14, 18, 25]; let entry_to_get = clamp( @@ -237,12 +233,12 @@ pub fn year_2_perks() { stab_values[entry_to_get as usize], ); stats - }), + }, ); add_dmr( Perks::ResevoirBurst, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let damage_mult = if _input.calc_data.curr_mag >= _input.calc_data.base_mag { 1.25 } else { @@ -253,12 +249,12 @@ pub fn year_2_perks() { explosive_dmg_scale: damage_mult, ..Default::default() } - }), + }, ); add_dmr( Perks::Surrounded, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let mut damage_mult = 1.0; if _input.value > 0 { damage_mult = if *_input.calc_data.weapon_type == WeaponType::SWORD { @@ -275,12 +271,12 @@ pub fn year_2_perks() { explosive_dmg_scale: damage_mult, crit_scale: 1.0, } - }), + }, ); add_dmr( Perks::FullCourt, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let mut damage_mult = 1.0; if _input.value > 0 { damage_mult = 1.25; @@ -290,12 +286,12 @@ pub fn year_2_perks() { explosive_dmg_scale: damage_mult, crit_scale: 1.0, } - }), + }, ); add_dmr( Perks::Swashbuckler, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let val = clamp(_input.value, 0, 5); let duration = if _input.is_enhanced { 6.0 } else { 4.5 }; let mut dmg_boost = 0.067 * val as f64; @@ -307,12 +303,12 @@ pub fn year_2_perks() { explosive_dmg_scale: 1.0 + dmg_boost, crit_scale: 1.0, } - }), + }, ); add_dmr( Perks::MultikillClip, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let val = clamp(_input.value, 0, 5); let mut damage_mult = (1.0 / 6.0) * val as f64; if _input.calc_data.num_reloads > 0.0 { @@ -323,12 +319,12 @@ pub fn year_2_perks() { explosive_dmg_scale: 1.0 + damage_mult, crit_scale: 1.0, } - }), + }, ); add_dmr( Perks::ExplosiveLight, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let shots = if _input.is_enhanced { 7.0 } else { 6.0 }; let shots_left = _input.value as f64 * shots - _input.calc_data.total_shots_fired; if shots_left <= 0.0 { @@ -345,55 +341,53 @@ pub fn year_2_perks() { impact_dmg_scale: mult.1, crit_scale: 1.0, } - }), + }, ); add_sbr( Perks::ExplosiveLight, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut out = HashMap::new(); if _input.value > 0 { out.insert(StatHashes::BLAST_RADIUS.into(), 100); }; out - }), + }, ); add_sbr( Perks::EyeOfTheStorm, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut out = HashMap::new(); if _input.value > 0 { out.insert(StatHashes::HANDLING.into(), 30); }; out - }), + }, ); add_hmr( Perks::EyeOfTheStorm, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - if _input.value > 0 { - HandlingModifierResponse { - stat_add: 30, - ..Default::default() - } - } else { - HandlingModifierResponse::default() + |_input: ModifierResponseInput| -> HandlingModifierResponse { + if _input.value > 0 { + HandlingModifierResponse { + stat_add: 30, + ..Default::default() } - }, - ), + } else { + HandlingModifierResponse::default() + } + }, ); add_flmr( Perks::NoDistractions, - Box::new(|_input: ModifierResponseInput| -> FlinchModifierResponse { + |_input: ModifierResponseInput| -> FlinchModifierResponse { if _input.value > 0 { FlinchModifierResponse { flinch_scale: 0.65 } } else { FlinchModifierResponse::default() } - }), + }, ); } diff --git a/src/perks/year_3_perks.rs b/src/perks/year_3_perks.rs index 1ab3abe9..efdcac0b 100644 --- a/src/perks/year_3_perks.rs +++ b/src/perks/year_3_perks.rs @@ -18,20 +18,18 @@ use super::{ pub fn year_3_perks() { add_mmr( Perks::ClownCartridge, - Box::new( - |_input: ModifierResponseInput| -> MagazineModifierResponse { - MagazineModifierResponse { - magazine_add: 0.0, - magazine_scale: 1.5, - magazine_stat_add: 0, - } - }, - ), + |_input: ModifierResponseInput| -> MagazineModifierResponse { + MagazineModifierResponse { + magazine_add: 0.0, + magazine_scale: 1.5, + magazine_stat_add: 0, + } + }, ); add_sbr( Perks::ElementalCapacitor, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut stats = HashMap::new(); let ev = if _input.is_enhanced { 5 } else { 0 }; if _input.value == 1 { @@ -46,28 +44,26 @@ pub fn year_3_perks() { stats.insert(StatHashes::AIRBORNE.into(), 20 + ev); }; stats - }), + }, ); add_hmr( Perks::ElementalCapacitor, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - let mut handling = 0; - if _input.value == 3 { - handling = if _input.is_enhanced { 55 } else { 50 }; - }; - HandlingModifierResponse { - stat_add: handling, - ..Default::default() - } - }, - ), + |_input: ModifierResponseInput| -> HandlingModifierResponse { + let mut handling = 0; + if _input.value == 3 { + handling = if _input.is_enhanced { 55 } else { 50 }; + }; + HandlingModifierResponse { + stat_add: handling, + ..Default::default() + } + }, ); add_rsmr( Perks::ElementalCapacitor, - Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { + |_input: ModifierResponseInput| -> ReloadModifierResponse { let mut reload = 0; if _input.value == 2 { reload = if _input.is_enhanced { 55 } else { 50 }; @@ -76,24 +72,24 @@ pub fn year_3_perks() { reload_stat_add: reload, ..Default::default() } - }), + }, ); add_sbr( Perks::KillingWind, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut stats = HashMap::new(); if _input.value > 0 { stats.insert(StatHashes::HANDLING.into(), 40); stats.insert(StatHashes::RANGE.into(), 20); }; stats - }), + }, ); add_rmr( Perks::KillingWind, - Box::new(|_input: ModifierResponseInput| -> RangeModifierResponse { + |_input: ModifierResponseInput| -> RangeModifierResponse { if _input.value > 0 { RangeModifierResponse { range_stat_add: 20, @@ -109,39 +105,37 @@ pub fn year_3_perks() { range_hip_scale: 1.0, } } - }), + }, ); add_hmr( Perks::KillingWind, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - if _input.value > 0 { - HandlingModifierResponse { - stat_add: 40, - ..Default::default() - } - } else { - HandlingModifierResponse::default() + |_input: ModifierResponseInput| -> HandlingModifierResponse { + if _input.value > 0 { + HandlingModifierResponse { + stat_add: 40, + ..Default::default() } - }, - ), + } else { + HandlingModifierResponse::default() + } + }, ); add_dmr( Perks::LastingImpression, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { DamageModifierResponse { impact_dmg_scale: 1.0, explosive_dmg_scale: 1.25, crit_scale: 1.0, } - }), + }, ); add_dmr( Perks::Vorpal, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let mut buff = 1.0; if (*_input.calc_data.enemy_type == EnemyType::BOSS || *_input.calc_data.enemy_type == EnemyType::MINIBOSS @@ -161,12 +155,12 @@ pub fn year_3_perks() { explosive_dmg_scale: buff, crit_scale: 1.0, } - }), + }, ); add_sbr( Perks::TrenchBarrel, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut buffer: HashMap = HashMap::new(); let bump = if _input.is_enhanced { 35 } else { 30 }; if _input.value > 0 { @@ -175,28 +169,26 @@ pub fn year_3_perks() { buffer.insert(StatHashes::RELOAD.into(), bump); } buffer - }), + }, ); add_hmr( Perks::TrenchBarrel, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - if _input.value == 0 { - return HandlingModifierResponse::default(); - } - HandlingModifierResponse { - stat_add: if _input.is_enhanced { 35 } else { 30 }, - ..Default::default() - } - }, - ), + |_input: ModifierResponseInput| -> HandlingModifierResponse { + if _input.value == 0 { + return HandlingModifierResponse::default(); + } + HandlingModifierResponse { + stat_add: if _input.is_enhanced { 35 } else { 30 }, + ..Default::default() + } + }, ); //ready for when someone finds the reload information add_rsmr( Perks::TrenchBarrel, - Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { + |_input: ModifierResponseInput| -> ReloadModifierResponse { if _input.value == 0 { return ReloadModifierResponse::default(); } @@ -204,12 +196,12 @@ pub fn year_3_perks() { reload_stat_add: if _input.is_enhanced { 35 } else { 30 }, ..Default::default() } - }), + }, ); add_dmr( Perks::TrenchBarrel, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { if _input.value > 0 { return DamageModifierResponse { impact_dmg_scale: 1.5, @@ -218,6 +210,6 @@ pub fn year_3_perks() { }; } DamageModifierResponse::default() - }), + }, ); } diff --git a/src/perks/year_4_perks.rs b/src/perks/year_4_perks.rs index a637a325..2d0a671a 100644 --- a/src/perks/year_4_perks.rs +++ b/src/perks/year_4_perks.rs @@ -16,7 +16,7 @@ use super::{ pub fn year_4_perks() { add_dmr( Perks::Adagio, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let duration = if _input.is_enhanced { 8.0 } else { 7.0 }; let mut dmg_boost = 0.3; if *_input.calc_data.weapon_type == WeaponType::BOW @@ -32,12 +32,12 @@ pub fn year_4_perks() { explosive_dmg_scale: 1.0 + dmg_boost, crit_scale: 1.0, } - }), + }, ); add_fmr( Perks::Adagio, - Box::new(|_input: ModifierResponseInput| -> FiringModifierResponse { + |_input: ModifierResponseInput| -> FiringModifierResponse { let duration = if _input.is_enhanced { 8.0 } else { 7.0 }; let mut firing_slow = 1.2; if _input.calc_data.time_total > duration || _input.value == 0 { @@ -49,24 +49,24 @@ pub fn year_4_perks() { inner_burst_scale: firing_slow, burst_size_add: 0.0, } - }), + }, ); add_sbr( Perks::Adagio, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut map = HashMap::new(); let duration = if _input.is_enhanced { 8.0 } else { 7.0 }; if _input.calc_data.time_total <= duration && _input.value > 0 { map.insert(StatHashes::RANGE.into(), 10); } map - }), + }, ); add_rmr( Perks::Adagio, - Box::new(|_input: ModifierResponseInput| -> RangeModifierResponse { + |_input: ModifierResponseInput| -> RangeModifierResponse { if _input.value == 0 { return RangeModifierResponse::default(); } @@ -75,12 +75,12 @@ pub fn year_4_perks() { range_stat_add: 10, ..Default::default() } - }), + }, ); add_dmr( Perks::AdrenalineJunkie, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let val = clamp(_input.value, 0, 5); let duration = if _input.is_enhanced { 6.0 } else { 4.5 }; let mut dmg_boost = 0.067 * val as f64; @@ -92,12 +92,12 @@ pub fn year_4_perks() { explosive_dmg_scale: 1.0 + dmg_boost, crit_scale: 1.0, } - }), + }, ); add_sbr( Perks::AdrenalineJunkie, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let duration = if _input.is_enhanced { 6.0 } else { 4.5 }; let mut handling = 0; if _input.calc_data.time_total <= duration && _input.value > 0 { @@ -106,25 +106,23 @@ pub fn year_4_perks() { let mut out = HashMap::new(); out.insert(StatHashes::HANDLING.into(), handling); out - }), + }, ); add_hmr( Perks::AdrenalineJunkie, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - let handling = if _input.value > 0 { 20 } else { 0 }; - HandlingModifierResponse { - stat_add: handling, - ..Default::default() - } - }, - ), + |_input: ModifierResponseInput| -> HandlingModifierResponse { + let handling = if _input.value > 0 { 20 } else { 0 }; + HandlingModifierResponse { + stat_add: handling, + ..Default::default() + } + }, ); add_fmr( Perks::Cornered, - Box::new(|_input: ModifierResponseInput| -> FiringModifierResponse { + |_input: ModifierResponseInput| -> FiringModifierResponse { let mut delay_mult = 1.0; if _input.value > 0 { delay_mult = 0.85; @@ -135,12 +133,12 @@ pub fn year_4_perks() { inner_burst_scale: 1.0, burst_size_add: 0.0, } - }), + }, ); add_sbr( Perks::Ensemble, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let handling = if _input.is_enhanced { 35 } else { 30 }; let reload = if _input.is_enhanced { 45 } else { 40 }; if _input.value > 0 { @@ -151,29 +149,27 @@ pub fn year_4_perks() { } else { HashMap::new() } - }), + }, ); add_hmr( Perks::Ensemble, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - let handling = if _input.is_enhanced { 35 } else { 30 }; - if _input.value > 0 { - HandlingModifierResponse { - stat_add: handling, - ..Default::default() - } - } else { - HandlingModifierResponse::default() + |_input: ModifierResponseInput| -> HandlingModifierResponse { + let handling = if _input.is_enhanced { 35 } else { 30 }; + if _input.value > 0 { + HandlingModifierResponse { + stat_add: handling, + ..Default::default() } - }, - ), + } else { + HandlingModifierResponse::default() + } + }, ); add_rsmr( Perks::Ensemble, - Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { + |_input: ModifierResponseInput| -> ReloadModifierResponse { let reload = if _input.is_enhanced { 45 } else { 40 }; if _input.value > 0 { ReloadModifierResponse { @@ -186,12 +182,12 @@ pub fn year_4_perks() { reload_time_scale: 1.0, } } - }), + }, ); add_rsmr( Perks::Frenzy, - Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { + |_input: ModifierResponseInput| -> ReloadModifierResponse { let mut reload = 0; if _input.value > 0 { reload = 100; @@ -203,31 +199,29 @@ pub fn year_4_perks() { reload_stat_add: reload, reload_time_scale: 1.0, } - }), + }, ); add_hmr( Perks::Frenzy, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - let mut handling = 0; - if _input.value > 0 { - handling = 100; - }; - if _input.calc_data.time_total > 12.0 { - handling = 100; - }; - HandlingModifierResponse { - stat_add: handling, - ..Default::default() - } - }, - ), + |_input: ModifierResponseInput| -> HandlingModifierResponse { + let mut handling = 0; + if _input.value > 0 { + handling = 100; + }; + if _input.calc_data.time_total > 12.0 { + handling = 100; + }; + HandlingModifierResponse { + stat_add: handling, + ..Default::default() + } + }, ); add_dmr( Perks::Frenzy, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let mut dmg = 0.0; if _input.value > 0 { dmg = 0.15; @@ -240,12 +234,12 @@ pub fn year_4_perks() { explosive_dmg_scale: 1.0 + dmg, crit_scale: 1.0, } - }), + }, ); add_sbr( Perks::Frenzy, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut handling = 0; let mut reload = 0; if _input.value > 0 { @@ -260,12 +254,12 @@ pub fn year_4_perks() { out.insert(StatHashes::HANDLING.into(), handling); out.insert(StatHashes::RELOAD.into(), reload); out - }), + }, ); add_rsmr( Perks::ImpulseAmplifier, - Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { + |_input: ModifierResponseInput| -> ReloadModifierResponse { let reload = if _input.is_enhanced { 25 } else { 20 }; let reload_mult = if *_input.calc_data.weapon_type == WeaponType::ROCKET { 0.8 @@ -276,33 +270,31 @@ pub fn year_4_perks() { reload_stat_add: reload, reload_time_scale: reload_mult, } - }), + }, ); add_sbr( Perks::ImpulseAmplifier, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let reload = if _input.is_enhanced { 25 } else { 20 }; let mut out = HashMap::new(); out.insert(StatHashes::RELOAD.into(), reload); out - }), + }, ); add_vmr( Perks::ImpulseAmplifier, - Box::new( - |_input: ModifierResponseInput| -> VelocityModifierResponse { - VelocityModifierResponse { - velocity_scaler: 1.35, - } - }, - ), + |_input: ModifierResponseInput| -> VelocityModifierResponse { + VelocityModifierResponse { + velocity_scaler: 1.35, + } + }, ); add_sbr( Perks::PerpetualMotion, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let val = clamp(_input.value, 0, 2); let mut stat_bump = 0; if val == 1 { @@ -315,31 +307,29 @@ pub fn year_4_perks() { out.insert(StatHashes::HANDLING.into(), stat_bump); out.insert(StatHashes::STABILITY.into(), stat_bump); out - }), + }, ); add_hmr( Perks::PerpetualMotion, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - let val = clamp(_input.value, 0, 2); - let mut stat_bump = 0; - if val == 1 { - stat_bump = 10; - } else if val == 2 { - stat_bump = 20; - }; - HandlingModifierResponse { - stat_add: stat_bump, - ..Default::default() - } - }, - ), + |_input: ModifierResponseInput| -> HandlingModifierResponse { + let val = clamp(_input.value, 0, 2); + let mut stat_bump = 0; + if val == 1 { + stat_bump = 10; + } else if val == 2 { + stat_bump = 20; + }; + HandlingModifierResponse { + stat_add: stat_bump, + ..Default::default() + } + }, ); add_rsmr( Perks::PerpetualMotion, - Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { + |_input: ModifierResponseInput| -> ReloadModifierResponse { let val = clamp(_input.value, 0, 2); let mut stat_bump = 0; if val == 1 { @@ -351,83 +341,79 @@ pub fn year_4_perks() { reload_stat_add: stat_bump, reload_time_scale: 1.0, } - }), + }, ); add_sbr( Perks::PerfectFloat, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut out = HashMap::new(); if _input.value > 0 { out.insert(StatHashes::AIRBORNE.into(), 30); }; out - }), + }, ); add_flmr( Perks::PerfectFloat, - Box::new(|_input: ModifierResponseInput| -> FlinchModifierResponse { + |_input: ModifierResponseInput| -> FlinchModifierResponse { let val = if _input.value > 0 { 0.65 } else { 1.0 }; FlinchModifierResponse { flinch_scale: val } - }), + }, ); add_sbr( Perks::Pugilist, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut out = HashMap::new(); if _input.value > 0 { out.insert(StatHashes::HANDLING.into(), 35); }; out - }), + }, ); add_hmr( Perks::Pugilist, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - let mut handling = 0; - if _input.value > 0 { - handling = 35; - }; - HandlingModifierResponse { - stat_add: handling, - ..Default::default() - } - }, - ), + |_input: ModifierResponseInput| -> HandlingModifierResponse { + let mut handling = 0; + if _input.value > 0 { + handling = 35; + }; + HandlingModifierResponse { + stat_add: handling, + ..Default::default() + } + }, ); add_mmr( Perks::Reconstruction, - Box::new( - |_input: ModifierResponseInput| -> MagazineModifierResponse { - let mag_scale = if _input.value > 0 { 2.0 } else { 1.0 }; - MagazineModifierResponse { - magazine_stat_add: 0, - magazine_scale: mag_scale, - magazine_add: 0.0, - } - }, - ), + |_input: ModifierResponseInput| -> MagazineModifierResponse { + let mag_scale = if _input.value > 0 { 2.0 } else { 1.0 }; + MagazineModifierResponse { + magazine_stat_add: 0, + magazine_scale: mag_scale, + magazine_add: 0.0, + } + }, ); add_sbr( Perks::DangerZone, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut out = HashMap::new(); if _input.value > 0 { out.insert(StatHashes::BLAST_RADIUS.into(), 100); }; out - }), + }, ); add_dmr( Perks::OneForAll, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let mut dmg = 0.0; let duration = if _input.is_enhanced { 11.0 } else { 10.0 }; if _input.value > 0 { @@ -441,23 +427,23 @@ pub fn year_4_perks() { explosive_dmg_scale: 1.0 + dmg, crit_scale: 1.0, } - }), + }, ); add_sbr( Perks::FireFly, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut buffer: HashMap = HashMap::new(); if _input.value > 0 { buffer.insert(StatHashes::RELOAD.into(), 50); } buffer - }), + }, ); add_rsmr( Perks::FireFly, - Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { + |_input: ModifierResponseInput| -> ReloadModifierResponse { if _input.value > 0 { ReloadModifierResponse { reload_stat_add: 50, @@ -466,12 +452,12 @@ pub fn year_4_perks() { } else { ReloadModifierResponse::default() } - }), + }, ); add_dmr( Perks::GoldenTricorn, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let val = clamp(_input.value, 0, 2); let mut duration = if val == 2 { 10.0 } else { 7.0 }; if _input.is_enhanced && val == 1 { @@ -487,12 +473,12 @@ pub fn year_4_perks() { } else { DamageModifierResponse::default() } - }), + }, ); add_dmr( Perks::Harmony, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let mut damage_mult = if _input.value > 0 { 0.20 } else { 0.0 }; let duration = if _input.is_enhanced { 8.0 } else { 7.0 }; if _input.calc_data.time_total > duration { @@ -503,36 +489,34 @@ pub fn year_4_perks() { explosive_dmg_scale: 1.0 + damage_mult, crit_scale: 1.0, } - }), + }, ); add_hmr( Perks::Harmony, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - let handling = if _input.value > 0 { 15 } else { 0 }; - HandlingModifierResponse { - stat_add: handling, - ..Default::default() - } - }, - ), + |_input: ModifierResponseInput| -> HandlingModifierResponse { + let handling = if _input.value > 0 { 15 } else { 0 }; + HandlingModifierResponse { + stat_add: handling, + ..Default::default() + } + }, ); add_sbr( Perks::Harmony, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut out = HashMap::new(); if _input.value > 0 { out.insert(StatHashes::HANDLING.into(), 15); } out - }), + }, ); add_sbr( Perks::Surplus, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut out = HashMap::new(); if _input.value == 1 { out.insert(StatHashes::HANDLING.into(), 10); @@ -548,33 +532,31 @@ pub fn year_4_perks() { out.insert(StatHashes::STABILITY.into(), 25); } out - }), + }, ); add_hmr( Perks::Surplus, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - let handling = if _input.value == 1 { - 10 - } else if _input.value == 2 { - 25 - } else if _input.value == 3 { - 50 - } else { - 0 - }; - HandlingModifierResponse { - stat_add: handling, - ..Default::default() - } - }, - ), + |_input: ModifierResponseInput| -> HandlingModifierResponse { + let handling = if _input.value == 1 { + 10 + } else if _input.value == 2 { + 25 + } else if _input.value == 3 { + 50 + } else { + 0 + }; + HandlingModifierResponse { + stat_add: handling, + ..Default::default() + } + }, ); add_rsmr( Perks::Surplus, - Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { + |_input: ModifierResponseInput| -> ReloadModifierResponse { let reload = if _input.value == 1 { 5 } else if _input.value == 2 { @@ -588,50 +570,48 @@ pub fn year_4_perks() { reload_stat_add: reload, reload_time_scale: 1.0, } - }), + }, ); add_sbr( Perks::HeatingUp, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let val = clamp(_input.value, 0, 2) as i32; let mut out = HashMap::new(); out.insert(StatHashes::RECOIL_DIR.into(), 20 * val); out.insert(StatHashes::STABILITY.into(), 15 * val); out - }), + }, ); add_sbr( Perks::TunnelVision, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut out = HashMap::new(); if _input.value > 0 { out.insert(StatHashes::AIM_ASSIST.into(), 20); } out - }), + }, ); add_hmr( Perks::TunnelVision, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - if _input.value > 0 { - HandlingModifierResponse { - ads_scale: 0.85, - ..Default::default() - } - } else { - HandlingModifierResponse::default() + |_input: ModifierResponseInput| -> HandlingModifierResponse { + if _input.value > 0 { + HandlingModifierResponse { + ads_scale: 0.85, + ..Default::default() } - }, - ), + } else { + HandlingModifierResponse::default() + } + }, ); add_dmr( Perks::KickStart, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let mut damage_mult = if _input.value > 0 { 0.20 } else { 0.0 }; let duration = 1.0; if _input.calc_data.time_total > duration { @@ -642,12 +622,12 @@ pub fn year_4_perks() { explosive_dmg_scale: 1.0 + damage_mult, crit_scale: 1.0, } - }), + }, ); add_fmr( Perks::KickStart, - Box::new(|_input: ModifierResponseInput| -> FiringModifierResponse { + |_input: ModifierResponseInput| -> FiringModifierResponse { let mut fire_rate_mult = if _input.value > 0 { 0.20 } else { 0.0 }; let duration = 1.0; if _input.calc_data.time_total > duration { @@ -657,12 +637,12 @@ pub fn year_4_perks() { burst_delay_scale: 1.0 - fire_rate_mult, ..Default::default() } - }), + }, ); add_dmr( Perks::Recombination, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { //to make sure it doesn't go over the max stacks let val = if _input.is_enhanced { clamp(_input.value, 0, 8) as f64 @@ -685,6 +665,6 @@ pub fn year_4_perks() { impact_dmg_scale: buff, ..Default::default() } - }), + }, ); } diff --git a/src/perks/year_5_perks.rs b/src/perks/year_5_perks.rs index 48bcb545..f9f7052e 100644 --- a/src/perks/year_5_perks.rs +++ b/src/perks/year_5_perks.rs @@ -15,7 +15,7 @@ use super::{ pub fn year_5_perks() { add_fmr( Perks::CascadePoint, - Box::new(|_input: ModifierResponseInput| -> FiringModifierResponse { + |_input: ModifierResponseInput| -> FiringModifierResponse { let duration = if _input.is_enhanced { 3.0 } else { 2.5 }; let mut delay_mult = 1.0; if _input.calc_data.time_total < duration && _input.value > 0 { @@ -33,12 +33,12 @@ pub fn year_5_perks() { inner_burst_scale: 1.0, burst_size_add: 0.0, } - }), + }, ); add_sbr( Perks::Encore, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut map = HashMap::new(); let val = clamp(_input.value, 0, 4) as i32; let stability_boost = 8 * val; @@ -46,25 +46,24 @@ pub fn year_5_perks() { map.insert(StatHashes::RANGE.into(), range_boost); map.insert(StatHashes::STABILITY.into(), stability_boost); map - }), + }, ); add_rmr( Perks::Encore, - Box::new(|_input: ModifierResponseInput| -> RangeModifierResponse { + |_input: ModifierResponseInput| -> RangeModifierResponse { let val = clamp(_input.value, 0, 4) as i32; let range_boost = 5 * val; RangeModifierResponse { range_stat_add: range_boost, ..Default::default() } - }), + }, ); add_dmr( Perks::FocusedFury, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { - + |_input: ModifierResponseInput| -> DamageModifierResponse { let shots_needed = (_input.calc_data.base_mag * (_input.calc_data.curr_firing_data.burst_size as f64)) / 2.0; @@ -80,12 +79,12 @@ pub fn year_5_perks() { explosive_dmg_scale: dmg_boost, crit_scale: 1.0, } - }), + }, ); add_rmr( Perks::FragileFocus, - Box::new(|_input: ModifierResponseInput| -> RangeModifierResponse { + |_input: ModifierResponseInput| -> RangeModifierResponse { let range_bonus = if _input.value > 0 { 20 } else { 0 }; RangeModifierResponse { range_stat_add: range_bonus, @@ -93,12 +92,12 @@ pub fn year_5_perks() { range_hip_scale: 1.0, range_zoom_scale: 1.0, } - }), + }, ); add_sbr( Perks::FragileFocus, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut map = HashMap::new(); let mut range_bonus = 0; if _input.value > 0 { @@ -106,12 +105,12 @@ pub fn year_5_perks() { }; map.insert(StatHashes::RANGE.into(), range_bonus); map - }), + }, ); add_dmr( Perks::GutShot, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let high_weapons = [ WeaponType::AUTORIFLE, WeaponType::HANDCANNON, @@ -135,12 +134,12 @@ pub fn year_5_perks() { explosive_dmg_scale: dmg_scale, crit_scale, } - }), + }, ); add_sbr( Perks::OffhandStrike, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut map = HashMap::new(); let mut stability_boost = 0; if _input.value > 0 { @@ -148,12 +147,12 @@ pub fn year_5_perks() { }; map.insert(StatHashes::STABILITY.into(), stability_boost); map - }), + }, ); add_rmr( Perks::OffhandStrike, - Box::new(|_input: ModifierResponseInput| -> RangeModifierResponse { + |_input: ModifierResponseInput| -> RangeModifierResponse { let mut range_hip_mult = 1.0; if _input.value > 0 { range_hip_mult = 1.45; @@ -164,35 +163,33 @@ pub fn year_5_perks() { range_hip_scale: range_hip_mult, range_zoom_scale: 1.0, } - }), + }, ); add_hmr( Perks::Slickdraw, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - HandlingModifierResponse { - stat_add: 100, - stow_scale: 1.0, - draw_scale: 0.95, - ..Default::default() - } - }, - ), + |_input: ModifierResponseInput| -> HandlingModifierResponse { + HandlingModifierResponse { + stat_add: 100, + stow_scale: 1.0, + draw_scale: 0.95, + ..Default::default() + } + }, ); add_sbr( Perks::Slickdraw, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut map = HashMap::new(); map.insert(StatHashes::HANDLING.into(), 100); map - }), + }, ); add_sbr( Perks::StatsForAll, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut out = HashMap::new(); let mut stability_boost = 0; let mut range_boost = 0; @@ -209,29 +206,27 @@ pub fn year_5_perks() { out.insert(StatHashes::RELOAD.into(), reload_boost); out.insert(StatHashes::HANDLING.into(), handling_boost); out - }), + }, ); add_hmr( Perks::StatsForAll, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - let mut handling_boost = 0; - let duration = if _input.is_enhanced { 11.0 } else { 10.0 }; - if _input.value > 0 && _input.calc_data.time_total < duration { - handling_boost = 35; - }; - HandlingModifierResponse { - stat_add: handling_boost, - ..Default::default() - } - }, - ), + |_input: ModifierResponseInput| -> HandlingModifierResponse { + let mut handling_boost = 0; + let duration = if _input.is_enhanced { 11.0 } else { 10.0 }; + if _input.value > 0 && _input.calc_data.time_total < duration { + handling_boost = 35; + }; + HandlingModifierResponse { + stat_add: handling_boost, + ..Default::default() + } + }, ); add_rmr( Perks::StatsForAll, - Box::new(|_input: ModifierResponseInput| -> RangeModifierResponse { + |_input: ModifierResponseInput| -> RangeModifierResponse { let mut range = 0; let mut range_mult = 1.0; if _input.value > 0 { @@ -244,12 +239,12 @@ pub fn year_5_perks() { range_hip_scale: 1.0, range_zoom_scale: 1.0, } - }), + }, ); add_rsmr( Perks::StatsForAll, - Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { + |_input: ModifierResponseInput| -> ReloadModifierResponse { let mut reload = 0; let mut reload_mult = 1.0; let duration = if _input.is_enhanced { 11.0 } else { 10.0 }; @@ -261,12 +256,12 @@ pub fn year_5_perks() { reload_stat_add: reload, reload_time_scale: reload_mult, } - }), + }, ); add_sbr( Perks::SteadyHands, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut map = HashMap::new(); let mut handling = 0; if _input.value > 0 { @@ -274,33 +269,31 @@ pub fn year_5_perks() { }; map.insert(StatHashes::HANDLING.into(), handling); map - }), + }, ); add_hmr( Perks::SteadyHands, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - let mut handling_mult = 1.0; - let mut handling = 0; - let duration = if _input.is_enhanced { 9.0 } else { 8.5 }; - if _input.value > 0 && _input.calc_data.time_total < duration { - handling_mult = 0.825; - handling = 100; - }; - HandlingModifierResponse { - stat_add: handling, - stow_scale: handling_mult, - draw_scale: handling_mult, - ..Default::default() - } - }, - ), + |_input: ModifierResponseInput| -> HandlingModifierResponse { + let mut handling_mult = 1.0; + let mut handling = 0; + let duration = if _input.is_enhanced { 9.0 } else { 8.5 }; + if _input.value > 0 && _input.calc_data.time_total < duration { + handling_mult = 0.825; + handling = 100; + }; + HandlingModifierResponse { + stat_add: handling, + stow_scale: handling_mult, + draw_scale: handling_mult, + ..Default::default() + } + }, ); add_dmr( Perks::TargetLock, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let nerf = 0.625; //patch 7.1.5 let enh_increase = if _input.is_enhanced { 1.2 } else { 1.0 }; let low_end_dmg = 0.0934 * enh_increase * nerf; @@ -326,12 +319,12 @@ pub fn year_5_perks() { explosive_dmg_scale: buff + 1.0, crit_scale: 1.0, } - }), + }, ); add_dmr( Perks::OverUnder, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let mut buff = 1.0_f64; if _input.calc_data.has_overshield { buff += 0.2; @@ -344,12 +337,12 @@ pub fn year_5_perks() { explosive_dmg_scale: buff, crit_scale: 1.0, } - }), + }, ); add_sbr( Perks::WellRounded, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let val = clamp(_input.value, 0, 2) as i32; let mut map = HashMap::new(); let stat_base = if _input.is_enhanced { 12 } else { 10 }; @@ -358,29 +351,27 @@ pub fn year_5_perks() { map.insert(StatHashes::RANGE.into(), stat_bump); map.insert(StatHashes::HANDLING.into(), stat_bump); map - }), + }, ); add_hmr( Perks::WellRounded, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - let val = clamp(_input.value, 0, 2) as i32; - //due to ease of activation and upkeep will assume its always active - // let mut duration = if _input.is_enhanced {9.0} else {8.5}; - let stat_base = if _input.is_enhanced { 12 } else { 10 }; - let handling = stat_base * val; - HandlingModifierResponse { - stat_add: handling, - ..Default::default() - } - }, - ), + |_input: ModifierResponseInput| -> HandlingModifierResponse { + let val = clamp(_input.value, 0, 2) as i32; + //due to ease of activation and upkeep will assume its always active + // let mut duration = if _input.is_enhanced {9.0} else {8.5}; + let stat_base = if _input.is_enhanced { 12 } else { 10 }; + let handling = stat_base * val; + HandlingModifierResponse { + stat_add: handling, + ..Default::default() + } + }, ); add_rmr( Perks::WellRounded, - Box::new(|_input: ModifierResponseInput| -> RangeModifierResponse { + |_input: ModifierResponseInput| -> RangeModifierResponse { let val = clamp(_input.value, 0, 2) as i32; let stat_base = if _input.is_enhanced { 12 } else { 10 }; let range = stat_base * val; @@ -390,12 +381,12 @@ pub fn year_5_perks() { range_hip_scale: 1.0, range_zoom_scale: 1.0, } - }), + }, ); add_dmr( Perks::BaitAndSwitch, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { if _input.value > 0 { DamageModifierResponse { impact_dmg_scale: 1.35, @@ -405,12 +396,12 @@ pub fn year_5_perks() { } else { DamageModifierResponse::default() } - }), + }, ); add_rsmr( Perks::CompulsiveReloader, - Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { + |_input: ModifierResponseInput| -> ReloadModifierResponse { let reload_add = if _input.is_enhanced { 55 } else { 50 }; if _input.calc_data.shots_fired_this_mag <= _input.calc_data.base_mag / 2.0 && _input.value > 0 @@ -422,12 +413,12 @@ pub fn year_5_perks() { } else { ReloadModifierResponse::default() } - }), + }, ); add_sbr( Perks::CompulsiveReloader, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let reload_add = if _input.is_enhanced { 55 } else { 50 }; let mut map = HashMap::new(); if _input.calc_data.shots_fired_this_mag <= _input.calc_data.base_mag / 2.0 @@ -436,12 +427,12 @@ pub fn year_5_perks() { map.insert(StatHashes::RELOAD.into(), reload_add); } map - }), + }, ); add_sbr( Perks::SleightOfHand, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let val = clamp(_input.value, 0, 3) as i32; let mut map = HashMap::new(); let stat_base = 10; @@ -450,27 +441,25 @@ pub fn year_5_perks() { map.insert(StatHashes::RELOAD.into(), stat_bump); map.insert(StatHashes::HANDLING.into(), stat_bump); map - }), + }, ); add_hmr( Perks::SleightOfHand, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - let val = clamp(_input.value, 0, 3) as i32; - let stat_base = 10; - let handling = stat_base * val; - HandlingModifierResponse { - stat_add: handling, - ..Default::default() - } - }, - ), + |_input: ModifierResponseInput| -> HandlingModifierResponse { + let val = clamp(_input.value, 0, 3) as i32; + let stat_base = 10; + let handling = stat_base * val; + HandlingModifierResponse { + stat_add: handling, + ..Default::default() + } + }, ); add_rsmr( Perks::SleightOfHand, - Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { + |_input: ModifierResponseInput| -> ReloadModifierResponse { let val = clamp(_input.value, 0, 3) as i32; let stat_base = 10; let reload = stat_base * val; @@ -478,44 +467,42 @@ pub fn year_5_perks() { reload_stat_add: reload, ..Default::default() } - }), + }, ); add_hmr( Perks::ShotSwap, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - let mut handling_mult = 1.0; - let mut handling = 0; - if _input.value > 0 { - handling_mult = 0.95; - handling = 100; - }; - HandlingModifierResponse { - draw_add: handling, - stow_add: handling, - stow_scale: handling_mult, - draw_scale: handling_mult, - ..Default::default() - } - }, - ), + |_input: ModifierResponseInput| -> HandlingModifierResponse { + let mut handling_mult = 1.0; + let mut handling = 0; + if _input.value > 0 { + handling_mult = 0.95; + handling = 100; + }; + HandlingModifierResponse { + draw_add: handling, + stow_add: handling, + stow_scale: handling_mult, + draw_scale: handling_mult, + ..Default::default() + } + }, ); add_sbr( Perks::ShotSwap, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut map = HashMap::new(); if _input.value > 0 { map.insert(StatHashes::HANDLING.into(), 100); } map - }), + }, ); add_fmr( Perks::SuccesfulWarmup, - Box::new(|_input: ModifierResponseInput| -> FiringModifierResponse { + |_input: ModifierResponseInput| -> FiringModifierResponse { let fire_rate_buff = if _input.value > 0 { 0.625 } else { 1.0 }; let duration = if _input.value > 0 { 6_f64 @@ -532,17 +519,17 @@ pub fn year_5_perks() { } else { FiringModifierResponse::default() } - }), + }, ); add_dmr( Perks::UnstoppableForce, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let scalar = if _input.value >= 1 { 1.20 } else { 1.0 }; DamageModifierResponse { impact_dmg_scale: scalar, explosive_dmg_scale: scalar, crit_scale: 1.0, } - }), + }, ); } diff --git a/src/perks/year_6_perks.rs b/src/perks/year_6_perks.rs index 81eaefb0..63ba8d8b 100644 --- a/src/perks/year_6_perks.rs +++ b/src/perks/year_6_perks.rs @@ -17,7 +17,7 @@ use super::{ pub fn year_6_perks() { add_sbr( Perks::KeepAway, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut map = HashMap::new(); let mut range_bonus = 0; let mut reload_bonus = 0; @@ -29,36 +29,36 @@ pub fn year_6_perks() { map.insert(StatHashes::RANGE.into(), range_bonus); map.insert(StatHashes::RELOAD.into(), reload_bonus); map - }), + }, ); add_rmr( Perks::KeepAway, - Box::new(|_input: ModifierResponseInput| -> RangeModifierResponse { + |_input: ModifierResponseInput| -> RangeModifierResponse { let ev = if _input.is_enhanced { 2 } else { 0 }; let range_bonus = if _input.value > 0 { 10 + ev } else { 0 }; RangeModifierResponse { range_stat_add: range_bonus, ..Default::default() } - }), + }, ); add_rsmr( Perks::KeepAway, - Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { + |_input: ModifierResponseInput| -> ReloadModifierResponse { let ev = if _input.is_enhanced { 2 } else { 0 }; let reload_bonus = if _input.value > 0 { 30 + ev } else { 0 }; ReloadModifierResponse { reload_stat_add: reload_bonus, ..Default::default() } - }), + }, ); add_sbr( Perks::FieldTested, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut map = HashMap::new(); if _input.value > 4 { map.insert(StatHashes::RANGE.into(), 20); @@ -77,12 +77,12 @@ pub fn year_6_perks() { map.insert(StatHashes::RANGE.into(), 3); } map - }), + }, ); // add_hmr( // Perks::FieldTested, - // Box::new( + // // |_input: ModifierResponseInput| -> HandlingModifierResponse { // let val = clamp(_input.value, 0, 5) as i32; // HandlingModifierResponse { @@ -95,7 +95,7 @@ pub fn year_6_perks() { add_rsmr( Perks::FieldTested, - Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { + |_input: ModifierResponseInput| -> ReloadModifierResponse { let reload_bump; if _input.value > 4 { reload_bump = 55; @@ -114,12 +114,12 @@ pub fn year_6_perks() { reload_stat_add: reload_bump, ..Default::default() } - }), + }, ); add_rmr( Perks::FieldTested, - Box::new(|_input: ModifierResponseInput| -> RangeModifierResponse { + |_input: ModifierResponseInput| -> RangeModifierResponse { let range_bump; if _input.value > 4 { range_bump = 20; @@ -138,12 +138,12 @@ pub fn year_6_perks() { range_stat_add: range_bump, ..Default::default() } - }), + }, ); add_dmr( Perks::ParacausalAffinity, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { if _input.value > 0 { DamageModifierResponse { explosive_dmg_scale: 1.2, @@ -153,29 +153,27 @@ pub fn year_6_perks() { } else { DamageModifierResponse::default() } - }), + }, ); add_mmr( Perks::EnviousAssasin, - Box::new( - |_input: ModifierResponseInput| -> MagazineModifierResponse { - let val = _input.value as f64; - //i dont know why this if is here? - harm - if _input.calc_data.total_shots_fired == 0.0 { - return MagazineModifierResponse { - magazine_scale: 1.0 + clamp(0.1 * val, 0.0, 1.5), - ..Default::default() - }; + |_input: ModifierResponseInput| -> MagazineModifierResponse { + let val = _input.value as f64; + //i dont know why this if is here? - harm + if _input.calc_data.total_shots_fired == 0.0 { + return MagazineModifierResponse { + magazine_scale: 1.0 + clamp(0.1 * val, 0.0, 1.5), + ..Default::default() }; - MagazineModifierResponse::default() - }, - ), + }; + MagazineModifierResponse::default() + }, ); add_dmr( Perks::CollectiveAction, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let buff = match (_input.pvp, _input.value) { (_, 0) => 1.0, (true, 1..) => 1.1, @@ -186,57 +184,53 @@ pub fn year_6_perks() { explosive_dmg_scale: buff, ..Default::default() } - }), + }, ); add_dmr( Perks::Bipod, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { DamageModifierResponse { impact_dmg_scale: 0.75, explosive_dmg_scale: 0.75, ..Default::default() } - }), + }, ); add_mmr( Perks::Bipod, - Box::new( - |_input: ModifierResponseInput| -> MagazineModifierResponse { - MagazineModifierResponse { - magazine_scale: 2.0, - ..Default::default() - } - }, - ), + |_input: ModifierResponseInput| -> MagazineModifierResponse { + MagazineModifierResponse { + magazine_scale: 2.0, + ..Default::default() + } + }, ); add_imr( Perks::Bipod, - Box::new( - |_input: ModifierResponseInput| -> InventoryModifierResponse { - InventoryModifierResponse { - inv_add: 5, - ..Default::default() - } - }, - ), + |_input: ModifierResponseInput| -> InventoryModifierResponse { + InventoryModifierResponse { + inv_add: 5, + ..Default::default() + } + }, ); add_fmr( Perks::Bipod, - Box::new(|_input: ModifierResponseInput| -> FiringModifierResponse { + |_input: ModifierResponseInput| -> FiringModifierResponse { FiringModifierResponse { burst_delay_scale: 0.75, ..Default::default() } - }), + }, ); add_fmr( Perks::ControlledBurst, - Box::new(|_input: ModifierResponseInput| -> FiringModifierResponse { + |_input: ModifierResponseInput| -> FiringModifierResponse { if _input.value > 0 { return FiringModifierResponse { burst_delay_scale: 0.9, @@ -244,11 +238,11 @@ pub fn year_6_perks() { }; } FiringModifierResponse::default() - }), + }, ); add_dmr( Perks::ControlledBurst, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { if _input.value > 0 { return DamageModifierResponse { impact_dmg_scale: 1.2, @@ -257,21 +251,21 @@ pub fn year_6_perks() { }; } DamageModifierResponse::default() - }), + }, ); add_sbr( Perks::InvisibleHand, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut stats = HashMap::new(); if _input.value > 0 { stats.insert(StatHashes::STABILITY.into(), 25); } stats - }), + }, ); add_sbr( Perks::UnsatedHunger, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut stats = HashMap::new(); if _input.value > 0 { stats.insert(StatHashes::STABILITY.into(), 20); @@ -279,12 +273,12 @@ pub fn year_6_perks() { stats.insert(StatHashes::RELOAD.into(), 60); } stats - }), + }, ); add_rsmr( Perks::UnsatedHunger, - Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { + |_input: ModifierResponseInput| -> ReloadModifierResponse { if _input.value > 0 { return ReloadModifierResponse { reload_stat_add: 60, @@ -292,52 +286,48 @@ pub fn year_6_perks() { }; } ReloadModifierResponse::default() - }), + }, ); add_hmr( Perks::UnsatedHunger, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - if _input.value > 0 { - return HandlingModifierResponse { - stat_add: 60, - ..Default::default() - }; - } - HandlingModifierResponse::default() - }, - ), + |_input: ModifierResponseInput| -> HandlingModifierResponse { + if _input.value > 0 { + return HandlingModifierResponse { + stat_add: 60, + ..Default::default() + }; + } + HandlingModifierResponse::default() + }, ); add_hmr( Perks::Discord, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - if _input.value > 0 { - return HandlingModifierResponse { - ads_scale: 0.75, - ..Default::default() - }; - } - HandlingModifierResponse::default() - }, - ), + |_input: ModifierResponseInput| -> HandlingModifierResponse { + if _input.value > 0 { + return HandlingModifierResponse { + ads_scale: 0.75, + ..Default::default() + }; + } + HandlingModifierResponse::default() + }, ); add_sbr( Perks::Discord, - Box::new(|_input: ModifierResponseInput| -> HashMap { + |_input: ModifierResponseInput| -> HashMap { let mut stats = HashMap::new(); if _input.value > 0 { stats.insert(StatHashes::AIRBORNE.into(), 30); } stats - }), + }, ); add_dmr( Perks::PrecisionInstrument, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let max_percent = if _input.is_enhanced { 0.26 } else { 0.25 }; let max_stacks = 6.0; let shots_hit = _input.calc_data.total_shots_hit; @@ -348,12 +338,12 @@ pub fn year_6_perks() { crit_scale: 1.0 + stacks * max_percent / max_stacks, ..Default::default() } - }), + }, ); add_rsmr( Perks::LooseChange, - Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { + |_input: ModifierResponseInput| -> ReloadModifierResponse { if _input.value == 0 { return ReloadModifierResponse::default(); } @@ -361,24 +351,22 @@ pub fn year_6_perks() { reload_stat_add: 50, ..Default::default() } - }), + }, ); add_sbr( Perks::LooseChange, - Box::new( - |_input: ModifierResponseInput| -> HashMap { - if _input.value == 0 { - return HashMap::new(); - } - HashMap::from([(StatHashes::RELOAD.into(), 50)]) - }, - ), + |_input: ModifierResponseInput| -> HashMap { + if _input.value == 0 { + return HashMap::new(); + } + HashMap::from([(StatHashes::RELOAD.into(), 50)]) + }, ); add_dmr( Perks::HighGround, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { if _input.value == 0 { return DamageModifierResponse::default(); } @@ -389,39 +377,35 @@ pub fn year_6_perks() { explosive_dmg_scale: mult, ..Default::default() } - }), + }, ); add_sbr( Perks::HeadRush, - Box::new( - |_input: ModifierResponseInput| -> HashMap { - if _input.value == 0 { - return HashMap::new(); - } - HashMap::from([ - (StatHashes::RELOAD.into(), 10), - (StatHashes::HANDLING.into(), 0), - ]) - }, - ), + |_input: ModifierResponseInput| -> HashMap { + if _input.value == 0 { + return HashMap::new(); + } + HashMap::from([ + (StatHashes::RELOAD.into(), 10), + (StatHashes::HANDLING.into(), 0), + ]) + }, ); add_hmr( Perks::HeadRush, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - if _input.value == 0 { - return HandlingModifierResponse::default(); - } - //unknown at time - HandlingModifierResponse { - ..Default::default() - } - }, - ), + |_input: ModifierResponseInput| -> HandlingModifierResponse { + if _input.value == 0 { + return HandlingModifierResponse::default(); + } + //unknown at time + HandlingModifierResponse { + ..Default::default() + } + }, ); add_rsmr( Perks::HeadRush, - Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { + |_input: ModifierResponseInput| -> ReloadModifierResponse { if _input.value == 0 { return ReloadModifierResponse::default(); } @@ -429,45 +413,41 @@ pub fn year_6_perks() { reload_stat_add: 10, ..Default::default() } - }), + }, ); add_sbr( Perks::EnlightendAction, - Box::new( - |_input: ModifierResponseInput| -> HashMap { - let shots_hit = _input.calc_data.total_shots_hit as i32; - let value = _input.value as i32; - let stat_per_stack = 10; - let max_stacks = 5; + |_input: ModifierResponseInput| -> HashMap { + let shots_hit = _input.calc_data.total_shots_hit as i32; + let value = _input.value as i32; + let stat_per_stack = 10; + let max_stacks = 5; - let stat_bump = clamp(value + shots_hit, 0, max_stacks) * stat_per_stack; - HashMap::from([ - (StatHashes::RELOAD.into(), stat_bump), - (StatHashes::HANDLING.into(), stat_bump), - ]) - }, - ), + let stat_bump = clamp(value + shots_hit, 0, max_stacks) * stat_per_stack; + HashMap::from([ + (StatHashes::RELOAD.into(), stat_bump), + (StatHashes::HANDLING.into(), stat_bump), + ]) + }, ); add_hmr( Perks::EnlightendAction, - Box::new( - |_input: ModifierResponseInput| -> HandlingModifierResponse { - let shots_hit = _input.calc_data.total_shots_hit as i32; - let value = _input.value as i32; - let stat_per_stack = 10; - let max_stacks = 5; + |_input: ModifierResponseInput| -> HandlingModifierResponse { + let shots_hit = _input.calc_data.total_shots_hit as i32; + let value = _input.value as i32; + let stat_per_stack = 10; + let max_stacks = 5; - let stat_bump = clamp(value + shots_hit, 0, max_stacks) * stat_per_stack; - HandlingModifierResponse { - stat_add: stat_bump, - ..Default::default() - } - }, - ), + let stat_bump = clamp(value + shots_hit, 0, max_stacks) * stat_per_stack; + HandlingModifierResponse { + stat_add: stat_bump, + ..Default::default() + } + }, ); add_rsmr( Perks::EnlightendAction, - Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { + |_input: ModifierResponseInput| -> ReloadModifierResponse { let shots_hit = _input.calc_data.total_shots_hit as i32; let value = _input.value as i32; let stat_per_stack = 10; @@ -478,11 +458,11 @@ pub fn year_6_perks() { reload_stat_add: stat_bump, ..Default::default() } - }), + }, ); add_dmr( Perks::SwordLogic, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { + |_input: ModifierResponseInput| -> DamageModifierResponse { let buff = match _input.value { 0 => 1.0, 1..=3 => 1.05 + (0.1 * _input.value as f64), @@ -493,6 +473,6 @@ pub fn year_6_perks() { explosive_dmg_scale: buff, ..Default::default() } - }), + }, ) } diff --git a/src/test.rs b/src/test.rs index 6e39d045..a9cfbfa3 100644 --- a/src/test.rs +++ b/src/test.rs @@ -15,6 +15,7 @@ fn cmp_floats(a: T, b: T) -> bool { (a - b).abs() < delta } +#[allow(unused)] fn cmp_floats_delta(a: T, b: T, delta: T) -> bool { (a - b).abs() < delta } diff --git a/src/types/formula_types.rs b/src/types/formula_types.rs new file mode 100644 index 00000000..ed64ff5d --- /dev/null +++ b/src/types/formula_types.rs @@ -0,0 +1,124 @@ +use serde::{Serialize, Deserialize}; + + +///Describes the addresses of all the formulas for a given weapon +/// based off the weapon path +#[derive(Debug, Clone)] +pub struct DataPointers { + pub h: usize, + pub r: usize, + pub rl: usize, + pub s: usize, + pub f: usize, + pub a: usize, +} + +///The path to a weapon in the database +#[derive(Debug, Clone, Hash, PartialEq, Eq)] +pub struct WeaponPath( + //type id + pub u32, + //intrinsic hash + pub u32 +); + +//even if just linear use this +#[derive(Debug, Clone, Copy, Default, Serialize, Deserialize)] +#[serde(deny_unknown_fields, default, rename_all(serialize = "camelCase"))] +pub struct StatQuadraticFormula { + pub evpp: f64, + pub vpp: f64, + pub offset: f64, +} +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, Copy, Serialize, Deserialize)] +#[serde(deny_unknown_fields, default, rename_all(serialize = "camelCase"))] +pub struct FiringDataFormula { + pub damage: f64, + pub crit_mult: f64, + pub burst_delay: f64, + pub inner_burst_delay: f64, + pub burst_size: i32, + pub one_ammo: bool, + pub charge: bool, + #[serde(skip_deserializing)] + pub timestamp: u64, +} + +#[derive(Debug, Clone, Copy, Serialize, Deserialize)] +#[serde(deny_unknown_fields, default, rename_all(serialize = "camelCase"))] +pub struct DamageModFormula { + pub pve: f64, + pub minor: f64, + pub elite: f64, + pub miniboss: f64, + pub champion: f64, + pub boss: f64, + pub vehicle: f64, + #[serde(skip_deserializing)] + pub timestamp: u64, +} +impl Default for DamageModFormula { + fn default() -> Self { + DamageModFormula { + pve: 1.0, + minor: 1.0, + elite: 1.0, + miniboss: 1.0, + champion: 1.0, + boss: 1.0, + vehicle: 1.0, + timestamp: Default::default(), + } + } +} + +#[derive(Debug, Clone, Copy, Default, Serialize, Deserialize)] +#[serde(deny_unknown_fields, default, rename_all(serialize = "camelCase"))] +pub struct RangeFormula { + pub start: StatQuadraticFormula, + pub end: StatQuadraticFormula, + pub floor_percent: f64, + pub fusion: bool, + #[serde(skip_deserializing)] + pub timestamp: u64, +} + +#[derive(Debug, Clone, Copy, Default, Serialize, Deserialize)] +#[serde(deny_unknown_fields, default, rename_all(serialize = "camelCase"))] +pub struct ReloadFormula { + pub reload_data: StatQuadraticFormula, + pub ammo_percent: f64, + #[serde(skip_deserializing)] + pub timestamp: u64, +} + +#[derive(Debug, Clone, Copy, Default, Serialize, Deserialize)] +#[serde(deny_unknown_fields, default, rename_all(serialize = "camelCase"))] +pub struct HandlingFormula { + pub ready: StatQuadraticFormula, + pub stow: StatQuadraticFormula, + pub ads: StatQuadraticFormula, + #[serde(skip_deserializing)] + pub timestamp: u64, +} + +#[derive(Debug, Clone, Copy, Default, Serialize, Deserialize)] +#[serde(deny_unknown_fields, default, rename_all(serialize = "camelCase"))] +pub struct AmmoFormula { + pub mag: StatQuadraticFormula, + pub round_to: i32, + pub reserve_id: u32, + #[serde(skip_deserializing)] + pub timestamp: u64, +} \ No newline at end of file diff --git a/src/types/js_types.rs b/src/types/js_types.rs index dfaaf8de..415d57e8 100644 --- a/src/types/js_types.rs +++ b/src/types/js_types.rs @@ -1,29 +1,22 @@ -use std::{ - collections::HashMap, - fmt::{self, write}, -}; + +use std::fmt; use crate::{ activity::damage_calc::DifficultyOptions, enemies::EnemyType, - perks::Perk, - types::rs_types::StatQuadraticFormula, weapons::{ ttk_calc::{BodyKillData, OptimalKillData, ResillienceSummary}, Stat, }, }; use serde::{Deserialize, Serialize}; -// use tsify::Tsify; use wasm_bindgen::{ - convert::{IntoWasmAbi, WasmSlice}, prelude::wasm_bindgen, JsValue, }; use super::rs_types::{ - AmmoFormula, AmmoResponse, DamageMods, DpsResponse, FiringData, FiringResponse, - HandlingFormula, HandlingResponse, RangeFormula, RangeResponse, ReloadFormula, ReloadResponse, + AmmoResponse, DpsResponse, FiringResponse, HandlingResponse, RangeResponse, ReloadResponse, }; #[derive(Debug, Clone, Copy, Serialize)] diff --git a/src/types/mod.rs b/src/types/mod.rs index 3e7e30b0..ccf692d9 100644 --- a/src/types/mod.rs +++ b/src/types/mod.rs @@ -1,3 +1,10 @@ pub mod js_types; pub mod rs_types; +pub mod formula_types; + +pub mod prelude { + pub use super::formula_types::*; + pub use super::js_types::*; + pub use super::rs_types::*; +} \ No newline at end of file diff --git a/src/types/rs_types.rs b/src/types/rs_types.rs index 98363358..786084ef 100644 --- a/src/types/rs_types.rs +++ b/src/types/rs_types.rs @@ -1,122 +1,4 @@ -use std::collections::HashMap; -use serde::{Deserialize, Serialize}; - -use crate::{enemies::EnemyType, perks::clamp}; - -#[derive(Debug, Clone)] -pub struct DataPointers { - pub h: usize, - pub r: usize, - pub rl: usize, - pub s: usize, - pub f: usize, - pub a: usize, -} - -#[derive(Debug, Clone, Hash, PartialEq, Eq)] -pub struct WeaponPath(pub u32, pub u32); - -#[derive(Debug, Clone, Default, Copy, Serialize)] -pub struct FiringData { - pub damage: f64, - pub crit_mult: f64, - pub burst_delay: f64, - pub inner_burst_delay: f64, - pub burst_size: i32, - pub one_ammo: bool, - pub charge: bool, - pub timestamp: u64, -} - -#[derive(Debug, Clone, Copy, Serialize)] -pub struct DamageMods { - pub pve: f64, - pub minor: f64, - pub elite: f64, - pub miniboss: f64, - pub champion: f64, - pub boss: f64, - pub vehicle: f64, - pub timestamp: u64, -} -impl Default for DamageMods { - fn default() -> Self { - DamageMods { - pve: 1.0, - minor: 1.0, - elite: 1.0, - miniboss: 1.0, - champion: 1.0, - boss: 1.0, - vehicle: 1.0, - timestamp: 0, - } - } -} -impl DamageMods { - pub fn get_mod(&self, _type: &EnemyType) -> f64 { - match *_type { - EnemyType::MINOR => self.minor, - EnemyType::ELITE => self.elite, - EnemyType::MINIBOSS => self.miniboss, - EnemyType::CHAMPION => self.champion, - EnemyType::BOSS => self.boss, - EnemyType::VEHICLE => self.vehicle, - _ => 1.0, - } - } -} - -#[derive(Debug, Clone, Copy, Default, Serialize)] -pub struct RangeFormula { - pub start: StatQuadraticFormula, - pub end: StatQuadraticFormula, - pub floor_percent: f64, - pub fusion: bool, - pub timestamp: u64, -} - -//even if just linear use this -#[derive(Debug, Clone, Copy, Default, Serialize)] -pub struct StatQuadraticFormula { - pub evpp: f64, - pub vpp: f64, - pub offset: f64, -} -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, Copy, Default, Serialize)] -pub struct ReloadFormula { - pub reload_data: StatQuadraticFormula, - pub ammo_percent: f64, - pub timestamp: u64, -} - -#[derive(Debug, Clone, Copy, Default, Serialize)] -pub struct HandlingFormula { - pub ready: StatQuadraticFormula, - pub stow: StatQuadraticFormula, - pub ads: StatQuadraticFormula, - pub timestamp: u64, -} - -#[derive(Debug, Clone, Copy, Default, Serialize)] -pub struct AmmoFormula { - pub mag: StatQuadraticFormula, - pub round_to: i32, - pub reserve_id: u32, - pub timestamp: u64, -} #[derive(Debug, Clone, Default)] pub struct RangeResponse { @@ -136,14 +18,14 @@ pub struct HandlingResponse { pub timestamp: u64, } -#[derive(Debug, Clone, Default)] +#[derive(Debug, Clone, Default, Copy)] pub struct AmmoResponse { pub mag_size: i32, pub reserve_size: i32, pub timestamp: u64, } -#[derive(Debug, Clone, Default)] +#[derive(Debug, Clone, Default, Copy)] pub struct ReloadResponse { pub reload_time: f64, pub ammo_time: f64, @@ -182,7 +64,7 @@ impl DpsResponse { } } -#[derive(Debug, Clone, Default)] +#[derive(Debug, Clone, Default, Copy)] pub struct FiringResponse { pub pvp_impact_damage: f64, pub pvp_explosion_damage: f64, @@ -208,15 +90,7 @@ impl FiringResponse { _pve_mult: f64, _combatant_mult: f64, ) { - crate::logging::log( - format!( - "rpl: {}, gpl: {}, pve: {}, combat_mult: {}", - _rpl_mult, _gpl_mult, _pve_mult, _combatant_mult - ) - .as_str(), - crate::logging::LogLevel::Debug.into(), - ); self.pve_impact_damage *= _rpl_mult * _gpl_mult * _pve_mult * _combatant_mult; self.pve_explosion_damage *= _rpl_mult * _gpl_mult * _pve_mult * _combatant_mult; } -} +} \ No newline at end of file diff --git a/src/weapons/dps_calc.rs b/src/weapons/dps_calc.rs index 139ce5e1..68b62c55 100644 --- a/src/weapons/dps_calc.rs +++ b/src/weapons/dps_calc.rs @@ -1,11 +1,11 @@ use std::collections::HashMap; -use std::{cell::RefCell, rc::Rc}; +use std::rc::Rc; use super::Weapon; use crate::d2_enums::{AmmoType, WeaponType}; use crate::enemies::Enemy; use crate::perks::lib::{ - CalculationInput, ExtraDamageResponse, RefundResponse, ReloadOverrideResponse, + CalculationInput, ExtraDamageResponse, RefundResponse, }; use crate::perks::*; use crate::types::rs_types::DpsResponse; diff --git a/src/weapons/mod.rs b/src/weapons/mod.rs index b844087d..be85f189 100644 --- a/src/weapons/mod.rs +++ b/src/weapons/mod.rs @@ -1,4 +1,6 @@ -pub mod dps_calc; +// TODO: get dps back in while coping with it wont be perfect +// under current system +// pub mod dps_calc; pub mod reserve_calc; pub mod stat_calc; pub mod ttk_calc; @@ -6,20 +8,18 @@ pub mod weapon_constructor; use std::collections::HashMap; -use serde::{Deserialize, Serialize}; +use serde::Serialize; -use crate::d2_enums::{AmmoType, DamageType, StatHashes, WeaponType}; -use crate::enemies::Enemy; +use crate::d2_enums::{AmmoType, DamageType, WeaponType}; use crate::perks::{ - get_magazine_modifier, get_reserve_modifier, get_stat_bumps, lib::CalculationInput, Perk, + get_stat_bumps, lib::CalculationInput, Perk, }; -use crate::types::rs_types::{ - AmmoFormula, DamageMods, DpsResponse, FiringData, HandlingFormula, RangeFormula, ReloadFormula, +use crate::types::formula_types::{ + AmmoFormula, DamageModFormula, FiringDataFormula, HandlingFormula, RangeFormula, + ReloadFormula, }; -use self::dps_calc::complex_dps_calc; - #[derive(Debug, Clone)] pub struct PsuedoWeapon {} @@ -71,8 +71,8 @@ pub struct Weapon { #[serde(skip)] pub perk_value_map: HashMap, - pub damage_mods: DamageMods, - pub firing_data: FiringData, + pub damage_mods: DamageModFormula, + pub firing_data: FiringDataFormula, pub range_formula: RangeFormula, pub ammo_formula: AmmoFormula, pub handling_formula: HandlingFormula, @@ -131,8 +131,8 @@ impl Weapon { self.perks = HashMap::new(); self.stats = HashMap::new(); self.hash = 0; - self.damage_mods = DamageMods::default(); - self.firing_data = FiringData::default(); + self.damage_mods = DamageModFormula::default(); + self.firing_data = FiringDataFormula::default(); self.range_formula = RangeFormula::default(); self.ammo_formula = AmmoFormula::default(); self.handling_formula = HandlingFormula::default(); @@ -223,9 +223,6 @@ impl Weapon { } } } - pub fn calc_dps(&self, _enemy: Enemy, _pl_dmg_mult: f64) -> DpsResponse { - complex_dps_calc(self.clone(), _enemy, _pl_dmg_mult) - } } impl Default for Weapon { fn default() -> Weapon { @@ -237,8 +234,8 @@ impl Default for Weapon { stats: HashMap::new(), perk_value_map: HashMap::new(), - damage_mods: DamageMods::default(), - firing_data: FiringData::default(), + damage_mods: DamageModFormula::default(), + firing_data: FiringDataFormula::default(), range_formula: RangeFormula::default(), ammo_formula: AmmoFormula::default(), diff --git a/src/weapons/reserve_calc.rs b/src/weapons/reserve_calc.rs index 502144be..4f03b4b0 100644 --- a/src/weapons/reserve_calc.rs +++ b/src/weapons/reserve_calc.rs @@ -79,7 +79,7 @@ pub fn calc_reserves(_mag_size: f64, _mag_stat: i32, _inv_stat: i32, _id: u32, _ fn small_machinegun(_mag_size: f64, _mag_stat: i32, _inv_stat: i32) -> f64 { let round_amount = _mag_size.ceil() - _mag_size; let offset = (-0.875 + round_amount * 2.0) * (2.0 - ((100.0 - _mag_stat as f64) / 100.0)); - + 225.0 + offset + _inv_stat as f64 * ((225.0 + offset) * 2.0 - (225.0 + offset)) / 100.0 } diff --git a/src/weapons/stat_calc.rs b/src/weapons/stat_calc.rs index f7749a0d..7e4dadc9 100644 --- a/src/weapons/stat_calc.rs +++ b/src/weapons/stat_calc.rs @@ -12,12 +12,11 @@ use crate::{ HandlingModifierResponse, InventoryModifierResponse, MagazineModifierResponse, RangeModifierResponse, ReloadModifierResponse, }, - Perks, - }, - types::rs_types::{ - AmmoFormula, AmmoResponse, FiringResponse, HandlingFormula, HandlingResponse, RangeFormula, - RangeResponse, ReloadFormula, ReloadResponse, }, + types::{rs_types::{ + AmmoResponse, FiringResponse, HandlingResponse, + RangeResponse, ReloadResponse, + }, formula_types::*} }; impl ReloadFormula { @@ -38,8 +37,8 @@ impl Weapon { _cached_data: Option<&mut HashMap>, _pvp: bool, ) -> ReloadResponse { - let mut default_chd_dt = HashMap::new(); - let cached_data = _cached_data.unwrap_or(&mut default_chd_dt); + let mut default_cache_data = HashMap::new(); + let cached_data = _cached_data.unwrap_or(&mut default_cache_data); let mut reload_stat = self .stats @@ -455,10 +454,8 @@ impl Weapon { //this should be in weapons_formulas fn get_ads_multiplier(weapon_type: WeaponType, intrinsic_hash: u32) -> Result { //EXCEPTIONS + // TODO: make this system not cringe 🙏 const LAST_WORD: u32 = 2770223582; - const ACE_OF_SPACEDS: u32 = 647617635; //only during memento - const DEVILS_RUIN: u32 = 334466122; //only when laser - const REVISION_ZERO: u32 = 2770223582; //only in hunters trance const CRIMSON: u32 = 1030990989; const VEX_MYTHOCLAST: u32 = 3610750208; const FORERUNNER: u32 = 2984682260; diff --git a/src/weapons/ttk_calc.rs b/src/weapons/ttk_calc.rs index 39f7d366..443aa551 100644 --- a/src/weapons/ttk_calc.rs +++ b/src/weapons/ttk_calc.rs @@ -4,16 +4,10 @@ use serde::Serialize; use crate::{ d2_enums::WeaponType, - logging::extern_log, - perks::{get_dmg_modifier, get_firing_modifier, lib::CalculationInput}, + perks::{get_dmg_modifier, get_firing_modifier}, }; -use super::{FiringData, Weapon}; - -//just to make code cleaner for now -fn ceil(x: f64) -> f64 { - x.ceil() -} +use super::Weapon; const RESILIENCE_VALUES: [f64; 11] = [ 185.001, 186.001, 187.001, 188.001, 189.001, 190.001, 192.001, 194.001, 196.001, 198.01, 200.00, diff --git a/src/weapons/weapon_constructor.rs b/src/weapons/weapon_constructor.rs index 6719102d..562a4e3c 100644 --- a/src/weapons/weapon_constructor.rs +++ b/src/weapons/weapon_constructor.rs @@ -4,13 +4,10 @@ use crate::{ d2_enums::{AmmoType, DamageType, WeaponType}, database, perks::{enhanced_check, Perk}, - types::rs_types::{ - AmmoFormula, DamageMods, DataPointers, HandlingFormula, RangeFormula, ReloadFormula, - StatQuadraticFormula, WeaponPath, - }, + types::formula_types::*, }; -use super::{FiringData, Weapon}; +use super::Weapon; fn get_data_pointers(_weapon_type_id: u8, _intrinsic_hash: u32) -> Result { let pointer_map: HashMap = HashMap::from(database::DATA_POINTERS); @@ -43,9 +40,9 @@ impl Weapon { let reload_formula: ReloadFormula = database::RELOAD_DATA[data_pointer.rl]; - let damage_mods: DamageMods = database::SCALAR_DATA[data_pointer.s]; + let damage_mods: DamageModFormula = database::SCALAR_DATA[data_pointer.s]; - let firing_data: FiringData = database::FIRING_DATA[data_pointer.f]; + let firing_data: FiringDataFormula = database::FIRING_DATA[data_pointer.f]; let ammo_formula: AmmoFormula = database::AMMO_DATA[data_pointer.a]; From 6a84ad882a251901a03f3f6416be7d933421ae1c Mon Sep 17 00:00:00 2001 From: oh-yes-0-fps Date: Wed, 13 Sep 2023 20:24:35 -0400 Subject: [PATCH 31/38] ran cargo fmt --- build.rs | 4 +--- src/enemies/mod.rs | 2 +- src/lib.rs | 2 -- src/perks/lib.rs | 2 +- src/perks/mod.rs | 1 - src/types/formula_types.rs | 7 +++---- src/types/js_types.rs | 6 +----- src/types/mod.rs | 4 ++-- src/types/rs_types.rs | 4 +--- src/weapons/mod.rs | 7 ++----- src/weapons/stat_calc.rs | 8 ++++---- 11 files changed, 16 insertions(+), 31 deletions(-) diff --git a/build.rs b/build.rs index 6f973e73..1a2668c6 100644 --- a/build.rs +++ b/build.rs @@ -380,9 +380,7 @@ fn main() { let mut formula_file = std::fs::File::create(formula_dst).unwrap(); //write imports in file - let res = writeln!( - formula_file, - "use crate::types::prelude::*;"); + let res = writeln!(formula_file, "use crate::types::prelude::*;"); if res.is_err() { panic!("cargo:warning=error writing imports"); } diff --git a/src/enemies/mod.rs b/src/enemies/mod.rs index 5295b52f..3ffe4da0 100644 --- a/src/enemies/mod.rs +++ b/src/enemies/mod.rs @@ -40,4 +40,4 @@ impl crate::types::formula_types::DamageModFormula { _ => 1.0, } } -} \ No newline at end of file +} diff --git a/src/lib.rs b/src/lib.rs index 9dd42a51..890087fb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -22,7 +22,6 @@ use std::cell::RefCell; use std::collections::HashMap; use std::panic; - // SAFETY: This application is single threaded, so using AssumeSingleThreaded is allowed. #[cfg(target_arch = "wasm32")] use lol_alloc::{AssumeSingleThreaded, FreeListAllocator}; @@ -31,7 +30,6 @@ use lol_alloc::{AssumeSingleThreaded, FreeListAllocator}; static ALLOCATOR: AssumeSingleThreaded = unsafe { AssumeSingleThreaded::new(FreeListAllocator::new()) }; - mod built_info { include!(concat!(env!("OUT_DIR"), "/built.rs")); } diff --git a/src/perks/lib.rs b/src/perks/lib.rs index aa792b90..eda28e7e 100644 --- a/src/perks/lib.rs +++ b/src/perks/lib.rs @@ -1,7 +1,7 @@ use crate::{ d2_enums::{AmmoType, BungieHash, DamageSource, DamageType, StatBump, WeaponType}, enemies::EnemyType, - types::{rs_types::HandlingResponse, formula_types::FiringDataFormula}, + types::{formula_types::FiringDataFormula, rs_types::HandlingResponse}, weapons::Stat, }; use serde::Serialize; diff --git a/src/perks/mod.rs b/src/perks/mod.rs index 88722e06..6e611e42 100644 --- a/src/perks/mod.rs +++ b/src/perks/mod.rs @@ -1,6 +1,5 @@ //quiet rust analyzer while refactoring #![allow(unused_imports)] - //is because the people who make num enum dont know how to make macros #![allow(non_upper_case_globals)] diff --git a/src/types/formula_types.rs b/src/types/formula_types.rs index ed64ff5d..8e7a4e88 100644 --- a/src/types/formula_types.rs +++ b/src/types/formula_types.rs @@ -1,5 +1,4 @@ -use serde::{Serialize, Deserialize}; - +use serde::{Deserialize, Serialize}; ///Describes the addresses of all the formulas for a given weapon /// based off the weapon path @@ -19,7 +18,7 @@ pub struct WeaponPath( //type id pub u32, //intrinsic hash - pub u32 + pub u32, ); //even if just linear use this @@ -121,4 +120,4 @@ pub struct AmmoFormula { pub reserve_id: u32, #[serde(skip_deserializing)] pub timestamp: u64, -} \ No newline at end of file +} diff --git a/src/types/js_types.rs b/src/types/js_types.rs index 415d57e8..47b718f1 100644 --- a/src/types/js_types.rs +++ b/src/types/js_types.rs @@ -1,4 +1,3 @@ - use std::fmt; use crate::{ @@ -10,10 +9,7 @@ use crate::{ }, }; use serde::{Deserialize, Serialize}; -use wasm_bindgen::{ - prelude::wasm_bindgen, - JsValue, -}; +use wasm_bindgen::{prelude::wasm_bindgen, JsValue}; use super::rs_types::{ AmmoResponse, DpsResponse, FiringResponse, HandlingResponse, RangeResponse, ReloadResponse, diff --git a/src/types/mod.rs b/src/types/mod.rs index ccf692d9..029e94ae 100644 --- a/src/types/mod.rs +++ b/src/types/mod.rs @@ -1,10 +1,10 @@ pub mod js_types; -pub mod rs_types; pub mod formula_types; +pub mod rs_types; pub mod prelude { pub use super::formula_types::*; pub use super::js_types::*; pub use super::rs_types::*; -} \ No newline at end of file +} diff --git a/src/types/rs_types.rs b/src/types/rs_types.rs index 786084ef..d92645b7 100644 --- a/src/types/rs_types.rs +++ b/src/types/rs_types.rs @@ -1,5 +1,3 @@ - - #[derive(Debug, Clone, Default)] pub struct RangeResponse { pub hip_falloff_start: f64, @@ -93,4 +91,4 @@ impl FiringResponse { self.pve_impact_damage *= _rpl_mult * _gpl_mult * _pve_mult * _combatant_mult; self.pve_explosion_damage *= _rpl_mult * _gpl_mult * _pve_mult * _combatant_mult; } -} \ No newline at end of file +} diff --git a/src/weapons/mod.rs b/src/weapons/mod.rs index be85f189..cf419289 100644 --- a/src/weapons/mod.rs +++ b/src/weapons/mod.rs @@ -11,13 +11,10 @@ use std::collections::HashMap; use serde::Serialize; use crate::d2_enums::{AmmoType, DamageType, WeaponType}; -use crate::perks::{ - get_stat_bumps, lib::CalculationInput, Perk, -}; +use crate::perks::{get_stat_bumps, lib::CalculationInput, Perk}; use crate::types::formula_types::{ - AmmoFormula, DamageModFormula, FiringDataFormula, HandlingFormula, RangeFormula, - ReloadFormula, + AmmoFormula, DamageModFormula, FiringDataFormula, HandlingFormula, RangeFormula, ReloadFormula, }; #[derive(Debug, Clone)] diff --git a/src/weapons/stat_calc.rs b/src/weapons/stat_calc.rs index 7e4dadc9..5559f6f3 100644 --- a/src/weapons/stat_calc.rs +++ b/src/weapons/stat_calc.rs @@ -13,10 +13,10 @@ use crate::{ RangeModifierResponse, ReloadModifierResponse, }, }, - types::{rs_types::{ - AmmoResponse, FiringResponse, HandlingResponse, - RangeResponse, ReloadResponse, - }, formula_types::*} + types::{ + formula_types::*, + rs_types::{AmmoResponse, FiringResponse, HandlingResponse, RangeResponse, ReloadResponse}, + }, }; impl ReloadFormula { From d6acbd01e9dd3431023e9c79518a0a269c23d19c Mon Sep 17 00:00:00 2001 From: oh-yes-0-fps Date: Wed, 13 Sep 2023 22:18:14 -0400 Subject: [PATCH 32/38] =?UTF-8?q?clippy=F0=9F=A4=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/abilities/mod.rs | 2 +- src/activity/damage_calc.rs | 20 +++++----- src/activity/mod.rs | 2 +- src/enemies/mod.rs | 2 +- src/lib.rs | 61 +++++++++++++++++++++---------- src/logging.rs | 5 +-- src/perks/lib.rs | 28 +++++++------- src/perks/meta_perks.rs | 8 ++-- src/perks/mod.rs | 4 +- src/perks/perk_options_handler.rs | 2 +- src/perks/year_1_perks.rs | 1 + src/perks/year_5_perks.rs | 2 +- src/test.rs | 16 ++++---- src/types/formula_types.rs | 4 +- src/types/rs_types.rs | 2 +- src/weapons/dps_calc.rs | 1 - src/weapons/mod.rs | 4 +- src/weapons/stat_calc.rs | 2 + src/weapons/ttk_calc.rs | 6 +-- src/weapons/weapon_constructor.rs | 4 +- 20 files changed, 99 insertions(+), 77 deletions(-) diff --git a/src/abilities/mod.rs b/src/abilities/mod.rs index 02cd3aee..2cf72ca9 100644 --- a/src/abilities/mod.rs +++ b/src/abilities/mod.rs @@ -14,7 +14,7 @@ pub enum AbilityType { } #[allow(dead_code)] -#[derive(Debug, Clone, Default)] +#[derive(Debug, Clone, Copy, Default)] pub struct AbilityDamageProfile { impact: f64, secondary: f64, diff --git a/src/activity/damage_calc.rs b/src/activity/damage_calc.rs index 43f2d212..3cfb4740 100644 --- a/src/activity/damage_calc.rs +++ b/src/activity/damage_calc.rs @@ -1,18 +1,18 @@ -#![allow(dead_code)] +// #![allow(dead_code)] use super::Activity; use crate::logging; use piecewise_linear::PiecewiseLinearFunction; #[derive(Debug, Clone)] pub struct DifficultyData { - name: String, + // name: String, cap: i32, table: PiecewiseLinearFunction, } const WEAPON_DELTA_EXPONENT: f64 = 0.00672; -#[derive(Debug, Clone, Default)] +#[derive(Debug, Clone, Copy, Default)] pub enum DifficultyOptions { #[default] NORMAL = 1, @@ -24,7 +24,7 @@ impl DifficultyOptions { pub fn get_difficulty_data(&self) -> DifficultyData { match self { DifficultyOptions::NORMAL => DifficultyData { - name: "Normal".to_string(), + // name: "Normal".to_string(), cap: 50, table: PiecewiseLinearFunction::try_from(vec![ (-99.0, 0.4018), @@ -39,10 +39,10 @@ impl DifficultyOptions { (-10.0, 0.7800), (0.0, 1.0), ]) - .unwrap(), + .expect("Failed to create PiecewiseLinearFunction in difficulty data"), }, DifficultyOptions::MASTER => DifficultyData { - name: "Master".to_string(), + // name: "Master".to_string(), cap: 20, table: PiecewiseLinearFunction::try_from(vec![ (-99.0, 0.4018), @@ -57,10 +57,10 @@ impl DifficultyOptions { (-10.0, 0.6800), (0.0, 0.8500), ]) - .unwrap(), + .expect("Failed to create PiecewiseLinearFunction in difficulty data"), }, DifficultyOptions::RAID => DifficultyData { - name: "Raid & Dungeon".to_string(), + // name: "Raid & Dungeon".to_string(), cap: 20, table: PiecewiseLinearFunction::try_from(vec![ (-99.0, 0.4018), @@ -75,7 +75,7 @@ impl DifficultyOptions { (-10.0, 0.73), (0.0, 0.925), ]) - .unwrap(), + .expect("Failed to create PiecewiseLinearFunction in difficulty data"), }, } } @@ -109,7 +109,7 @@ pub(super) fn get_gear_delta_mult(_activity: &Activity) -> f64 { } else { difficulty_data.table.y_at_x(0.0) } - .unwrap(); + .expect("Failed to get gear delta mult"); crate::logging::log( format!("gear_delta_mult: {}", gear_delta_mult).as_str(), diff --git a/src/activity/mod.rs b/src/activity/mod.rs index 53ff0a5f..509b3987 100644 --- a/src/activity/mod.rs +++ b/src/activity/mod.rs @@ -11,7 +11,7 @@ pub enum PlayerClass { Warlock = 3, } -#[derive(Debug, Clone, Default)] +#[derive(Debug, Clone, Copy, Default)] pub struct Player { pub power: u32, pub wep_power: u32, diff --git a/src/enemies/mod.rs b/src/enemies/mod.rs index 3ffe4da0..510d5b92 100644 --- a/src/enemies/mod.rs +++ b/src/enemies/mod.rs @@ -13,7 +13,7 @@ pub enum EnemyType { CHAMPION, } -#[derive(Debug, Clone, Default)] +#[derive(Debug, Clone, Copy, Default)] pub struct Enemy { pub health: f64, pub damage: f64, diff --git a/src/lib.rs b/src/lib.rs index 890087fb..e7a0e10d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,31 @@ +// #![forbid(clippy::all)]//, clippy::pedantic, clippy::nursery, clippy::cargo +#![warn( + missing_copy_implementations, + single_use_lifetimes, + variant_size_differences, + clippy::many_single_char_names, + clippy::get_unwrap, + clippy::unwrap_in_result, + clippy::unwrap_used, + clippy::panicking_unwrap, + arithmetic_overflow, + missing_debug_implementations +)] +#![forbid( + while_true, + absolute_paths_not_starting_with_crate, + bare_trait_objects, + semicolon_in_expressions_from_macros, + trivial_casts, + trivial_numeric_casts, + unreachable_pub, + unused_import_braces, + unused_lifetimes, + redundant_semicolons +)] + + + extern crate alloc; use logging::LogLevel; @@ -73,6 +101,7 @@ extern "C" { #[macro_export] macro_rules! console_log { + // ($($t:tt)*) => () ($($t:tt)*) => ($crate::log(&format_args!($($t)*).to_string())) } @@ -87,6 +116,7 @@ pub fn start() { #[wasm_bindgen(js_name = "getMetadata")] pub fn get_metadata() -> Result { + #[allow(clippy::unwrap_used)] let metadata = JsMetaData { api_timestamp: built_info::BUILT_TIME_UTC, api_version: built_info::PKG_VERSION, @@ -99,7 +129,7 @@ pub fn get_metadata() -> Result { #[wasm_bindgen(js_name = "stringifyWeapon")] pub fn weapon_as_string() -> Result { let weapon = PERS_DATA.with(|perm_data| perm_data.borrow().weapon.clone()); - Ok(serde_wasm_bindgen::to_value(&weapon).unwrap()) + serde_wasm_bindgen::to_value(&weapon).map_err(JsValue::from) } // @@ -151,16 +181,12 @@ pub fn get_stats() -> Result { for (key, value) in stat_map { js_stat_map.insert(key, JsStat::from(value)); } - let value = serde_wasm_bindgen::to_value(&js_stat_map); - if value.is_err() { - return Err(JsValue::from_str("Could not convert stats to JsValue")); - } - Ok(value.unwrap()) + serde_wasm_bindgen::to_value(&js_stat_map).map_err(JsValue::from) } #[wasm_bindgen(js_name = "setStats")] pub fn set_stats(_stats: JsValue) -> Result<(), JsValue> { - let in_stats: HashMap = serde_wasm_bindgen::from_value(_stats).unwrap(); + let in_stats: HashMap = serde_wasm_bindgen::from_value(_stats).map_err(JsValue::from)?; let mut stats = HashMap::new(); for (key, value) in in_stats { stats.insert(key, Stat::from(value)); @@ -173,7 +199,7 @@ pub fn set_stats(_stats: JsValue) -> Result<(), JsValue> { pub fn add_perk(_stats: JsValue, _value: u32, _hash: u32) -> Result<(), JsValue> { let data = perks::enhanced_check(_hash); let perk = Perk { - stat_buffs: serde_wasm_bindgen::from_value(_stats).unwrap(), + stat_buffs: serde_wasm_bindgen::from_value(_stats).map_err(JsValue::from)?, enhanced: data.1, value: _value, raw_hash: _hash, @@ -208,13 +234,10 @@ pub fn change_perk_value(perk_hash: u32, new_value: u32) { #[wasm_bindgen(js_name = "getTraitOptions")] pub fn get_perk_options_js(_perks: Vec) -> Result { let options = perks::perk_options_handler::get_perk_options(_perks); - let value = serde_wasm_bindgen::to_value(&options); - if value.is_err() { - return Err(JsValue::from_str( - "Could not convert perk options to JsValue", - )); + match serde_wasm_bindgen::to_value(&options) { + Ok(value) => Ok(value), + Err(_) => Err(JsValue::from_str("Could not convert perk options to JsValue")), } - Ok(value.unwrap()) } #[wasm_bindgen(js_name = "getWeaponRangeFalloff")] @@ -273,7 +296,7 @@ pub fn get_weapon_ttk(_overshield: f64) -> Result { let weapon = PERS_DATA.with(|perm_data| perm_data.borrow().weapon.clone()); let ttk_data = weapon.calc_ttk(_overshield); let js_ttk_data: Vec = ttk_data.into_iter().map(|r| r.into()).collect(); - Ok(serde_wasm_bindgen::to_value(&js_ttk_data).unwrap()) + serde_wasm_bindgen::to_value(&js_ttk_data).map_err(JsValue::from) } ///DEPRECATED for now @@ -343,12 +366,12 @@ pub fn get_weapon_flinch( pub fn get_misc_data(_dynamic_traits: bool, _pvp: bool) -> Result { let weapon = PERS_DATA.with(|perm_data| perm_data.borrow().weapon.clone()); if _dynamic_traits { - Ok(serde_wasm_bindgen::to_value( + serde_wasm_bindgen::to_value( &weapon.get_misc_stats(Some(weapon.static_calc_input()), _pvp), ) - .unwrap()) + .map_err(JsValue::from) } else { - Ok(serde_wasm_bindgen::to_value(&weapon.get_misc_stats(None, _pvp)).unwrap()) + serde_wasm_bindgen::to_value(&weapon.get_misc_stats(None, _pvp)).map_err(JsValue::from) } } @@ -392,7 +415,7 @@ pub fn get_modifier_response(_dynamic_traits: bool, _pvp: bool) -> Result LogLevel { } pub fn extern_log(s: &str, log_level: LogLevel) { - if log_level > get_log_level() { - return; + if log_level < get_log_level() { + crate::console_log!("{}", s); } - crate::console_log!("{}", s); } pub fn log(s: &str, log_level: usize) { diff --git a/src/perks/lib.rs b/src/perks/lib.rs index eda28e7e..060641d0 100644 --- a/src/perks/lib.rs +++ b/src/perks/lib.rs @@ -143,7 +143,7 @@ impl<'a> CalculationInput<'a> { } } -#[derive(Debug, Clone, PartialEq, Serialize)] +#[derive(Debug, Clone, Copy, PartialEq, Serialize)] pub struct DamageModifierResponse { pub impact_dmg_scale: f64, pub explosive_dmg_scale: f64, @@ -159,7 +159,7 @@ impl Default for DamageModifierResponse { } } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, Copy, PartialEq)] pub struct ExtraDamageResponse { pub additive_damage: f64, pub time_for_additive_damage: f64, @@ -194,7 +194,7 @@ impl Default for ExtraDamageResponse { } } -#[derive(Debug, Clone, PartialEq, Serialize)] +#[derive(Debug, Clone, Copy, PartialEq, Serialize)] pub struct ReloadModifierResponse { pub reload_stat_add: i32, pub reload_time_scale: f64, @@ -208,7 +208,7 @@ impl Default for ReloadModifierResponse { } } -#[derive(Debug, Clone, PartialEq, Serialize)] +#[derive(Debug, Clone, Copy, PartialEq, Serialize)] pub struct FiringModifierResponse { pub burst_delay_scale: f64, pub burst_delay_add: f64, @@ -226,7 +226,7 @@ impl Default for FiringModifierResponse { } } -#[derive(Debug, Clone, PartialEq, Serialize)] +#[derive(Debug, Clone, Copy, PartialEq, Serialize)] pub struct HandlingModifierResponse { pub stat_add: i32, //separated stats @@ -253,7 +253,7 @@ impl Default for HandlingModifierResponse { } } -#[derive(Debug, Clone, PartialEq, Serialize)] +#[derive(Debug, Clone, Copy, PartialEq, Serialize)] pub struct RangeModifierResponse { pub range_stat_add: i32, pub range_all_scale: f64, @@ -271,7 +271,7 @@ impl Default for RangeModifierResponse { } } -#[derive(Debug, Clone, PartialEq, Default)] +#[derive(Debug, Clone, Copy, PartialEq, Default)] pub struct RefundResponse { pub crit: bool, pub requirement: i32, @@ -279,7 +279,7 @@ pub struct RefundResponse { pub refund_reserves: i32, } -#[derive(Debug, Clone, PartialEq, Serialize)] +#[derive(Debug, Clone, Copy, PartialEq, Serialize)] pub struct MagazineModifierResponse { pub magazine_stat_add: i32, pub magazine_scale: f64, @@ -295,7 +295,7 @@ impl Default for MagazineModifierResponse { } } -#[derive(Debug, Clone, PartialEq, Serialize)] +#[derive(Debug, Clone, Copy, PartialEq, Serialize)] pub struct InventoryModifierResponse { pub inv_stat_add: i32, pub inv_scale: f64, @@ -311,7 +311,7 @@ impl Default for InventoryModifierResponse { } } -#[derive(Debug, Clone, PartialEq, Serialize)] +#[derive(Debug, Clone, Copy, PartialEq, Serialize)] pub struct FlinchModifierResponse { pub flinch_scale: f64, } @@ -321,7 +321,7 @@ impl Default for FlinchModifierResponse { } } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, Copy, PartialEq)] pub struct VelocityModifierResponse { pub velocity_scaler: f64, } @@ -333,7 +333,7 @@ impl Default for VelocityModifierResponse { } } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, Copy, PartialEq)] pub struct ReloadOverrideResponse { pub valid: bool, pub reload_time: f64, @@ -357,7 +357,7 @@ impl ReloadOverrideResponse { } } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, Copy, PartialEq)] pub struct ExplosivePercentResponse { pub percent: f64, pub delyed: f64, @@ -373,7 +373,7 @@ impl Default for ExplosivePercentResponse { } } -#[derive(Debug, Clone, PartialEq, Serialize)] +#[derive(Debug, Clone, Copy, PartialEq, Serialize)] pub struct DamageResistModifierResponse { pub body_shot_resist: f64, pub head_shot_resist: f64, diff --git a/src/perks/meta_perks.rs b/src/perks/meta_perks.rs index b00c461d..a22f5a8c 100644 --- a/src/perks/meta_perks.rs +++ b/src/perks/meta_perks.rs @@ -50,7 +50,7 @@ pub fn meta_perks() { .calc_data .stats .get(&StatHashes::CHARGE_TIME.into()) - .unwrap(); + .expect("Charge time not found"); //source: https://docs.google.com/spreadsheets/d/1QaUwtOW2_RJCTK1uaIGkbCoEXDa8UStvjDQSHSDxLOM/edit#gid=497378026 //damage value updated from harm and stardust during super DR testing let total_damage = _input.calc_data.curr_firing_data.damage @@ -70,7 +70,6 @@ pub fn meta_perks() { add_fmr( Perks::BuiltIn, |_input: ModifierResponseInput| -> FiringModifierResponse { - #[allow(unused_mut)] let mut delay_add = 0.0; if matches!( @@ -82,7 +81,7 @@ pub fn meta_perks() { .calc_data .stats .get(&StatHashes::CHARGE_TIME.into()) - .unwrap(); + .expect("Charge time not found"); let stat = (charge_time.perk_val() - charge_time.base_value) as f64; delay_add -= match _input.calc_data.weapon_type { WeaponType::FUSIONRIFLE => stat * 0.0040, @@ -96,8 +95,7 @@ pub fn meta_perks() { .calc_data .stats .get(&StatHashes::DRAW_TIME.into()) - .unwrap() - .clone(); + .expect("Draw time not found"); delay_add += match _input.calc_data.intrinsic_hash { //Lightweights, Wishender, Ticcus, Verglas 905 | 1470121888 | 3239299468 | 2636679416 => { diff --git a/src/perks/mod.rs b/src/perks/mod.rs index 6e611e42..f64dffc1 100644 --- a/src/perks/mod.rs +++ b/src/perks/mod.rs @@ -473,7 +473,7 @@ type ModifierFunction = fn(ModifierResponseInput) -> T; type StatMap = HashMap; type ModifierMap = HashMap>; -#[derive(Default)] +#[derive(Default, Debug)] pub struct PersistentModifierResponses { pub sbr: ModifierMap, pub dmr: ModifierMap, @@ -1047,7 +1047,7 @@ impl Weapon { return buffer; } - let calc_input = _calc_input.unwrap(); + let calc_input = _calc_input.expect("Calculation input is none"); for perk in self.list_perks() { let mod_buffer = PERK_FUNC_MAP.with(|pers_modifier| { diff --git a/src/perks/perk_options_handler.rs b/src/perks/perk_options_handler.rs index 365a5131..86ea8e8f 100644 --- a/src/perks/perk_options_handler.rs +++ b/src/perks/perk_options_handler.rs @@ -4,7 +4,7 @@ use serde::Serialize; use super::{enhanced_check, Perk, Perks}; -#[derive(Debug, Clone, Serialize, Default)] +#[derive(Debug, Clone, Copy, Serialize, Default)] pub enum PerkValueVariant { #[default] STATIC, diff --git a/src/perks/year_1_perks.rs b/src/perks/year_1_perks.rs index 73a28b1f..af5cde5d 100644 --- a/src/perks/year_1_perks.rs +++ b/src/perks/year_1_perks.rs @@ -773,6 +773,7 @@ pub fn year_1_perks() { Perks::PhaseMag, |_input: ModifierResponseInput| -> DamageModifierResponse { //set up precision smg to get damage values from + #[allow(clippy::unwrap_used)] let precision = Weapon::generate_weapon( 0, 24, //smg 1636108362, //precision diff --git a/src/perks/year_5_perks.rs b/src/perks/year_5_perks.rs index f9f7052e..2839bde0 100644 --- a/src/perks/year_5_perks.rs +++ b/src/perks/year_5_perks.rs @@ -511,7 +511,7 @@ pub fn year_5_perks() { } else { 0.0 }; - if _input.calc_data.time_total < duration as f64 { + if _input.calc_data.time_total < duration { FiringModifierResponse { burst_delay_scale: fire_rate_buff, ..Default::default() diff --git a/src/test.rs b/src/test.rs index a9cfbfa3..8ac34579 100644 --- a/src/test.rs +++ b/src/test.rs @@ -11,11 +11,12 @@ use crate::{ const FLOAT_DELTA: f32 = 0.0001; fn cmp_floats(a: T, b: T) -> bool { + #[allow(clippy::unwrap_used)] let delta = T::from(FLOAT_DELTA).unwrap(); (a - b).abs() < delta } -#[allow(unused)] +#[allow(dead_code)] fn cmp_floats_delta(a: T, b: T, delta: T) -> bool { (a - b).abs() < delta } @@ -36,7 +37,7 @@ fn setup_pulse() { 1, //primary 3373582085, //kinetic ) - .unwrap(); + .expect("Failed to generate weapon"); let mut stats = HashMap::new(); stats.insert(StatHashes::RELOAD.into(), Stat::from(50)); stats.insert(StatHashes::HANDLING.into(), Stat::from(50)); @@ -60,7 +61,7 @@ fn test_pulse_setup() { let test_stat = weapon .get_stats() .get(&(StatHashes::HANDLING.into())) - .unwrap() + .expect("Failed to get stat") .val(); assert_eq!(test_stat, 50, "test_stat: {}", test_stat); }); @@ -186,7 +187,7 @@ fn setup_bow() { 2, //special 3949783978, //strand ) - .unwrap(); + .expect("Failed to generate weapon"); let mut stats = HashMap::new(); stats.insert(StatHashes::RELOAD.into(), Stat::from(50)); stats.insert(StatHashes::HANDLING.into(), Stat::from(50)); @@ -210,7 +211,7 @@ fn test_bow_setup() { let test_stat = weapon .get_stats() .get(&(StatHashes::HANDLING.into())) - .unwrap() + .expect("Failed to get stat") .val(); assert_eq!(test_stat, 50, "test_stat: {}", test_stat); }); @@ -323,14 +324,15 @@ fn test_phase_mag() { 1, //primary 3949783978, //strand ) - .unwrap(); + .expect("Failed to generate weapon"); + let precision = Weapon::generate_weapon( 3240434620, 24, //smg 1636108362, //precision 1, //primary 3949783978, //strand ) - .unwrap(); + .expect("Failed to generate weapon"); //setup perks map_perks(); diff --git a/src/types/formula_types.rs b/src/types/formula_types.rs index 8e7a4e88..8098064b 100644 --- a/src/types/formula_types.rs +++ b/src/types/formula_types.rs @@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize}; ///Describes the addresses of all the formulas for a given weapon /// based off the weapon path -#[derive(Debug, Clone)] +#[derive(Debug, Copy, Clone)] pub struct DataPointers { pub h: usize, pub r: usize, @@ -13,7 +13,7 @@ pub struct DataPointers { } ///The path to a weapon in the database -#[derive(Debug, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)] pub struct WeaponPath( //type id pub u32, diff --git a/src/types/rs_types.rs b/src/types/rs_types.rs index d92645b7..d5a259d7 100644 --- a/src/types/rs_types.rs +++ b/src/types/rs_types.rs @@ -1,4 +1,4 @@ -#[derive(Debug, Clone, Default)] +#[derive(Debug, Clone, Copy, Default)] pub struct RangeResponse { pub hip_falloff_start: f64, pub hip_falloff_end: f64, diff --git a/src/weapons/dps_calc.rs b/src/weapons/dps_calc.rs index 68b62c55..249d2a43 100644 --- a/src/weapons/dps_calc.rs +++ b/src/weapons/dps_calc.rs @@ -156,7 +156,6 @@ pub fn complex_dps_calc(_weapon: Weapon, _enemy: Enemy, _pl_dmg_mult: f64) -> Dp ) .reserve_size; - #[allow(unused_mut)] while reserve > 0 { let mut shots_this_mag = 0; //MAGAZINE///////////////////// diff --git a/src/weapons/mod.rs b/src/weapons/mod.rs index cf419289..04bc0fd8 100644 --- a/src/weapons/mod.rs +++ b/src/weapons/mod.rs @@ -17,10 +17,8 @@ use crate::types::formula_types::{ AmmoFormula, DamageModFormula, FiringDataFormula, HandlingFormula, RangeFormula, ReloadFormula, }; -#[derive(Debug, Clone)] -pub struct PsuedoWeapon {} -#[derive(Debug, Clone, Serialize)] +#[derive(Debug, Clone, Copy, Serialize)] pub struct Stat { pub base_value: i32, pub part_value: i32, diff --git a/src/weapons/stat_calc.rs b/src/weapons/stat_calc.rs index 5559f6f3..7d996906 100644 --- a/src/weapons/stat_calc.rs +++ b/src/weapons/stat_calc.rs @@ -240,6 +240,7 @@ impl Weapon { let mut out; let mut default_chd_dt = HashMap::new(); let cached_data = _cached_data.unwrap_or(&mut default_chd_dt); + #[allow(clippy::unwrap_used)] if _calc_input.is_some() { let mag_modifiers = get_magazine_modifier( self.list_perks(), @@ -294,6 +295,7 @@ impl Weapon { let firing_modifiers: FiringModifierResponse; let mut default_cached_data = HashMap::new(); let cached_data = _cached_data.unwrap_or(&mut default_cached_data); + #[allow(clippy::unwrap_used)] if _calc_input.is_some() { firing_modifiers = get_firing_modifier( self.list_perks(), diff --git a/src/weapons/ttk_calc.rs b/src/weapons/ttk_calc.rs index 443aa551..9658e75e 100644 --- a/src/weapons/ttk_calc.rs +++ b/src/weapons/ttk_calc.rs @@ -13,7 +13,7 @@ const RESILIENCE_VALUES: [f64; 11] = [ 185.001, 186.001, 187.001, 188.001, 189.001, 190.001, 192.001, 194.001, 196.001, 198.01, 200.00, ]; -#[derive(Debug, Clone, Serialize)] +#[derive(Debug, Clone, Copy, Serialize)] pub struct OptimalKillData { pub headshots: i32, pub bodyshots: i32, @@ -21,14 +21,14 @@ pub struct OptimalKillData { pub time_taken: f64, } -#[derive(Debug, Clone, Serialize)] +#[derive(Debug, Clone, Copy, Serialize)] pub struct BodyKillData { pub bodyshots: i32, #[serde(rename = "timeTaken")] pub time_taken: f64, } -#[derive(Debug, Clone, Serialize)] +#[derive(Debug, Clone, Copy, Serialize)] pub struct ResillienceSummary { pub value: i32, #[serde(rename = "bodyTtk")] diff --git a/src/weapons/weapon_constructor.rs b/src/weapons/weapon_constructor.rs index 562a4e3c..f1eda5b2 100644 --- a/src/weapons/weapon_constructor.rs +++ b/src/weapons/weapon_constructor.rs @@ -18,8 +18,8 @@ fn get_data_pointers(_weapon_type_id: u8, _intrinsic_hash: u32) -> Result Date: Wed, 13 Sep 2023 22:26:51 -0400 Subject: [PATCH 33/38] =?UTF-8?q?=F0=9F=A4=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e9612a94..567c26ba 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Run `cargo build` to install the dependencies required by Oracle Engine. In order to build the WebAssembly (wasm) pack you will need to download wasm-pack from this [site](https://rustwasm.github.io/wasm-pack/installer/) or via this cURL command: -`curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh` +`cargo install wasm-pack` Once you have this installed you can build the app via this wasm-pack command. From 33a0497f55288061029c55b766a2653121c76eed Mon Sep 17 00:00:00 2001 From: oh-yes-0-fps Date: Wed, 13 Sep 2023 22:27:53 -0400 Subject: [PATCH 34/38] =?UTF-8?q?=F0=9F=99=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 567c26ba..93ddffc4 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ This is also where we plan on having our project board for keeping track of our If you wish to interact with us on a closer basis, our [Discord Server](https://discord.gg/dzW2DZBBQH) is where you can find us and have discussions with like minded guardians. We look forward to seeing you there! -## Building Oracle Engine for Foundry +## Building Oracle Engine Run `cargo build` to install the dependencies required by Oracle Engine. From a82d38424d5b9d2995f145ecf7fb0a988eeecd6f Mon Sep 17 00:00:00 2001 From: oh-yes-0-fps Date: Wed, 13 Sep 2023 22:47:20 -0400 Subject: [PATCH 35/38] remove unreachable pub --- src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 9dac47fc..bdfc7c5f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -18,7 +18,6 @@ semicolon_in_expressions_from_macros, trivial_casts, trivial_numeric_casts, - unreachable_pub, unused_import_braces, unused_lifetimes, redundant_semicolons From b592cac4000a932b76b976a50980f7c4063d42e7 Mon Sep 17 00:00:00 2001 From: oh-yes-0-fps Date: Wed, 13 Sep 2023 23:09:26 -0400 Subject: [PATCH 36/38] Renamed cased enums --- Cargo.toml | 1 - src/activity/damage_calc.rs | 21 ++- src/d2_enums.rs | 304 ++++++++++++++++++------------------ src/enemies/mod.rs | 28 ++-- src/perks/buff_perks.rs | 4 +- src/perks/exotic_armor.rs | 104 ++++++------ src/perks/exotic_perks.rs | 40 ++--- src/perks/lib.rs | 8 +- src/perks/meta_perks.rs | 36 ++--- src/perks/origin_perks.rs | 36 ++--- src/perks/other_perks.rs | 46 +++--- src/perks/year_1_perks.rs | 54 +++---- src/perks/year_2_perks.rs | 12 +- src/perks/year_3_perks.rs | 34 ++-- src/perks/year_4_perks.rs | 54 +++---- src/perks/year_5_perks.rs | 36 ++--- src/perks/year_6_perks.rs | 44 +++--- src/test.rs | 28 ++-- src/types/js_types.rs | 56 +++---- src/weapons/mod.rs | 5 +- src/weapons/stat_calc.rs | 24 +-- 21 files changed, 485 insertions(+), 490 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ef368ade..04563f61 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,7 +29,6 @@ wasm-bindgen = { version = "^0.2"} num_enum = "0.7.0" lol_alloc = { version = "0.4.0", default-features = false} piecewise-linear = "0.1.0" -thiserror = "1.0.48" [lib] diff --git a/src/activity/damage_calc.rs b/src/activity/damage_calc.rs index 3cfb4740..7464f744 100644 --- a/src/activity/damage_calc.rs +++ b/src/activity/damage_calc.rs @@ -1,4 +1,3 @@ -// #![allow(dead_code)] use super::Activity; use crate::logging; use piecewise_linear::PiecewiseLinearFunction; @@ -15,15 +14,15 @@ const WEAPON_DELTA_EXPONENT: f64 = 0.00672; #[derive(Debug, Clone, Copy, Default)] pub enum DifficultyOptions { #[default] - NORMAL = 1, - RAID = 2, - MASTER = 3, + Normal = 1, + Raid = 2, + Master = 3, } impl DifficultyOptions { pub fn get_difficulty_data(&self) -> DifficultyData { match self { - DifficultyOptions::NORMAL => DifficultyData { + DifficultyOptions::Normal => DifficultyData { // name: "Normal".to_string(), cap: 50, table: PiecewiseLinearFunction::try_from(vec![ @@ -41,7 +40,7 @@ impl DifficultyOptions { ]) .expect("Failed to create PiecewiseLinearFunction in difficulty data"), }, - DifficultyOptions::MASTER => DifficultyData { + DifficultyOptions::Master => DifficultyData { // name: "Master".to_string(), cap: 20, table: PiecewiseLinearFunction::try_from(vec![ @@ -59,7 +58,7 @@ impl DifficultyOptions { ]) .expect("Failed to create PiecewiseLinearFunction in difficulty data"), }, - DifficultyOptions::RAID => DifficultyData { + DifficultyOptions::Raid => DifficultyData { // name: "Raid & Dungeon".to_string(), cap: 20, table: PiecewiseLinearFunction::try_from(vec![ @@ -83,10 +82,10 @@ impl DifficultyOptions { impl From for DifficultyOptions { fn from(i: i32) -> Self { match i { - 1 => DifficultyOptions::NORMAL, - 2 => DifficultyOptions::RAID, - 3 => DifficultyOptions::MASTER, - _ => DifficultyOptions::NORMAL, + 1 => DifficultyOptions::Normal, + 2 => DifficultyOptions::Raid, + 3 => DifficultyOptions::Master, + _ => DifficultyOptions::Normal, } } } diff --git a/src/d2_enums.rs b/src/d2_enums.rs index f87d7b16..cd635fef 100644 --- a/src/d2_enums.rs +++ b/src/d2_enums.rs @@ -1,26 +1,26 @@ -#![allow(dead_code)] - use serde::Serialize; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize)] +#[serde(rename_all = "SCREAMING_SNAKE_CASE")] pub enum AmmoType { - PRIMARY = 1, - SPECIAL = 2, - HEAVY = 3, - UNKNOWN = 0, + Primary = 1, + Special = 2, + Heavy = 3, + Unknown = 0, } impl From for AmmoType { fn from(_value: u32) -> AmmoType { match _value { - 1 => AmmoType::PRIMARY, - 2 => AmmoType::SPECIAL, - 3 => AmmoType::HEAVY, - _ => AmmoType::UNKNOWN, + 1 => AmmoType::Primary, + 2 => AmmoType::Special, + 3 => AmmoType::Heavy, + _ => AmmoType::Unknown, } } } #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize)] +#[serde(rename_all = "SCREAMING_SNAKE_CASE")] pub enum WeaponType { AUTORIFLE = 6, BOW = 31, @@ -66,118 +66,114 @@ impl From for WeaponType { } } -#[allow(non_snake_case, non_camel_case_types)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum StatHashes { - ACCURACY, - AIM_ASSIST, - AIRBORNE, - AMMO_CAPACITY, - ATTACK, - BLAST_RADIUS, - CHARGE_RATE, - CHARGE_TIME, - DISCIPLINE, - DRAW_TIME, - GUARD_EFFICIENCY, - GUARD_ENDURANCE, - GUARD_RESISTANCE, - HANDLING, - IMPACT, - INTELLECT, - INVENTORY_SIZE, - MAGAZINE, - MOBILITY, - POWER, - RANGE, - RECOIL_DIR, - RECOVERY, - RELOAD, - RESILIENCE, - RPM, - SHIELD_DURATION, - STABILITY, - STRENGTH, - SWING_SPEED, - VELOCITY, - ZOOM, - UNKNOWN, + Accuracy, + AimAssist, + Airborne, + AmmoCapacity, + Attack, + BlastRadius, + ChargeRate, + ChargeTime, + Discipline, + DrawTime, + GuardEfficiency, + GuardEndurance, + GuardResistance, + Handling, + Impact, + Itellect, + InventorySize, + Magazine, + Mobility, + Range, + RecoilDir, + Recovery, + Reload, + Resilience, + Rpm, + ShieldDuration, + Stability, + Strength, + SwingSpeed, + Velocity, + Zoom, + Unknown, } impl From for StatHashes { fn from(_value: u32) -> StatHashes { match _value { - 1591432999 => StatHashes::ACCURACY, - 1345609583 => StatHashes::AIM_ASSIST, - 2714457168 => StatHashes::AIRBORNE, - 925767036 => StatHashes::AMMO_CAPACITY, - 1480404414 => StatHashes::ATTACK, - 3614673599 => StatHashes::BLAST_RADIUS, - 3022301683 => StatHashes::CHARGE_RATE, - 2961396640 => StatHashes::CHARGE_TIME, - 1735777505 => StatHashes::DISCIPLINE, - 447667954 => StatHashes::DRAW_TIME, - 2762071195 => StatHashes::GUARD_EFFICIENCY, - 3736848092 => StatHashes::GUARD_ENDURANCE, - 209426660 => StatHashes::GUARD_RESISTANCE, - 943549884 => StatHashes::HANDLING, - 4043523819 => StatHashes::IMPACT, - 144602215 => StatHashes::INTELLECT, - 1931675084 => StatHashes::INVENTORY_SIZE, - 3871231066 => StatHashes::MAGAZINE, - 2996146975 => StatHashes::MOBILITY, - 1935470627 => StatHashes::POWER, - 1240592695 => StatHashes::RANGE, - 2715839340 => StatHashes::RECOIL_DIR, - 1943323491 => StatHashes::RECOVERY, - 4188031367 => StatHashes::RELOAD, - 392767087 => StatHashes::RESILIENCE, - 4284893193 => StatHashes::RPM, - 1842278586 => StatHashes::SHIELD_DURATION, - 155624089 => StatHashes::STABILITY, - 4244567218 => StatHashes::STRENGTH, - 2837207746 => StatHashes::SWING_SPEED, - 2523465841 => StatHashes::VELOCITY, - 3555269338 => StatHashes::ZOOM, - _ => StatHashes::UNKNOWN, + 1591432999 => StatHashes::Accuracy, + 1345609583 => StatHashes::AimAssist, + 2714457168 => StatHashes::Airborne, + 925767036 => StatHashes::AmmoCapacity, + 1480404414 => StatHashes::Attack, + 3614673599 => StatHashes::BlastRadius, + 3022301683 => StatHashes::ChargeRate, + 2961396640 => StatHashes::ChargeTime, + 1735777505 => StatHashes::Discipline, + 447667954 => StatHashes::DrawTime, + 2762071195 => StatHashes::GuardEfficiency, + 3736848092 => StatHashes::GuardEndurance, + 209426660 => StatHashes::GuardResistance, + 943549884 => StatHashes::Handling, + 4043523819 => StatHashes::Impact, + 144602215 => StatHashes::Itellect, + 1931675084 => StatHashes::InventorySize, + 3871231066 => StatHashes::Magazine, + 2996146975 => StatHashes::Mobility, + 1240592695 => StatHashes::Range, + 2715839340 => StatHashes::RecoilDir, + 1943323491 => StatHashes::Recovery, + 4188031367 => StatHashes::Reload, + 392767087 => StatHashes::Resilience, + 4284893193 => StatHashes::Rpm, + 1842278586 => StatHashes::ShieldDuration, + 155624089 => StatHashes::Stability, + 4244567218 => StatHashes::Strength, + 2837207746 => StatHashes::SwingSpeed, + 2523465841 => StatHashes::Velocity, + 3555269338 => StatHashes::Zoom, + _ => StatHashes::Unknown, } } } impl From for u32 { fn from(val: StatHashes) -> Self { match val { - StatHashes::ACCURACY => 1591432999, - StatHashes::AIM_ASSIST => 1345609583, - StatHashes::AIRBORNE => 2714457168, - StatHashes::AMMO_CAPACITY => 925767036, - StatHashes::ATTACK => 1480404414, - StatHashes::BLAST_RADIUS => 3614673599, - StatHashes::CHARGE_RATE => 3022301683, - StatHashes::CHARGE_TIME => 2961396640, - StatHashes::DISCIPLINE => 1735777505, - StatHashes::DRAW_TIME => 447667954, - StatHashes::GUARD_EFFICIENCY => 2762071195, - StatHashes::GUARD_ENDURANCE => 3736848092, - StatHashes::GUARD_RESISTANCE => 209426660, - StatHashes::HANDLING => 943549884, - StatHashes::IMPACT => 4043523819, - StatHashes::INTELLECT => 144602215, - StatHashes::INVENTORY_SIZE => 1931675084, - StatHashes::MAGAZINE => 3871231066, - StatHashes::MOBILITY => 2996146975, - StatHashes::POWER => 1935470627, - StatHashes::RANGE => 1240592695, - StatHashes::RECOIL_DIR => 2715839340, - StatHashes::RECOVERY => 1943323491, - StatHashes::RELOAD => 4188031367, - StatHashes::RESILIENCE => 392767087, - StatHashes::RPM => 4284893193, - StatHashes::SHIELD_DURATION => 1842278586, - StatHashes::STABILITY => 155624089, - StatHashes::STRENGTH => 4244567218, - StatHashes::SWING_SPEED => 2837207746, - StatHashes::VELOCITY => 2523465841, - StatHashes::ZOOM => 3555269338, - StatHashes::UNKNOWN => 0, + StatHashes::Accuracy => 1591432999, + StatHashes::AimAssist => 1345609583, + StatHashes::Airborne => 2714457168, + StatHashes::AmmoCapacity => 925767036, + StatHashes::Attack => 1480404414, + StatHashes::BlastRadius => 3614673599, + StatHashes::ChargeRate => 3022301683, + StatHashes::ChargeTime => 2961396640, + StatHashes::Discipline => 1735777505, + StatHashes::DrawTime => 447667954, + StatHashes::GuardEfficiency => 2762071195, + StatHashes::GuardEndurance => 3736848092, + StatHashes::GuardResistance => 209426660, + StatHashes::Handling => 943549884, + StatHashes::Impact => 4043523819, + StatHashes::Itellect => 144602215, + StatHashes::InventorySize => 1931675084, + StatHashes::Magazine => 3871231066, + StatHashes::Mobility => 2996146975, + StatHashes::Range => 1240592695, + StatHashes::RecoilDir => 2715839340, + StatHashes::Recovery => 1943323491, + StatHashes::Reload => 4188031367, + StatHashes::Resilience => 392767087, + StatHashes::Rpm => 4284893193, + StatHashes::ShieldDuration => 1842278586, + StatHashes::Stability => 155624089, + StatHashes::Strength => 4244567218, + StatHashes::SwingSpeed => 2837207746, + StatHashes::Velocity => 2523465841, + StatHashes::Zoom => 3555269338, + StatHashes::Unknown => 0, } } } @@ -185,66 +181,68 @@ impl StatHashes { pub fn is_weapon_stat(&self) -> bool { matches!( self, - StatHashes::ACCURACY - | StatHashes::AIM_ASSIST - | StatHashes::AIRBORNE - | StatHashes::AMMO_CAPACITY - | StatHashes::ZOOM - | StatHashes::RANGE - | StatHashes::STABILITY - | StatHashes::RELOAD - | StatHashes::MAGAZINE - | StatHashes::HANDLING - | StatHashes::VELOCITY - | StatHashes::BLAST_RADIUS - | StatHashes::CHARGE_TIME - | StatHashes::INVENTORY_SIZE - | StatHashes::RECOIL_DIR - | StatHashes::RPM - | StatHashes::GUARD_EFFICIENCY - | StatHashes::GUARD_ENDURANCE - | StatHashes::GUARD_RESISTANCE - | StatHashes::DRAW_TIME - | StatHashes::SWING_SPEED - | StatHashes::SHIELD_DURATION - | StatHashes::IMPACT - | StatHashes::CHARGE_RATE + StatHashes::Accuracy + | StatHashes::AimAssist + | StatHashes::Airborne + | StatHashes::AmmoCapacity + | StatHashes::Zoom + | StatHashes::Range + | StatHashes::Stability + | StatHashes::Reload + | StatHashes::Magazine + | StatHashes::Handling + | StatHashes::Velocity + | StatHashes::BlastRadius + | StatHashes::ChargeTime + | StatHashes::InventorySize + | StatHashes::RecoilDir + | StatHashes::Rpm + | StatHashes::GuardEfficiency + | StatHashes::GuardEndurance + | StatHashes::GuardResistance + | StatHashes::DrawTime + | StatHashes::SwingSpeed + | StatHashes::ShieldDuration + | StatHashes::Impact + | StatHashes::ChargeRate ) } } #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize)] +#[serde(rename_all = "SCREAMING_SNAKE_CASE")] pub enum DamageType { - ARC, - VOID, - SOLAR, - STASIS, - KINETIC, - STRAND, - UNKNOWN, + Arc, + Void, + Solar, + Stasis, + Kinetic, + Strand, + Unknown, } impl From for DamageType { fn from(_value: u32) -> DamageType { match _value { - 2303181850 => DamageType::ARC, - 3454344768 => DamageType::VOID, - 1847026933 => DamageType::SOLAR, - 151347233 => DamageType::STASIS, - 3373582085 => DamageType::KINETIC, - 3949783978 => DamageType::STRAND, - _ => DamageType::UNKNOWN, + 2303181850 => DamageType::Arc, + 3454344768 => DamageType::Void, + 1847026933 => DamageType::Solar, + 151347233 => DamageType::Stasis, + 3373582085 => DamageType::Kinetic, + 3949783978 => DamageType::Strand, + _ => DamageType::Unknown, } } } #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize)] +#[serde(rename_all = "SCREAMING_SNAKE_CASE")] pub enum DamageSource { - SNIPER, - MELEE, - EXPLOSION, - ENVIRONMENTAL, - UNKNOWN, + Sniper, + Melee, + Eplosion, + Enviromental, + Unknown, } pub type Seconds = f64; diff --git a/src/enemies/mod.rs b/src/enemies/mod.rs index 510d5b92..a60ca554 100644 --- a/src/enemies/mod.rs +++ b/src/enemies/mod.rs @@ -2,15 +2,15 @@ use crate::activity::Activity; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)] pub enum EnemyType { - MINOR, - ELITE, - MINIBOSS, - BOSS, - VEHICLE, + Minor, + Elite, + Miniboss, + Boss, + Vehicle, #[default] - ENCLAVE, - PLAYER, - CHAMPION, + Enclave, + Player, + Champion, } #[derive(Debug, Clone, Copy, Default)] @@ -31,12 +31,12 @@ impl Enemy { impl crate::types::formula_types::DamageModFormula { pub fn get_mod(&self, _type: &EnemyType) -> f64 { match *_type { - EnemyType::MINOR => self.minor, - EnemyType::ELITE => self.elite, - EnemyType::MINIBOSS => self.miniboss, - EnemyType::CHAMPION => self.champion, - EnemyType::BOSS => self.boss, - EnemyType::VEHICLE => self.vehicle, + EnemyType::Minor => self.minor, + EnemyType::Elite => self.elite, + EnemyType::Miniboss => self.miniboss, + EnemyType::Champion => self.champion, + EnemyType::Boss => self.boss, + EnemyType::Vehicle => self.vehicle, _ => 1.0, } } diff --git a/src/perks/buff_perks.rs b/src/perks/buff_perks.rs index 97f90e44..3fe39c77 100644 --- a/src/perks/buff_perks.rs +++ b/src/perks/buff_perks.rs @@ -346,7 +346,7 @@ pub fn buff_perks() { let buff = if _input.value > 0 && matches!( _input.calc_data.damage_type, - DamageType::STASIS | DamageType::ARC + DamageType::Stasis | DamageType::Arc ) { surge_buff(_input.cached_data, 4, _input.pvp) } else { @@ -362,7 +362,7 @@ pub fn buff_perks() { add_dmr( Perks::SanguineAlchemy, |_input: ModifierResponseInput| -> DamageModifierResponse { - if _input.value == 0 || *_input.calc_data.damage_type == DamageType::KINETIC { + if _input.value == 0 || *_input.calc_data.damage_type == DamageType::Kinetic { return DamageModifierResponse::default(); } diff --git a/src/perks/exotic_armor.rs b/src/perks/exotic_armor.rs index 91aac9e3..bc7239bd 100644 --- a/src/perks/exotic_armor.rs +++ b/src/perks/exotic_armor.rs @@ -22,12 +22,12 @@ pub fn exotic_armor() { |_input: ModifierResponseInput| -> DamageModifierResponse { let mut modifier = DamageModifierResponse::default(); let value = if _input.pvp { 1.05 } else { 1.15 }; - if _input.calc_data.damage_type == &DamageType::STASIS && _input.value >= 1 { + if _input.calc_data.damage_type == &DamageType::Stasis && _input.value >= 1 { modifier.impact_dmg_scale = value; modifier.explosive_dmg_scale = value; } modifier - } + }, ); add_dmr( @@ -43,7 +43,7 @@ pub fn exotic_armor() { impact_dmg_scale: damage_mult, ..Default::default() } - } + }, ); //doesnt work for sturm overcharge, (maybe) memento @@ -63,7 +63,7 @@ pub fn exotic_armor() { return DamageModifierResponse::default(); } - let mult = if _input.calc_data.ammo_type == &AmmoType::SPECIAL { + let mult = if _input.calc_data.ammo_type == &AmmoType::Special { 0.3 } else { 0.6 @@ -73,7 +73,7 @@ pub fn exotic_armor() { impact_dmg_scale: 1.0 + mult * _input.value.clamp(0, 10) as f64, ..Default::default() } - } + }, ); add_sbr( @@ -81,10 +81,10 @@ pub fn exotic_armor() { |_input: ModifierResponseInput| -> HashMap { let mut stats = HashMap::new(); if _input.value > 0 { - stats.insert(StatHashes::AIRBORNE.into(), 50); + stats.insert(StatHashes::Airborne.into(), 50); } stats - } + }, ); add_flmr( @@ -95,14 +95,14 @@ pub fn exotic_armor() { } else { FlinchModifierResponse::default() } - } + }, ); add_sbr( Perks::KnuckleheadRadar, |_input: ModifierResponseInput| -> HashMap { - HashMap::from([(StatHashes::AIRBORNE.into(), 20)]) - } + HashMap::from([(StatHashes::Airborne.into(), 20)]) + }, ); add_dmr( @@ -118,7 +118,7 @@ pub fn exotic_armor() { explosive_dmg_scale: modifier, crit_scale: 1.0, } - } + }, ); //TODO: MECHANEER'S TRICKSLEEVES AUTORELOAD @@ -128,12 +128,12 @@ pub fn exotic_armor() { |_input: ModifierResponseInput| -> HashMap { let mut stats = HashMap::new(); if _input.calc_data.weapon_type == &WeaponType::SIDEARM { - stats.insert(StatHashes::AIRBORNE.into(), 50); - stats.insert(StatHashes::HANDLING.into(), 100); - stats.insert(StatHashes::RELOAD.into(), 100); + stats.insert(StatHashes::Airborne.into(), 50); + stats.insert(StatHashes::Handling.into(), 100); + stats.insert(StatHashes::Reload.into(), 100); }; stats - } + }, ); add_hmr( @@ -147,7 +147,7 @@ pub fn exotic_armor() { } else { HandlingModifierResponse::default() } - } + }, ); add_rsmr( Perks::MechaneersTricksleeves, @@ -160,7 +160,7 @@ pub fn exotic_armor() { } else { ReloadModifierResponse::default() } - } + }, ); add_dmr( @@ -176,7 +176,7 @@ pub fn exotic_armor() { } else { DamageModifierResponse::default() } - } + }, ); add_sbr( @@ -184,11 +184,11 @@ pub fn exotic_armor() { |_input: ModifierResponseInput| -> HashMap { let mut stats = HashMap::new(); if _input.calc_data.weapon_type == &WeaponType::BOW { - stats.insert(StatHashes::AIRBORNE.into(), 40); - stats.insert(StatHashes::DRAW_TIME.into(), 10); + stats.insert(StatHashes::Airborne.into(), 40); + stats.insert(StatHashes::DrawTime.into(), 10); }; stats - } + }, ); add_sbr( @@ -196,7 +196,7 @@ pub fn exotic_armor() { |_input: ModifierResponseInput| -> HashMap { let mut stats = HashMap::new(); if _input.value > 0 { - stats.insert(StatHashes::AIRBORNE.into(), 50); + stats.insert(StatHashes::Airborne.into(), 50); }; stats }, @@ -210,11 +210,11 @@ pub fn exotic_armor() { |_input: ModifierResponseInput| -> HashMap { let mut stat = HashMap::new(); if _input.value > 0 && _input.calc_data.weapon_type == &WeaponType::HANDCANNON { - stat.insert(StatHashes::AIRBORNE.into(), 20); - stat.insert(StatHashes::HANDLING.into(), 100); + stat.insert(StatHashes::Airborne.into(), 20); + stat.insert(StatHashes::Handling.into(), 100); }; stat - } + }, ); add_hmr( @@ -228,7 +228,7 @@ pub fn exotic_armor() { }; } HandlingModifierResponse::default() - } + }, ); add_sbr( @@ -236,10 +236,10 @@ pub fn exotic_armor() { |_input: ModifierResponseInput| -> HashMap { let mut stats = HashMap::new(); if _input.calc_data.weapon_type == &WeaponType::SHOTGUN { - stats.insert(StatHashes::AIRBORNE.into(), 30); + stats.insert(StatHashes::Airborne.into(), 30); }; stats - } + }, ); add_dmr( @@ -255,7 +255,7 @@ pub fn exotic_armor() { explosive_dmg_scale: buff, ..Default::default() } - } + }, ); add_sbr( @@ -265,10 +265,10 @@ pub fn exotic_armor() { if _input.calc_data.weapon_type == &WeaponType::AUTORIFLE || _input.calc_data.weapon_type == &WeaponType::MACHINEGUN { - stats.insert(StatHashes::AIRBORNE.into(), 30); + stats.insert(StatHashes::Airborne.into(), 30); } stats - } + }, ); //TODO: AUTORELOAD ON ACTIUM WAR RIG @@ -276,7 +276,7 @@ pub fn exotic_armor() { add_sbr( Perks::HallowfireHeart, |_input: ModifierResponseInput| -> HashMap { - HashMap::from([(StatHashes::AIRBORNE.into(), 20)]) + HashMap::from([(StatHashes::Airborne.into(), 20)]) }, ); @@ -285,7 +285,7 @@ pub fn exotic_armor() { |_input: ModifierResponseInput| -> HashMap { let mut stats = HashMap::new(); if _input.value > 0 { - stats.insert(StatHashes::AIRBORNE.into(), 50); + stats.insert(StatHashes::Airborne.into(), 50); }; stats }, @@ -296,8 +296,8 @@ pub fn exotic_armor() { |_input: ModifierResponseInput| -> HashMap { let mut stats = HashMap::new(); if _input.calc_data.weapon_type == &WeaponType::SUBMACHINEGUN { - stats.insert(StatHashes::AIRBORNE.into(), 40); - stats.insert(StatHashes::HANDLING.into(), 100); + stats.insert(StatHashes::Airborne.into(), 40); + stats.insert(StatHashes::Handling.into(), 100); }; stats }, @@ -316,33 +316,33 @@ pub fn exotic_armor() { }; } HandlingModifierResponse::default() - } + }, ); add_sbr( Perks::PeregrineGreaves, |_input: ModifierResponseInput| -> HashMap { - HashMap::from([(StatHashes::AIRBORNE.into(), 20)]) - } + HashMap::from([(StatHashes::Airborne.into(), 20)]) + }, ); add_sbr( Perks::EyeOfAnotherWorld, |_input: ModifierResponseInput| -> HashMap { - HashMap::from([(StatHashes::AIRBORNE.into(), 15)]) - } + HashMap::from([(StatHashes::Airborne.into(), 15)]) + }, ); add_sbr( Perks::AstrocyteVerse, |_input: ModifierResponseInput| -> HashMap { let mut stats = HashMap::new(); - stats.insert(StatHashes::AIRBORNE.into(), 30); + stats.insert(StatHashes::Airborne.into(), 30); if _input.value > 0 { - stats.insert(StatHashes::HANDLING.into(), 100); + stats.insert(StatHashes::Handling.into(), 100); } stats - } + }, ); add_hmr( @@ -355,7 +355,7 @@ pub fn exotic_armor() { draw_add: 100, ..Default::default() } - } + }, ); add_sbr( @@ -367,7 +367,7 @@ pub fn exotic_armor() { || _input.calc_data.intrinsic_hash == 2724693746 { //Thorn, Osteo Striga, Touch of Malice - stats.insert(StatHashes::AIRBORNE.into(), 30); + stats.insert(StatHashes::Airborne.into(), 30); }; stats }, @@ -379,7 +379,7 @@ pub fn exotic_armor() { let mut stats = HashMap::new(); if _input.calc_data.intrinsic_hash == 2144092201 { //Lumina - stats.insert(StatHashes::AIRBORNE.into(), 30); + stats.insert(StatHashes::Airborne.into(), 30); }; stats }, @@ -392,7 +392,7 @@ pub fn exotic_armor() { if _input.calc_data.weapon_type == &WeaponType::FUSIONRIFLE || _input.calc_data.weapon_type == &WeaponType::LINEARFUSIONRIFLE { - stats.insert(StatHashes::AIRBORNE.into(), 30); + stats.insert(StatHashes::Airborne.into(), 30); } stats }, @@ -412,9 +412,9 @@ pub fn exotic_armor() { }; HashMap::from([ - (StatHashes::RELOAD.into(), modifiers.0), - (StatHashes::HANDLING.into(), modifiers.1), //? - (StatHashes::AIRBORNE.into(), modifiers.2), + (StatHashes::Reload.into(), modifiers.0), + (StatHashes::Handling.into(), modifiers.1), //? + (StatHashes::Airborne.into(), modifiers.2), ]) }, ); @@ -463,7 +463,7 @@ pub fn exotic_armor() { |_input: ModifierResponseInput| -> HashMap { let mut stat = HashMap::new(); if _input.value >= 1 { - stat.insert(StatHashes::RELOAD.into(), 100); + stat.insert(StatHashes::Reload.into(), 100); } stat }, @@ -500,7 +500,7 @@ pub fn exotic_armor() { |_input| -> HashMap { let mut stats = HashMap::new(); if _input.value > 0 && *_input.calc_data.weapon_type == WeaponType::GLAIVE { - stats.insert(StatHashes::RELOAD.into(), 50); + stats.insert(StatHashes::Reload.into(), 50); } stats }, diff --git a/src/perks/exotic_perks.rs b/src/perks/exotic_perks.rs index 2ed1bebc..91b70c99 100644 --- a/src/perks/exotic_perks.rs +++ b/src/perks/exotic_perks.rs @@ -57,9 +57,9 @@ pub fn exotic_perks() { .get(&213689231) .unwrap_or(&0); let buff_val = (clamp(inter_val, 0, 7) * 5) as i32; - out.insert(StatHashes::RELOAD.into(), buff_val); - out.insert(StatHashes::RANGE.into(), buff_val); - out.insert(StatHashes::HANDLING.into(), buff_val); + out.insert(StatHashes::Reload.into(), buff_val); + out.insert(StatHashes::Range.into(), buff_val); + out.insert(StatHashes::Handling.into(), buff_val); out }, ); @@ -158,8 +158,8 @@ pub fn exotic_perks() { |_input: ModifierResponseInput| -> HashMap { let mut out = HashMap::new(); if _input.value > 0 { - out.insert(StatHashes::HANDLING.into(), 20); - out.insert(StatHashes::RELOAD.into(), 40); + out.insert(StatHashes::Handling.into(), 20); + out.insert(StatHashes::Reload.into(), 40); }; out }, @@ -501,9 +501,9 @@ pub fn exotic_perks() { let mut out = HashMap::new(); if has_cat { if _input.value == 0 { - out.insert(StatHashes::STABILITY.into(), 40); + out.insert(StatHashes::Stability.into(), 40); } else if _input.value == 1 { - out.insert(StatHashes::RELOAD.into(), 100); + out.insert(StatHashes::Reload.into(), 100); } } out @@ -556,14 +556,14 @@ pub fn exotic_perks() { |_input: ModifierResponseInput| -> HashMap { let mut stats = HashMap::new(); if _input.value == 1 { - stats.insert(StatHashes::STABILITY.into(), 20); - stats.insert(StatHashes::AIM_ASSIST.into(), 10); + stats.insert(StatHashes::Stability.into(), 20); + stats.insert(StatHashes::AimAssist.into(), 10); } else if _input.value == 2 { - stats.insert(StatHashes::AIRBORNE.into(), 20); - stats.insert(StatHashes::RELOAD.into(), 35); + stats.insert(StatHashes::Airborne.into(), 20); + stats.insert(StatHashes::Reload.into(), 35); } else if _input.value == 3 { - stats.insert(StatHashes::RANGE.into(), 5); - stats.insert(StatHashes::HANDLING.into(), 25); + stats.insert(StatHashes::Range.into(), 5); + stats.insert(StatHashes::Handling.into(), 25); }; stats }, @@ -616,7 +616,7 @@ pub fn exotic_perks() { |_input: ModifierResponseInput| -> HashMap { let mut out = HashMap::new(); if _input.value > 0 { - out.insert(StatHashes::RELOAD.into(), 70); + out.insert(StatHashes::Reload.into(), 70); } out }, @@ -655,7 +655,7 @@ pub fn exotic_perks() { |_input: ModifierResponseInput| -> HashMap { let mut out = HashMap::new(); if _input.value > 0 { - out.insert(StatHashes::RELOAD.into(), 100); + out.insert(StatHashes::Reload.into(), 100); } out }, @@ -805,8 +805,8 @@ pub fn exotic_perks() { |_input: ModifierResponseInput| -> HashMap { let mut out = HashMap::new(); if _input.value > 0 { - out.insert(StatHashes::ZOOM.into(), 3); - out.insert(StatHashes::RANGE.into(), 30); + out.insert(StatHashes::Zoom.into(), 3); + out.insert(StatHashes::Range.into(), 30); } out }, @@ -835,7 +835,7 @@ pub fn exotic_perks() { burst_delay_add: val as f64 * (-0.625 / 30.0), ..Default::default() } - } + }, ); add_mmr( @@ -878,8 +878,8 @@ pub fn exotic_perks() { |_input: ModifierResponseInput| -> HashMap { let mut out = HashMap::new(); let val = clamp(_input.value, 0, 5) as i32; - out.insert(StatHashes::RANGE.into(), 8 * val); - out.insert(StatHashes::AIM_ASSIST.into(), 4 * val); + out.insert(StatHashes::Range.into(), 8 * val); + out.insert(StatHashes::AimAssist.into(), 4 * val); out }, ); diff --git a/src/perks/lib.rs b/src/perks/lib.rs index 060641d0..3b8a53c8 100644 --- a/src/perks/lib.rs +++ b/src/perks/lib.rs @@ -65,7 +65,7 @@ impl<'a> CalculationInput<'a> { ammo_type: _ammo_type, handling_data: HandlingResponse::default(), num_reloads: 0.0, - enemy_type: &EnemyType::BOSS, + enemy_type: &EnemyType::Boss, perk_value_map: _perk_value_map, has_overshield: false, } @@ -98,11 +98,11 @@ impl<'a> CalculationInput<'a> { time_this_mag: 0.0, stats: _stats, weapon_type: _weapon_type, - damage_type: &DamageType::STASIS, + damage_type: &DamageType::Stasis, ammo_type: _ammo_type, handling_data: _handling_data, num_reloads: 0.0, - enemy_type: &EnemyType::PLAYER, + enemy_type: &EnemyType::Player, perk_value_map: _perk_value_map, has_overshield: _has_overshield, } @@ -136,7 +136,7 @@ impl<'a> CalculationInput<'a> { ammo_type: _ammo_type, handling_data: HandlingResponse::default(), num_reloads: 0.0, - enemy_type: &EnemyType::ENCLAVE, + enemy_type: &EnemyType::Enclave, perk_value_map: _perk_value_map, has_overshield: false, } diff --git a/src/perks/meta_perks.rs b/src/perks/meta_perks.rs index a22f5a8c..bade37bb 100644 --- a/src/perks/meta_perks.rs +++ b/src/perks/meta_perks.rs @@ -27,17 +27,17 @@ pub fn meta_perks() { if *_input.calc_data.weapon_type == WeaponType::LINEARFUSIONRIFLE && !_input.pvp { crit_scale *= 1.15; }; - if *_input.calc_data.damage_type == DamageType::KINETIC && !_input.pvp { - if _input.calc_data.ammo_type == &AmmoType::PRIMARY { + if *_input.calc_data.damage_type == DamageType::Kinetic && !_input.pvp { + if _input.calc_data.ammo_type == &AmmoType::Primary { dmg_scale *= 1.1; - } else if _input.calc_data.ammo_type == &AmmoType::SPECIAL { + } else if _input.calc_data.ammo_type == &AmmoType::Special { dmg_scale *= 1.15; }; }; - if *_input.calc_data.ammo_type == AmmoType::PRIMARY + if *_input.calc_data.ammo_type == AmmoType::Primary && _input.calc_data.intrinsic_hash > 1000 - && *_input.calc_data.enemy_type == EnemyType::MINOR + && *_input.calc_data.enemy_type == EnemyType::Minor && !_input.pvp { dmg_scale *= 1.4; @@ -49,7 +49,7 @@ pub fn meta_perks() { let charge_time = _input .calc_data .stats - .get(&StatHashes::CHARGE_TIME.into()) + .get(&StatHashes::ChargeTime.into()) .expect("Charge time not found"); //source: https://docs.google.com/spreadsheets/d/1QaUwtOW2_RJCTK1uaIGkbCoEXDa8UStvjDQSHSDxLOM/edit#gid=497378026 //damage value updated from harm and stardust during super DR testing @@ -80,7 +80,7 @@ pub fn meta_perks() { let charge_time = _input .calc_data .stats - .get(&StatHashes::CHARGE_TIME.into()) + .get(&StatHashes::ChargeTime.into()) .expect("Charge time not found"); let stat = (charge_time.perk_val() - charge_time.base_value) as f64; delay_add -= match _input.calc_data.weapon_type { @@ -94,7 +94,7 @@ pub fn meta_perks() { let draw_time = _input .calc_data .stats - .get(&StatHashes::DRAW_TIME.into()) + .get(&StatHashes::DrawTime.into()) .expect("Draw time not found"); delay_add += match _input.calc_data.intrinsic_hash { //Lightweights, Wishender, Ticcus, Verglas @@ -122,17 +122,17 @@ pub fn meta_perks() { |_input: ModifierResponseInput| -> ExplosivePercentResponse { if *_input.calc_data.weapon_type == WeaponType::GRENADELAUNCHER { let blast_radius_struct = - _input.calc_data.stats.get(&StatHashes::BLAST_RADIUS.into()); + _input.calc_data.stats.get(&StatHashes::BlastRadius.into()); let blast_radius = blast_radius_struct.cloned().unwrap_or_default().perk_val(); - if _input.calc_data.ammo_type == &AmmoType::SPECIAL { + if _input.calc_data.ammo_type == &AmmoType::Special { return ExplosivePercentResponse { percent: 0.5 + 0.003 * blast_radius as f64, delyed: 0.0, retain_base_total: true, }; - } else if _input.calc_data.ammo_type == &AmmoType::HEAVY { + } else if _input.calc_data.ammo_type == &AmmoType::Heavy { return ExplosivePercentResponse { percent: 0.7 + 0.00175 * blast_radius as f64, delyed: 0.0, @@ -189,11 +189,11 @@ pub fn meta_perks() { |_input: ModifierResponseInput| -> HashMap { let mut stats = HashMap::new(); if _input.value == 1 { - stats.insert(StatHashes::AIM_ASSIST.into(), 5); + stats.insert(StatHashes::AimAssist.into(), 5); } else if _input.value == 2 { - stats.insert(StatHashes::AIM_ASSIST.into(), 8); + stats.insert(StatHashes::AimAssist.into(), 8); } else if _input.value > 2 { - stats.insert(StatHashes::AIM_ASSIST.into(), 10); + stats.insert(StatHashes::AimAssist.into(), 10); } stats }, @@ -228,7 +228,7 @@ pub fn meta_perks() { inv_buff += 20; } let mut stats = HashMap::new(); - stats.insert(StatHashes::INVENTORY_SIZE.into(), inv_buff); + stats.insert(StatHashes::InventorySize.into(), inv_buff); stats }, ); @@ -261,7 +261,7 @@ pub fn meta_perks() { 2 => 15, 3.. => 18, }; - stats.insert(StatHashes::RELOAD.into(), buff); + stats.insert(StatHashes::Reload.into(), buff); stats }, ); @@ -285,8 +285,8 @@ pub fn meta_perks() { Perks::RallyBarricade, |_input: ModifierResponseInput| -> HashMap { let mut stats = HashMap::new(); - stats.insert(StatHashes::STABILITY.into(), 30); - stats.insert(StatHashes::RELOAD.into(), 100); + stats.insert(StatHashes::Stability.into(), 30); + stats.insert(StatHashes::Reload.into(), 100); stats }, ); diff --git a/src/perks/origin_perks.rs b/src/perks/origin_perks.rs index 797ac0da..80daef43 100644 --- a/src/perks/origin_perks.rs +++ b/src/perks/origin_perks.rs @@ -98,10 +98,10 @@ pub fn origin_perks() { let reload = if _input.value > 0 { 50 } else { 0 }; let stability = if _input.value > 0 { 20 } else { 0 }; let aim_assist = if _input.value > 0 { 10 } else { 0 }; - map.insert(StatHashes::RANGE.into(), range); - map.insert(StatHashes::RELOAD.into(), reload); - map.insert(StatHashes::STABILITY.into(), stability); - map.insert(StatHashes::AIM_ASSIST.into(), aim_assist); + map.insert(StatHashes::Range.into(), range); + map.insert(StatHashes::Reload.into(), reload); + map.insert(StatHashes::Stability.into(), stability); + map.insert(StatHashes::AimAssist.into(), aim_assist); map }, ); @@ -113,8 +113,8 @@ pub fn origin_perks() { let range = if _input.is_enhanced { 30 } else { 20 }; let handling = if _input.is_enhanced { 40 } else { 20 }; if _input.calc_data.time_total < 2.0 && _input.value > 0 { - map.insert(StatHashes::RANGE.into(), range); - map.insert(StatHashes::HANDLING.into(), handling); + map.insert(StatHashes::Range.into(), range); + map.insert(StatHashes::Handling.into(), handling); } map }, @@ -225,8 +225,8 @@ pub fn origin_perks() { if _input.calc_data.shots_fired_this_mag <= _input.calc_data.base_mag / 2.0 && _input.value > 0 { - map.insert(StatHashes::RELOAD.into(), reload); - map.insert(StatHashes::STABILITY.into(), stability); + map.insert(StatHashes::Reload.into(), reload); + map.insert(StatHashes::Stability.into(), stability); } map }, @@ -251,7 +251,7 @@ pub fn origin_perks() { |_input: ModifierResponseInput| -> HashMap { let mut map = HashMap::new(); if _input.value > 0 { - map.insert(StatHashes::RELOAD.into(), 40); + map.insert(StatHashes::Reload.into(), 40); } map }, @@ -282,7 +282,7 @@ pub fn origin_perks() { |_input: ModifierResponseInput| -> HashMap { let mut map = HashMap::new(); let val = clamp(_input.value, 0, 5) as i32; - map.insert(StatHashes::RELOAD.into(), val * 10); + map.insert(StatHashes::Reload.into(), val * 10); map }, ); @@ -308,8 +308,8 @@ pub fn origin_perks() { let mut map = HashMap::new(); let stat_bump = if _input.is_enhanced { 20 } else { 10 }; if _input.value > 0 { - map.insert(StatHashes::AIM_ASSIST.into(), stat_bump); - map.insert(StatHashes::RANGE.into(), stat_bump); + map.insert(StatHashes::AimAssist.into(), stat_bump); + map.insert(StatHashes::Range.into(), stat_bump); } map }, @@ -345,8 +345,8 @@ pub fn origin_perks() { |_input: ModifierResponseInput| -> HashMap { let mut map = HashMap::new(); if _input.value > 0 { - map.insert(StatHashes::HANDLING.into(), 20); - map.insert(StatHashes::RELOAD.into(), 20); + map.insert(StatHashes::Handling.into(), 20); + map.insert(StatHashes::Reload.into(), 20); } map }, @@ -385,7 +385,7 @@ pub fn origin_perks() { |_input: ModifierResponseInput| -> HashMap { let mut out = HashMap::new(); if _input.value > 0 { - out.insert(StatHashes::HANDLING.into(), 40); + out.insert(StatHashes::Handling.into(), 40); } out }, @@ -421,11 +421,11 @@ pub fn origin_perks() { |_input: ModifierResponseInput| -> HashMap { let mut out = HashMap::new(); if _input.value == 1 { - out.insert(StatHashes::HANDLING.into(), 10); + out.insert(StatHashes::Handling.into(), 10); } if _input.value > 1 { - out.insert(StatHashes::RELOAD.into(), 20); - out.insert(StatHashes::HANDLING.into(), 20); + out.insert(StatHashes::Reload.into(), 20); + out.insert(StatHashes::Handling.into(), 20); } out }, diff --git a/src/perks/other_perks.rs b/src/perks/other_perks.rs index 05817f5e..3a81b8d9 100644 --- a/src/perks/other_perks.rs +++ b/src/perks/other_perks.rs @@ -65,7 +65,7 @@ pub fn other_perks() { |_input: ModifierResponseInput| -> HashMap { let mut stats = HashMap::new(); if _input.calc_data.weapon_type == &WeaponType::HANDCANNON { - stats.insert(StatHashes::AIRBORNE.into(), 25); + stats.insert(StatHashes::Airborne.into(), 25); } stats }, @@ -127,9 +127,9 @@ pub fn other_perks() { Perks::OphidianAspect, |_input: ModifierResponseInput| -> HashMap { let mut stats = HashMap::new(); - stats.insert(StatHashes::HANDLING.into(), 35); - stats.insert(StatHashes::RELOAD.into(), 35); - stats.insert(StatHashes::AIRBORNE.into(), 10); + stats.insert(StatHashes::Handling.into(), 35); + stats.insert(StatHashes::Reload.into(), 35); + stats.insert(StatHashes::Airborne.into(), 10); stats }, ); @@ -139,8 +139,8 @@ pub fn other_perks() { |_input: ModifierResponseInput| -> HashMap { let mut stats = HashMap::new(); if _input.value >= 1 { - stats.insert(StatHashes::HANDLING.into(), 100); - stats.insert(StatHashes::RELOAD.into(), 100); + stats.insert(StatHashes::Handling.into(), 100); + stats.insert(StatHashes::Reload.into(), 100); } stats }, @@ -180,7 +180,7 @@ pub fn other_perks() { Perks::Amplified, |_input: ModifierResponseInput| -> HashMap { let mut stats = HashMap::new(); - stats.insert(StatHashes::HANDLING.into(), 40); + stats.insert(StatHashes::Handling.into(), 40); stats }, ); @@ -216,7 +216,7 @@ pub fn other_perks() { |_input: ModifierResponseInput| -> HashMap { let mut stats = HashMap::new(); if _input.value > 0 { - stats.insert(StatHashes::RELOAD.into(), 50); + stats.insert(StatHashes::Reload.into(), 50); }; stats }, @@ -241,7 +241,7 @@ pub fn other_perks() { |_input: ModifierResponseInput| -> HashMap { let mut stats = HashMap::new(); if _input.value > 0 { - stats.insert(StatHashes::RELOAD.into(), 50); + stats.insert(StatHashes::Reload.into(), 50); }; stats }, @@ -252,7 +252,7 @@ pub fn other_perks() { |_input: ModifierResponseInput| -> HashMap { let mut stats = HashMap::new(); if _input.value > 0 { - stats.insert(StatHashes::AIRBORNE.into(), 20); + stats.insert(StatHashes::Airborne.into(), 20); }; stats }, @@ -264,8 +264,8 @@ pub fn other_perks() { let mut stats = HashMap::new(); let val = clamp(_input.value, 0, 3) as i32; if _input.value > 0 { - stats.insert(StatHashes::HANDLING.into(), 20 * val); - stats.insert(StatHashes::RELOAD.into(), 20 * val); + stats.insert(StatHashes::Handling.into(), 20 * val); + stats.insert(StatHashes::Reload.into(), 20 * val); }; stats }, @@ -301,7 +301,7 @@ pub fn other_perks() { if _input.value > 0 { buff += 50; }; - stats.insert(StatHashes::AIRBORNE.into(), buff); + stats.insert(StatHashes::Airborne.into(), buff); stats }, ); @@ -311,9 +311,9 @@ pub fn other_perks() { |_input: ModifierResponseInput| -> HashMap { let mut stats = HashMap::new(); if _input.value > 0 { - stats.insert(StatHashes::AIRBORNE.into(), 20); - stats.insert(StatHashes::AIM_ASSIST.into(), 15); - stats.insert(StatHashes::STABILITY.into(), 30); + stats.insert(StatHashes::Airborne.into(), 20); + stats.insert(StatHashes::AimAssist.into(), 15); + stats.insert(StatHashes::Stability.into(), 30); }; stats }, @@ -322,7 +322,7 @@ pub fn other_perks() { add_dmr( Perks::BossSpec, |_input: ModifierResponseInput| -> DamageModifierResponse { - let damage_mult = if *_input.calc_data.enemy_type == EnemyType::BOSS && !_input.pvp { + let damage_mult = if *_input.calc_data.enemy_type == EnemyType::Boss && !_input.pvp { 1.077 } else { 1.0 @@ -340,7 +340,7 @@ pub fn other_perks() { |_input: ModifierResponseInput| -> DamageModifierResponse { if !matches!( *_input.calc_data.enemy_type, - EnemyType::ELITE | EnemyType::MINIBOSS | EnemyType::CHAMPION + EnemyType::Elite | EnemyType::Miniboss | EnemyType::Champion ) || _input.pvp { return DamageModifierResponse::default(); @@ -359,7 +359,7 @@ pub fn other_perks() { |_input: ModifierResponseInput| -> DamageModifierResponse { if !matches!( *_input.calc_data.enemy_type, - EnemyType::ELITE | EnemyType::MINIBOSS | EnemyType::CHAMPION | EnemyType::BOSS + EnemyType::Elite | EnemyType::Miniboss | EnemyType::Champion | EnemyType::Boss ) || _input.pvp { return DamageModifierResponse::default(); @@ -376,7 +376,7 @@ pub fn other_perks() { add_dmr( Perks::MinorSpec, |_input: ModifierResponseInput| -> DamageModifierResponse { - let damage_mult = if _input.calc_data.enemy_type == &EnemyType::MINOR && !_input.pvp { + let damage_mult = if _input.calc_data.enemy_type == &EnemyType::Minor && !_input.pvp { 1.077 } else { 1.0 @@ -525,9 +525,9 @@ pub fn other_perks() { |_input: ModifierResponseInput| -> HashMap { let mut map = HashMap::new(); if _input.value > 0 { - map.insert(StatHashes::AIRBORNE.into(), 30); - map.insert(StatHashes::RELOAD.into(), 40); - map.insert(StatHashes::HANDLING.into(), 40); + map.insert(StatHashes::Airborne.into(), 30); + map.insert(StatHashes::Reload.into(), 40); + map.insert(StatHashes::Handling.into(), 40); } map }, diff --git a/src/perks/year_1_perks.rs b/src/perks/year_1_perks.rs index 11648518..8a682c34 100644 --- a/src/perks/year_1_perks.rs +++ b/src/perks/year_1_perks.rs @@ -28,9 +28,9 @@ pub fn year_1_perks() { _ => (40, 55, 100), }; let mut out = HashMap::new(); - out.insert(StatHashes::STABILITY.into(), stats.0); - out.insert(StatHashes::RELOAD.into(), stats.1); - out.insert(StatHashes::HANDLING.into(), stats.2); + out.insert(StatHashes::Stability.into(), stats.0); + out.insert(StatHashes::Reload.into(), stats.1); + out.insert(StatHashes::Handling.into(), stats.2); out }, ); @@ -102,7 +102,7 @@ pub fn year_1_perks() { let val = clamp(_input.value, 0, 15) as f64; if _input.calc_data.total_shots_fired == 0.0 { let mut mag_mult = 1.0; - if *_input.calc_data.ammo_type == AmmoType::PRIMARY { + if *_input.calc_data.ammo_type == AmmoType::Primary { mag_mult += 0.2 * val; } else { mag_mult += 0.1 * val; @@ -214,13 +214,13 @@ pub fn year_1_perks() { let mut out = HashMap::new(); if _input.value > 0 { let reload = if _input.is_enhanced { 55 } else { 50 }; - out.insert(StatHashes::RELOAD.into(), reload); + out.insert(StatHashes::Reload.into(), reload); }; let mut reserves = if _input.is_enhanced { 40 } else { 30 }; if *_input.calc_data.weapon_type == WeaponType::GRENADELAUNCHER { reserves -= 10; }; - out.insert(StatHashes::INVENTORY_SIZE.into(), reserves); + out.insert(StatHashes::InventorySize.into(), reserves); out }, ); @@ -277,11 +277,11 @@ pub fn year_1_perks() { }; let mut out = HashMap::new(); if _input.value > 0 { - out.insert(StatHashes::HANDLING.into(), handling); - out.insert(StatHashes::STABILITY.into(), stabiltiy); + out.insert(StatHashes::Handling.into(), handling); + out.insert(StatHashes::Stability.into(), stabiltiy); } out - } + }, ); add_hmr( @@ -335,8 +335,8 @@ pub fn year_1_perks() { |_input: ModifierResponseInput| -> HashMap { let mut out = HashMap::new(); if _input.value > 0 { - out.insert(StatHashes::AIM_ASSIST.into(), 15); - out.insert(StatHashes::STABILITY.into(), 25); + out.insert(StatHashes::AimAssist.into(), 15); + out.insert(StatHashes::Stability.into(), 25); }; out }, @@ -379,7 +379,7 @@ pub fn year_1_perks() { let aim_assist = if _input.is_enhanced { 11 } else { 10 }; let mut out = HashMap::new(); if _input.value >= 1 { - out.insert(StatHashes::AIM_ASSIST.into(), aim_assist); + out.insert(StatHashes::AimAssist.into(), aim_assist); } out }, @@ -392,8 +392,8 @@ pub fn year_1_perks() { let range = if _input.is_enhanced { 30 } else { 25 }; let mut out = HashMap::new(); if _input.value > 0 { - out.insert(StatHashes::AIM_ASSIST.into(), aim_assist); - out.insert(StatHashes::RANGE.into(), range); + out.insert(StatHashes::AimAssist.into(), aim_assist); + out.insert(StatHashes::Range.into(), range); } out }, @@ -420,7 +420,7 @@ pub fn year_1_perks() { |_input: ModifierResponseInput| -> HashMap { let mut out = HashMap::new(); if _input.value > 0 { - out.insert(StatHashes::RELOAD.into(), 70); + out.insert(StatHashes::Reload.into(), 70); } out }, @@ -457,8 +457,8 @@ pub fn year_1_perks() { let range = if _input.is_enhanced { 25 } else { 20 }; let mut out = HashMap::new(); if _input.value > 0 { - out.insert(StatHashes::STABILITY.into(), stability); - out.insert(StatHashes::RANGE.into(), range); + out.insert(StatHashes::Stability.into(), stability); + out.insert(StatHashes::Range.into(), range); } out }, @@ -489,8 +489,8 @@ pub fn year_1_perks() { let handling = if _input.is_enhanced { 25 } else { 20 }; let mut out = HashMap::new(); if _input.value > 0 { - out.insert(StatHashes::STABILITY.into(), stability); - out.insert(StatHashes::HANDLING.into(), handling); + out.insert(StatHashes::Stability.into(), stability); + out.insert(StatHashes::Handling.into(), handling); } out }, @@ -511,7 +511,7 @@ pub fn year_1_perks() { Perks::Snapshot, |_input: ModifierResponseInput| -> HandlingModifierResponse { let mut ads_mult = 0.5; - if *_input.calc_data.ammo_type == AmmoType::SPECIAL { + if *_input.calc_data.ammo_type == AmmoType::Special { ads_mult = 0.8; //its 0.8 from my testing idk }; HandlingModifierResponse { @@ -530,7 +530,7 @@ pub fn year_1_perks() { } let mut out = HashMap::new(); if _input.value > 0 { - out.insert(StatHashes::STABILITY.into(), stability); + out.insert(StatHashes::Stability.into(), stability); } out }, @@ -629,7 +629,7 @@ pub fn year_1_perks() { }; let mut out = HashMap::new(); if _input.value > 0 { - out.insert(StatHashes::HANDLING.into(), handling); + out.insert(StatHashes::Handling.into(), handling); } out }, @@ -658,7 +658,7 @@ pub fn year_1_perks() { let mut damage_mult = if _input.value > 0 { 0.5 } else { 0.0 }; let duration = if _input.is_enhanced { 5.0 } else { 4.0 }; if _input.calc_data.time_total > duration - || _input.calc_data.damage_type != &DamageType::KINETIC + || _input.calc_data.damage_type != &DamageType::Kinetic { damage_mult = 0.0; }; @@ -690,7 +690,7 @@ pub fn year_1_perks() { |_input: ModifierResponseInput| -> HashMap { let mut map = HashMap::new(); if _input.value > 0 { - map.insert(StatHashes::HANDLING.into(), 100); + map.insert(StatHashes::Handling.into(), 100); } map }, @@ -717,7 +717,7 @@ pub fn year_1_perks() { |_input: ModifierResponseInput| -> HashMap { let mut map = HashMap::new(); if _input.value > 0 { - map.insert(StatHashes::HANDLING.into(), 50); + map.insert(StatHashes::Handling.into(), 50); } map }, @@ -728,7 +728,7 @@ pub fn year_1_perks() { |_input: ModifierResponseInput| -> HashMap { let mut map = HashMap::new(); if _input.value > 0 { - map.insert(StatHashes::RELOAD.into(), 100); + map.insert(StatHashes::Reload.into(), 100); } map }, @@ -754,7 +754,7 @@ pub fn year_1_perks() { let mut map = HashMap::new(); let buff = if _input.is_enhanced { 35 } else { 30 }; if _input.value > 0 { - map.insert(StatHashes::STABILITY.into(), buff); + map.insert(StatHashes::Stability.into(), buff); } map }, diff --git a/src/perks/year_2_perks.rs b/src/perks/year_2_perks.rs index e7f65869..bebea247 100644 --- a/src/perks/year_2_perks.rs +++ b/src/perks/year_2_perks.rs @@ -23,7 +23,7 @@ pub fn year_2_perks() { let mut stats = HashMap::new(); let ae_per_stack = if _input.is_enhanced { 35 } else { 30 }; let ae = ae_per_stack * _input.value as i32; - stats.insert(StatHashes::AIRBORNE.into(), ae); + stats.insert(StatHashes::Airborne.into(), ae); stats }, ); @@ -124,7 +124,7 @@ pub fn year_2_perks() { if _input.calc_data.time_total > duration { reload = 0; }; - stats.insert(StatHashes::RELOAD.into(), reload); + stats.insert(StatHashes::Reload.into(), reload); stats }, ); @@ -227,9 +227,9 @@ pub fn year_2_perks() { 5, ); let mut stats = HashMap::new(); - stats.insert(StatHashes::RELOAD.into(), rel_values[entry_to_get as usize]); + stats.insert(StatHashes::Reload.into(), rel_values[entry_to_get as usize]); stats.insert( - StatHashes::STABILITY.into(), + StatHashes::Stability.into(), stab_values[entry_to_get as usize], ); stats @@ -349,7 +349,7 @@ pub fn year_2_perks() { |_input: ModifierResponseInput| -> HashMap { let mut out = HashMap::new(); if _input.value > 0 { - out.insert(StatHashes::BLAST_RADIUS.into(), 100); + out.insert(StatHashes::BlastRadius.into(), 100); }; out }, @@ -360,7 +360,7 @@ pub fn year_2_perks() { |_input: ModifierResponseInput| -> HashMap { let mut out = HashMap::new(); if _input.value > 0 { - out.insert(StatHashes::HANDLING.into(), 30); + out.insert(StatHashes::Handling.into(), 30); }; out }, diff --git a/src/perks/year_3_perks.rs b/src/perks/year_3_perks.rs index efdcac0b..80a49e24 100644 --- a/src/perks/year_3_perks.rs +++ b/src/perks/year_3_perks.rs @@ -33,15 +33,15 @@ pub fn year_3_perks() { let mut stats = HashMap::new(); let ev = if _input.is_enhanced { 5 } else { 0 }; if _input.value == 1 { - stats.insert(StatHashes::STABILITY.into(), 20 + ev); + stats.insert(StatHashes::Stability.into(), 20 + ev); } else if _input.value == 2 { - stats.insert(StatHashes::RELOAD.into(), 50 + ev); + stats.insert(StatHashes::Reload.into(), 50 + ev); } else if _input.value == 3 { - stats.insert(StatHashes::HANDLING.into(), 50 + ev); + stats.insert(StatHashes::Handling.into(), 50 + ev); } else if _input.value == 4 { - stats.insert(StatHashes::RECOIL_DIR.into(), 20 + ev); + stats.insert(StatHashes::RecoilDir.into(), 20 + ev); } else if _input.value == 5 { - stats.insert(StatHashes::AIRBORNE.into(), 20 + ev); + stats.insert(StatHashes::Airborne.into(), 20 + ev); }; stats }, @@ -80,8 +80,8 @@ pub fn year_3_perks() { |_input: ModifierResponseInput| -> HashMap { let mut stats = HashMap::new(); if _input.value > 0 { - stats.insert(StatHashes::HANDLING.into(), 40); - stats.insert(StatHashes::RANGE.into(), 20); + stats.insert(StatHashes::Handling.into(), 40); + stats.insert(StatHashes::Range.into(), 20); }; stats }, @@ -137,17 +137,17 @@ pub fn year_3_perks() { Perks::Vorpal, |_input: ModifierResponseInput| -> DamageModifierResponse { let mut buff = 1.0; - if (*_input.calc_data.enemy_type == EnemyType::BOSS - || *_input.calc_data.enemy_type == EnemyType::MINIBOSS - || *_input.calc_data.enemy_type == EnemyType::CHAMPION - || *_input.calc_data.enemy_type == EnemyType::VEHICLE) + if (*_input.calc_data.enemy_type == EnemyType::Boss + || *_input.calc_data.enemy_type == EnemyType::Miniboss + || *_input.calc_data.enemy_type == EnemyType::Champion + || *_input.calc_data.enemy_type == EnemyType::Vehicle) && !_input.pvp { buff = match *_input.calc_data.ammo_type { - AmmoType::HEAVY => 1.1, - AmmoType::SPECIAL => 1.15, - AmmoType::PRIMARY => 1.2, - AmmoType::UNKNOWN => 0.0, //this should make someone point out a bug? whats error handling lol + AmmoType::Heavy => 1.1, + AmmoType::Special => 1.15, + AmmoType::Primary => 1.2, + AmmoType::Unknown => 0.0, //this should make someone point out a bug? whats error handling lol }; } DamageModifierResponse { @@ -164,9 +164,9 @@ pub fn year_3_perks() { let mut buffer: HashMap = HashMap::new(); let bump = if _input.is_enhanced { 35 } else { 30 }; if _input.value > 0 { - buffer.insert(StatHashes::HANDLING.into(), bump); + buffer.insert(StatHashes::Handling.into(), bump); //reload unknown - buffer.insert(StatHashes::RELOAD.into(), bump); + buffer.insert(StatHashes::Reload.into(), bump); } buffer }, diff --git a/src/perks/year_4_perks.rs b/src/perks/year_4_perks.rs index 2d0a671a..08ced9b8 100644 --- a/src/perks/year_4_perks.rs +++ b/src/perks/year_4_perks.rs @@ -58,7 +58,7 @@ pub fn year_4_perks() { let mut map = HashMap::new(); let duration = if _input.is_enhanced { 8.0 } else { 7.0 }; if _input.calc_data.time_total <= duration && _input.value > 0 { - map.insert(StatHashes::RANGE.into(), 10); + map.insert(StatHashes::Range.into(), 10); } map }, @@ -104,7 +104,7 @@ pub fn year_4_perks() { handling = 20; }; let mut out = HashMap::new(); - out.insert(StatHashes::HANDLING.into(), handling); + out.insert(StatHashes::Handling.into(), handling); out }, ); @@ -143,8 +143,8 @@ pub fn year_4_perks() { let reload = if _input.is_enhanced { 45 } else { 40 }; if _input.value > 0 { let mut out = HashMap::new(); - out.insert(StatHashes::HANDLING.into(), handling); - out.insert(StatHashes::RELOAD.into(), reload); + out.insert(StatHashes::Handling.into(), handling); + out.insert(StatHashes::Reload.into(), reload); out } else { HashMap::new() @@ -251,8 +251,8 @@ pub fn year_4_perks() { reload = 100; }; let mut out = HashMap::new(); - out.insert(StatHashes::HANDLING.into(), handling); - out.insert(StatHashes::RELOAD.into(), reload); + out.insert(StatHashes::Handling.into(), handling); + out.insert(StatHashes::Reload.into(), reload); out }, ); @@ -278,7 +278,7 @@ pub fn year_4_perks() { |_input: ModifierResponseInput| -> HashMap { let reload = if _input.is_enhanced { 25 } else { 20 }; let mut out = HashMap::new(); - out.insert(StatHashes::RELOAD.into(), reload); + out.insert(StatHashes::Reload.into(), reload); out }, ); @@ -303,9 +303,9 @@ pub fn year_4_perks() { stat_bump = 20; }; let mut out = HashMap::new(); - out.insert(StatHashes::RELOAD.into(), stat_bump); - out.insert(StatHashes::HANDLING.into(), stat_bump); - out.insert(StatHashes::STABILITY.into(), stat_bump); + out.insert(StatHashes::Reload.into(), stat_bump); + out.insert(StatHashes::Handling.into(), stat_bump); + out.insert(StatHashes::Stability.into(), stat_bump); out }, ); @@ -349,7 +349,7 @@ pub fn year_4_perks() { |_input: ModifierResponseInput| -> HashMap { let mut out = HashMap::new(); if _input.value > 0 { - out.insert(StatHashes::AIRBORNE.into(), 30); + out.insert(StatHashes::Airborne.into(), 30); }; out }, @@ -368,7 +368,7 @@ pub fn year_4_perks() { |_input: ModifierResponseInput| -> HashMap { let mut out = HashMap::new(); if _input.value > 0 { - out.insert(StatHashes::HANDLING.into(), 35); + out.insert(StatHashes::Handling.into(), 35); }; out }, @@ -405,7 +405,7 @@ pub fn year_4_perks() { |_input: ModifierResponseInput| -> HashMap { let mut out = HashMap::new(); if _input.value > 0 { - out.insert(StatHashes::BLAST_RADIUS.into(), 100); + out.insert(StatHashes::BlastRadius.into(), 100); }; out }, @@ -435,7 +435,7 @@ pub fn year_4_perks() { |_input: ModifierResponseInput| -> HashMap { let mut buffer: HashMap = HashMap::new(); if _input.value > 0 { - buffer.insert(StatHashes::RELOAD.into(), 50); + buffer.insert(StatHashes::Reload.into(), 50); } buffer }, @@ -508,7 +508,7 @@ pub fn year_4_perks() { |_input: ModifierResponseInput| -> HashMap { let mut out = HashMap::new(); if _input.value > 0 { - out.insert(StatHashes::HANDLING.into(), 15); + out.insert(StatHashes::Handling.into(), 15); } out }, @@ -519,17 +519,17 @@ pub fn year_4_perks() { |_input: ModifierResponseInput| -> HashMap { let mut out = HashMap::new(); if _input.value == 1 { - out.insert(StatHashes::HANDLING.into(), 10); - out.insert(StatHashes::RELOAD.into(), 5); - out.insert(StatHashes::STABILITY.into(), 5); + out.insert(StatHashes::Handling.into(), 10); + out.insert(StatHashes::Reload.into(), 5); + out.insert(StatHashes::Stability.into(), 5); } else if _input.value == 2 { - out.insert(StatHashes::HANDLING.into(), 25); - out.insert(StatHashes::RELOAD.into(), 25); - out.insert(StatHashes::STABILITY.into(), 15); + out.insert(StatHashes::Handling.into(), 25); + out.insert(StatHashes::Reload.into(), 25); + out.insert(StatHashes::Stability.into(), 15); } else if _input.value == 3 { - out.insert(StatHashes::HANDLING.into(), 50); - out.insert(StatHashes::RELOAD.into(), 50); - out.insert(StatHashes::STABILITY.into(), 25); + out.insert(StatHashes::Handling.into(), 50); + out.insert(StatHashes::Reload.into(), 50); + out.insert(StatHashes::Stability.into(), 25); } out }, @@ -578,8 +578,8 @@ pub fn year_4_perks() { |_input: ModifierResponseInput| -> HashMap { let val = clamp(_input.value, 0, 2) as i32; let mut out = HashMap::new(); - out.insert(StatHashes::RECOIL_DIR.into(), 20 * val); - out.insert(StatHashes::STABILITY.into(), 15 * val); + out.insert(StatHashes::RecoilDir.into(), 20 * val); + out.insert(StatHashes::Stability.into(), 15 * val); out }, ); @@ -589,7 +589,7 @@ pub fn year_4_perks() { |_input: ModifierResponseInput| -> HashMap { let mut out = HashMap::new(); if _input.value > 0 { - out.insert(StatHashes::AIM_ASSIST.into(), 20); + out.insert(StatHashes::AimAssist.into(), 20); } out }, diff --git a/src/perks/year_5_perks.rs b/src/perks/year_5_perks.rs index 2839bde0..42286841 100644 --- a/src/perks/year_5_perks.rs +++ b/src/perks/year_5_perks.rs @@ -43,8 +43,8 @@ pub fn year_5_perks() { let val = clamp(_input.value, 0, 4) as i32; let stability_boost = 8 * val; let range_boost = 5 * val; - map.insert(StatHashes::RANGE.into(), range_boost); - map.insert(StatHashes::STABILITY.into(), stability_boost); + map.insert(StatHashes::Range.into(), range_boost); + map.insert(StatHashes::Stability.into(), stability_boost); map }, ); @@ -103,7 +103,7 @@ pub fn year_5_perks() { if _input.value > 0 { range_bonus = 20; }; - map.insert(StatHashes::RANGE.into(), range_bonus); + map.insert(StatHashes::Range.into(), range_bonus); map }, ); @@ -145,7 +145,7 @@ pub fn year_5_perks() { if _input.value > 0 { stability_boost = 30; }; - map.insert(StatHashes::STABILITY.into(), stability_boost); + map.insert(StatHashes::Stability.into(), stability_boost); map }, ); @@ -182,7 +182,7 @@ pub fn year_5_perks() { Perks::Slickdraw, |_input: ModifierResponseInput| -> HashMap { let mut map = HashMap::new(); - map.insert(StatHashes::HANDLING.into(), 100); + map.insert(StatHashes::Handling.into(), 100); map }, ); @@ -201,10 +201,10 @@ pub fn year_5_perks() { reload_boost = 35; handling_boost = 35; }; - out.insert(StatHashes::STABILITY.into(), stability_boost); - out.insert(StatHashes::RANGE.into(), range_boost); - out.insert(StatHashes::RELOAD.into(), reload_boost); - out.insert(StatHashes::HANDLING.into(), handling_boost); + out.insert(StatHashes::Stability.into(), stability_boost); + out.insert(StatHashes::Range.into(), range_boost); + out.insert(StatHashes::Reload.into(), reload_boost); + out.insert(StatHashes::Handling.into(), handling_boost); out }, ); @@ -267,7 +267,7 @@ pub fn year_5_perks() { if _input.value > 0 { handling = 100; }; - map.insert(StatHashes::HANDLING.into(), handling); + map.insert(StatHashes::Handling.into(), handling); map }, ); @@ -347,9 +347,9 @@ pub fn year_5_perks() { let mut map = HashMap::new(); let stat_base = if _input.is_enhanced { 12 } else { 10 }; let stat_bump = stat_base * val; - map.insert(StatHashes::STABILITY.into(), stat_bump); - map.insert(StatHashes::RANGE.into(), stat_bump); - map.insert(StatHashes::HANDLING.into(), stat_bump); + map.insert(StatHashes::Stability.into(), stat_bump); + map.insert(StatHashes::Range.into(), stat_bump); + map.insert(StatHashes::Handling.into(), stat_bump); map }, ); @@ -424,7 +424,7 @@ pub fn year_5_perks() { if _input.calc_data.shots_fired_this_mag <= _input.calc_data.base_mag / 2.0 && _input.value > 0 { - map.insert(StatHashes::RELOAD.into(), reload_add); + map.insert(StatHashes::Reload.into(), reload_add); } map }, @@ -437,9 +437,9 @@ pub fn year_5_perks() { let mut map = HashMap::new(); let stat_base = 10; let stat_bump = stat_base * val; - map.insert(StatHashes::STABILITY.into(), stat_bump); - map.insert(StatHashes::RELOAD.into(), stat_bump); - map.insert(StatHashes::HANDLING.into(), stat_bump); + map.insert(StatHashes::Stability.into(), stat_bump); + map.insert(StatHashes::Reload.into(), stat_bump); + map.insert(StatHashes::Handling.into(), stat_bump); map }, ); @@ -494,7 +494,7 @@ pub fn year_5_perks() { |_input: ModifierResponseInput| -> HashMap { let mut map = HashMap::new(); if _input.value > 0 { - map.insert(StatHashes::HANDLING.into(), 100); + map.insert(StatHashes::Handling.into(), 100); } map }, diff --git a/src/perks/year_6_perks.rs b/src/perks/year_6_perks.rs index 3786dafd..802e6409 100644 --- a/src/perks/year_6_perks.rs +++ b/src/perks/year_6_perks.rs @@ -26,8 +26,8 @@ pub fn year_6_perks() { range_bonus = 10 + ev; reload_bonus = 30 + ev; }; - map.insert(StatHashes::RANGE.into(), range_bonus); - map.insert(StatHashes::RELOAD.into(), reload_bonus); + map.insert(StatHashes::Range.into(), range_bonus); + map.insert(StatHashes::Reload.into(), reload_bonus); map }, ); @@ -61,20 +61,20 @@ pub fn year_6_perks() { |_input: ModifierResponseInput| -> HashMap { let mut map = HashMap::new(); if _input.value > 4 { - map.insert(StatHashes::RANGE.into(), 20); - map.insert(StatHashes::RELOAD.into(), 55); + map.insert(StatHashes::Range.into(), 20); + map.insert(StatHashes::Reload.into(), 55); } else if _input.value == 4 { - map.insert(StatHashes::RANGE.into(), 12); - map.insert(StatHashes::RELOAD.into(), 35); + map.insert(StatHashes::Range.into(), 12); + map.insert(StatHashes::Reload.into(), 35); } else if _input.value == 3 { - map.insert(StatHashes::RANGE.into(), 9); - map.insert(StatHashes::RELOAD.into(), 20); + map.insert(StatHashes::Range.into(), 9); + map.insert(StatHashes::Reload.into(), 20); } else if _input.value == 2 { - map.insert(StatHashes::RANGE.into(), 6); - map.insert(StatHashes::RELOAD.into(), 10); + map.insert(StatHashes::Range.into(), 6); + map.insert(StatHashes::Reload.into(), 10); } else if _input.value == 1 { - map.insert(StatHashes::RELOAD.into(), 5); - map.insert(StatHashes::RANGE.into(), 3); + map.insert(StatHashes::Reload.into(), 5); + map.insert(StatHashes::Range.into(), 3); } map }, @@ -258,7 +258,7 @@ pub fn year_6_perks() { |_input: ModifierResponseInput| -> HashMap { let mut stats = HashMap::new(); if _input.value > 0 { - stats.insert(StatHashes::STABILITY.into(), 25); + stats.insert(StatHashes::Stability.into(), 25); } stats }, @@ -268,9 +268,9 @@ pub fn year_6_perks() { |_input: ModifierResponseInput| -> HashMap { let mut stats = HashMap::new(); if _input.value > 0 { - stats.insert(StatHashes::STABILITY.into(), 20); - stats.insert(StatHashes::HANDLING.into(), 60); - stats.insert(StatHashes::RELOAD.into(), 60); + stats.insert(StatHashes::Stability.into(), 20); + stats.insert(StatHashes::Handling.into(), 60); + stats.insert(StatHashes::Reload.into(), 60); } stats }, @@ -319,7 +319,7 @@ pub fn year_6_perks() { |_input: ModifierResponseInput| -> HashMap { let mut stats = HashMap::new(); if _input.value > 0 { - stats.insert(StatHashes::AIRBORNE.into(), 30); + stats.insert(StatHashes::Airborne.into(), 30); } stats }, @@ -360,7 +360,7 @@ pub fn year_6_perks() { if _input.value == 0 { return HashMap::new(); } - HashMap::from([(StatHashes::RELOAD.into(), 50)]) + HashMap::from([(StatHashes::Reload.into(), 50)]) }, ); @@ -386,8 +386,8 @@ pub fn year_6_perks() { return HashMap::new(); } HashMap::from([ - (StatHashes::RELOAD.into(), 10), - (StatHashes::HANDLING.into(), 0), + (StatHashes::Reload.into(), 10), + (StatHashes::Handling.into(), 0), ]) }, ); @@ -425,8 +425,8 @@ pub fn year_6_perks() { let stat_bump = clamp(value + shots_hit, 0, max_stacks) * stat_per_stack; HashMap::from([ - (StatHashes::RELOAD.into(), stat_bump), - (StatHashes::HANDLING.into(), stat_bump), + (StatHashes::Reload.into(), stat_bump), + (StatHashes::Handling.into(), stat_bump), ]) }, ); diff --git a/src/test.rs b/src/test.rs index 8ac34579..6214a4c8 100644 --- a/src/test.rs +++ b/src/test.rs @@ -39,10 +39,10 @@ fn setup_pulse() { ) .expect("Failed to generate weapon"); let mut stats = HashMap::new(); - stats.insert(StatHashes::RELOAD.into(), Stat::from(50)); - stats.insert(StatHashes::HANDLING.into(), Stat::from(50)); - stats.insert(StatHashes::RANGE.into(), Stat::from(50)); - stats.insert(StatHashes::ZOOM.into(), Stat::from(15)); + stats.insert(StatHashes::Reload.into(), Stat::from(50)); + stats.insert(StatHashes::Handling.into(), Stat::from(50)); + stats.insert(StatHashes::Range.into(), Stat::from(50)); + stats.insert(StatHashes::Zoom.into(), Stat::from(15)); new_weapon.set_stats(stats); PERS_DATA.with(|perm_data| { perm_data.borrow_mut().weapon = new_weapon; @@ -54,13 +54,13 @@ fn test_pulse_setup() { setup_pulse(); PERS_DATA.with(|perm_data| { let mut weapon = perm_data.borrow().weapon.clone(); - assert_eq!(weapon.damage_type, DamageType::KINETIC); - assert_eq!(weapon.ammo_type, AmmoType::PRIMARY); + assert_eq!(weapon.damage_type, DamageType::Kinetic); + assert_eq!(weapon.ammo_type, AmmoType::Primary); assert_eq!(weapon.intrinsic_hash, 69420); assert_eq!(weapon.weapon_type, WeaponType::PULSERIFLE); let test_stat = weapon .get_stats() - .get(&(StatHashes::HANDLING.into())) + .get(&(StatHashes::Handling.into())) .expect("Failed to get stat") .val(); assert_eq!(test_stat, 50, "test_stat: {}", test_stat); @@ -189,10 +189,10 @@ fn setup_bow() { ) .expect("Failed to generate weapon"); let mut stats = HashMap::new(); - stats.insert(StatHashes::RELOAD.into(), Stat::from(50)); - stats.insert(StatHashes::HANDLING.into(), Stat::from(50)); - stats.insert(StatHashes::RANGE.into(), Stat::from(50)); - stats.insert(StatHashes::ZOOM.into(), Stat::from(15)); + stats.insert(StatHashes::Reload.into(), Stat::from(50)); + stats.insert(StatHashes::Handling.into(), Stat::from(50)); + stats.insert(StatHashes::Range.into(), Stat::from(50)); + stats.insert(StatHashes::Zoom.into(), Stat::from(15)); new_weapon.set_stats(stats); PERS_DATA.with(|perm_data| { perm_data.borrow_mut().weapon = new_weapon; @@ -204,13 +204,13 @@ fn test_bow_setup() { setup_bow(); PERS_DATA.with(|perm_data| { let mut weapon = perm_data.borrow().weapon.clone(); - assert_eq!(weapon.damage_type, DamageType::STRAND); - assert_eq!(weapon.ammo_type, AmmoType::SPECIAL); + assert_eq!(weapon.damage_type, DamageType::Strand); + assert_eq!(weapon.ammo_type, AmmoType::Special); assert_eq!(weapon.intrinsic_hash, 696969); assert_eq!(weapon.weapon_type, WeaponType::BOW); let test_stat = weapon .get_stats() - .get(&(StatHashes::HANDLING.into())) + .get(&(StatHashes::Handling.into())) .expect("Failed to get stat") .val(); assert_eq!(test_stat, 50, "test_stat: {}", test_stat); diff --git a/src/types/js_types.rs b/src/types/js_types.rs index bbf82bde..d9503836 100644 --- a/src/types/js_types.rs +++ b/src/types/js_types.rs @@ -1,4 +1,3 @@ - use std::fmt; use crate::{ @@ -122,6 +121,7 @@ pub struct JsDpsResponse { #[wasm_bindgen(js_name = "totalShots", readonly)] pub total_shots: i32, } +#[allow(clippy::unwrap_used)] #[wasm_bindgen(js_class = "DpsResponse")] impl JsDpsResponse { #[wasm_bindgen(js_name = "toJSON")] @@ -195,7 +195,7 @@ impl From for JsBodyKillData { } } -#[derive(Debug, Clone, Serialize)] +#[derive(Debug, Clone, Copy, Serialize)] #[wasm_bindgen(js_name = "ResillienceSummary", inspectable)] pub struct JsResillienceSummary { #[serde(rename = "resillienceValue")] @@ -218,7 +218,7 @@ impl From for JsResillienceSummary { } } -#[derive(Debug, Clone, Default, Serialize)] +#[derive(Debug, Clone, Copy, Default, Serialize)] #[wasm_bindgen(js_name = "FiringResponse", inspectable)] pub struct JsFiringResponse { #[wasm_bindgen(js_name = "pvpImpactDamage", readonly)] @@ -294,7 +294,7 @@ impl From for JsStat { } } -#[derive(Debug, Clone, Serialize)] +#[derive(Debug, Clone, Copy, Serialize)] #[wasm_bindgen(js_name = "MetaData", inspectable)] pub struct JsMetaData { #[wasm_bindgen(js_name = "apiVersion", readonly)] @@ -307,7 +307,7 @@ pub struct JsMetaData { pub api_branch: &'static str, } -#[derive(Debug, Clone, Default)] +#[derive(Debug, Clone, Copy, Default)] #[wasm_bindgen(js_name = "ScalarResponseSummary", inspectable)] pub struct JsScalarResponse { #[wasm_bindgen(js_name = "reloadScalar", readonly)] @@ -330,19 +330,19 @@ pub struct JsScalarResponse { pub reserve_size_scalar: f64, } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Copy)] #[wasm_bindgen(js_name = "DifficultyOptions")] pub enum JsDifficultyOptions { - NORMAL = 1, - RAID = 2, - MASTER = 3, + Normal = 1, + Raid = 2, + Master = 3, } impl From for DifficultyOptions { fn from(val: JsDifficultyOptions) -> Self { match val { - JsDifficultyOptions::NORMAL => DifficultyOptions::NORMAL, - JsDifficultyOptions::RAID => DifficultyOptions::RAID, - JsDifficultyOptions::MASTER => DifficultyOptions::MASTER, + JsDifficultyOptions::Normal => DifficultyOptions::Normal, + JsDifficultyOptions::Raid => DifficultyOptions::Raid, + JsDifficultyOptions::Master => DifficultyOptions::Master, } } } @@ -350,26 +350,26 @@ impl From for DifficultyOptions { #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[wasm_bindgen(js_name = "EnemyType")] pub enum JsEnemyType { - MINOR, - ELITE, - MINIBOSS, - BOSS, - VEHICLE, - ENCLAVE, - PLAYER, - CHAMPION, + Minor, + Elite, + Miniboss, + Boss, + Vehicle, + Enclave, + Player, + Champion, } impl From for EnemyType { fn from(val: JsEnemyType) -> Self { match val { - JsEnemyType::MINOR => EnemyType::MINOR, - JsEnemyType::ELITE => EnemyType::ELITE, - JsEnemyType::MINIBOSS => EnemyType::MINIBOSS, - JsEnemyType::BOSS => EnemyType::BOSS, - JsEnemyType::VEHICLE => EnemyType::VEHICLE, - JsEnemyType::ENCLAVE => EnemyType::ENCLAVE, - JsEnemyType::PLAYER => EnemyType::PLAYER, - JsEnemyType::CHAMPION => EnemyType::CHAMPION, + JsEnemyType::Minor => EnemyType::Minor, + JsEnemyType::Elite => EnemyType::Elite, + JsEnemyType::Miniboss => EnemyType::Miniboss, + JsEnemyType::Boss => EnemyType::Boss, + JsEnemyType::Vehicle => EnemyType::Vehicle, + JsEnemyType::Enclave => EnemyType::Enclave, + JsEnemyType::Player => EnemyType::Player, + JsEnemyType::Champion => EnemyType::Champion, } } } diff --git a/src/weapons/mod.rs b/src/weapons/mod.rs index 04bc0fd8..29bc85b0 100644 --- a/src/weapons/mod.rs +++ b/src/weapons/mod.rs @@ -17,7 +17,6 @@ use crate::types::formula_types::{ AmmoFormula, DamageModFormula, FiringDataFormula, HandlingFormula, RangeFormula, ReloadFormula, }; - #[derive(Debug, Clone, Copy, Serialize)] pub struct Stat { pub base_value: i32, @@ -238,8 +237,8 @@ impl Default for Weapon { reload_formula: ReloadFormula::default(), weapon_type: WeaponType::UNKNOWN, - damage_type: DamageType::UNKNOWN, - ammo_type: AmmoType::UNKNOWN, + damage_type: DamageType::Unknown, + ammo_type: AmmoType::Unknown, } } } diff --git a/src/weapons/stat_calc.rs b/src/weapons/stat_calc.rs index 7d996906..3f0a5f6c 100644 --- a/src/weapons/stat_calc.rs +++ b/src/weapons/stat_calc.rs @@ -42,7 +42,7 @@ impl Weapon { let mut reload_stat = self .stats - .get(&StatHashes::RELOAD.into()) + .get(&StatHashes::Reload.into()) .unwrap_or(&Stat::new()) .perk_val(); @@ -104,7 +104,7 @@ impl Weapon { let range_stat = self .stats - .get(&StatHashes::RANGE.into()) + .get(&StatHashes::Range.into()) .unwrap_or(&Stat::new()) .val(); let ads_mult = get_ads_multiplier(self.weapon_type, self.intrinsic_hash).unwrap_or(1.0); @@ -162,7 +162,7 @@ impl Weapon { let handling_stat = self .stats - .get(&StatHashes::HANDLING.into()) + .get(&StatHashes::Handling.into()) .unwrap_or(&Stat::new()) .val(); @@ -229,12 +229,12 @@ impl Weapon { ) -> AmmoResponse { let mag_stat = self .stats - .get(&StatHashes::MAGAZINE.into()) + .get(&StatHashes::Magazine.into()) .unwrap_or(&Stat::new()) .val(); let inv_stat = self .stats - .get(&StatHashes::INVENTORY_SIZE.into()) + .get(&StatHashes::InventorySize.into()) .unwrap_or(&Stat::new()) .val(); let mut out; @@ -438,7 +438,7 @@ impl Weapon { let total_stability: f64 = self .stats - .get(&StatHashes::STABILITY.into()) + .get(&StatHashes::Stability.into()) .unwrap_or(&Stat::new()) .perk_val() .clamp(0, 100) @@ -517,7 +517,7 @@ impl Weapon { WeaponType::GLAIVE => { f64::from( self.stats - .get(&StatHashes::RANGE.into()) + .get(&StatHashes::Range.into()) .unwrap_or(&Stat::new()) .perk_val() .clamp(0, 100), @@ -527,7 +527,7 @@ impl Weapon { WeaponType::GRENADELAUNCHER => { f64::from( self.stats - .get(&StatHashes::VELOCITY.into()) + .get(&StatHashes::Velocity.into()) .unwrap_or(&Stat::new()) .perk_val() .clamp(0, 100), @@ -537,7 +537,7 @@ impl Weapon { WeaponType::ROCKET => { f64::from( self.stats - .get(&StatHashes::VELOCITY.into()) + .get(&StatHashes::Velocity.into()) .unwrap_or(&Stat::new()) .perk_val() .clamp(0, 100), @@ -559,7 +559,7 @@ impl Weapon { pub fn calc_perfect_draw(&self) -> Seconds { let stability: f64 = self .stats - .get(&StatHashes::STABILITY.into()) + .get(&StatHashes::Stability.into()) .unwrap_or(&Stat::new()) .perk_val() .clamp(0, 100) @@ -580,7 +580,7 @@ impl Weapon { if self.weapon_type == WeaponType::GLAIVE { let shield_duration: f64 = self .stats - .get(&StatHashes::SHIELD_DURATION.into()) + .get(&StatHashes::ShieldDuration.into()) .unwrap_or(&Stat::new()) .perk_val() .clamp(0, 100) @@ -589,7 +589,7 @@ impl Weapon { } else if self.weapon_type == WeaponType::SWORD { let guard_endruance: f64 = self .stats - .get(&StatHashes::GUARD_ENDURANCE.into()) + .get(&StatHashes::GuardEndurance.into()) .unwrap_or(&Stat::new()) .perk_val() .clamp(0, 100) From 6c26fe4cb095f77e51b5e8b29dfd4c9961ab883a Mon Sep 17 00:00:00 2001 From: oh-yes-0-fps Date: Wed, 13 Sep 2023 23:19:41 -0400 Subject: [PATCH 37/38] re-add unreachable pub --- README.md | 8 ++++---- build.rs | 2 +- src/lib.rs | 7 ++++--- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 93ddffc4..cf6d9dd7 100644 --- a/README.md +++ b/README.md @@ -8,13 +8,13 @@ Oracle Engine is [Foundry](https://d2foundry.gg)'s Rust and WebAssembly based Destiny 2 calculation API, originally forked from the [D2 Calculation API](https://github.com/D2-Insight/D2_Calculation_API). This repo is what holds the weapon formulas, stat calculations, perk info, etc. that we use to display on Foundry. -This is also where we plan on having our project board for keeping track of our tasks on a lower level. We hope that this will give insight on what we are spending our time on and what is in the near future. +This is also where we plan on having our project board for keeping track of our tasks on a lower level. We hope that this will give insight on what we are spending our time on and what is in the near future. -If you wish to interact with us on a closer basis, our [Discord Server](https://discord.gg/dzW2DZBBQH) is where you can find us and have discussions with like minded guardians. We look forward to seeing you there! +If you wish to interact with us on a closer basis, our [Discord Server](https://discord.gg/dzW2DZBBQH) is where you can find us and have discussions with like minded guardians. We look forward to seeing you there! ## Building Oracle Engine -Run `cargo build` to install the dependencies required by Oracle Engine. +Run `cargo build` to install the dependencies required by Oracle Engine. In order to build the WebAssembly (wasm) pack you will need to download wasm-pack from this [site](https://rustwasm.github.io/wasm-pack/installer/) or via this cURL command: @@ -26,4 +26,4 @@ Once you have this installed you can build the app via this wasm-pack command. ## Contributing -Looking to help contribute to Foundry? We welcome you to contribute to our project! Please see our [CONTRIBUTING.md](./CONTRIBUTING.md) to learn the various ways you can help us. Thank you for having an interest in contributing! +Looking to help contribute to Foundry? We welcome you to contribute to our project! Please see our [CONTRIBUTING.md](./CONTRIBUTING.md) to learn the various ways you can help us. Thank you for having an interest in contributing! diff --git a/build.rs b/build.rs index e62da923..bcf8573e 100644 --- a/build.rs +++ b/build.rs @@ -358,7 +358,7 @@ fn write_variable( ) { let res = writeln!( writer, - "#[doc=r#\"{}\"#]\n#[allow(dead_code)]\n#[allow(clippy::approx_constant)]\npub const {}: {} = {};", + "#[doc=r#\"{}\"#]\n#[allow(dead_code)]\n#[allow(clippy::approx_constant)]\npub(crate) const {}: {} = {};", doc, name, datatype, value ); if res.is_err() { diff --git a/src/lib.rs b/src/lib.rs index bdfc7c5f..59f2e0f1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -20,7 +20,8 @@ trivial_numeric_casts, unused_import_braces, unused_lifetimes, - redundant_semicolons + redundant_semicolons, + unreachable_pub )] @@ -57,11 +58,11 @@ use lol_alloc::{AssumeSingleThreaded, FreeListAllocator}; static ALLOCATOR: AssumeSingleThreaded = unsafe { AssumeSingleThreaded::new(FreeListAllocator::new()) }; -mod built_info { +pub mod built_info { include!(concat!(env!("OUT_DIR"), "/built.rs")); } -mod database { +pub(crate) mod database { include!(concat!(env!("OUT_DIR"), "/formulas.rs")); } From a92074a7ee975c5d1a1401c5e6cc6f2fa1ad1c27 Mon Sep 17 00:00:00 2001 From: oh-yes-0-fps Date: Thu, 14 Sep 2023 18:37:36 -0400 Subject: [PATCH 38/38] removed js_types --- src/activity/damage_calc.rs | 2 +- src/enemies/mod.rs | 4 +- src/lib.rs | 130 +++++++++++++++++------------------- src/test.rs | 4 +- src/types/js_types.rs | 106 ++++++++++++++--------------- src/types/mod.rs | 10 ++- src/types/rs_types.rs | 93 ++++++++++++++++---------- src/weapons/mod.rs | 1 + src/weapons/ttk_calc.rs | 71 ++++++++++---------- 9 files changed, 217 insertions(+), 204 deletions(-) diff --git a/src/activity/damage_calc.rs b/src/activity/damage_calc.rs index 7464f744..f805be58 100644 --- a/src/activity/damage_calc.rs +++ b/src/activity/damage_calc.rs @@ -11,7 +11,7 @@ pub struct DifficultyData { const WEAPON_DELTA_EXPONENT: f64 = 0.00672; -#[derive(Debug, Clone, Copy, Default)] +#[derive(Debug, Clone, Copy, Default, serde::Deserialize)] pub enum DifficultyOptions { #[default] Normal = 1, diff --git a/src/enemies/mod.rs b/src/enemies/mod.rs index a60ca554..6c45bd38 100644 --- a/src/enemies/mod.rs +++ b/src/enemies/mod.rs @@ -1,6 +1,6 @@ use crate::activity::Activity; -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, serde::Deserialize)] pub enum EnemyType { Minor, Elite, @@ -18,7 +18,7 @@ pub struct Enemy { pub health: f64, pub damage: f64, pub damage_resistance: f64, - pub type_: EnemyType, + pub r#type: EnemyType, pub tier: u8, } impl Enemy { diff --git a/src/lib.rs b/src/lib.rs index 59f2e0f1..38a81171 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -24,8 +24,6 @@ unreachable_pub )] - - extern crate alloc; use logging::LogLevel; @@ -62,18 +60,25 @@ pub mod built_info { include!(concat!(env!("OUT_DIR"), "/built.rs")); } +#[derive(Debug, Clone, Copy, serde::Serialize)] +#[serde(rename_all(serialize = "camelCase"))] +pub struct MetaData { + pub api_version: &'static str, + pub api_timestamp: &'static str, + pub api_commit: &'static str, + pub api_branch: &'static str, +} + pub(crate) mod database { include!(concat!(env!("OUT_DIR"), "/formulas.rs")); } //JavaScript -use crate::types::prelude::*; +use crate::types::*; use wasm_bindgen::prelude::*; -use crate::types::js_types::JsScalarResponse; - #[derive(Debug, Clone, Default)] pub struct PersistentData { pub weapon: Weapon, @@ -114,15 +119,15 @@ pub fn start() { //---------------WEAPONS---------------// #[wasm_bindgen(js_name = "getMetadata")] -pub fn get_metadata() -> Result { +pub fn get_metadata() -> Result { #[allow(clippy::unwrap_used)] - let metadata = JsMetaData { + let metadata = MetaData { api_timestamp: built_info::BUILT_TIME_UTC, api_version: built_info::PKG_VERSION, api_commit: built_info::GIT_COMMIT_HASH.unwrap(), api_branch: built_info::GIT_HEAD_REF.unwrap(), }; - Ok(metadata) + serde_wasm_bindgen::to_value(&metadata).map_err(JsValue::from) } #[wasm_bindgen(js_name = "stringifyWeapon")] @@ -146,7 +151,7 @@ pub fn set_weapon( _intrinsic_hash: u32, _ammo_type_id: u32, _damage_type_id: u32, -) -> Result<(), JsValue> { +) { PERS_DATA.with(|perm_data| { let new_weapon = Weapon::generate_weapon( _hash, @@ -170,22 +175,18 @@ pub fn set_weapon( perm_data.borrow_mut().weapon = Weapon::default(); } }); - Ok(()) } #[wasm_bindgen(js_name = "getStats")] pub fn get_stats() -> Result { let stat_map = PERS_DATA.with(|perm_data| perm_data.borrow().weapon.stats.clone()); - let mut js_stat_map = HashMap::new(); - for (key, value) in stat_map { - js_stat_map.insert(key, JsStat::from(value)); - } - serde_wasm_bindgen::to_value(&js_stat_map).map_err(JsValue::from) + serde_wasm_bindgen::to_value(&stat_map).map_err(JsValue::from) } #[wasm_bindgen(js_name = "setStats")] pub fn set_stats(_stats: JsValue) -> Result<(), JsValue> { - let in_stats: HashMap = serde_wasm_bindgen::from_value(_stats).map_err(JsValue::from)?; + let in_stats: HashMap = + serde_wasm_bindgen::from_value(_stats).map_err(JsValue::from)?; let mut stats = HashMap::new(); for (key, value) in in_stats { stats.insert(key, Stat::from(value)); @@ -209,9 +210,8 @@ pub fn add_perk(_stats: JsValue, _value: u32, _hash: u32) -> Result<(), JsValue> } #[wasm_bindgen(js_name = "resetTraits")] -pub fn reset_perks() -> Result<(), JsValue> { +pub fn reset_perks() { PERS_DATA.with(|perm_data| perm_data.borrow_mut().weapon.reset_perks()); - Ok(()) } #[wasm_bindgen(js_name = "getTraitHashes")] @@ -235,67 +235,61 @@ pub fn get_perk_options_js(_perks: Vec) -> Result { let options = perks::perk_options_handler::get_perk_options(_perks); match serde_wasm_bindgen::to_value(&options) { Ok(value) => Ok(value), - Err(_) => Err(JsValue::from_str("Could not convert perk options to JsValue")), + Err(_) => Err(JsValue::from_str( + "Could not convert perk options to JsValue", + )), } } #[wasm_bindgen(js_name = "getWeaponRangeFalloff")] -pub fn get_weapon_range(_dynamic_traits: bool, _pvp: bool) -> Result { +pub fn get_weapon_range(_dynamic_traits: bool, _pvp: bool) -> Result { let weapon = PERS_DATA.with(|perm_data| perm_data.borrow().weapon.clone()); - if _dynamic_traits { - Ok(weapon - .calc_range_falloff(Some(weapon.static_calc_input()), None, _pvp) - .into()) + let out = if _dynamic_traits { + weapon.calc_range_falloff(Some(weapon.static_calc_input()), None, _pvp) } else { - Ok(weapon.calc_range_falloff(None, None, _pvp).into()) - } + weapon.calc_range_falloff(None, None, _pvp) + }; + serde_wasm_bindgen::to_value(&out).map_err(JsValue::from) } #[wasm_bindgen(js_name = "getWeaponHandlingTimes")] -pub fn get_weapon_handling( - _dynamic_traits: bool, - _pvp: bool, -) -> Result { +pub fn get_weapon_handling(_dynamic_traits: bool, _pvp: bool) -> Result { let weapon = PERS_DATA.with(|perm_data| perm_data.borrow().weapon.clone()); - if _dynamic_traits { - Ok(weapon - .calc_handling_times(Some(weapon.static_calc_input()), None, _pvp) - .into()) + let out = if _dynamic_traits { + weapon.calc_handling_times(Some(weapon.static_calc_input()), None, _pvp) } else { - Ok(weapon.calc_handling_times(None, None, _pvp).into()) - } + weapon.calc_handling_times(None, None, _pvp) + }; + serde_wasm_bindgen::to_value(&out).map_err(JsValue::from) } #[wasm_bindgen(js_name = "getWeaponReloadTimes")] -pub fn get_weapon_reload(_dynamic_traits: bool, _pvp: bool) -> Result { +pub fn get_weapon_reload(_dynamic_traits: bool, _pvp: bool) -> Result { let weapon = PERS_DATA.with(|perm_data| perm_data.borrow().weapon.clone()); - if _dynamic_traits { - Ok(weapon - .calc_reload_time(Some(weapon.static_calc_input()), None, _pvp) - .into()) + let out = if _dynamic_traits { + weapon.calc_reload_time(Some(weapon.static_calc_input()), None, _pvp) } else { - Ok(weapon.calc_reload_time(None, None, _pvp).into()) - } + weapon.calc_reload_time(None, None, _pvp) + }; + serde_wasm_bindgen::to_value(&out).map_err(JsValue::from) } #[wasm_bindgen(js_name = "getWeaponAmmoSizes")] -pub fn get_weapon_ammo(_dynamic_traits: bool, _pvp: bool) -> Result { +pub fn get_weapon_ammo(_dynamic_traits: bool, _pvp: bool) -> Result { let weapon = PERS_DATA.with(|perm_data| perm_data.borrow().weapon.clone()); - if _dynamic_traits { - Ok(weapon - .calc_ammo_sizes(Some(weapon.static_calc_input()), None, _pvp) - .into()) + let out = if _dynamic_traits { + weapon.calc_ammo_sizes(Some(weapon.static_calc_input()), None, _pvp) } else { - Ok(weapon.calc_ammo_sizes(None, None, _pvp).into()) - } + weapon.calc_ammo_sizes(None, None, _pvp) + }; + serde_wasm_bindgen::to_value(&out).map_err(JsValue::from) } #[wasm_bindgen(js_name = "getWeaponTtk")] pub fn get_weapon_ttk(_overshield: f64) -> Result { let weapon = PERS_DATA.with(|perm_data| perm_data.borrow().weapon.clone()); let ttk_data = weapon.calc_ttk(_overshield); - let js_ttk_data: Vec = ttk_data.into_iter().map(|r| r.into()).collect(); - serde_wasm_bindgen::to_value(&js_ttk_data).map_err(JsValue::from) + serde_wasm_bindgen::to_value(&ttk_data).map_err(JsValue::from) } ///DEPRECATED for now @@ -318,12 +312,12 @@ pub fn get_weapon_firing_data( _dynamic_traits: bool, _pvp: bool, _use_rpl: bool, -) -> Result { +) -> Result { let persistent = PERS_DATA.with(|_perm_data| _perm_data.borrow().clone()); let mut response: types::rs_types::FiringResponse; let calc_input: Option = if _dynamic_traits { let mut buffer = persistent.weapon.static_calc_input(); - buffer.enemy_type = &persistent.enemy.type_; + buffer.enemy_type = &persistent.enemy.r#type; Some(buffer) } else { None @@ -336,10 +330,9 @@ pub fn get_weapon_firing_data( persistent .weapon .damage_mods - .get_mod(&persistent.enemy.type_), + .get_mod(&persistent.enemy.r#type), ); - crate::logging::log(format!("{:?}", response).as_str(), LogLevel::Debug.into()); - Ok(response.into()) + serde_wasm_bindgen::to_value(&response).map_err(JsValue::from) } #[wasm_bindgen(js_name = "getWeaponFlinch")] @@ -365,10 +358,8 @@ pub fn get_weapon_flinch( pub fn get_misc_data(_dynamic_traits: bool, _pvp: bool) -> Result { let weapon = PERS_DATA.with(|perm_data| perm_data.borrow().weapon.clone()); if _dynamic_traits { - serde_wasm_bindgen::to_value( - &weapon.get_misc_stats(Some(weapon.static_calc_input()), _pvp), - ) - .map_err(JsValue::from) + serde_wasm_bindgen::to_value(&weapon.get_misc_stats(Some(weapon.static_calc_input()), _pvp)) + .map_err(JsValue::from) } else { serde_wasm_bindgen::to_value(&weapon.get_misc_stats(None, _pvp)).map_err(JsValue::from) } @@ -380,20 +371,22 @@ pub fn set_encounter( _player_pl: u32, _weapon_pl: u32, _override_cap: i32, - _difficulty: JsDifficultyOptions, - _enemy_type: JsEnemyType, + _difficulty: JsValue, + _enemy_type: JsValue, ) -> Result<(), JsValue> { + let difficulty = serde_wasm_bindgen::from_value(_difficulty).map_err(JsValue::from)?; PERS_DATA.with(|perm_data| { let activity = &mut perm_data.borrow_mut().activity; activity.rpl = _recommend_pl; activity.cap = _override_cap; - activity.difficulty = _difficulty.into(); + activity.difficulty = difficulty; activity.player.power = _player_pl; activity.player.wep_power = _weapon_pl; }); + let enemy_type = serde_wasm_bindgen::from_value(_enemy_type).map_err(JsValue::from)?; PERS_DATA.with(|perm_data| { let enemy = &mut perm_data.borrow_mut().enemy; - enemy.type_ = _enemy_type.into(); + enemy.r#type = enemy_type; }); Ok(()) } @@ -418,7 +411,7 @@ pub fn get_modifier_response(_dynamic_traits: bool, _pvp: bool) -> Result Result { +pub fn get_scalar_response(_pvp: bool) -> Result { let weapon = PERS_DATA.with(|perm_data| perm_data.borrow().weapon.clone()); let input_data = weapon.static_calc_input(); let mut cached_data = HashMap::new(); @@ -429,7 +422,7 @@ pub fn get_scalar_response(_pvp: bool) -> Result { let hmr = perks::get_handling_modifier(weapon.list_perks(), &input_data, _pvp, &mut cached_data); let imr = perks::get_reserve_modifier(weapon.list_perks(), &input_data, _pvp, &mut cached_data); - Ok(JsScalarResponse { + let out = ScalarResponse { ads_range_scalar: rmr.range_zoom_scale, global_range_scalar: rmr.range_all_scale, hipfire_range_scalar: rmr.range_hip_scale, @@ -439,5 +432,6 @@ pub fn get_scalar_response(_pvp: bool) -> Result { reload_scalar: rsmr.reload_time_scale, mag_size_scalar: mmr.magazine_scale, reserve_size_scalar: imr.inv_scale, - }) + }; + serde_wasm_bindgen::to_value(&out).map_err(JsValue::from) } diff --git a/src/test.rs b/src/test.rs index 6214a4c8..5cc51e43 100644 --- a/src/test.rs +++ b/src/test.rs @@ -149,7 +149,7 @@ fn test_pulse_firing_data() { .borrow() .weapon .damage_mods - .get_mod(&perm_data.borrow().enemy.type_), + .get_mod(&perm_data.borrow().enemy.r#type), ) }); assert!( @@ -289,7 +289,7 @@ fn test_bow_firing_data() { .borrow() .weapon .damage_mods - .get_mod(&perm_data.borrow().enemy.type_), + .get_mod(&perm_data.borrow().enemy.r#type), ) }); assert!( diff --git a/src/types/js_types.rs b/src/types/js_types.rs index d9503836..a3d715c8 100644 --- a/src/types/js_types.rs +++ b/src/types/js_types.rs @@ -9,10 +9,10 @@ use crate::{ }, }; use serde::{Deserialize, Serialize}; -use wasm_bindgen::{prelude::wasm_bindgen, JsValue}; +use wasm_bindgen::prelude::wasm_bindgen; use super::rs_types::{ - AmmoResponse, DpsResponse, FiringResponse, HandlingResponse, RangeResponse, ReloadResponse, + AmmoResponse, FiringResponse, HandlingResponse, RangeResponse, ReloadResponse, }; #[derive(Debug, Clone, Copy, Serialize)] @@ -107,57 +107,57 @@ impl From for JsAmmoResponse { } } -#[derive(Debug, Clone, Serialize)] -#[wasm_bindgen(js_name = "DpsResponse")] -pub struct JsDpsResponse { - #[wasm_bindgen(skip)] - pub dps_per_mag: Vec, - #[wasm_bindgen(skip)] - pub time_damage_data: Vec<(f64, f64)>, - #[wasm_bindgen(js_name = "totalDamage", readonly)] - pub total_damage: f64, - #[wasm_bindgen(js_name = "totalTime", readonly)] - pub total_time: f64, - #[wasm_bindgen(js_name = "totalShots", readonly)] - pub total_shots: i32, -} -#[allow(clippy::unwrap_used)] -#[wasm_bindgen(js_class = "DpsResponse")] -impl JsDpsResponse { - #[wasm_bindgen(js_name = "toJSON")] - pub fn to_json(self) -> String { - serde_wasm_bindgen::to_value(&self) - .unwrap() - .as_string() - .unwrap() - } - ///Returns a list of tuples of time and damage - #[wasm_bindgen(getter, js_name = "timeDamageData")] - pub fn time_damage_data(&self) -> JsValue { - serde_wasm_bindgen::to_value(&self.time_damage_data).unwrap() - } - ///Returns a list of dps values for each magazine - #[wasm_bindgen(getter, js_name = "dpsPerMag")] - pub fn dps_per_mag(&self) -> JsValue { - serde_wasm_bindgen::to_value(&self.dps_per_mag).unwrap() - } -} -impl fmt::Display for JsDpsResponse { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{:?}", self) - } -} -impl From for JsDpsResponse { - fn from(dps: DpsResponse) -> Self { - JsDpsResponse { - dps_per_mag: dps.dps_per_mag, - time_damage_data: dps.time_damage_data, - total_damage: dps.total_damage, - total_time: dps.total_time, - total_shots: dps.total_shots, - } - } -} +// #[derive(Debug, Clone, Serialize)] +// #[wasm_bindgen(js_name = "DpsResponse")] +// pub struct JsDpsResponse { +// #[wasm_bindgen(skip)] +// pub dps_per_mag: Vec, +// #[wasm_bindgen(skip)] +// pub time_damage_data: Vec<(f64, f64)>, +// #[wasm_bindgen(js_name = "totalDamage", readonly)] +// pub total_damage: f64, +// #[wasm_bindgen(js_name = "totalTime", readonly)] +// pub total_time: f64, +// #[wasm_bindgen(js_name = "totalShots", readonly)] +// pub total_shots: i32, +// } +// #[allow(clippy::unwrap_used)] +// #[wasm_bindgen(js_class = "DpsResponse")] +// impl JsDpsResponse { +// #[wasm_bindgen(js_name = "toJSON")] +// pub fn to_json(self) -> String { +// serde_wasm_bindgen::to_value(&self) +// .unwrap() +// .as_string() +// .unwrap() +// } +// ///Returns a list of tuples of time and damage +// #[wasm_bindgen(getter, js_name = "timeDamageData")] +// pub fn time_damage_data(&self) -> JsValue { +// serde_wasm_bindgen::to_value(&self.time_damage_data).unwrap() +// } +// ///Returns a list of dps values for each magazine +// #[wasm_bindgen(getter, js_name = "dpsPerMag")] +// pub fn dps_per_mag(&self) -> JsValue { +// serde_wasm_bindgen::to_value(&self.dps_per_mag).unwrap() +// } +// } +// impl fmt::Display for JsDpsResponse { +// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { +// write!(f, "{:?}", self) +// } +// } +// impl From for JsDpsResponse { +// fn from(dps: DpsResponse) -> Self { +// JsDpsResponse { +// dps_per_mag: dps.dps_per_mag, +// time_damage_data: dps.time_damage_data, +// total_damage: dps.total_damage, +// total_time: dps.total_time, +// total_shots: dps.total_shots, +// } +// } +// } #[derive(Debug, Clone, Copy, Serialize)] #[wasm_bindgen(js_name = "OptimalKillData", inspectable)] diff --git a/src/types/mod.rs b/src/types/mod.rs index 029e94ae..0dcaa5e4 100644 --- a/src/types/mod.rs +++ b/src/types/mod.rs @@ -1,10 +1,8 @@ -pub mod js_types; +// pub mod js_types; pub mod formula_types; pub mod rs_types; -pub mod prelude { - pub use super::formula_types::*; - pub use super::js_types::*; - pub use super::rs_types::*; -} + +pub use super::formula_types::*; +pub use super::rs_types::*; diff --git a/src/types/rs_types.rs b/src/types/rs_types.rs index ec1c7c6b..a201a68a 100644 --- a/src/types/rs_types.rs +++ b/src/types/rs_types.rs @@ -1,6 +1,9 @@ +use serde::Serialize; -#[derive(Debug, Clone, Copy, Default)] +#[derive(Debug, Clone, Copy, Default, Serialize)] + +#[serde(rename_all(serialize = "camelCase"))] pub struct RangeResponse { pub hip_falloff_start: f64, pub hip_falloff_end: f64, @@ -10,7 +13,8 @@ pub struct RangeResponse { pub timestamp: u64, } -#[derive(Debug, Clone, Default, Copy)] +#[derive(Debug, Clone, Copy, Default, Serialize)] +#[serde(rename_all(serialize = "camelCase"))] pub struct HandlingResponse { pub ready_time: f64, pub stow_time: f64, @@ -18,53 +22,56 @@ pub struct HandlingResponse { pub timestamp: u64, } -#[derive(Debug, Clone, Default, Copy)] +#[derive(Debug, Clone, Copy, Default, Serialize)] +#[serde(rename_all(serialize = "camelCase"))] pub struct AmmoResponse { pub mag_size: i32, pub reserve_size: i32, pub timestamp: u64, } -#[derive(Debug, Clone, Default, Copy)] +#[derive(Debug, Clone, Copy, Default, Serialize)] +#[serde(rename_all(serialize = "camelCase"))] pub struct ReloadResponse { pub reload_time: f64, pub ammo_time: f64, pub timestamp: u64, } -#[derive(Debug, Clone, Default)] -pub struct DpsResponse { - pub dps_per_mag: Vec, - pub time_damage_data: Vec<(f64, f64)>, - pub total_damage: f64, - pub total_time: f64, - pub total_shots: i32, -} -impl DpsResponse { - pub fn apply_rpl(&mut self, rpl: f64) { - for mag in self.dps_per_mag.iter_mut() { - *mag *= rpl; - } - for (_, damage) in self.time_damage_data.iter_mut() { - *damage *= rpl; - } - self.total_damage *= rpl; - } - pub fn get_dps_over_time(&self) -> Vec<(f64, f64)> { - let dps_data = &self.time_damage_data; - let mut damage_so_far = dps_data[0].1; - let mut dps_lst = Vec::new(); - for hit in dps_data { - if hit.0 != 0.0 { - dps_lst.push((hit.0, damage_so_far / hit.0)); - } - damage_so_far += hit.1; - } - dps_lst - } -} +// #[derive(Debug, Clone, Default)] +// pub struct DpsResponse { +// pub dps_per_mag: Vec, +// pub time_damage_data: Vec<(f64, f64)>, +// pub total_damage: f64, +// pub total_time: f64, +// pub total_shots: i32, +// } +// impl DpsResponse { +// pub fn apply_rpl(&mut self, rpl: f64) { +// for mag in self.dps_per_mag.iter_mut() { +// *mag *= rpl; +// } +// for (_, damage) in self.time_damage_data.iter_mut() { +// *damage *= rpl; +// } +// self.total_damage *= rpl; +// } +// pub fn get_dps_over_time(&self) -> Vec<(f64, f64)> { +// let dps_data = &self.time_damage_data; +// let mut damage_so_far = dps_data[0].1; +// let mut dps_lst = Vec::new(); +// for hit in dps_data { +// if hit.0 != 0.0 { +// dps_lst.push((hit.0, damage_so_far / hit.0)); +// } +// damage_so_far += hit.1; +// } +// dps_lst +// } +// } -#[derive(Debug, Clone, Default, Copy)] +#[derive(Debug, Clone, Copy, Default, Serialize)] +#[serde(rename_all(serialize = "camelCase"))] pub struct FiringResponse { pub pvp_impact_damage: f64, pub pvp_explosion_damage: f64, @@ -94,3 +101,17 @@ impl FiringResponse { self.pve_explosion_damage *= _rpl_mult * _gpl_mult * _pve_mult * _combatant_mult; } } + +#[derive(Debug, Clone, Copy, Default, Serialize)] +#[serde(rename_all(serialize = "camelCase"))] +pub struct ScalarResponse { + pub reload_scalar: f64, + pub draw_scalar: f64, + pub ads_scalar: f64, + pub stow_scalar: f64, + pub global_range_scalar: f64, + pub hipfire_range_scalar: f64, + pub ads_range_scalar: f64, + pub mag_size_scalar: f64, + pub reserve_size_scalar: f64, +} \ No newline at end of file diff --git a/src/weapons/mod.rs b/src/weapons/mod.rs index 29bc85b0..48266be3 100644 --- a/src/weapons/mod.rs +++ b/src/weapons/mod.rs @@ -18,6 +18,7 @@ use crate::types::formula_types::{ }; #[derive(Debug, Clone, Copy, Serialize)] +#[serde(rename_all(serialize = "camelCase"))] pub struct Stat { pub base_value: i32, pub part_value: i32, diff --git a/src/weapons/ttk_calc.rs b/src/weapons/ttk_calc.rs index 9658e75e..f62e1add 100644 --- a/src/weapons/ttk_calc.rs +++ b/src/weapons/ttk_calc.rs @@ -14,39 +14,38 @@ const RESILIENCE_VALUES: [f64; 11] = [ ]; #[derive(Debug, Clone, Copy, Serialize)] +#[serde(rename_all(serialize = "camelCase"))] pub struct OptimalKillData { pub headshots: i32, pub bodyshots: i32, - #[serde(rename = "timeTaken")] pub time_taken: f64, } #[derive(Debug, Clone, Copy, Serialize)] +#[serde(rename_all(serialize = "camelCase"))] pub struct BodyKillData { pub bodyshots: i32, - #[serde(rename = "timeTaken")] pub time_taken: f64, } #[derive(Debug, Clone, Copy, Serialize)] +#[serde(rename_all(serialize = "camelCase"))] pub struct ResillienceSummary { pub value: i32, - #[serde(rename = "bodyTtk")] pub body_ttk: BodyKillData, - #[serde(rename = "optimalTtk")] pub optimal_ttk: OptimalKillData, } -pub fn calc_ttk(_weapon: &Weapon, _overshield: f64) -> Vec { +pub fn calc_ttk(weapon: &Weapon, overshield: f64) -> Vec { let mut ttk_data: Vec = Vec::new(); let mut persistent_data: HashMap = HashMap::new(); - let tmp_dmg_prof = _weapon.get_damage_profile(); + let tmp_dmg_prof = weapon.get_damage_profile(); let impact_dmg = tmp_dmg_prof.0; let explosion_dmg = tmp_dmg_prof.1; let mut crit_mult = tmp_dmg_prof.2; // let damage_delay = tmp_dmg_prof.3; - if _weapon.weapon_type == WeaponType::SHOTGUN && _weapon.firing_data.burst_size == 12 { + if weapon.weapon_type == WeaponType::SHOTGUN && weapon.firing_data.burst_size == 12 { crit_mult = 1.0; // shawty has no crits } @@ -68,20 +67,20 @@ pub fn calc_ttk(_weapon: &Weapon, _overshield: f64) -> Vec { persistent_data.insert("empowering".to_string(), 1.0); persistent_data.insert("debuff".to_string(), 1.0); persistent_data.insert("surge".to_string(), 1.0); - let calc_input = _weapon.pvp_calc_input( + let calc_input = weapon.pvp_calc_input( opt_bullets_fired, opt_bullets_hit, opt_time_taken, - (_overshield - opt_damage_dealt) > 0.0, + (overshield - opt_damage_dealt) > 0.0, ); let dmg_mods = get_dmg_modifier( - _weapon.list_perks().clone(), + weapon.list_perks().clone(), &calc_input, true, &mut persistent_data, ); let firing_mods = get_firing_modifier( - _weapon.list_perks().clone(), + weapon.list_perks().clone(), &calc_input, true, &mut persistent_data, @@ -94,12 +93,12 @@ pub fn calc_ttk(_weapon: &Weapon, _overshield: f64) -> Vec { let head_diff = ((impact_dmg * dmg_mods.impact_dmg_scale) * critical_multiplier) - (impact_dmg * dmg_mods.impact_dmg_scale); - let shot_burst_delay = (_weapon.firing_data.burst_delay + firing_mods.burst_delay_add) + let shot_burst_delay = (weapon.firing_data.burst_delay + firing_mods.burst_delay_add) * firing_mods.burst_delay_scale; let shot_inner_burst_delay = - _weapon.firing_data.inner_burst_delay * firing_mods.inner_burst_scale; + weapon.firing_data.inner_burst_delay * firing_mods.inner_burst_scale; let shot_burst_size = - _weapon.firing_data.burst_size as f64 + firing_mods.burst_size_add; + weapon.firing_data.burst_size as f64 + firing_mods.burst_size_add; let mut shot_delay = if opt_bullets_hit % shot_burst_size > 0.0 && opt_bullets_hit > 0.0 { @@ -110,25 +109,25 @@ pub fn calc_ttk(_weapon: &Weapon, _overshield: f64) -> Vec { shot_burst_delay }; - if _weapon.hash == 4289226715 { // vex mythoclast - } else if _weapon.weapon_type == WeaponType::LINEARFUSIONRIFLE { + if weapon.hash == 4289226715 { // vex mythoclast + } else if weapon.weapon_type == WeaponType::LINEARFUSIONRIFLE { shot_delay *= 1.95; - } else if _weapon.weapon_type == WeaponType::FUSIONRIFLE { + } else if weapon.weapon_type == WeaponType::FUSIONRIFLE { shot_delay *= 1.45; } - let ammo_fired = if _weapon.firing_data.one_ammo { + let ammo_fired = if weapon.firing_data.one_ammo { opt_bullets_hit / shot_burst_size } else { opt_bullets_fired }; if ammo_fired - mag_expended - >= _weapon + >= weapon .calc_ammo_sizes(Some(calc_input.clone()), Some(&mut persistent_data), true) .mag_size .into() { - shot_delay += _weapon + shot_delay += weapon .calc_reload_time(Some(calc_input.clone()), Some(&mut persistent_data), true) .reload_time; mag_expended += ammo_fired; @@ -191,39 +190,39 @@ pub fn calc_ttk(_weapon: &Weapon, _overshield: f64) -> Vec { persistent_data.insert("empowering".to_string(), 1.0); persistent_data.insert("debuff".to_string(), 1.0); persistent_data.insert("surge".to_string(), 1.0); - let calc_input = _weapon.pvp_calc_input( + let calc_input = weapon.pvp_calc_input( bdy_bullets_fired, bdy_bullets_hit, bdy_time_taken, - (_overshield - bdy_damage_dealt) > 0.0, + (overshield - bdy_damage_dealt) > 0.0, ); let dmg_mods = get_dmg_modifier( - _weapon.list_perks().clone(), + weapon.list_perks().clone(), &calc_input, true, &mut persistent_data, ); let firing_mods = get_firing_modifier( - _weapon.list_perks().clone(), + weapon.list_perks().clone(), &calc_input, true, &mut persistent_data, ); /////////////////////////////// - let tmp_dmg_prof = _weapon.get_damage_profile(); + let tmp_dmg_prof = weapon.get_damage_profile(); let impact_dmg = tmp_dmg_prof.0; let explosion_dmg = tmp_dmg_prof.1; let body_damage = (impact_dmg * dmg_mods.impact_dmg_scale) + (explosion_dmg * dmg_mods.explosive_dmg_scale); - let shot_burst_delay = (_weapon.firing_data.burst_delay + firing_mods.burst_delay_add) + let shot_burst_delay = (weapon.firing_data.burst_delay + firing_mods.burst_delay_add) * firing_mods.burst_delay_scale; let shot_inner_burst_delay = - _weapon.firing_data.inner_burst_delay * firing_mods.inner_burst_scale; + weapon.firing_data.inner_burst_delay * firing_mods.inner_burst_scale; let shot_burst_size = - _weapon.firing_data.burst_size as f64 + firing_mods.burst_size_add; + weapon.firing_data.burst_size as f64 + firing_mods.burst_size_add; let mut shot_delay = if bdy_bullets_hit % shot_burst_size > 0.0 && bdy_bullets_hit > 0.0 { @@ -234,25 +233,25 @@ pub fn calc_ttk(_weapon: &Weapon, _overshield: f64) -> Vec { shot_burst_delay }; - if _weapon.hash == 4289226715 { //vex mythoclast - } else if _weapon.weapon_type == WeaponType::LINEARFUSIONRIFLE { + if weapon.hash == 4289226715 { //vex mythoclast + } else if weapon.weapon_type == WeaponType::LINEARFUSIONRIFLE { shot_delay *= 1.95; - } else if _weapon.weapon_type == WeaponType::FUSIONRIFLE { + } else if weapon.weapon_type == WeaponType::FUSIONRIFLE { shot_delay *= 1.45; } - let ammo_fired = if _weapon.firing_data.one_ammo { + let ammo_fired = if weapon.firing_data.one_ammo { bdy_bullets_hit / shot_burst_size } else { bdy_bullets_fired }; if ammo_fired - mag_expended - >= _weapon + >= weapon .calc_ammo_sizes(Some(calc_input.clone()), Some(&mut persistent_data), true) .mag_size .into() { - shot_delay += _weapon + shot_delay += weapon .calc_reload_time(Some(calc_input.clone()), Some(&mut persistent_data), true) .reload_time; mag_expended += ammo_fired; @@ -286,7 +285,7 @@ pub fn calc_ttk(_weapon: &Weapon, _overshield: f64) -> Vec { } impl Weapon { - pub fn calc_ttk(&self, _overshield: f64) -> Vec { - calc_ttk(self, _overshield) + pub fn calc_ttk(&self, overshield: f64) -> Vec { + calc_ttk(self, overshield) } }