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..04563f61 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,12 +22,12 @@ 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" @@ -34,4 +36,5 @@ crate-type = ["cdylib"] [profile.release] lto = true +strip = true opt-level = "z" diff --git a/README.md b/README.md index e9612a94..cf6d9dd7 100644 --- a/README.md +++ b/README.md @@ -8,17 +8,17 @@ 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 for Foundry +## 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: -`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. @@ -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 3a2aea1d..bcf8573e 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 @@ -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() { @@ -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::rs_types::{{StatQuadraticFormula, RangeFormula, HandlingFormula, ReloadFormula, DamageMods, AmmoFormula, DataPointers, FiringData, WeaponPath}};"); + let res = writeln!(formula_file, "use crate::types::prelude::*;"); if res.is_err() { panic!("cargo:warning=error writing imports"); } @@ -496,8 +494,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 +645,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 +684,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 +750,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..2cf72ca9 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,8 +13,8 @@ pub enum AbilityType { UNKNOWN, } - -#[derive(Debug, Clone, Default)] +#[allow(dead_code)] +#[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 7bc92b98..f805be58 100644 --- a/src/activity/damage_calc.rs +++ b/src/activity/damage_calc.rs @@ -1,32 +1,29 @@ -#![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 { - name: String, + // name: String, cap: i32, table: PiecewiseLinearFunction, } const WEAPON_DELTA_EXPONENT: f64 = 0.00672; -#[derive(Debug, Clone)] -#[derive(Default)] +#[derive(Debug, Clone, Copy, Default, serde::Deserialize)] 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 { - name: "Normal".to_string(), + DifficultyOptions::Normal => DifficultyData { + // name: "Normal".to_string(), cap: 50, table: PiecewiseLinearFunction::try_from(vec![ (-99.0, 0.4018), @@ -41,10 +38,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(), + DifficultyOptions::Master => DifficultyData { + // name: "Master".to_string(), cap: 20, table: PiecewiseLinearFunction::try_from(vec![ (-99.0, 0.4018), @@ -59,10 +56,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(), + DifficultyOptions::Raid => DifficultyData { + // name: "Raid & Dungeon".to_string(), cap: 20, table: PiecewiseLinearFunction::try_from(vec![ (-99.0, 0.4018), @@ -77,7 +74,7 @@ impl DifficultyOptions { (-10.0, 0.73), (0.0, 0.925), ]) - .unwrap(), + .expect("Failed to create PiecewiseLinearFunction in difficulty data"), }, } } @@ -85,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, } } } @@ -111,7 +108,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 91a47bde..509b3987 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,8 +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, @@ -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/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 0b4e73ce..6c45bd38 100644 --- a/src/enemies/mod.rs +++ b/src/enemies/mod.rs @@ -1,26 +1,24 @@ use crate::activity::Activity; -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] -#[derive(Default)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, serde::Deserialize)] pub enum EnemyType { - MINOR, - ELITE, - MINIBOSS, - BOSS, - VEHICLE, + Minor, + Elite, + Miniboss, + Boss, + Vehicle, #[default] - ENCLAVE, - PLAYER, - CHAMPION, + Enclave, + Player, + Champion, } - -#[derive(Debug, Clone, Default)] +#[derive(Debug, Clone, Copy, Default)] 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 { @@ -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, + } + } +} diff --git a/src/lib.rs b/src/lib.rs index b7c424e3..38a81171 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,29 @@ -#![allow(dead_code)] -#![allow(unused_imports)] +// #![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, + unused_import_braces, + unused_lifetimes, + redundant_semicolons, + unreachable_pub +)] + extern crate alloc; use logging::LogLevel; @@ -15,44 +39,46 @@ 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; +// SAFETY: This application is single threaded, so using AssumeSingleThreaded is allowed. #[cfg(target_arch = "wasm32")] use lol_alloc::{AssumeSingleThreaded, FreeListAllocator}; - -// SAFETY: This application is single threaded, so using AssumeSingleThreaded is allowed. #[cfg(target_arch = "wasm32")] #[global_allocator] static ALLOCATOR: AssumeSingleThreaded = unsafe { AssumeSingleThreaded::new(FreeListAllocator::new()) }; -mod built_info { + +pub mod built_info { include!(concat!(env!("OUT_DIR"), "/built.rs")); } -mod database { +#[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::js_types::{ - JsAmmoResponse, JsDifficultyOptions, JsDpsResponse, JsEnemyType, JsFiringResponse, - JsHandlingResponse, JsMetaData, JsRangeResponse, JsReloadResponse, JsResillienceSummary, - JsStat, -}; +use crate::types::*; use wasm_bindgen::prelude::*; -use crate::types::js_types::JsScalarResponse; - #[derive(Debug, Clone, Default)] pub struct PersistentData { pub weapon: Weapon, @@ -93,20 +119,21 @@ pub fn start() { //---------------WEAPONS---------------// #[wasm_bindgen(js_name = "getMetadata")] -pub fn get_metadata() -> Result { - let metadata = JsMetaData { +pub fn get_metadata() -> Result { + #[allow(clippy::unwrap_used)] + 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")] 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) } // @@ -124,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, @@ -148,26 +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)); - } - 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(&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)); @@ -180,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, @@ -191,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")] @@ -215,72 +233,63 @@ 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( + 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")] -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(); - Ok(serde_wasm_bindgen::to_value(&js_ttk_data).unwrap()) + serde_wasm_bindgen::to_value(&ttk_data).map_err(JsValue::from) } ///DEPRECATED for now @@ -303,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 @@ -321,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")] @@ -350,12 +358,10 @@ 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( - &weapon.get_misc_stats(Some(weapon.static_calc_input()), _pvp), - ) - .unwrap()) + serde_wasm_bindgen::to_value(&weapon.get_misc_stats(Some(weapon.static_calc_input()), _pvp)) + .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) } } @@ -365,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(()) } @@ -399,11 +407,11 @@ 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(); @@ -414,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, @@ -424,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/logging.rs b/src/logging.rs index 814d9885..572baa8c 100644 --- a/src/logging.rs +++ b/src/logging.rs @@ -1,5 +1,5 @@ -#[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,16 +29,14 @@ impl From for usize { } } - fn get_log_level() -> LogLevel { crate::PERS_DATA.with(|perm_data| perm_data.borrow().log_level) } 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/buff_perks.rs b/src/perks/buff_perks.rs index 44dcb5fd..3fe39c77 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,15 +338,15 @@ 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, - DamageType::STASIS | DamageType::ARC + DamageType::Stasis | DamageType::Arc ) { surge_buff(_input.cached_data, 4, _input.pvp) } else { @@ -357,12 +357,12 @@ pub fn buff_perks() { explosive_dmg_scale: buff, ..Default::default() } - }), + }, ); add_dmr( Perks::SanguineAlchemy, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { - if _input.value == 0 || *_input.calc_data.damage_type == DamageType::KINETIC { + |_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..bc7239bd 100644 --- a/src/perks/exotic_armor.rs +++ b/src/perks/exotic_armor.rs @@ -19,20 +19,20 @@ 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 { + if _input.calc_data.damage_type == &DamageType::Stasis && _input.value >= 1 { modifier.impact_dmg_scale = value; 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 = @@ -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,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,48 +176,30 @@ 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::DrawTime.into(), 10); + }; + stats + }, ); - /*add_fmr( - Perks::Oathkeeper, - Box::new(|_input: ModifierResponsInput| -> FiringModifierResponse { - FiringModifierResponse { - burst_delay_add: match _input.calc_data.intrinsic_hash { - 906 => -36.0 / 1100.0, - 905 => -40.0 / 1100.0, - _ => 0.0, - }, - ..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 +207,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 +255,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 +455,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 +480,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 +493,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.insert(StatHashes::Reload.into(), 50); } stats - }), - ) + }, + ); } diff --git a/src/perks/exotic_perks.rs b/src/perks/exotic_perks.rs index 639b9d2b..91b70c99 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 @@ -59,16 +57,16 @@ 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 - }), + }, ); 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.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,28 +491,28 @@ 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 { 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 - }), + }, ); 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,58 +536,56 @@ 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); - 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 - }), + }, ); 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.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.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.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.insert(StatHashes::Range.into(), 8 * val); + out.insert(StatHashes::AimAssist.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,12 @@ 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 +1135,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..3b8a53c8 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::{formula_types::FiringDataFormula, rs_types::HandlingResponse}, 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, @@ -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, } @@ -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, @@ -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, } @@ -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, @@ -136,14 +136,14 @@ 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, } } } -#[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 c89fec7c..bade37bb 100644 --- a/src/perks/meta_perks.rs +++ b/src/perks/meta_perks.rs @@ -21,23 +21,23 @@ 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 { 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,8 +49,8 @@ pub fn meta_perks() { let charge_time = _input .calc_data .stats - .get(&StatHashes::CHARGE_TIME.into()) - .unwrap(); + .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 let total_damage = _input.calc_data.curr_firing_data.damage @@ -64,13 +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 { - #[allow(unused_mut)] + |_input: ModifierResponseInput| -> FiringModifierResponse { let mut delay_add = 0.0; if matches!( @@ -81,8 +80,8 @@ pub fn meta_perks() { let charge_time = _input .calc_data .stats - .get(&StatHashes::CHARGE_TIME.into()) - .unwrap(); + .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 { WeaponType::FUSIONRIFLE => stat * 0.0040, @@ -95,9 +94,8 @@ pub fn meta_perks() { let draw_time = _input .calc_data .stats - .get(&StatHashes::DRAW_TIME.into()) - .unwrap() - .clone(); + .get(&StatHashes::DrawTime.into()) + .expect("Draw time not found"); delay_add += match _input.calc_data.intrinsic_hash { //Lightweights, Wishender, Ticcus, Verglas 905 | 1470121888 | 3239299468 | 2636679416 => { @@ -116,120 +114,112 @@ 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::BlastRadius.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); + 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 - }), + }, ); 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; @@ -238,14 +228,14 @@ 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 - }), + }, ); add_rsmr( Perks::LoaderMod, - Box::new(|_input: ModifierResponseInput| -> ReloadModifierResponse { + |_input: ModifierResponseInput| -> ReloadModifierResponse { let stat = match _input.value { 0 => 0, 1 => 10, @@ -258,12 +248,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, @@ -271,14 +261,14 @@ pub fn meta_perks() { 2 => 15, 3.. => 18, }; - stats.insert(StatHashes::RELOAD.into(), buff); + 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 +278,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.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 +328,6 @@ pub fn meta_perks() { }, ..Default::default() } - }), + }, ); } diff --git a/src/perks/mod.rs b/src/perks/mod.rs index 3057f174..24dee673 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,11 +470,12 @@ 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>; -#[derive(Default)] +#[derive(Default, Debug)] pub struct PersistentModifierResponses { pub sbr: ModifierMap, pub dmr: ModifierMap, @@ -1044,7 +1049,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/origin_perks.rs b/src/perks/origin_perks.rs index 5c4b791d..80daef43 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,76 +53,76 @@ 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 }; 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 - }), + }, ); 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 }; 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 - }), + }, ); 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,28 +213,28 @@ 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 }; 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 - }), + }, ); 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.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.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,82 +299,76 @@ 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 { - 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 - }), + }, ); 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.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,65 +377,63 @@ 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.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); + 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 - }), + }, ); 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..3a81b8d9 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.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.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.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.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.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,98 +233,96 @@ 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.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.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 { - 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 - }), + }, ); 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 { buff += 50; }; - stats.insert(StatHashes::AIRBORNE.into(), buff); + 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); - 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 - }), + }, ); add_dmr( Perks::BossSpec, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { - let damage_mult = if *_input.calc_data.enemy_type == EnemyType::BOSS && !_input.pvp { + |_input: ModifierResponseInput| -> DamageModifierResponse { + let damage_mult = if *_input.calc_data.enemy_type == EnemyType::Boss && !_input.pvp { 1.077 } else { 1.0 @@ -348,15 +332,15 @@ 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 + EnemyType::Elite | EnemyType::Miniboss | EnemyType::Champion ) || _input.pvp { return DamageModifierResponse::default(); @@ -367,15 +351,15 @@ 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 + EnemyType::Elite | EnemyType::Miniboss | EnemyType::Champion | EnemyType::Boss ) || _input.pvp { return DamageModifierResponse::default(); @@ -386,13 +370,13 @@ pub fn other_perks() { explosive_dmg_scale: damage_mult, ..Default::default() } - }), + }, ); add_dmr( Perks::MinorSpec, - Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse { - let damage_mult = if _input.calc_data.enemy_type == &EnemyType::MINOR && !_input.pvp { + |_input: ModifierResponseInput| -> DamageModifierResponse { + let damage_mult = if _input.calc_data.enemy_type == &EnemyType::Minor && !_input.pvp { 1.077 } else { 1.0 @@ -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,42 +517,40 @@ 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); - 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 - }), + }, ); 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/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 7ccf8b36..8a682c34 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::InventorySize.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::AimAssist.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::AimAssist.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::AimAssist.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,16 +649,16 @@ 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 - || _input.calc_data.damage_type != &DamageType::KINETIC + || _input.calc_data.damage_type != &DamageType::Kinetic { damage_mult = 0.0; }; @@ -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,36 +745,35 @@ 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 + #[allow(clippy::unwrap_used)] let precision = Weapon::generate_weapon( 0, 24, //smg 1636108362, //precision @@ -849,6 +794,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..bebea247 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.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; @@ -126,14 +124,14 @@ 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 - }), + }, ); 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( @@ -231,18 +227,18 @@ 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 - }), + }, ); 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.insert(StatHashes::BlastRadius.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.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..80a49e24 100644 --- a/src/perks/year_3_perks.rs +++ b/src/perks/year_3_perks.rs @@ -18,56 +18,52 @@ 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 { - 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 - }), + }, ); 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.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,51 +105,49 @@ 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 - || *_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 { @@ -161,42 +155,40 @@ 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 { - 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 - }), + }, ); 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..08ced9b8 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.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,39 +92,37 @@ 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 { handling = 20; }; let mut out = HashMap::new(); - out.insert(StatHashes::HANDLING.into(), handling); + 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,45 +133,43 @@ 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 { 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() } - }), + }, ); 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 { @@ -257,15 +251,15 @@ 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 - }), + }, ); 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.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 { @@ -311,35 +303,33 @@ 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 - }), + }, ); 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.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.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.insert(StatHashes::BlastRadius.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.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,78 +489,74 @@ 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.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); - 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 - }), + }, ); 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.insert(StatHashes::RecoilDir.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.insert(StatHashes::AimAssist.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..42286841 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,38 +33,37 @@ 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; 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 - }), + }, ); 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,25 +92,25 @@ 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 { range_bonus = 20; }; - map.insert(StatHashes::RANGE.into(), range_bonus); + 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,25 +134,25 @@ 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 { stability_boost = 30; }; - map.insert(StatHashes::STABILITY.into(), stability_boost); + 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.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; @@ -204,34 +201,32 @@ 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 - }), + }, ); 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,46 +256,44 @@ 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 { handling = 100; }; - map.insert(StatHashes::HANDLING.into(), handling); + 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,43 +337,41 @@ 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 }; 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 - }), + }, ); 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,55 +413,53 @@ 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 && _input.value > 0 { - map.insert(StatHashes::RELOAD.into(), reload_add); + 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; 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 - }), + }, ); 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.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 @@ -524,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() @@ -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 68136de4..802e6409 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; @@ -26,63 +26,63 @@ 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 - }), + }, ); 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); - 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 - }), + }, ); // 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,34 +251,34 @@ 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.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); - 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 - }), + }, ); 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.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.pvp, _input.value) { (_, 0) => 1.0, (false, 1..=3) => 1.05 + (0.1 * _input.value as f64), @@ -495,6 +475,6 @@ pub fn year_6_perks() { explosive_dmg_scale: buff, ..Default::default() } - }), + }, ) } diff --git a/src/test.rs b/src/test.rs index 6e39d045..5cc51e43 100644 --- a/src/test.rs +++ b/src/test.rs @@ -11,10 +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(dead_code)] fn cmp_floats_delta(a: T, b: T, delta: T) -> bool { (a - b).abs() < delta } @@ -35,12 +37,12 @@ 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)); - 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; @@ -52,14 +54,14 @@ 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())) - .unwrap() + .get(&(StatHashes::Handling.into())) + .expect("Failed to get stat") .val(); assert_eq!(test_stat, 50, "test_stat: {}", test_stat); }); @@ -147,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!( @@ -185,12 +187,12 @@ 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)); - 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; @@ -202,14 +204,14 @@ 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())) - .unwrap() + .get(&(StatHashes::Handling.into())) + .expect("Failed to get stat") .val(); assert_eq!(test_stat, 50, "test_stat: {}", test_stat); }); @@ -287,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!( @@ -322,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 new file mode 100644 index 00000000..8098064b --- /dev/null +++ b/src/types/formula_types.rs @@ -0,0 +1,123 @@ +use serde::{Deserialize, Serialize}; + +///Describes the addresses of all the formulas for a given weapon +/// based off the weapon path +#[derive(Debug, Copy, 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, Copy, 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, +} diff --git a/src/types/js_types.rs b/src/types/js_types.rs index dfaaf8de..a3d715c8 100644 --- a/src/types/js_types.rs +++ b/src/types/js_types.rs @@ -1,29 +1,18 @@ -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 wasm_bindgen::prelude::wasm_bindgen; use super::rs_types::{ - AmmoFormula, AmmoResponse, DamageMods, DpsResponse, FiringData, FiringResponse, - HandlingFormula, HandlingResponse, RangeFormula, RangeResponse, ReloadFormula, ReloadResponse, + AmmoResponse, FiringResponse, HandlingResponse, RangeResponse, ReloadResponse, }; #[derive(Debug, Clone, Copy, Serialize)] @@ -118,56 +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, -} -#[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)] @@ -205,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")] @@ -228,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)] @@ -304,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)] @@ -317,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)] @@ -340,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, } } } @@ -360,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/types/mod.rs b/src/types/mod.rs index 3e7e30b0..0dcaa5e4 100644 --- a/src/types/mod.rs +++ b/src/types/mod.rs @@ -1,3 +1,8 @@ -pub mod js_types; +// pub mod js_types; +pub mod formula_types; pub mod 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 98363358..a201a68a 100644 --- a/src/types/rs_types.rs +++ b/src/types/rs_types.rs @@ -1,124 +1,9 @@ -use std::collections::HashMap; +use serde::Serialize; -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)] +#[serde(rename_all(serialize = "camelCase"))] pub struct RangeResponse { pub hip_falloff_start: f64, pub hip_falloff_end: f64, @@ -128,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, @@ -136,53 +22,56 @@ pub struct HandlingResponse { pub timestamp: u64, } -#[derive(Debug, Clone, Default)] +#[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)] +#[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)] +#[derive(Debug, Clone, Copy, Default, Serialize)] +#[serde(rename_all(serialize = "camelCase"))] pub struct FiringResponse { pub pvp_impact_damage: f64, pub pvp_explosion_damage: f64, @@ -208,15 +97,21 @@ 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; } } + +#[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/dps_calc.rs b/src/weapons/dps_calc.rs index 139ce5e1..249d2a43 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; @@ -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 b844087d..48266be3 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,24 +8,17 @@ 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::perks::{ - get_magazine_modifier, get_reserve_modifier, get_stat_bumps, lib::CalculationInput, Perk, -}; +use crate::d2_enums::{AmmoType, DamageType, WeaponType}; +use crate::perks::{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 {} - -#[derive(Debug, Clone, Serialize)] +#[derive(Debug, Clone, Copy, Serialize)] +#[serde(rename_all(serialize = "camelCase"))] pub struct Stat { pub base_value: i32, pub part_value: i32, @@ -71,8 +66,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 +126,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 +218,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 +229,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(), @@ -246,8 +238,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/reserve_calc.rs b/src/weapons/reserve_calc.rs index 502144be..6aa33477 100644 --- a/src/weapons/reserve_calc.rs +++ b/src/weapons/reserve_calc.rs @@ -79,7 +79,6 @@ 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..3f0a5f6c 100644 --- a/src/weapons/stat_calc.rs +++ b/src/weapons/stat_calc.rs @@ -12,11 +12,10 @@ use crate::{ HandlingModifierResponse, InventoryModifierResponse, MagazineModifierResponse, RangeModifierResponse, ReloadModifierResponse, }, - Perks, }, - types::rs_types::{ - AmmoFormula, AmmoResponse, FiringResponse, HandlingFormula, HandlingResponse, RangeFormula, - RangeResponse, ReloadFormula, ReloadResponse, + types::{ + formula_types::*, + rs_types::{AmmoResponse, FiringResponse, HandlingResponse, RangeResponse, ReloadResponse}, }, }; @@ -38,12 +37,12 @@ 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 - .get(&StatHashes::RELOAD.into()) + .get(&StatHashes::Reload.into()) .unwrap_or(&Stat::new()) .perk_val(); @@ -105,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); @@ -163,7 +162,7 @@ impl Weapon { let handling_stat = self .stats - .get(&StatHashes::HANDLING.into()) + .get(&StatHashes::Handling.into()) .unwrap_or(&Stat::new()) .val(); @@ -230,17 +229,18 @@ 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; 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(), @@ -295,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(), @@ -437,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) @@ -455,10 +456,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; @@ -518,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), @@ -528,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), @@ -538,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), @@ -560,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) @@ -581,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) @@ -590,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) diff --git a/src/weapons/ttk_calc.rs b/src/weapons/ttk_calc.rs index 39f7d366..f62e1add 100644 --- a/src/weapons/ttk_calc.rs +++ b/src/weapons/ttk_calc.rs @@ -4,55 +4,48 @@ 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, ]; -#[derive(Debug, Clone, Serialize)] +#[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, Serialize)] +#[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, Serialize)] +#[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 } @@ -74,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, @@ -100,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 { @@ -116,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; @@ -197,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 { @@ -240,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; @@ -292,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) } } diff --git a/src/weapons/weapon_constructor.rs b/src/weapons/weapon_constructor.rs index 6719102d..f1eda5b2 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); @@ -21,8 +18,8 @@ fn get_data_pointers(_weapon_type_id: u8, _intrinsic_hash: u32) -> Result