From 0bb8e3cd0c88514497fa3ec23cd702e23a2a2752 Mon Sep 17 00:00:00 2001 From: blinkysc <37940565+blinkysc@users.noreply.github.com> Date: Tue, 29 Apr 2025 20:27:19 -0500 Subject: [PATCH] fix(Scripts/SunwellPlateau): Dark Fiends should use threat table and not deal melee damage (#21991) --- .../SunwellPlateau/boss_muru.cpp | 51 +++++++++++++++++-- 1 file changed, 48 insertions(+), 3 deletions(-) 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: