From e391ffa84b675e1b3fe70581e216011c2c4f4a25 Mon Sep 17 00:00:00 2001 From: Patric Stout Date: Sat, 6 Jul 2024 13:57:54 +0200 Subject: [PATCH] chore: update to latest data-files These data-files add dogma-entries to do most of the special attribute calculation already. The only one remaining, is capacitor simulation. --- README.md | 4 +- src/calculate/pass_4.rs | 124 +------------ src/calculate/pass_4/align_time.rs | 37 ---- src/calculate/pass_4/capacitor.rs | 145 --------------- src/calculate/pass_4/cpu_power.rs | 86 --------- src/calculate/pass_4/damage.rs | 215 ---------------------- src/calculate/pass_4/drone.rs | 111 ----------- src/calculate/pass_4/ehp.rs | 253 -------------------------- src/calculate/pass_4/recharge.rs | 231 ----------------------- src/calculate/pass_4/scan_strength.rs | 31 ---- 10 files changed, 4 insertions(+), 1233 deletions(-) delete mode 100644 src/calculate/pass_4/align_time.rs delete mode 100644 src/calculate/pass_4/cpu_power.rs delete mode 100644 src/calculate/pass_4/damage.rs delete mode 100644 src/calculate/pass_4/drone.rs delete mode 100644 src/calculate/pass_4/ehp.rs delete mode 100644 src/calculate/pass_4/recharge.rs delete mode 100644 src/calculate/pass_4/scan_strength.rs diff --git a/README.md b/README.md index 9c39339..33ee9b4 100644 --- a/README.md +++ b/README.md @@ -12,11 +12,11 @@ This Dogma engine implements a multi-pass approach. - [pass 1](./src/calculate/pass_1.rs): collect all the Dogma attributes of the hull and modules. - [pass 2](./src/calculate/pass_2.rs): collect all the Dogma effects of the hull and modules. - [pass 3](./src/calculate/pass_3.rs): apply all the Dogma effects to the hull/modules, calculating the actual Dogma attribute values. -- [pass 4](./src/calculate/pass_4.rs): augment the Dogma attributes with EVEShip.fit specific attributes. +- [pass 4](./src/calculate/pass_4.rs): augment the Dogma attributes with EVEShip.fit specific attributes, that are too complex for the Dogma itself to handle. ## EVEShip.fit's specific attributes -`Pass 4` create Dogma attributes that do not exist in-game, but are calculated based on other Dogma attributes. +`Pass 4` create Dogma attributes that do not exist in-game, but are rather complicated to calculate. To make rendering a fit easier, these are calculated by this library, and presented as new Dogma attributes. Their identifier is always a negative value, to visually separate them. diff --git a/src/calculate/pass_4.rs b/src/calculate/pass_4.rs index 26a6bce..c781679 100644 --- a/src/calculate/pass_4.rs +++ b/src/calculate/pass_4.rs @@ -3,106 +3,20 @@ use super::{Info, Item, Pass, Ship}; pub struct PassFour {} -mod align_time; mod capacitor; -mod cpu_power; -mod damage; -mod drone; -mod ehp; -mod recharge; -mod scan_strength; #[allow(non_camel_case_types)] pub enum AttributeId { - alignTime = -1, - scanStrength = -2, - cpuUsed = -3, - powerUsed = -4, - cpuUnused = -5, - powerUnused = -6, - #[allow(dead_code)] - velocityBoost = -7, // Is taken care of with effects. - shieldEhpMultiplier = -8, - armorEhpMultiplier = -9, - hullEhpMultiplier = -10, - shieldEhp = -11, - armorEhp = -12, - hullEhp = -13, - ehp = -14, - passiveShieldRecharge = -15, - shieldRecharge = -16, - armorRecharge = -17, - hullRecharge = -18, - passiveShieldRechargeEhp = -19, - shieldRechargeEhp = -20, - armorRechargeEhp = -21, - hullRechargeEhp = -22, - capacitorPeakRecharge = -23, - capacitorPeakUsage = -24, - capacitorPeakDelta = -25, - capacitorPeakDeltaPercentage = -26, - capacitorDepletesIn = -27, - damageWithoutReloadDps = -28, - damageWithReloadDps = -29, - damageAlphaHp = -30, - droneActive = -31, - droneBandwidthUsedTotal = -32, - droneDamageAlphaHp = -33, - droneDamageDps = -34, - droneCapacityUsed = -35, + capacitorPeakDelta = -1, + capacitorDepletesIn = -2, - mass = 4, capacitorNeed = 6, - hp = 9, - powerOutput = 11, - power = 30, - capacity = 38, - cpuOutput = 48, - cpu = 50, speed = 51, rechargeRate = 55, - damageMultiplier = 64, - shieldBonus = 68, - agility = 70, duration = 73, - structureDamageAmount = 83, - armorDamageAmount = 84, - kineticDamageResonance = 109, - thermalDamageResonance = 110, - explosiveDamageResonance = 111, - emDamageResonance = 113, - - emDamage = 114, - explosiveDamage = 116, - kineticDamage = 117, - thermalDamage = 118, - - volume = 161, - - scanRadarStrength = 208, - scanLadarStrength = 209, - scanMagnetometricStrength = 210, - scanGravimetricStrength = 211, - - shieldCapacity = 263, - armorHp = 265, - - armorEmDamageResonance = 267, - armorExplosiveDamageResonance = 268, - armorKineticDamageResonance = 269, - armorThermalDamageResonance = 270, - shieldEmDamageResonance = 271, - shieldExplosiveDamageResonance = 272, - shieldKineticDamageResonance = 273, - shieldThermalDamageResonance = 274, - - shieldRechargeRate = 479, capacitorCapacity = 482, - - droneBandwidthUsed = 1272, - reloadTime = 1795, } impl Item { @@ -116,40 +30,6 @@ impl Item { /* Attributes don't contain all information displayed, so we calculate some fake attributes with those values. */ impl Pass for PassFour { fn pass(_info: &Info, ship: &mut Ship) { - align_time::attribute_align_time(ship); - scan_strength::attribute_scan_strength(ship); - - cpu_power::attribute_cpu_used(ship); - cpu_power::attribute_power_used(ship); - cpu_power::attribute_cpu_unused(ship); - cpu_power::attribute_power_unused(ship); - - ehp::attribute_shield_ehp_multiplier(ship); - ehp::attribute_armor_ehp_multiplier(ship); - ehp::attribute_hull_ehp_multiplier(ship); - ehp::attribute_shield_ehp(ship); - ehp::attribute_armor_ehp(ship); - ehp::attribute_hull_ehp(ship); - ehp::attribute_ehp(ship); - - recharge::attribute_passive_shield_recharge(ship); - recharge::attribute_shield_recharge(ship); - recharge::attribute_armor_recharge(ship); - recharge::attribute_hull_recharge(ship); - - capacitor::attribute_capacitor_peak_recharge(ship); - capacitor::attribute_capacitor_peak_usage(ship); - capacitor::attribute_capacitor_peak_delta(ship); - capacitor::attribute_capacitor_peak_delta_percentage(ship); capacitor::attribute_capacitor_depletes_in(ship); - - damage::attribute_damage_alpha_hp(ship); - damage::attribute_damage_without_reload(ship); - damage::attribute_damage_with_reload(ship); - - drone::attribute_drone_active(ship); - drone::attribute_drone_capacity_used(ship); - drone::attribute_drone_bandwidth_used(ship); - drone::attribute_drone_damage(ship); } } diff --git a/src/calculate/pass_4/align_time.rs b/src/calculate/pass_4/align_time.rs deleted file mode 100644 index a68db11..0000000 --- a/src/calculate/pass_4/align_time.rs +++ /dev/null @@ -1,37 +0,0 @@ -use super::super::Ship; -use super::AttributeId; - -pub fn attribute_align_time(ship: &mut Ship) { - /* Align-time is based on agility and mass. */ - - /* Structures do not have agility, and as such, no align-time. */ - if !ship - .hull - .attributes - .contains_key(&(AttributeId::agility as i32)) - { - return; - } - - let attr_agility = ship - .hull - .attributes - .get(&(AttributeId::agility as i32)) - .unwrap(); - let attr_mass = ship - .hull - .attributes - .get(&(AttributeId::mass as i32)) - .unwrap(); - - let base_agility = attr_agility.base_value; - let base_mass = attr_mass.base_value; - let base_align_time = -(0.25 as f64).ln() * base_agility * base_mass / 1000000.0; - - let agility = attr_agility.value.unwrap(); - let mass = attr_mass.value.unwrap(); - let align_time = -(0.25 as f64).ln() * agility * mass / 1000000.0; - - ship.hull - .add_attribute(AttributeId::alignTime, base_align_time, align_time); -} diff --git a/src/calculate/pass_4/capacitor.rs b/src/calculate/pass_4/capacitor.rs index 597d198..65a8747 100644 --- a/src/calculate/pass_4/capacitor.rs +++ b/src/calculate/pass_4/capacitor.rs @@ -1,151 +1,6 @@ use super::super::Ship; use super::AttributeId; -pub fn attribute_capacitor_peak_recharge(ship: &mut Ship) { - /* The peak recharge rate of the capacitor (in GJ/s). This happens at 25% of the capacity. */ - - let attr_capacitor_capacity = ship - .hull - .attributes - .get(&(AttributeId::capacitorCapacity as i32)) - .unwrap(); - let attr_recharge_rate = ship - .hull - .attributes - .get(&(AttributeId::rechargeRate as i32)) - .unwrap(); - - let base_capacitor_capacity = attr_capacitor_capacity.base_value; - let base_recharge_rate = attr_recharge_rate.base_value / 1000.0; - let base_peak_recharge = 5.0 / 2.0 * base_capacitor_capacity / base_recharge_rate; - - let capacitor_capacity = attr_capacitor_capacity.value.unwrap(); - let recharge_rate = attr_recharge_rate.value.unwrap() / 1000.0; - let peak_recharge = 5.0 / 2.0 * capacitor_capacity / recharge_rate; - - ship.hull.add_attribute( - AttributeId::capacitorPeakRecharge, - base_peak_recharge, - peak_recharge, - ); -} - -pub fn attribute_capacitor_peak_usage(ship: &mut Ship) { - /* The peak capacitor usage if all modules would activate at the same time, in GJ/s. */ - - let attr_capacitor_need = AttributeId::capacitorNeed as i32; - let attr_duration = AttributeId::duration as i32; - let attr_rate_of_fire = AttributeId::speed as i32; - - let mut base_peak_usage = 0.0; - let mut peak_usage = 0.0; - for item in &ship.items { - if !item.slot.is_module() || !item.state.is_active() { - continue; - } - - if !item.attributes.contains_key(&attr_capacitor_need) { - continue; - } - - /* Depending on the module, the duration is based either on "duration" or on "speed" (read: rate-of-fire). */ - let (duration_base, duration) = if item.attributes.contains_key(&attr_duration) { - ( - item.attributes.get(&attr_duration).unwrap().base_value, - item.attributes.get(&attr_duration).unwrap().value.unwrap(), - ) - } else if item.attributes.contains_key(&attr_rate_of_fire) { - ( - item.attributes.get(&attr_rate_of_fire).unwrap().base_value, - item.attributes - .get(&attr_rate_of_fire) - .unwrap() - .value - .unwrap(), - ) - } else { - /* Neither speed nor duration; so no cap use. */ - continue; - }; - - base_peak_usage += item - .attributes - .get(&attr_capacitor_need) - .unwrap() - .base_value - / duration_base - * 1000.0; - peak_usage += item - .attributes - .get(&attr_capacitor_need) - .unwrap() - .value - .unwrap() - / duration - * 1000.0; - } - - ship.hull - .add_attribute(AttributeId::capacitorPeakUsage, base_peak_usage, peak_usage); -} - -pub fn attribute_capacitor_peak_delta(ship: &mut Ship) { - /* The delta between peak recharge and peak usage, in GJ/s. */ - - let attr_capacitor_peak_recharge = ship - .hull - .attributes - .get(&(AttributeId::capacitorPeakRecharge as i32)) - .unwrap(); - let attr_capacitor_peak_usage = ship - .hull - .attributes - .get(&(AttributeId::capacitorPeakUsage as i32)) - .unwrap(); - - let base_peak_recharge = attr_capacitor_peak_recharge.base_value; - let base_peak_usage = attr_capacitor_peak_usage.base_value; - let base_peak_delta = base_peak_recharge - base_peak_usage; - - let peak_recharge = attr_capacitor_peak_recharge.value.unwrap(); - let peak_usage = attr_capacitor_peak_usage.value.unwrap(); - let peak_delta = peak_recharge - peak_usage; - - ship.hull - .add_attribute(AttributeId::capacitorPeakDelta, base_peak_delta, peak_delta); -} - -pub fn attribute_capacitor_peak_delta_percentage(ship: &mut Ship) { - /* The delta between peak recharge and peak usage, in % of peak recharge. */ - - let attr_capacitor_peak_recharge = ship - .hull - .attributes - .get(&(AttributeId::capacitorPeakRecharge as i32)) - .unwrap(); - let attr_capacitor_peak_usage = ship - .hull - .attributes - .get(&(AttributeId::capacitorPeakUsage as i32)) - .unwrap(); - - let base_peak_recharge = attr_capacitor_peak_recharge.base_value; - let base_peak_usage = attr_capacitor_peak_usage.base_value; - let base_peak_delta = base_peak_recharge - base_peak_usage; - let base_peak_delta_percentage = base_peak_delta / base_peak_recharge * 100.0; - - let peak_recharge = attr_capacitor_peak_recharge.value.unwrap(); - let peak_usage = attr_capacitor_peak_usage.value.unwrap(); - let peak_delta = peak_recharge - peak_usage; - let peak_delta_percentage = peak_delta / peak_recharge * 100.0; - - ship.hull.add_attribute( - AttributeId::capacitorPeakDeltaPercentage, - base_peak_delta_percentage, - peak_delta_percentage, - ); -} - struct Module { capacitor_need: f64, duration: f64, diff --git a/src/calculate/pass_4/cpu_power.rs b/src/calculate/pass_4/cpu_power.rs deleted file mode 100644 index 5da1180..0000000 --- a/src/calculate/pass_4/cpu_power.rs +++ /dev/null @@ -1,86 +0,0 @@ -use super::super::item::EffectCategory; -use super::super::Ship; -use super::AttributeId; - -pub fn attribute_cpu_used(ship: &mut Ship) { - /* How much CPU is being used, which is adding up cpu from all items. */ - - let attr_cpu = AttributeId::cpu as i32; - - let mut cpu_used = 0.0; - for item in &ship.items { - if !item.slot.is_module() || item.state == EffectCategory::Passive { - continue; - } - - if item.attributes.contains_key(&attr_cpu) { - cpu_used += item.attributes.get(&attr_cpu).unwrap().value.unwrap(); - } - } - - ship.hull.add_attribute(AttributeId::cpuUsed, 0.0, cpu_used); -} - -pub fn attribute_power_used(ship: &mut Ship) { - /* How much PG is being used, which is adding up power from all items. */ - - let attr_power = AttributeId::power as i32; - - let mut power_used = 0.0; - for item in &ship.items { - if !item.slot.is_module() || item.state == EffectCategory::Passive { - continue; - } - - if item.attributes.contains_key(&attr_power) { - power_used += item.attributes.get(&attr_power).unwrap().value.unwrap(); - } - } - - ship.hull - .add_attribute(AttributeId::powerUsed, 0.0, power_used); -} - -pub fn attribute_cpu_unused(ship: &mut Ship) { - /* How much CPU is left, which is the total CPU minus the usage. */ - - let attr_cpu_used = ship - .hull - .attributes - .get(&(AttributeId::cpuUsed as i32)) - .unwrap(); - let attr_cpu_output = ship - .hull - .attributes - .get(&(AttributeId::cpuOutput as i32)) - .unwrap(); - - let cpu_used = attr_cpu_used.value.unwrap(); - let cpu_output = attr_cpu_output.value.unwrap(); - let cpu_unused = cpu_output - cpu_used; - - ship.hull - .add_attribute(AttributeId::cpuUnused, 0.0, cpu_unused); -} - -pub fn attribute_power_unused(ship: &mut Ship) { - /* How much PG is left, which is the total PG minus the usage. */ - - let attr_power_used = ship - .hull - .attributes - .get(&(AttributeId::powerUsed as i32)) - .unwrap(); - let attr_power_output = ship - .hull - .attributes - .get(&(AttributeId::powerOutput as i32)) - .unwrap(); - - let power_used = attr_power_used.value.unwrap(); - let power_output = attr_power_output.value.unwrap(); - let power_unused = power_output - power_used; - - ship.hull - .add_attribute(AttributeId::powerUnused, 0.0, power_unused); -} diff --git a/src/calculate/pass_4/damage.rs b/src/calculate/pass_4/damage.rs deleted file mode 100644 index 2168cb8..0000000 --- a/src/calculate/pass_4/damage.rs +++ /dev/null @@ -1,215 +0,0 @@ -use super::super::item::Item; -use super::super::Ship; -use super::AttributeId; - -fn calculate_alpha( - item: &Item, - charge: &Item, - base_alpha_hp: &mut f64, - alpha_hp: &mut f64, -) -> bool { - let attr_damage_em = AttributeId::emDamage as i32; - let attr_damage_explosive = AttributeId::explosiveDamage as i32; - let attr_damage_kinetic = AttributeId::kineticDamage as i32; - let attr_damage_thermal = AttributeId::thermalDamage as i32; - let attr_damage_multiplier = AttributeId::damageMultiplier as i32; - - /* Only calculate for charges that do damage. */ - if !charge.attributes.contains_key(&attr_damage_em) - || !charge.attributes.contains_key(&attr_damage_explosive) - || !charge.attributes.contains_key(&attr_damage_kinetic) - || !charge.attributes.contains_key(&attr_damage_thermal) - { - return false; - } - - let base_damage_em = charge.attributes.get(&attr_damage_em).unwrap().base_value; - let base_damage_explosive = charge - .attributes - .get(&attr_damage_explosive) - .unwrap() - .base_value; - let base_damage_kinetic = charge - .attributes - .get(&attr_damage_kinetic) - .unwrap() - .base_value; - let base_damage_thermal = charge - .attributes - .get(&attr_damage_thermal) - .unwrap() - .base_value; - - let damage_em = charge - .attributes - .get(&attr_damage_em) - .unwrap() - .value - .unwrap(); - let damage_explosive = charge - .attributes - .get(&attr_damage_explosive) - .unwrap() - .value - .unwrap(); - let damage_kinetic = charge - .attributes - .get(&attr_damage_kinetic) - .unwrap() - .value - .unwrap(); - let damage_thermal = charge - .attributes - .get(&attr_damage_thermal) - .unwrap() - .value - .unwrap(); - - *base_alpha_hp += - base_damage_em + base_damage_explosive + base_damage_kinetic + base_damage_thermal; - *alpha_hp += damage_em + damage_explosive + damage_kinetic + damage_thermal; - - if item.attributes.contains_key(&attr_damage_multiplier) { - let damage_multiplier = item.attributes.get(&attr_damage_multiplier).unwrap(); - - *base_alpha_hp *= damage_multiplier.base_value; - *alpha_hp *= damage_multiplier.value.unwrap(); - } - - true -} - -pub fn attribute_damage_alpha_hp(ship: &mut Ship) { - /* Damage when all guns / drones fire at once, in hp. */ - - let mut total_base_alpha_hp = 0.0; - let mut total_alpha_hp = 0.0; - - for item in &mut ship.items { - if !item.state.is_active() { - continue; - } - - let mut base_alpha_hp = 0.0; - let mut alpha_hp = 0.0; - - /* Check for drone damage. */ - calculate_alpha(item, item, &mut base_alpha_hp, &mut alpha_hp); - /* Check for charge damage. */ - if let Some(charge) = item.charge.as_ref() { - calculate_alpha(item, charge, &mut base_alpha_hp, &mut alpha_hp); - } - - if base_alpha_hp > 0.0 || alpha_hp > 0.0 { - item.add_attribute(AttributeId::damageAlphaHp, base_alpha_hp, alpha_hp); - } - - total_base_alpha_hp += base_alpha_hp; - total_alpha_hp += alpha_hp; - } - - ship.hull.add_attribute( - AttributeId::damageAlphaHp, - total_base_alpha_hp, - total_alpha_hp, - ); -} - -pub fn attribute_damage_without_reload(ship: &mut Ship) { - /* Damage (per second) all guns do without reloading. */ - - let attr_rate_of_fire = AttributeId::speed as i32; - let attr_damage_alpha_hp = AttributeId::damageAlphaHp as i32; - - let mut total_base_damage = 0.0; - let mut total_damage = 0.0; - - for item in &mut ship.items { - if !item.state.is_active() { - continue; - } - - if item.attributes.contains_key(&attr_rate_of_fire) - && item.attributes.contains_key(&attr_damage_alpha_hp) - { - let rate_of_fire = item.attributes.get(&attr_rate_of_fire).unwrap(); - let damage_alpha_hp = item.attributes.get(&attr_damage_alpha_hp).unwrap(); - - let base_damage_dps = damage_alpha_hp.base_value / (rate_of_fire.base_value / 1000.0); - let damage_dps = - damage_alpha_hp.value.unwrap() / (rate_of_fire.value.unwrap() / 1000.0); - - item.add_attribute( - AttributeId::damageWithoutReloadDps, - base_damage_dps, - damage_dps, - ); - - total_base_damage += base_damage_dps; - total_damage += damage_dps; - } - } - - ship.hull.add_attribute( - AttributeId::damageWithoutReloadDps, - total_base_damage, - total_damage, - ); -} - -pub fn attribute_damage_with_reload(ship: &mut Ship) { - /* Damage (per second) all guns do with reloading. */ - - let attr_rate_of_fire = AttributeId::speed as i32; - let attr_damage_alpha_hp = AttributeId::damageAlphaHp as i32; - let attr_reload_time = AttributeId::reloadTime as i32; - let attr_volume = AttributeId::volume as i32; - let attr_capacity = AttributeId::capacity as i32; - - let mut total_base_damage = 0.0; - let mut total_damage = 0.0; - - for item in &mut ship.items { - if !item.slot.is_module() || !item.state.is_active() { - continue; - } - - if let Some(charge) = item.charge.as_ref() { - if item.attributes.contains_key(&attr_rate_of_fire) - && item.attributes.contains_key(&attr_damage_alpha_hp) - { - /* Most stats come from the module itself. */ - let rate_of_fire = item.attributes.get(&attr_rate_of_fire).unwrap(); - let damage_alpha_hp = item.attributes.get(&attr_damage_alpha_hp).unwrap(); - let reload_time = item.attributes.get(&attr_reload_time).unwrap(); - let capacity = item.attributes.get(&attr_capacity).unwrap(); - - /* Volume of the charge. */ - let volume = charge.attributes.get(&attr_volume).unwrap(); - - let charge_amount = (capacity.value.unwrap() / volume.value.unwrap()).floor(); - let reload_rof = reload_time.value.unwrap() / 1000.0 / charge_amount; - - let base_damage_dps = - damage_alpha_hp.base_value / ((rate_of_fire.base_value / 1000.0) + reload_rof); - let damage_dps = damage_alpha_hp.value.unwrap() - / ((rate_of_fire.value.unwrap() / 1000.0) + reload_rof); - - item.add_attribute( - AttributeId::damageWithReloadDps, - base_damage_dps, - damage_dps, - ); - - total_base_damage += base_damage_dps; - total_damage += damage_dps; - } - } - } - - ship.hull.add_attribute( - AttributeId::damageWithReloadDps, - total_base_damage, - total_damage, - ); -} diff --git a/src/calculate/pass_4/drone.rs b/src/calculate/pass_4/drone.rs deleted file mode 100644 index 6f3a419..0000000 --- a/src/calculate/pass_4/drone.rs +++ /dev/null @@ -1,111 +0,0 @@ -use super::super::item::{EffectCategory, SlotType}; -use super::super::Ship; -use super::AttributeId; - -pub fn attribute_drone_active(ship: &mut Ship) { - /* The amount of active drones. */ - - let mut active = 0; - for item in &ship.items { - if item.slot.r#type != SlotType::DroneBay || item.state != EffectCategory::Active { - continue; - } - - active += 1; - } - - ship.hull - .add_attribute(AttributeId::droneActive, 0.0, active as f64); -} - -pub fn attribute_drone_capacity_used(ship: &mut Ship) { - /* The capacity of the dronebay used by drones. */ - - let attr_drone_capacity = AttributeId::volume as i32; - - let mut capacity_used = 0.0; - for item in &ship.items { - if item.slot.r#type != SlotType::DroneBay { - continue; - } - - capacity_used += item - .attributes - .get(&attr_drone_capacity) - .unwrap() - .value - .unwrap(); - } - - ship.hull - .add_attribute(AttributeId::droneCapacityUsed, 0.0, capacity_used); -} - -pub fn attribute_drone_bandwidth_used(ship: &mut Ship) { - /* The bandwidth used by drones. */ - - let attr_drone_bandwidth = AttributeId::droneBandwidthUsed as i32; - - let mut bandwidth_used_total = 0.0; - for item in &ship.items { - if item.slot.r#type != SlotType::DroneBay || item.state != EffectCategory::Active { - continue; - } - - bandwidth_used_total += item - .attributes - .get(&attr_drone_bandwidth) - .unwrap() - .value - .unwrap(); - } - - ship.hull.add_attribute( - AttributeId::droneBandwidthUsedTotal, - 0.0, - bandwidth_used_total, - ); -} - -pub fn attribute_drone_damage(ship: &mut Ship) { - /* The total damage of drones. */ - - let mut total_alpha_hp = 0.0; - let mut total_base_alpha_hp = 0.0; - let mut total_alpha_hp_without_reload = 0.0; - let mut total_base_alpha_hp_without_reload = 0.0; - - let attr_damage_alpha_hp = AttributeId::damageAlphaHp as i32; - let attr_damage_without_reload_dps = AttributeId::damageWithoutReloadDps as i32; - - for item in &mut ship.items { - if item.slot.r#type != SlotType::DroneBay || item.state != EffectCategory::Active { - continue; - } - if !item.attributes.contains_key(&attr_damage_alpha_hp) { - continue; - } - - let damage_alpha_hp = item.attributes.get(&attr_damage_alpha_hp).unwrap(); - total_base_alpha_hp += damage_alpha_hp.base_value; - total_alpha_hp += damage_alpha_hp.value.unwrap(); - - let damage_without_reload_dps = item - .attributes - .get(&attr_damage_without_reload_dps) - .unwrap(); - total_base_alpha_hp_without_reload += damage_without_reload_dps.base_value; - total_alpha_hp_without_reload += damage_without_reload_dps.value.unwrap(); - } - - ship.hull.add_attribute( - AttributeId::droneDamageAlphaHp, - total_base_alpha_hp, - total_alpha_hp, - ); - ship.hull.add_attribute( - AttributeId::droneDamageDps, - total_base_alpha_hp_without_reload, - total_alpha_hp_without_reload, - ); -} diff --git a/src/calculate/pass_4/ehp.rs b/src/calculate/pass_4/ehp.rs deleted file mode 100644 index ca2d7d0..0000000 --- a/src/calculate/pass_4/ehp.rs +++ /dev/null @@ -1,253 +0,0 @@ -use super::super::Ship; -use super::AttributeId; - -const EHP_ATTRIBUTES: [i32; 3] = [ - AttributeId::shieldEhp as i32, - AttributeId::armorEhp as i32, - AttributeId::hullEhp as i32, -]; - -pub fn attribute_shield_ehp_multiplier(ship: &mut Ship) { - /* Based on the damage profile, calculate the shield eHP multiplier (how much damage is mitigated due to the resistance). */ - - let attr_shield_em = ship - .hull - .attributes - .get(&(AttributeId::shieldEmDamageResonance as i32)) - .unwrap(); - let attr_shield_explosive = ship - .hull - .attributes - .get(&(AttributeId::shieldExplosiveDamageResonance as i32)) - .unwrap(); - let attr_shield_kinetic = ship - .hull - .attributes - .get(&(AttributeId::shieldKineticDamageResonance as i32)) - .unwrap(); - let attr_shield_thermal = ship - .hull - .attributes - .get(&(AttributeId::shieldThermalDamageResonance as i32)) - .unwrap(); - - let base_shield_em = attr_shield_em.base_value * ship.damage_profile.em; - let base_shield_explosive = attr_shield_explosive.base_value * ship.damage_profile.explosive; - let base_shield_kinetic = attr_shield_kinetic.base_value * ship.damage_profile.kinetic; - let base_shield_thermal = attr_shield_thermal.base_value * ship.damage_profile.thermal; - - let shield_em_multiplier = attr_shield_em.value.unwrap() * ship.damage_profile.em; - let shield_explosive_multiplier = - attr_shield_explosive.value.unwrap() * ship.damage_profile.explosive; - let shield_kinetic_multiplier = - attr_shield_kinetic.value.unwrap() * ship.damage_profile.kinetic; - let shield_thermal_multiplier = - attr_shield_thermal.value.unwrap() * ship.damage_profile.thermal; - - /* Damage profile added up is always one; the initial damage divided by the actual damage is how much more eHP we have compared to HP. */ - let base_shield_ehp_multiplier = - 1.0 / (base_shield_em + base_shield_explosive + base_shield_kinetic + base_shield_thermal); - let shield_ehp_multiplier = 1.0 - / (shield_em_multiplier - + shield_explosive_multiplier - + shield_kinetic_multiplier - + shield_thermal_multiplier); - - ship.hull.add_attribute( - AttributeId::shieldEhpMultiplier, - base_shield_ehp_multiplier, - shield_ehp_multiplier, - ); -} - -pub fn attribute_armor_ehp_multiplier(ship: &mut Ship) { - /* Based on the damage profile, calculate the armor eHP multiplier (how much damage is mitigated due to the resistance). */ - - let attr_armor_em = ship - .hull - .attributes - .get(&(AttributeId::armorEmDamageResonance as i32)) - .unwrap(); - let attr_armor_explosive = ship - .hull - .attributes - .get(&(AttributeId::armorExplosiveDamageResonance as i32)) - .unwrap(); - let attr_armor_kinetic = ship - .hull - .attributes - .get(&(AttributeId::armorKineticDamageResonance as i32)) - .unwrap(); - let attr_armor_thermal = ship - .hull - .attributes - .get(&(AttributeId::armorThermalDamageResonance as i32)) - .unwrap(); - - let base_armor_em = attr_armor_em.base_value * ship.damage_profile.em; - let base_armor_explosive = attr_armor_explosive.base_value * ship.damage_profile.explosive; - let base_armor_kinetic = attr_armor_kinetic.base_value * ship.damage_profile.kinetic; - let base_armor_thermal = attr_armor_thermal.base_value * ship.damage_profile.thermal; - - let armor_em_multiplier = attr_armor_em.value.unwrap() * ship.damage_profile.em; - let armor_explosive_multiplier = - attr_armor_explosive.value.unwrap() * ship.damage_profile.explosive; - let armor_kinetic_multiplier = attr_armor_kinetic.value.unwrap() * ship.damage_profile.kinetic; - let armor_thermal_multiplier = attr_armor_thermal.value.unwrap() * ship.damage_profile.thermal; - - /* Damage profile added up is always one; the initial damage divided by the actual damage is how much more eHP we have compared to HP. */ - let base_armor_ehp_multiplier = - 1.0 / (base_armor_em + base_armor_explosive + base_armor_kinetic + base_armor_thermal); - let armor_ehp_multiplier = 1.0 - / (armor_em_multiplier - + armor_explosive_multiplier - + armor_kinetic_multiplier - + armor_thermal_multiplier); - - ship.hull.add_attribute( - AttributeId::armorEhpMultiplier, - base_armor_ehp_multiplier, - armor_ehp_multiplier, - ); -} - -pub fn attribute_hull_ehp_multiplier(ship: &mut Ship) { - /* Based on the damage profile, calculate the hull eHP multiplier (how much damage is mitigated due to the resistance). */ - - let attr_hull_em = ship - .hull - .attributes - .get(&(AttributeId::emDamageResonance as i32)) - .unwrap(); - let attr_hull_explosive = ship - .hull - .attributes - .get(&(AttributeId::explosiveDamageResonance as i32)) - .unwrap(); - let attr_hull_kinetic = ship - .hull - .attributes - .get(&(AttributeId::kineticDamageResonance as i32)) - .unwrap(); - let attr_hull_thermal = ship - .hull - .attributes - .get(&(AttributeId::thermalDamageResonance as i32)) - .unwrap(); - - let base_hull_em = attr_hull_em.base_value * ship.damage_profile.em; - let base_hull_explosive = attr_hull_explosive.base_value * ship.damage_profile.explosive; - let base_hull_kinetic = attr_hull_kinetic.base_value * ship.damage_profile.kinetic; - let base_hull_thermal = attr_hull_thermal.base_value * ship.damage_profile.thermal; - - let hull_em_multiplier = attr_hull_em.value.unwrap() * ship.damage_profile.em; - let hull_explosive_multiplier = - attr_hull_explosive.value.unwrap() * ship.damage_profile.explosive; - let hull_kinetic_multiplier = attr_hull_kinetic.value.unwrap() * ship.damage_profile.kinetic; - let hull_thermal_multiplier = attr_hull_thermal.value.unwrap() * ship.damage_profile.thermal; - - /* Damage profile added up is always one; the initial damage divided by the actual damage is how much more eHP we have compared to HP. */ - let base_hull_ehp_multiplier = - 1.0 / (base_hull_em + base_hull_explosive + base_hull_kinetic + base_hull_thermal); - let hull_ehp_multiplier = 1.0 - / (hull_em_multiplier - + hull_explosive_multiplier - + hull_kinetic_multiplier - + hull_thermal_multiplier); - - ship.hull.add_attribute( - AttributeId::hullEhpMultiplier, - base_hull_ehp_multiplier, - hull_ehp_multiplier, - ); -} - -pub fn attribute_shield_ehp(ship: &mut Ship) { - /* Calculate the shield eHP based on the shield HP and shield eHP multiplier. */ - - let attr_shield_ehp_multiplier = ship - .hull - .attributes - .get(&(AttributeId::shieldEhpMultiplier as i32)) - .unwrap(); - let attr_shield_hp = ship - .hull - .attributes - .get(&(AttributeId::shieldCapacity as i32)) - .unwrap(); - - let base_shield_ehp_multiplier = attr_shield_ehp_multiplier.base_value; - let base_shield_hp = attr_shield_hp.base_value; - let base_shield_ehp = base_shield_hp * base_shield_ehp_multiplier; - - let shield_ehp_multiplier = attr_shield_ehp_multiplier.value.unwrap(); - let shield_hp = attr_shield_hp.value.unwrap(); - let shield_ehp = shield_hp * shield_ehp_multiplier; - - ship.hull - .add_attribute(AttributeId::shieldEhp, base_shield_ehp, shield_ehp); -} - -pub fn attribute_armor_ehp(ship: &mut Ship) { - /* Calculate the armor eHP based on the armor HP and armor eHP multiplier. */ - - let attr_armor_ehp_multiplier = ship - .hull - .attributes - .get(&(AttributeId::armorEhpMultiplier as i32)) - .unwrap(); - let attr_armor_hp = ship - .hull - .attributes - .get(&(AttributeId::armorHp as i32)) - .unwrap(); - - let base_armor_ehp_multiplier = attr_armor_ehp_multiplier.base_value; - let base_armor_hp = attr_armor_hp.base_value; - let base_armor_ehp = base_armor_hp * base_armor_ehp_multiplier; - - let armor_ehp_multiplier = attr_armor_ehp_multiplier.value.unwrap(); - let armor_hp = attr_armor_hp.value.unwrap(); - let armor_ehp = armor_hp * armor_ehp_multiplier; - - ship.hull - .add_attribute(AttributeId::armorEhp, base_armor_ehp, armor_ehp); -} - -pub fn attribute_hull_ehp(ship: &mut Ship) { - /* Calculate the hull eHP based on the hull HP and hull eHP multiplier. */ - - let attr_hull_ehp_multiplier = ship - .hull - .attributes - .get(&(AttributeId::hullEhpMultiplier as i32)) - .unwrap(); - let attr_hull_hp = ship.hull.attributes.get(&(AttributeId::hp as i32)).unwrap(); - - let base_hull_ehp_multiplier = attr_hull_ehp_multiplier.base_value; - let base_hull_hp = attr_hull_hp.base_value; - let base_hull_ehp = base_hull_hp * base_hull_ehp_multiplier; - - let hull_ehp_multiplier = attr_hull_ehp_multiplier.value.unwrap(); - let hull_hp = attr_hull_hp.value.unwrap(); - let hull_ehp = hull_hp * hull_ehp_multiplier; - - ship.hull - .add_attribute(AttributeId::hullEhp, base_hull_ehp, hull_ehp); -} - -pub fn attribute_ehp(ship: &mut Ship) { - /* Adds up the shield + armor + hull ehp to come to a total ehp of the ship. */ - - let mut base_ehp = 0.0; - let mut ehp = 0.0; - - for attribute_id in EHP_ATTRIBUTES.iter() { - let attribute = ship.hull.attributes.get(attribute_id).unwrap(); - - base_ehp += attribute.base_value; - ehp += attribute.value.unwrap(); - } - - ship.hull.add_attribute(AttributeId::ehp, base_ehp, ehp); -} diff --git a/src/calculate/pass_4/recharge.rs b/src/calculate/pass_4/recharge.rs deleted file mode 100644 index 30430d3..0000000 --- a/src/calculate/pass_4/recharge.rs +++ /dev/null @@ -1,231 +0,0 @@ -use super::super::Ship; -use super::AttributeId; - -pub fn attribute_passive_shield_recharge(ship: &mut Ship) { - /* The passive recharge rate of shield, in HP/s and eHP/s. */ - - let attr_shield_recharge_rate = ship - .hull - .attributes - .get(&(AttributeId::shieldRechargeRate as i32)) - .unwrap(); - let attr_shield_capacity = ship - .hull - .attributes - .get(&(AttributeId::shieldCapacity as i32)) - .unwrap(); - let attr_shield_ehp_multiplier = ship - .hull - .attributes - .get(&(AttributeId::shieldEhpMultiplier as i32)) - .unwrap(); - - let base_shield_recharge_rate = attr_shield_recharge_rate.base_value / 1000.0; - let base_shield_capacity = attr_shield_capacity.base_value; - let base_passive_shield_recharge = 2.5 / base_shield_recharge_rate * base_shield_capacity; - let base_shield_ehp_multiplier = attr_shield_ehp_multiplier.base_value; - - let shield_recharge_rate = attr_shield_recharge_rate.value.unwrap() / 1000.0; - let shield_capacity = attr_shield_capacity.value.unwrap(); - let passive_shield_recharge = 2.5 / shield_recharge_rate * shield_capacity; - let shield_ehp_multiplier = attr_shield_ehp_multiplier.value.unwrap(); - - ship.hull.add_attribute( - AttributeId::passiveShieldRecharge, - base_passive_shield_recharge, - passive_shield_recharge, - ); - ship.hull.add_attribute( - AttributeId::passiveShieldRechargeEhp, - base_passive_shield_recharge * base_shield_ehp_multiplier, - passive_shield_recharge * shield_ehp_multiplier, - ); -} - -pub fn attribute_shield_recharge(ship: &mut Ship) { - /* The (active) recharge rate of shield, in HP/s and eHP/s. */ - - let attr_shield_ehp_multiplier = ship - .hull - .attributes - .get(&(AttributeId::shieldEhpMultiplier as i32)) - .unwrap(); - let attr_duration = AttributeId::duration as i32; - let attr_shield_bonus = AttributeId::shieldBonus as i32; - - let mut base_shield_recharge = 0.0; - for item in &ship.items { - if !item.slot.is_module() || !item.state.is_active() { - continue; - } - - if !item.attributes.contains_key(&attr_duration) - || !item.attributes.contains_key(&attr_shield_bonus) - { - continue; - } - - let duration = item.attributes.get(&attr_duration).unwrap().base_value / 1000.0; - base_shield_recharge += - item.attributes.get(&attr_shield_bonus).unwrap().base_value / duration; - } - let base_shield_ehp_multiplier = attr_shield_ehp_multiplier.base_value; - - let mut shield_recharge = 0.0; - for item in &ship.items { - if !item.slot.is_module() || !item.state.is_active() { - continue; - } - - if !item.attributes.contains_key(&attr_duration) - || !item.attributes.contains_key(&attr_shield_bonus) - { - continue; - } - - let duration = item.attributes.get(&attr_duration).unwrap().value.unwrap() / 1000.0; - shield_recharge += item - .attributes - .get(&attr_shield_bonus) - .unwrap() - .value - .unwrap() - / duration; - } - let shield_ehp_multiplier = attr_shield_ehp_multiplier.value.unwrap(); - - ship.hull.add_attribute( - AttributeId::shieldRecharge, - base_shield_recharge, - shield_recharge, - ); - ship.hull.add_attribute( - AttributeId::shieldRechargeEhp, - base_shield_recharge * base_shield_ehp_multiplier, - shield_recharge * shield_ehp_multiplier, - ); -} - -pub fn attribute_armor_recharge(ship: &mut Ship) { - /* The recharge rate of armor, in HP/s and eHP/s. */ - - let attr_armor_ehp_multiplier = ship - .hull - .attributes - .get(&(AttributeId::armorEhpMultiplier as i32)) - .unwrap(); - let attr_duration = AttributeId::duration as i32; - let attr_armor_bonus = AttributeId::armorDamageAmount as i32; - - let mut base_armor_recharge = 0.0; - for item in &ship.items { - if !item.slot.is_module() || !item.state.is_active() { - continue; - } - - if !item.attributes.contains_key(&attr_duration) - || !item.attributes.contains_key(&attr_armor_bonus) - { - continue; - } - - let duration = item.attributes.get(&attr_duration).unwrap().base_value / 1000.0; - base_armor_recharge += - item.attributes.get(&attr_armor_bonus).unwrap().base_value / duration; - } - let base_armor_ehp_multiplier = attr_armor_ehp_multiplier.base_value; - - let mut armor_recharge = 0.0; - for item in &ship.items { - if !item.slot.is_module() || !item.state.is_active() { - continue; - } - - if !item.attributes.contains_key(&attr_duration) - || !item.attributes.contains_key(&attr_armor_bonus) - { - continue; - } - - let duration = item.attributes.get(&attr_duration).unwrap().value.unwrap() / 1000.0; - armor_recharge += item - .attributes - .get(&attr_armor_bonus) - .unwrap() - .value - .unwrap() - / duration; - } - let armor_ehp_multiplier = attr_armor_ehp_multiplier.value.unwrap(); - - ship.hull.add_attribute( - AttributeId::armorRecharge, - base_armor_recharge, - armor_recharge, - ); - ship.hull.add_attribute( - AttributeId::armorRechargeEhp, - base_armor_recharge * base_armor_ehp_multiplier, - armor_recharge * armor_ehp_multiplier, - ); -} - -pub fn attribute_hull_recharge(ship: &mut Ship) { - /* The recharge rate of hull, in HP/s and eHP/s. */ - - let attr_hull_ehp_multiplier = ship - .hull - .attributes - .get(&(AttributeId::hullEhpMultiplier as i32)) - .unwrap(); - let attr_duration = AttributeId::duration as i32; - let attr_hull_bonus = AttributeId::structureDamageAmount as i32; - - let mut base_hull_recharge = 0.0; - for item in &ship.items { - if !item.slot.is_module() || !item.state.is_active() { - continue; - } - - if !item.attributes.contains_key(&attr_duration) - || !item.attributes.contains_key(&attr_hull_bonus) - { - continue; - } - - let duration = item.attributes.get(&attr_duration).unwrap().base_value / 1000.0; - base_hull_recharge += item.attributes.get(&attr_hull_bonus).unwrap().base_value / duration; - } - let base_hull_ehp_multiplier = attr_hull_ehp_multiplier.base_value; - - let mut hull_recharge = 0.0; - for item in &ship.items { - if !item.slot.is_module() || !item.state.is_active() { - continue; - } - - if !item.attributes.contains_key(&attr_duration) - || !item.attributes.contains_key(&attr_hull_bonus) - { - continue; - } - - let duration = item.attributes.get(&attr_duration).unwrap().value.unwrap() / 1000.0; - hull_recharge += item - .attributes - .get(&attr_hull_bonus) - .unwrap() - .value - .unwrap() - / duration; - } - let hull_ehp_multiplier = attr_hull_ehp_multiplier.value.unwrap(); - - ship.hull - .add_attribute(AttributeId::hullRecharge, base_hull_recharge, hull_recharge); - ship.hull.add_attribute( - AttributeId::hullRechargeEhp, - base_hull_recharge * base_hull_ehp_multiplier, - hull_recharge * hull_ehp_multiplier, - ); -} diff --git a/src/calculate/pass_4/scan_strength.rs b/src/calculate/pass_4/scan_strength.rs deleted file mode 100644 index c9b3b58..0000000 --- a/src/calculate/pass_4/scan_strength.rs +++ /dev/null @@ -1,31 +0,0 @@ -use super::super::Ship; -use super::AttributeId; - -const SCAN_STRENGTH_ATTRIBUTES: [i32; 4] = [ - AttributeId::scanRadarStrength as i32, - AttributeId::scanLadarStrength as i32, - AttributeId::scanMagnetometricStrength as i32, - AttributeId::scanGravimetricStrength as i32, -]; - -pub fn attribute_scan_strength(ship: &mut Ship) { - /* Scan Strength can be one of 4 scan strength values (radar, ladar, magnetometric, gravimetric). */ - - let mut base_scan_strength = 0.0; - let mut scan_strength = 0.0; - for attribute_id in SCAN_STRENGTH_ATTRIBUTES.iter() { - if ship.hull.attributes.contains_key(attribute_id) { - let attribute = ship.hull.attributes.get(attribute_id).unwrap(); - - if attribute.base_value > base_scan_strength { - base_scan_strength = attribute.base_value; - } - if attribute.value.unwrap() > scan_strength { - scan_strength = attribute.value.unwrap(); - } - } - } - - ship.hull - .add_attribute(AttributeId::scanStrength, base_scan_strength, scan_strength); -}