Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,15 @@ class boss_thaddius : public CreatureScript
uint32 resetTimer{};
bool ballLightningEnabled;

bool IsAnyPlayerInMeleeRange() const
{
for (auto const& ref : me->GetThreatMgr().GetThreatList())
if (Unit* target = ref->getTarget())
if (target->IsPlayer() && me->IsWithinMeleeRange(target))
return true;
return false;
}

Comment on lines +132 to +140
Copy link
Member

Choose a reason for hiding this comment

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

You could just use SelectNearestTarget() to see if it returns anything within melee range

void DoAction(int32 param) override
{
if (param == ACTION_SUMMON_DIED)
Expand Down Expand Up @@ -327,17 +336,11 @@ class boss_thaddius : public CreatureScript
break;
}

if (me->IsWithinMeleeRange(me->GetVictim()))
{
if (IsAnyPlayerInMeleeRange())
Copy link
Member

Choose a reason for hiding this comment

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

This IsAnyPlayerInMeleeRange is better part of the ballLightningEnabled check.

            else if (ballLightningEnabled && !IsAnyPlayerInMeleeRange)

DoMeleeAttackIfReady();
}
else if (ballLightningEnabled)
{
else if (ballLightningEnabled && !IsAnyPlayerInMeleeRange())
if (Unit* target = SelectTarget(SelectTargetMethod::MaxThreat))
{
me->CastSpell(target, SPELL_BALL_LIGHTNING, false);
}
}
}
};
};
Expand Down