1use wowlab_engine_combat::PeriodicDriver;
2use wowlab_engine_domain::dbc::ResolvedGameDataEffectExt as _;
3use wowlab_types::{
4 constants::{HUNDRED, MS_PER_SECOND},
5 sim::SpellIdx,
6};
7
8use crate::generated::specs::arms_warrior::{
9 AURA_BATTLE_STANCE, EFFECT, SET_BONUS, SPELL, SPELL_OVERPOWER, TALENT,
10};
11use crate::hooks::gated_or;
12use crate::hooks::shared::warrior::{
13 EXECUTE_BASE_PCT, FROTHING_CHANCE, IMPROVED_ATTACK_CHARGES, PRD_C_15,
14};
15
16const BASE_RAGE_PER_SWING_SECOND: f64 = 1.75;
17
18const EXECUTE_MAX_RAGE: f64 = 40.0;
20
21crate::hooks::define_spec_config! {
22pub(crate) struct ArmsConfig {
24 crit_swing_extra_rage: f64 { provenance: "Seasoned Soldier 279423 e1 extra rage on crit swings.", gate: true, source: crit_swing_extra_rage, transform: |value| value },
25 execute_threshold: f64 { provenance: "Massacre 281001 e2 execute threshold, otherwise the 20% baseline.", gate: true, source: gated_or(params.talent_picked(TALENT::MASSACRE), EXECUTE_BASE_PCT / HUNDRED, || base(EFFECT::MASSACRE_PCT) / HUNDRED), transform: |value| value },
26 execute_coef: f64 { provenance: "Execute damage 260798 e1 AP coefficient.", gate: true, source: ap(EFFECT::EXECUTE_DMG), transform: |value| value },
27 execute_refund_pct: f64 { provenance: "Execute 163201 e2 plus rank-scaled Critical Thinking 389306 e2.", gate: params.talent_picked(TALENT::IMPROVED_EXECUTE), source: base(EFFECT::EXECUTE_REFUND) / HUNDRED + base(EFFECT::CRITICAL_THINKING_REFUND) * f64::from(params.talent_ranks(TALENT::CRITICAL_THINKING)) / HUNDRED, transform: |value| value },
28 deep_wounds: bool { provenance: "Deep Wounds 1261060 applies the shared execute-impact `DoT`.", gate: params.talent_picked(TALENT::DEEP_WOUNDS), source: true, transform: |value| value },
29 mortal_wounds: bool { provenance: "Mortal Wounds 1261062 applies Deep Wounds from qualifying crits.", gate: params.talent_picked(TALENT::MORTAL_WOUNDS), source: true, transform: |value| value },
30 fatality_chance: f64 { provenance: "Fatality 383703 mark chance.", gate: params.talent_picked(TALENT::FATALITY), source: base(EFFECT::FATALITY_CHANCE), transform: |value| value / HUNDRED },
31 fatality_coef: f64 { provenance: "Fatality burst 383706 e1 AP coefficient.", gate: true, source: ap(EFFECT::FATALITY_DMG), transform: |value| value },
32 dreadnaught_coef: f64 { provenance: "Dreadnaught wave 315961 e1 AP coefficient.", gate: params.talent_picked(TALENT::DREADNAUGHT), source: ap(EFFECT::DREADNAUGHT_DMG), transform: |value| value },
33 tactician_chance: f64 { provenance: "Tactician 184783 e1 reset chance.", gate: params.talent_picked(TALENT::TACTICIAN), source: base(EFFECT::TACTICIAN_CHANCE), transform: |value| value / HUNDRED },
34 anger_management_div: f64 { provenance: "Anger Management 152278 e1 rage per second of CDR.", gate: params.talent_picked(TALENT::ANGER_MANAGEMENT), source: base(EFFECT::ANGER_MANAGEMENT_DIV), transform: |value| value },
35 martial_prowess: bool { provenance: "Martial Prowess selection gates Mortal Strike buff stacks.", gate: params.talent_picked(TALENT::MARTIAL_PROWESS), source: true, transform: |value| value },
36 executioners_precision: bool { provenance: "Executioner's Precision selection gates its Mortal Strike stacks.", gate: params.talent_picked(TALENT::EXECUTIONERS_PRECISION), source: true, transform: |value| value },
37 master_of_warfare: bool { provenance: "Master of Warfare 1269314 gates qualifying impact rolls.", gate: params.talent_picked(TALENT::MASTER_OF_WARFARE), source: true, transform: |value| value },
38 prd_c: f64 { provenance: "`SimC` PRD constant for the 15% nominal proc rate.", gate: true, source: PRD_C_15, transform: |value| value },
39 overpower_coef: f64 { provenance: "Overpower AP coefficient from its manifest effect binding.", gate: true, source: ap(EFFECT::OVERPOWER_DMG), transform: |value| value },
40 slayers_dominance: bool { provenance: "Slayer's Dominance 444767 selection.", gate: params.talent_picked(TALENT::SLAYERS_DOMINANCE), source: true, transform: |value| value },
41 slayers_strike_coef: f64 { provenance: "Slayer's Strike AP coefficient from its manifest effect binding.", gate: true, source: ap(EFFECT::SLAYERS_STRIKE_DMG), transform: |value| value },
42 imminent_demise_every: i32 { provenance: "Imminent Demise 444769 e1 strike interval, gated by Sudden Death.", gate: imminent_demise, source: base(EFFECT::IMMINENT_DEMISE_EVERY), transform: wowlab_types::numeric::f64_to_i32_saturating_trunc },
43 reap_the_storm: bool { provenance: "Reap the Storm requires its talent and active Imminent Demise.", gate: params.talent_picked(TALENT::REAP_THE_STORM) && imminent_demise, source: true, transform: |value| value },
44 reap_coef: f64 { provenance: "Reap the Storm AP coefficient from its manifest effect binding.", gate: true, source: ap(EFFECT::REAP_DMG), transform: |value| value },
45 unhinged: bool { provenance: "Unhinged 386628 makes odd Bladestorm ticks deal Mortal Strike.", gate: params.talent_picked(TALENT::UNHINGED), source: true, transform: |value| value },
46 overwhelming_blades: bool { provenance: "Overwhelming Blades 444772 stacks Overwhelmed from Bladestorm.", gate: params.talent_picked(TALENT::OVERWHELMING_BLADES), source: true, transform: |value| value },
47 op_finish_pct: f64 { provenance: "Overpowering Finish 400205 e1 damage fraction.", gate: params.talent_picked(TALENT::OVERPOWERING_FINISH), source: base(EFFECT::OVERPOWERING_FINISH_PCT), transform: |value| value / HUNDRED },
48 op_finish_below: f64 { provenance: "Overpowering Finish 400205 e2 health threshold.", gate: true, source: base(EFFECT::OVERPOWERING_FINISH_BELOW), transform: |value| value / HUNDRED },
49 frothing_chance: f64 { provenance: "Frothing Berserker `SpellAuraOptions` proc chance.", gate: params.talent_picked(TALENT::FROTHING_BERSERKER), source: FROTHING_CHANCE, transform: |value| value },
50 frothing_refund_pct: f64 { provenance: "Frothing Berserker 392792 e1 rage-refund fraction.", gate: true, source: base(EFFECT::FROTHING_REFUND), transform: |value| value / HUNDRED },
51 uo_cdr_ms_per_stack: u32 { provenance: "Unrelenting Onslaught 444780 e1 seconds converted to milliseconds.", gate: params.talent_picked(TALENT::UNRELENTING_ONSLAUGHT), source: base(EFFECT::UNRELENTING_CDR_S), transform: |value| wowlab_types::numeric::f64_to_u32_saturating_trunc(value * MS_PER_SECOND) },
52 uo_overwhelmed_per_stack: i32 { provenance: "Unrelenting Onslaught 444780 e2 Overwhelmed stacks.", gate: true, source: base(EFFECT::UNRELENTING_OVERWHELMED), transform: wowlab_types::numeric::f64_to_i32_saturating_trunc },
53 fierce_followthrough: bool { provenance: "Fierce Followthrough selection gates its next-Mortal-Strike proc.", gate: params.talent_picked(TALENT::FIERCE_FOLLOWTHROUGH), source: true, transform: |value| value },
54 set4pc_cs_extend_ms: u32 { provenance: "MID1 Arms 4pc 1264876 e1 Colossus Smash extension in milliseconds.", gate: params.set_bonus_auras.contains(&SET_BONUS::MID1_ARMS_4PC), source: base(EFFECT::SET4PC_CS_EXTEND_MS), transform: wowlab_types::numeric::f64_to_u32_saturating_trunc },
55 execute_max_rage: f64 { provenance: "Execute maximum rage consumption from `SpellPower` 163201.", gate: true, source: EXECUTE_MAX_RAGE, transform: |value| value },
56 bladestorm_duration_ms: u32 { provenance: "Bladestorm's resolved aura lifetime drives its finite mechanic callbacks.", gate: bladestorm_driver, source: data.require_aura_duration_ms(SpellIdx::from_raw(SPELL::BLADESTORM))?, transform: |value| value },
57 bladestorm_period_ms: u32 { provenance: "Bladestorm 227847 e1 provides its mechanic callback cadence and Imminent Demise extension quantum.", gate: bladestorm_driver, source: data.effect_lookup(EFFECT::BLADESTORM_PERIOD).period(), transform: wowlab_types::numeric::f64_to_u32_saturating_round },
58 unhinged_coef: f64 { provenance: "Unhinged's Mortal Strike callbacks use Mortal Strike 12294 e1's AP coefficient.", gate: params.talent_picked(TALENT::UNHINGED), source: ap(EFFECT::MORTAL_STRIKE_DMG), transform: |value| value },
59}
60accessor pub(super) fn arms_config(ctx);
61register pub(super) fn register_arms(built, params) -> Result<ArmsConfig, wowlab_engine_ports::EngineError>;
62prepare {
63 let data = ¶ms.game_data;
64 let base = |effect| data.effect_base_points(effect);
65 let ap = |effect| data.effect_ap_coefficient(effect);
66 let swing_s = built
67 .first_auto_attack()
68 .map_or(0.0, |aa| f64::from(aa.swing_ms) / MS_PER_SECOND);
69 let crit_swing_extra_rage =
70 swing_s * BASE_RAGE_PER_SWING_SECOND * (base(EFFECT::SEASONED_SOLDIER_CRIT) / HUNDRED);
71
72 let imminent_demise =
73 params.talent_picked(TALENT::IMMINENT_DEMISE) && params.talent_picked(TALENT::SUDDEN_DEATH);
74 let bladestorm_driver = params.talent_picked(TALENT::OVERWHELMING_BLADES)
75 || params.talent_picked(TALENT::UNHINGED);
76
77}
78auras {}
79wiring {
80 { provenance: "Sudden Death uses its DBC RPPM driver and proc-category recovery.", gate: params.talent_picked(TALENT::SUDDEN_DEATH), apply: {
81 let _ = built.register_system_rppm_from_data(TALENT::SUDDEN_DEATH)?;
82 } },
83 { provenance: "Improved Overpower charge and initialized cooldown adjustment.", gate: params.talent_picked(TALENT::IMPROVED_OVERPOWER), apply: {
84 built.patch_spell(SPELL_OVERPOWER, |spell| {
85 spell.cooldown.max_charges = IMPROVED_ATTACK_CHARGES;
86 if spell.cooldown.recharge_ms == 0 { spell.cooldown.recharge_ms = spell.cooldown.cooldown_duration_ms; }
87 });
88 } },
89 { provenance: "Battle Stance precombat aura.", gate: params.talent_picked(TALENT::BATTLE_STANCE), apply: {
90 built.push_precombat_aura(AURA_BATTLE_STANCE);
91 } },
92}
93finish |cfg| {
94 let period = std::num::NonZeroU32::new(cfg.bladestorm_period_ms);
95 let duration = std::num::NonZeroU32::new(cfg.bladestorm_duration_ms);
96
97 match (period, duration) {
98 (Some(period), Some(duration)) => {
99 if cfg.overwhelming_blades {
100 built.register_periodic_driver(
101 PeriodicDriver::new(
102 TALENT::OVERWHELMING_BLADES,
103 period.get(),
104 super::hooks::overwhelming_blades_tick,
105 )
106 .triggered_for(duration.get()),
107 );
108 }
109 if cfg.unhinged {
110 let Some(unhinged_period) = std::num::NonZeroU32::new(period.get().saturating_mul(2)) else {
111 return Err(wowlab_engine_ports::EngineError::spec_construction(
112 "Arms Unhinged periodic driver interval overflowed",
113 ));
114 };
115 built.register_periodic_driver(
116 PeriodicDriver::new(
117 TALENT::UNHINGED,
118 unhinged_period.get(),
119 super::hooks::unhinged_tick,
120 )
121 .triggered_for(duration.get()),
122 );
123 }
124 }
125 _ if bladestorm_driver && !params.game_data.is_empty() => {
126 return Err(wowlab_engine_ports::EngineError::spec_construction(
127 "Arms Bladestorm periodic driver resolved a zero duration or interval",
128 ));
129 }
130 _ => {}
131 }
132 built.state.set_spec_config(cfg);
133 Ok(cfg)
134}
135}