Skip to content

Commit

Permalink
fix: convert get_damage_profile return from tuple to struct (#108)
Browse files Browse the repository at this point in the history
* fix: convert get_damage_profile return from tuple to struct

* Remove Default from DamageProfile

* Add Copy to DamageProfile
  • Loading branch information
FlaminSarge authored Apr 23, 2024
1 parent 719ccc4 commit 15c0cf4
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 18 deletions.
8 changes: 8 additions & 0 deletions src/perks/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,3 +405,11 @@ pub struct ModifierResponseSummary {
pub drmr: Option<DamageResistModifierResponse>,
pub statbump: Option<HashMap<BungieHash, StatBump>>,
}

#[derive(Debug, Copy, Clone, PartialEq, Serialize)]
pub struct DamageProfile {
pub impact_dmg: f64,
pub explosion_dmg: f64,
pub crit_mult: f64,
pub damage_delay: f64,
}
4 changes: 2 additions & 2 deletions src/perks/year_1_perks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -845,8 +845,8 @@ pub fn year_1_perks() {
let lightweight_body = _input.calc_data.curr_firing_data.damage;
let lightweight_crit = _input.calc_data.curr_firing_data.crit_mult;

let precision_body = p_data.0;
let precision_crit = p_data.2;
let precision_body = p_data.impact_dmg;
let precision_crit = p_data.crit_mult;
DamageModifierResponse {
impact_dmg_scale: precision_body / lightweight_body,
explosive_dmg_scale: precision_body / lightweight_body,
Expand Down
8 changes: 4 additions & 4 deletions src/weapons/dps_calc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ pub fn complex_dps_calc(_weapon: Weapon, _enemy: Enemy, _pl_dmg_mult: f64) -> Dp
let ammo_type = weapon.ammo_type;

let tmp_dmg_prof = weapon.get_damage_profile(true);
let impact_dmg = tmp_dmg_prof.0;
let explosion_dmg = tmp_dmg_prof.1;
let crit_mult = tmp_dmg_prof.2;
// let damage_delay = tmp_dmg_prof.3;
let impact_dmg = tmp_dmg_prof.impact_dmg;
let explosion_dmg = tmp_dmg_prof.explosion_dmg;
let crit_mult = tmp_dmg_prof.crit_mult;
// let damage_delay = tmp_dmg_prof.damage_delay;

let base_mag = weapon.calc_ammo_sizes(None, None, false).mag_size;
let maximum_shots = if base_mag * 5 < 15 { 15 } else { base_mag * 5 };
Expand Down
17 changes: 11 additions & 6 deletions src/weapons/stat_calc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{
get_handling_modifier, get_magazine_modifier, get_range_modifier, get_reload_modifier,
get_reserve_modifier, get_velocity_modifier,
lib::{
CalculationInput, DamageModifierResponse, FiringModifierResponse,
CalculationInput, DamageModifierResponse, DamageProfile, FiringModifierResponse,
HandlingModifierResponse, InventoryModifierResponse, MagazineModifierResponse,
RangeModifierResponse, ReloadModifierResponse,
},
Expand Down Expand Up @@ -320,9 +320,9 @@ impl Weapon {
pve_damage_modifiers = DamageModifierResponse::default();
};
let tmp_dmg_prof = self.get_damage_profile(_pvp);
let impact_dmg = tmp_dmg_prof.0;
let explosion_dmg = tmp_dmg_prof.1;
let crit_mult = tmp_dmg_prof.2;
let impact_dmg = tmp_dmg_prof.impact_dmg;
let explosion_dmg = tmp_dmg_prof.explosion_dmg;
let crit_mult = tmp_dmg_prof.crit_mult;

let fd = self.firing_data;
let extra_charge_delay = if self.weapon_type == WeaponType::FUSIONRIFLE {
Expand Down Expand Up @@ -368,7 +368,7 @@ impl Weapon {
}

impl Weapon {
pub fn get_damage_profile(&self, _pvp: bool) -> (f64, f64, f64, f64) {
pub fn get_damage_profile(&self, _pvp: bool) -> DamageProfile {
let mut impact = if _pvp {
self.firing_data.damage
} else {
Expand All @@ -392,7 +392,12 @@ impl Weapon {
}
delay = epr.delyed;
}
(impact, explosion, crit, delay)
DamageProfile {
impact_dmg: impact,
explosion_dmg: explosion,
crit_mult: crit,
damage_delay: delay,
}
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/weapons/ttk_calc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ pub fn calc_ttk(_weapon: &Weapon, _overshield: f64) -> Vec<ResillienceSummary> {
let mut persistent_data: HashMap<String, f64> = HashMap::new();

let tmp_dmg_prof = _weapon.get_damage_profile(true);
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;
let impact_dmg = tmp_dmg_prof.impact_dmg;
let explosion_dmg = tmp_dmg_prof.explosion_dmg;
let mut crit_mult = tmp_dmg_prof.crit_mult;
// let damage_delay = tmp_dmg_prof.damage_delay;
if _weapon.weapon_type == WeaponType::SHOTGUN && _weapon.firing_data.burst_size == 12 {
crit_mult = 1.0; // shawty has no crits
}
Expand Down Expand Up @@ -218,8 +218,8 @@ pub fn calc_ttk(_weapon: &Weapon, _overshield: f64) -> Vec<ResillienceSummary> {
///////////////////////////////

let tmp_dmg_prof = _weapon.get_damage_profile(true);
let impact_dmg = tmp_dmg_prof.0;
let explosion_dmg = tmp_dmg_prof.1;
let impact_dmg = tmp_dmg_prof.impact_dmg;
let explosion_dmg = tmp_dmg_prof.explosion_dmg;

let body_damage = (impact_dmg * dmg_mods.impact_dmg_scale)
+ (explosion_dmg * dmg_mods.explosive_dmg_scale);
Expand Down

0 comments on commit 15c0cf4

Please sign in to comment.