From 745f757551a93f2c1c040d39f5fd8e39e6329288 Mon Sep 17 00:00:00 2001 From: Tereneckla Date: Mon, 9 Jun 2025 14:55:17 +0000 Subject: [PATCH] refactor(Scripts/SunwellPlateau): use existing functions for Dark Fiend target search (#22025) --- .../SunwellPlateau/boss_muru.cpp | 45 +------------------ 1 file changed, 2 insertions(+), 43 deletions(-) diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp index 748303e1e..04be10538 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp @@ -209,52 +209,11 @@ struct npc_dark_fiend : public ScriptedAI me->m_Events.AddEventAtOffset([this]() { me->SetReactState(REACT_AGGRESSIVE); + 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 const& threatList = muru->GetThreatMgr().GetThreatList(); - std::vector 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 const& threatList = entropius->GetThreatMgr().GetThreatList(); - std::vector 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)]; - } - } - } - } + target = muru->GetAI()->SelectTarget(SelectTargetMethod::Random, 0, FarthestTargetSelector(me, 50.0f, true, true)); if (target) {