Skip to main content

wowlab_engine_content/hooks/fury_warrior/
config.rs

1use wowlab_engine_combat::{BuffEffect, ImpactProc, ResourcePool};
2use wowlab_engine_domain::dbc::ResolvedGameDataEffectExt as _;
3use wowlab_types::{
4    constants::{HUNDRED, MS_PER_SECOND},
5    sim::SpellIdx,
6};
7
8use crate::{
9    generated::specs::fury_warrior::{
10        AURA_BERSERKER_STANCE, AURA_RECKLESSNESS, EFFECT, SET_BONUS, SPELL, SPELL_EXECUTE,
11        SPELL_RAGING_BLOW, SPELL_RECKLESSNESS, TALENT,
12    },
13    hooks::{
14        gated, gated_or,
15        shared::warrior::{EXECUTE_BASE_PCT, FROTHING_CHANCE, IMPROVED_ATTACK_CHARGES, PRD_C_15},
16    },
17};
18
19/// Rampage cast spell affected by the Rampaging Berserker reck-window cost delta.
20static RAMPAGE_COST_SPELLS: [u32; 1] = [SPELL::RAMPAGE];
21/// Raw e1 value divided by ten for rage display scaling.
22const RAMPAGING_BERSERKER_COST_DIVISOR: f64 = 10.0;
23use super::hooks::{
24    bloodbath_dot_impact, bloodbath_impact_filter, bloodthirst_family_impact_filter,
25    cold_steel_hot_blood_impact,
26};
27
28/// Rage power-type display divisor (DBC stores rage *10).
29pub(super) const RAGE_DISPLAY_DIV: f64 = 10.0;
30
31const FRENZY_TALENT: u32 = 335_077;
32const FOCUS_IN_CHAOS_TALENT: u32 = 383_486;
33
34crate::hooks::define_spec_config! {
35/// Talent-gated Fury hook parameters.
36pub(super) struct FuryConfig {
37    bloodborne: bool { provenance: "Bloodborne 385703 grants its periodic-damage aura from Bloodthirst and Bloodbath.", gate: params.talent_picked(TALENT::BLOODBORNE), source: true, transform: |value| value },
38    frenzy: bool { provenance: "Frenzy 335077 applies its asynchronous haste aura from Rampage.", gate: params.talent_picked(FRENZY_TALENT), source: true, transform: |value| value },
39    wild_strikes: bool { provenance: "Wild Strikes selection gates the auto-crit speed buff.", gate: params.talent_picked(TALENT::WILD_STRIKES), source: true, transform: |value| value },
40    surge_of_adrenaline: bool { provenance: "Surge of Adrenaline selection gates reset-triggered buffs.", gate: params.talent_picked(TALENT::SURGE_OF_ADRENALINE), source: true, transform: |value| value },
41    rb_reset_chance: f64 { provenance: "Raging Blow 85288 e1 reset chance.", gate: params.talent_picked(TALENT::IMPROVED_RAGING_BLOW), source: base(EFFECT::RB_RESET_CHANCE), transform: |value| value / HUNDRED },
42    wnf_reset_chance: f64 { provenance: "Wrath and Fury 392936 e1 extra reset chance while enraged.", gate: params.talent_picked(TALENT::IMPROVED_RAGING_BLOW) && params.talent_picked(TALENT::WRATH_AND_FURY), source: base(EFFECT::WNF_RESET_CHANCE), transform: |value| value / HUNDRED },
43    execute_threshold: f64 { provenance: "Massacre 206315 e2 threshold, otherwise the 20% baseline.", gate: true, source: gated_or(params.talent_picked(TALENT::MASSACRE), EXECUTE_BASE_PCT, || base(EFFECT::MASSACRE_PCT)), transform: |value| value / HUNDRED },
44    deep_wounds: bool { provenance: "Deep Wounds 1261060 applies from Execute main-hand impacts.", gate: params.talent_picked(TALENT::DEEP_WOUNDS), source: true, transform: |value| value },
45    slayers_dominance: bool { provenance: "Slayer's Dominance 444767 selection.", gate: params.talent_picked(TALENT::SLAYERS_DOMINANCE), source: true, transform: |value| value },
46    slayers_strike_coef: f64 { provenance: "Slayer's Strike AP coefficient.", gate: true, source: ap(EFFECT::SLAYERS_STRIKE_DMG), transform: |value| value },
47    prd_c: f64 { provenance: "`SimC` PRD constant for the 15% nominal rate.", gate: true, source: PRD_C_15, transform: |value| value },
48    imminent_demise_every: i32 { provenance: "Imminent Demise 444769 e1 strike interval.", gate: imminent_demise, source: base(EFFECT::IMMINENT_DEMISE_EVERY), transform: wowlab_types::numeric::f64_to_i32_saturating_trunc },
49    reap_chance: f64 { provenance: "Imminent Demise 444769 e2 Reap chance.", gate: reap, source: base(EFFECT::IMMINENT_DEMISE_REAP_CHANCE), transform: |value| value / HUNDRED },
50    reap_coef: f64 { provenance: "Reap the Storm 446005 e1 AP coefficient.", gate: true, source: ap(EFFECT::REAP_DMG), transform: |value| value },
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    unhinged: bool { provenance: "Unhinged 386628 casts Bloodthirst on odd Bladestorm ticks.", gate: params.talent_picked(TALENT::UNHINGED), source: true, transform: |value| value },
54    executioners_wrath: bool { provenance: "Executioner's Wrath selection gates the Rampage buff.", gate: params.talent_picked(TALENT::EXECUTIONERS_WRATH), source: true, transform: |value| value },
55    set4pc_odyns_cdr_ms: u32 { provenance: "MID1 Fury 4pc 1264878 e1 Odyn's Fury CDR.", gate: set4, source: base(EFFECT::SET4PC_ODYNS_CDR_MS), transform: wowlab_types::numeric::f64_to_u32_saturating_trunc },
56    anger_management_div: f64 { provenance: "Anger Management 152278 e3 rage per second of CDR.", gate: params.talent_picked(TALENT::ANGER_MANAGEMENT), source: base(EFFECT::ANGER_MANAGEMENT_DIV), transform: |value| value },
57    frothing_chance: f64 { provenance: "Frothing Berserker `SpellAuraOptions` proc chance.", gate: params.talent_picked(TALENT::FROTHING_BERSERKER), source: FROTHING_CHANCE, transform: |value| value },
58    frothing_refund_pct: f64 { provenance: "Frothing Berserker 392792 e1 refund fraction.", gate: true, source: base(EFFECT::FROTHING_REFUND), transform: |value| value / HUNDRED },
59    bladestorm_duration_ms: u32 { provenance: "Bladestorm's resolved aura lifetime drives its finite mechanic callbacks.", gate: params.talent_picked(TALENT::UNHINGED), source: data.require_aura_duration_ms(SpellIdx::from_raw(SPELL::BLADESTORM))?, transform: |value| value },
60    bladestorm_period_ms: u32 { provenance: "Bladestorm 227847 e1 provides the Unhinged callback cadence and Imminent Demise extension quantum.", gate: params.talent_picked(TALENT::UNHINGED), source: data.effect_lookup(EFFECT::BLADESTORM_PERIOD).period(), transform: wowlab_types::numeric::f64_to_u32_saturating_round },
61    unhinged_bloodthirst_coef: f64 { provenance: "Unhinged's Bloodthirst callbacks use Bloodthirst 23881 e1's AP coefficient.", gate: params.talent_picked(TALENT::UNHINGED), source: ap(EFFECT::BLOODTHIRST_DAMAGE), transform: |value| value },
62    unhinged_bloodthirst_rage: f64 { provenance: "Unhinged's Bloodthirst callbacks energize from Bloodthirst 23881 e2 with rage display scaling.", gate: params.talent_picked(TALENT::UNHINGED), source: base(EFFECT::BLOODTHIRST_RAGE), transform: |value| value / RAGE_DISPLAY_DIV },
63    unhinged_bloodbath_coef: f64 { provenance: "Reckless Abandon makes Unhinged use Bloodbath 335096 e1 while Recklessness is active.", gate: params.talent_picked(TALENT::UNHINGED), source: ap(EFFECT::BLOODBATH_DAMAGE), transform: |value| value },
64    unhinged_bloodbath_rage: f64 { provenance: "Unhinged Bloodbath callbacks energize from Bloodbath 335096 e2 with rage display scaling.", gate: params.talent_picked(TALENT::UNHINGED), source: base(EFFECT::BLOODBATH_RAGE), transform: |value| value / RAGE_DISPLAY_DIV },
65}
66accessor pub(super) fn fury_config(ctx);
67register pub(super) fn register_fury(built, params) -> Result<FuryConfig, wowlab_engine_ports::EngineError>;
68prepare {
69    let data = &params.game_data;
70    let base = |effect| data.effect_base_points(effect);
71    let ap = |effect| data.effect_ap_coefficient(effect);
72
73    let imminent_demise =
74        params.talent_picked(TALENT::IMMINENT_DEMISE) && params.talent_picked(TALENT::SUDDEN_DEATH);
75    let reap = params.talent_picked(TALENT::REAP_THE_STORM) && imminent_demise;
76    let set4 = params.set_bonus_auras.contains(&SET_BONUS::MID1_FURY_4PC);
77
78}
79auras {
80    { provenance: "Rampaging Berserker rank two: Rampage rage-cost delta while Recklessness is active (1269309 e1 / 10; SimC rampage_parent_t::cost, sc_warrior.cpp:5560, gated by parse_effects enable(14) at sc_warrior.cpp:1080).", gate: params.talent_picked(TALENT::RAMPAGING_BERSERKER_2), aura: AURA_RECKLESSNESS, effect: BuffEffect::SpellCostFlat(base(EFFECT::RAMPAGING_BERSERKER_COST) / RAMPAGING_BERSERKER_COST_DIVISOR, &RAMPAGE_COST_SPELLS, ResourcePool::Primary) },
81    { provenance: "Rampaging Berserker rank two: Rampage damage while Recklessness is active (1269309 e2; SimC rampage_attack_t::composite_da_multiplier, sc_warrior.cpp:5349).", gate: params.talent_picked(TALENT::RAMPAGING_BERSERKER_2), aura: AURA_RECKLESSNESS, effect: BuffEffect::DamageMultSpells(1.0 + base(EFFECT::RAMPAGING_BERSERKER_DMG) / HUNDRED, &RAMPAGE_COST_SPELLS) },
82}
83wiring {
84    { provenance: "Sudden Death uses its DBC RPPM driver and proc-category recovery.", gate: params.talent_picked(TALENT::SUDDEN_DEATH), apply: {
85        let _ = built.register_system_rppm_from_data(TALENT::SUDDEN_DEATH)?;
86    } },
87    { provenance: "Focus in Chaos 383486 removes the dual-wield white-miss penalty while Enrage is active.", gate: params.talent_picked(FOCUS_IN_CHAOS_TALENT), apply: {
88        built.patch_auto_attacks(|attacks| for attack in attacks {
89            if !attack.is_pet {
90                attack.miss_chance_hook = Some(super::hooks::focus_in_chaos_miss_chance);
91            }
92        });
93    } },
94    { provenance: "Bloodbath applies its 113344 bleed on direct impact.", gate: true, apply: {
95        built.register_impact_proc(ImpactProc::new(bloodbath_dot_impact).with_spell_filter(bloodbath_impact_filter).skip_periodic());
96    } },
97    { provenance: "Cold Steel, Hot Blood applies Gushing Wound and energizes on Bloodthirst-family critical impacts.", gate: params.talent_picked(TALENT::COLD_STEEL_HOT_BLOOD), apply: {
98        built.register_impact_proc(ImpactProc::new(cold_steel_hot_blood_impact).with_spell_filter(bloodthirst_family_impact_filter).skip_periodic().crit_only());
99    } },
100    { provenance: "Improved Raging Blow charge adjustment.", gate: params.talent_picked(TALENT::IMPROVED_RAGING_BLOW), apply: {
101        built.patch_spell(SPELL_RAGING_BLOW, |spell| {
102            spell.cooldown.max_charges = IMPROVED_ATTACK_CHARGES;
103            if spell.cooldown.recharge_ms == 0 { spell.cooldown.recharge_ms = spell.cooldown.cooldown_duration_ms; }
104        });
105    } },
106    { provenance: "Improved Execute cost replacement and rage gain.", gate: params.talent_picked(TALENT::IMPROVED_EXECUTE), apply: {
107        let gain = base(EFFECT::IMPROVED_EXECUTE_RAGE) / RAGE_DISPLAY_DIV
108            + gated(params.talent_picked(TALENT::EXECUTIONERS_WRATH), || base(EFFECT::EXECUTIONERS_WRATH_RAGE) / RAGE_DISPLAY_DIV);
109        built.patch_spell(SPELL_EXECUTE, |spell| {
110            spell.cost.resource_cost = 0.0;
111            spell.cost.resource_gain = gain;
112        });
113    } },
114    { provenance: "Massacre Execute cooldown reduction.", gate: params.talent_picked(TALENT::MASSACRE), apply: {
115        let cdr = wowlab_types::numeric::f64_to_u32_saturating_trunc(base(EFFECT::MASSACRE_EXECUTE_CDR_MS));
116        built.patch_spell(SPELL_EXECUTE, |spell| {
117            spell.cooldown.cooldown_duration_ms = spell.cooldown.cooldown_duration_ms.saturating_sub(cdr);
118        });
119    } },
120    { provenance: "Reckless Abandon Recklessness rage gain.", gate: params.talent_picked(TALENT::RECKLESS_ABANDON), apply: {
121        built.patch_spell(SPELL_RECKLESSNESS, |spell| {
122            spell.cost.resource_gain = base(EFFECT::RECKLESS_ABANDON_RAGE) / RAGE_DISPLAY_DIV;
123        });
124    } },
125    { provenance: "Berserker Stance precombat aura.", gate: params.talent_picked(TALENT::BERSERKER_STANCE), apply: {
126        built.push_precombat_aura(AURA_BERSERKER_STANCE);
127    } },
128}
129finish |cfg| {
130    built.state.set_spec_config(cfg);
131    Ok(cfg)
132}
133}