diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp index 63f284452..748303e1e 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp @@ -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 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)]; + } + } + } + } + + if (target) { AttackStart(target); me->AddThreat(target, 100000.0f); @@ -255,8 +302,6 @@ struct npc_dark_fiend : public ScriptedAI me->DespawnOrUnsummon(); }, 1s); } - - DoMeleeAttackIfReady(); } private: