Skip to content

Commit

Permalink
fix(Scripts/SerpentshrineCavern) Filter Watery Grave Target (azerothc…
Browse files Browse the repository at this point in the history
…ore#18463)

Filter_Target
  • Loading branch information
Alethrion authored Mar 1, 2024
1 parent b9c1dc9 commit 016d980
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,23 @@ class spell_morogrim_tidewalker_watery_grave : public SpellScript
return true;
}

void FilterTargets(std::list<WorldObject*>& targets)
{
uint8 maxSize = 4;
Unit* caster = GetCaster();

targets.remove_if([caster](WorldObject const* target) -> bool
{
// Should not target current victim.
return caster->GetVictim() == target;
});

if (targets.size() > maxSize)
{
Acore::Containers::RandomResize(targets, maxSize);
}
}

void HandleDummy(SpellEffIndex effIndex)
{
PreventHitDefaultEffect(effIndex);
Expand All @@ -159,6 +176,7 @@ class spell_morogrim_tidewalker_watery_grave : public SpellScript

void Register() override
{
OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_morogrim_tidewalker_watery_grave::FilterTargets, EFFECT_ALL, TARGET_UNIT_SRC_AREA_ENEMY);
OnEffectHitTarget += SpellEffectFn(spell_morogrim_tidewalker_watery_grave::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}

Expand Down

0 comments on commit 016d980

Please sign in to comment.