Skip to main content

wowlab_engine_combat/pipeline/
channel_start.rs

1use super::{
2    CombatCtx, DamageFlags, RuntimeDamageDef, SpellData, apply_cast_aura,
3    player_aura_for_triggered_payload, process_followup_effects, resolve_payload_flags,
4};
5
6pub(super) fn process_channel_start_payload(
7    ctx: &mut CombatCtx<'_>,
8    spell_local: crate::state::LocalSpellIdx,
9    spell: &SpellData,
10) {
11    if spell.applies_aura.is_none() && spell.followup_effects.len == 0 {
12        return;
13    }
14
15    let base_flags = spell.damage_attribute_flags
16        | if spell.behavior.is_pet {
17            DamageFlags::PET
18        } else {
19            DamageFlags::empty()
20        }
21        | if spell.damage_policy.may_crit {
22            DamageFlags::empty()
23        } else {
24            DamageFlags::NO_CRIT
25        };
26    let Some(flags) = resolve_payload_flags(
27        ctx,
28        ctx.program.damage.spell_action(spell_local),
29        RuntimeDamageDef::None,
30        spell.applies_aura,
31        spell.followup_effects,
32        base_flags,
33    ) else {
34        return;
35    };
36    let aura_before_payload = player_aura_for_triggered_payload(ctx.program, ctx.instance, spell);
37
38    if let Some(aura_local) = aura_before_payload {
39        apply_cast_aura(ctx, aura_local, None, flags);
40    }
41
42    if let Some(aura_local) = spell
43        .applies_aura
44        .filter(|aura_local| Some(*aura_local) != aura_before_payload)
45    {
46        apply_cast_aura(ctx, aura_local, None, flags);
47    }
48
49    process_followup_effects(ctx, spell_local, spell, flags);
50}