fix(Scripts/SunwellPlateau): Dark Fiends should use threat table and not deal melee damage (#21991)

This commit is contained in:
blinkysc 2025-04-29 20:27:19 -05:00 committed by GitHub
parent 5686f1e87a
commit 0bb8e3cd0c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -209,7 +209,54 @@ struct npc_dark_fiend : public ScriptedAI
me->m_Events.AddEventAtOffset([this]() {
me->SetReactState(REACT_AGGRESSIVE);
if (Unit* target = SelectTargetFromPlayerList(200.0f, 0, true))
Unit* target = nullptr;
if (InstanceScript* instance = me->GetInstanceScript())
{
if (Creature* muru = instance->GetCreature(DATA_MURU))
{
if (muru->IsAlive() && !muru->HasUnitFlag(UNIT_FLAG_NOT_SELECTABLE))
{
std::list<HostileReference*> const& threatList = muru->GetThreatMgr().GetThreatList();
std::vector<Unit*> validTargets;
for (HostileReference* ref : threatList)
{
if (Unit* unit = ObjectAccessor::GetUnit(*muru, ref->getUnitGuid()))
{
if (unit->IsPlayer() && unit->IsAlive() && unit->IsWithinDist(me, 50.0f))
validTargets.push_back(unit);
}
}
if (!validTargets.empty())
target = validTargets[urand(0, validTargets.size() - 1)];
}
else
{
if (Creature* entropius = me->FindNearestCreature(NPC_ENTROPIUS, 100.0f))
{
std::list<HostileReference*> const& threatList = entropius->GetThreatMgr().GetThreatList();
std::vector<Unit*> validTargets;
for (HostileReference* ref : threatList)
{
if (Unit* unit = ObjectAccessor::GetUnit(*entropius, ref->getUnitGuid()))
{
if (unit->IsPlayer() && unit->IsAlive() && unit->IsWithinDist(me, 50.0f))
{
validTargets.push_back(unit);
}
}
}
if (!validTargets.empty())
target = validTargets[urand(0, validTargets.size() - 1)];
}
}
}
}
if (target)
{
AttackStart(target);
me->AddThreat(target, 100000.0f);
@ -255,8 +302,6 @@ struct npc_dark_fiend : public ScriptedAI
me->DespawnOrUnsummon();
}, 1s);
}
DoMeleeAttackIfReady();
}
private: