Skip to content

Core/Spells: Warrior fix Storm Bolt target selection #30827

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Apr 18, 2025

Conversation

MoltenCrystal
Copy link
Contributor

@MoltenCrystal MoltenCrystal commented Apr 7, 2025

Changes proposed:

  • Fixes AoE problem unless Storm Bolts is talented
  • Fixes Storm Bolt stun

Issues addressed:

Closes #30810

Tests performed:

Builds, and hits primary target like it now should unless talented in Storm Bolts

Known issues and TODO list: (add/remove lines as needed)

  • [ ]
  • [ ]

@MoltenCrystal MoltenCrystal changed the title Fixed spell Storm Bolt Core/Spells: Warrior fix Storm Bolt target selection Apr 7, 2025
Unit* caster = GetCaster();
Unit* target = GetHitUnit();

if (!caster || !target)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not necessary as caster and target are guaranteed to exist on OnEffectHitTarget

return;

// Apply the stun effect to the primary target
caster->CastSpell(target, SPELL_WARRIOR_STORM_BOLT_STUN, true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we also don't pass all cast flags anymore (true is full trigger flags) if possible, we pass required ones only

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unsure on how trigger flags work as of now, where should I look or what should I use in this case?

// Add the desired target back to the list
if (Unit* target = GetExplTargetUnit())
{
targets.push_back(GetExplTargetUnit());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's no need for brackets for a single-liner

{
Unit* caster = GetCaster();

if (!caster)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

caster is also guaranteed to exist at OnObjectAreaTargetSelect

}

void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_warr_storm_bolt::HandleOnHit, EFFECT_1, SPELL_EFFECT_DUMMY);
OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_warr_storm_bolt::FilterTargets, EFFECT_0, TARGET_UNIT_DEST_AREA_ENEMY);
OnEffectHitTarget += SpellEffectFn(spell_warr_storm_bolt::HandleDummy, EFFECT_1, SPELL_EFFECT_DUMMY);
Copy link
Contributor

@Nyr97 Nyr97 Apr 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hooked to the wrong effect as it currently stands: effect 1 uses TARGET_UNIT_TARGET_ENEMY which will only cast the stun spell on the explicit target regardless of clearing additional targets or not from effect 0 (clearing targets from one effect doesn't automatically apply to any other).

also, the wording of the talent is confusing since it doesn't state whether it should damage those additional targets or just stun them: if it's the former, hooking to effect 0 is fine; if it's the latter, then you gotta save those additional target guids from effect 0, then loop them in effect 1, etc., but it is likely not the case since the targetA is TARGET_UNIT_TARGET_ENEMY.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not quite there yet with hooks and handling, but shouldn't EFFECT_1 still be SPELL_EFFECT_DUMMY? Because if the caster has the talent [Storm Bolts] (https://www.wowhead.com/spell=436162/storm-bolts), it should hit, damage and stun two additional targets. But then I am not fully into what the "dummy" does right now either haha.

Any poiners to looping that? I was thinking about doing something with resize, but got told that it was a bad idea, and I am still learning how all of this works

Thank you so much for all comments!

@mdX7
Copy link
Member

mdX7 commented Apr 18, 2025

i moved it to a separate script, makes it more maintainable, as its only related to that specific talent.
The check if the caster has the aura was moved to Load(), so the entire script is not loaded, when Storm Bolt should hit multiple targets
The last parameter for hook registers via SpellEffectFn is the SPELL_EFFECT, not the target type (notice SpellEffect in the name). Target type is only used for target selection related hooks.

@mdX7 mdX7 merged commit f2ede23 into TrinityCore:master Apr 18, 2025
4 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Core/Spells: Storm Bolt sends three missiles without required talent
3 participants