From b615ccd9e978daab691a5a83bc9de996c8c560f5 Mon Sep 17 00:00:00 2001 From: UltraNix <80540499+UltraNix@users.noreply.github.com> Date: Sun, 11 Dec 2022 15:35:28 +0100 Subject: [PATCH] =?UTF-8?q?fix(Core/SmartScripts):=20Added=20new=20paramet?= =?UTF-8?q?er=20`onlyInCombat`=20to=20`SMART=5F=E2=80=A6=20(#13947)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(Core/SmartScripts): Added new parameter `onlyInCombat` to `SMART_EVENT_FRIENDLY_MISSING_BUFF` event. Coilfang Scale-Healer should cast Power Word: Shield only in combat. Fixes #13838 * missing sql. --- .../rev_1669456032833719200.sql | 2 ++ .../game/AI/SmartScripts/SmartScript.cpp | 21 ++++++++++++------- .../game/AI/SmartScripts/SmartScriptMgr.h | 3 ++- 3 files changed, 17 insertions(+), 9 deletions(-) create mode 100644 data/sql/updates/pending_db_world/rev_1669456032833719200.sql diff --git a/data/sql/updates/pending_db_world/rev_1669456032833719200.sql b/data/sql/updates/pending_db_world/rev_1669456032833719200.sql new file mode 100644 index 000000000..bbc1c0022 --- /dev/null +++ b/data/sql/updates/pending_db_world/rev_1669456032833719200.sql @@ -0,0 +1,2 @@ +-- +UPDATE `smart_scripts` SET `event_param5`=1 WHERE `entryorguid`=21126 AND `source_type`=0 AND `id` IN (5,6); diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index edc439a65..240e0eeab 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -3511,16 +3511,21 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui break; } case SMART_EVENT_FRIENDLY_MISSING_BUFF: + { + if (e.event.missingBuff.onlyInCombat && !me->IsEngaged()) { - std::vector creatures; - DoFindFriendlyMissingBuff(creatures, float(e.event.missingBuff.radius), e.event.missingBuff.spell); - - if (creatures.empty()) - return; - - ProcessTimedAction(e, e.event.missingBuff.repeatMin, e.event.missingBuff.repeatMax, Acore::Containers::SelectRandomContainerElement(creatures)); - break; + return; } + + std::vector creatures; + DoFindFriendlyMissingBuff(creatures, float(e.event.missingBuff.radius), e.event.missingBuff.spell); + + if (creatures.empty()) + return; + + ProcessTimedAction(e, e.event.missingBuff.repeatMin, e.event.missingBuff.repeatMax, Acore::Containers::SelectRandomContainerElement(creatures)); + break; + } case SMART_EVENT_HAS_AURA: { if (!me) diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.h b/src/server/game/AI/SmartScripts/SmartScriptMgr.h index e1bdfd60c..27cbca259 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.h +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.h @@ -131,7 +131,7 @@ enum SMART_EVENT SMART_EVENT_VICTIM_CASTING = 13, // RepeatMin, RepeatMax, spellid SMART_EVENT_FRIENDLY_HEALTH = 14, // HPDeficit, Radius, RepeatMin, RepeatMax SMART_EVENT_FRIENDLY_IS_CC = 15, // Radius, RepeatMin, RepeatMax - SMART_EVENT_FRIENDLY_MISSING_BUFF = 16, // SpellId, Radius, RepeatMin, RepeatMax + SMART_EVENT_FRIENDLY_MISSING_BUFF = 16, // SpellId, Radius, RepeatMin, RepeatMax, onlyInCombat SMART_EVENT_SUMMONED_UNIT = 17, // CreatureId(0 all), CooldownMin, CooldownMax SMART_EVENT_TARGET_MANA_PCT = 18, // ManaMin%, ManaMax%, RepeatMin, RepeatMax SMART_EVENT_ACCEPTED_QUEST = 19, // QuestID (0 = any), CooldownMin, CooldownMax @@ -301,6 +301,7 @@ struct SmartEvent uint32 radius; uint32 repeatMin; uint32 repeatMax; + uint32 onlyInCombat; } missingBuff; struct