From 6674950c9b7e75f5dd70054122de91fc3981b344 Mon Sep 17 00:00:00 2001 From: killerwife Date: Fri, 15 Dec 2023 11:40:48 +0100 Subject: [PATCH] Scripts: Implement SCRIPT_FLAG_BUDDY_IS_DESPAWNED for SCRIPT_FLAG_BUDDY_BY_STRING_ID --- src/game/DBScripts/ScriptMgr.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/game/DBScripts/ScriptMgr.cpp b/src/game/DBScripts/ScriptMgr.cpp index e8f865ac45..e95d3c779e 100644 --- a/src/game/DBScripts/ScriptMgr.cpp +++ b/src/game/DBScripts/ScriptMgr.cpp @@ -1470,13 +1470,17 @@ std::pair ScriptAction::GetScriptProcessTargets(WorldObject* origina if ((m_script->data_flags & SCRIPT_FLAG_ALL_ELIGIBLE_BUDDIES) != 0) { for (WorldObject* wo : *worldObjects) - buddies.push_back(wo); + if (!wo->IsCreature() || static_cast(wo)->IsAlive() != m_script->IsDeadOrDespawnedBuddy()) + buddies.push_back(wo); } else { WorldObject* closest = nullptr; for (WorldObject* wo : *worldObjects) { + if (wo->IsCreature() && static_cast(wo)->IsAlive() == m_script->IsDeadOrDespawnedBuddy()) + continue; + if (!closest) closest = wo; else if (origin->GetDistance(wo, true, DIST_CALC_NONE) < origin->GetDistance(closest, true, DIST_CALC_NONE))