Skip to content

Commit

Permalink
fix: reconstruction + envious (#134)
Browse files Browse the repository at this point in the history
also static calc data...
  • Loading branch information
BarmonHammer authored Aug 29, 2024
1 parent 55c93e7 commit 1e114e9
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 61 deletions.
36 changes: 14 additions & 22 deletions src/perks/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::{
d2_enums::{AmmoType, BungieHash, DamageSource, DamageType, StatBump, StatHashes, WeaponType},
enemies::EnemyType,
types::rs_types::{FiringData, HandlingResponse},
weapons::Stat,
weapons::{Stat, Weapon},
};
use serde::Serialize;
use std::{cell::RefCell, collections::HashMap, ops::Mul};
Expand Down Expand Up @@ -108,36 +108,28 @@ impl<'a> CalculationInput<'a> {
}
}
#[allow(clippy::too_many_arguments)]
pub fn construct_static(
_intrinsic_hash: u32,
_firing_data: &'a FiringData,
_stats: &'a HashMap<u32, Stat>,
_perk_value_map: &'a HashMap<u32, u32>,
_weapon_type: &'a WeaponType,
_ammo_type: &'a AmmoType,
_damage_type: &'a DamageType,
_crit_mult: f64,
) -> Self {
pub fn construct_static(weapon: &'a Weapon) -> Self {
let ammo = weapon.calc_ammo_sizes(None, None, true);
Self {
intrinsic_hash: _intrinsic_hash,
curr_firing_data: _firing_data,
base_crit_mult: _crit_mult,
intrinsic_hash: weapon.intrinsic_hash,
curr_firing_data: &weapon.firing_data,
base_crit_mult: weapon.firing_data.crit_mult,
shots_fired_this_mag: 0.0,
total_shots_fired: 0.0,
total_shots_hit: 0.0,
base_mag: 10.0,
curr_mag: 10.0,
reserves_left: 100.0,
base_mag: ammo.mag_size as f64,
curr_mag: ammo.mag_size as f64,
reserves_left: ammo.reserve_size as f64,
time_total: 0.0,
time_this_mag: 0.0,
stats: _stats,
weapon_type: _weapon_type,
damage_type: _damage_type,
ammo_type: _ammo_type,
stats: &weapon.stats,
weapon_type: &weapon.weapon_type,
damage_type: &weapon.damage_type,
ammo_type: &weapon.ammo_type,
handling_data: HandlingResponse::default(),
num_reloads: 0.0,
enemy_type: &EnemyType::ENCLAVE,
perk_value_map: _perk_value_map,
perk_value_map: &weapon.perk_value_map,
has_overshield: false,
}
}
Expand Down
44 changes: 25 additions & 19 deletions src/perks/year_4_perks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ pub fn year_4_perks() {
Box::new(|_input: ModifierResponseInput| -> DamageModifierResponse {
let duration = if _input.is_enhanced { 11.0 } else { 10.0 };
if _input.calc_data.time_total > duration
|| _input.calc_data.total_shots_fired > _input.calc_data.curr_firing_data.burst_size.into()
|| _input.calc_data.total_shots_fired
> _input.calc_data.curr_firing_data.burst_size.into()
|| _input.value == 0
{
return DamageModifierResponse::default();
Expand All @@ -146,7 +147,8 @@ pub fn year_4_perks() {
Box::new(|_input: ModifierResponseInput| -> HashMap<u32, i32> {
let duration = if _input.is_enhanced { 11.0 } else { 10.0 };
if _input.calc_data.time_total > duration
|| _input.calc_data.total_shots_fired > _input.calc_data.curr_firing_data.burst_size.into()
|| _input.calc_data.total_shots_fired
> _input.calc_data.curr_firing_data.burst_size.into()
|| _input.value == 0
{
return HashMap::new();
Expand All @@ -157,19 +159,22 @@ pub fn year_4_perks() {

add_hmr(
Perks::BluntExecutionRounds,
Box::new(|_input: ModifierResponseInput| -> HandlingModifierResponse {
let duration = if _input.is_enhanced { 11.0 } else { 10.0 };
if _input.calc_data.time_total > duration
|| _input.calc_data.total_shots_fired > _input.calc_data.curr_firing_data.burst_size.into()
|| _input.value == 0
{
return HandlingModifierResponse::default();
}
HandlingModifierResponse {
stat_add: 100,
..Default::default()
}
}),
Box::new(
|_input: ModifierResponseInput| -> HandlingModifierResponse {
let duration = if _input.is_enhanced { 11.0 } else { 10.0 };
if _input.calc_data.time_total > duration
|| _input.calc_data.total_shots_fired
> _input.calc_data.curr_firing_data.burst_size.into()
|| _input.value == 0
{
return HandlingModifierResponse::default();
}
HandlingModifierResponse {
stat_add: 100,
..Default::default()
}
},
),
);

add_fmr(
Expand Down Expand Up @@ -454,11 +459,12 @@ pub fn year_4_perks() {
Perks::Reconstruction,
Box::new(
|_input: ModifierResponseInput| -> MagazineModifierResponse {
let mag_scale = if _input.value > 0 { 2.0 } else { 1.0 };
if _input.value == 0 {
return MagazineModifierResponse::default();
}
MagazineModifierResponse {
magazine_stat_add: 0,
magazine_scale: mag_scale,
magazine_add: 0.0,
magazine_add: _input.calc_data.base_mag,
..Default::default()
}
},
),
Expand Down
22 changes: 2 additions & 20 deletions src/weapons/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,7 @@ impl Weapon {
}

pub fn static_calc_input(&self) -> CalculationInput {
CalculationInput::construct_static(
self.intrinsic_hash,
&self.firing_data,
&self.stats,
&self.perk_value_map,
&self.weapon_type,
&self.ammo_type,
&self.damage_type,
self.firing_data.crit_mult,
)
CalculationInput::construct_static(self)
}

pub fn sparse_calc_input(&self, _total_shots_fired: i32, _total_time: f64) -> CalculationInput {
Expand Down Expand Up @@ -199,16 +190,7 @@ impl Weapon {
}
pub fn update_stats(&mut self) {
self.perk_value_map = self.perk_value_map_update();
let input = CalculationInput::construct_static(
self.intrinsic_hash,
&self.firing_data,
&self.stats,
&self.perk_value_map,
&self.weapon_type,
&self.ammo_type,
&self.damage_type,
self.firing_data.crit_mult,
);
let input = CalculationInput::construct_static(self);
let inter_var = get_stat_bumps(self.list_perks(), input, false, &mut HashMap::new());
let dynamic_stats = &inter_var[0];
let static_stats = &inter_var[1];
Expand Down

0 comments on commit 1e114e9

Please sign in to comment.