From 2a1d706a2f11bf307cfb5ae84afbcd4418393ca2 Mon Sep 17 00:00:00 2001 From: UltraNix <80540499+UltraNix@users.noreply.github.com> Date: Fri, 12 May 2023 14:15:02 +0200 Subject: [PATCH] =?UTF-8?q?fix(Scripts/Underbog):=20Underbat's=20Tentacle?= =?UTF-8?q?=20Lash=20should=20be=20casted=20only=20=E2=80=A6=20(#14566)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(Scripts/Underbog: Underbat's Tentacle Lash should be casted only on targets behind the bat. Fixes #13972 * buildfix. --- .../rev_1673176236867407100.sql | 7 +++ .../CoilfangReservoir/underbog/underbog.cpp | 47 +++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 data/sql/updates/pending_db_world/rev_1673176236867407100.sql diff --git a/data/sql/updates/pending_db_world/rev_1673176236867407100.sql b/data/sql/updates/pending_db_world/rev_1673176236867407100.sql new file mode 100644 index 000000000..73a95444b --- /dev/null +++ b/data/sql/updates/pending_db_world/rev_1673176236867407100.sql @@ -0,0 +1,7 @@ +-- +UPDATE `creature_template` SET `AiName`='', `ScriptName`='npc_underbat' WHERE `entry`=17724; +DELETE FROM `smart_scripts` WHERE `entryorguid`=17724 AND `source_type`=0; + +DELETE FROM `spelldifficulty_dbc` WHERE `ID`=34171; +INSERT INTO `spelldifficulty_dbc` VALUES +(34171,34171,37956,0,0); diff --git a/src/server/scripts/Outland/CoilfangReservoir/underbog/underbog.cpp b/src/server/scripts/Outland/CoilfangReservoir/underbog/underbog.cpp index 6f68fcd74..04880735e 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/underbog/underbog.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/underbog/underbog.cpp @@ -16,9 +16,55 @@ */ #include "ScriptMgr.h" +#include "ScriptedCreature.h" #include "SpellScript.h" +#include "TaskScheduler.h" #include "the_underbog.h" +enum UnderbatSpells +{ + SPELL_TENTACLE_LASH = 34171 +}; + +struct npc_underbat : public ScriptedAI +{ + npc_underbat(Creature* c) : ScriptedAI(c) {} + + void Reset() override + { + _scheduler.CancelAll(); + } + + void JustEngagedWith(Unit* /*who*/) override + { + _scheduler.Schedule(2200ms, 6900ms, [this](TaskContext context) + { + if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, [&](Unit* u) + { + return u->IsAlive() && !u->IsPet() && me->IsWithinCombatRange(u, 20.f) && !me->HasInArc(M_PI, u); + })) + { + DoCast(target, SPELL_TENTACLE_LASH); + } + context.Repeat(5700ms, 9700ms); + }); + } + + void UpdateAI(uint32 diff) override + { + if (!UpdateVictim()) + return; + + _scheduler.Update(diff, [this] + { + DoMeleeAttackIfReady(); + }); + } + +private: + TaskScheduler _scheduler; +}; + class spell_fungal_decay : public AuraScript { PrepareAuraScript(spell_fungal_decay); @@ -72,6 +118,7 @@ class spell_allergies : public AuraScript void AddSC_underbog() { + RegisterUnderbogCreatureAI(npc_underbat); RegisterSpellScript(spell_fungal_decay); RegisterSpellScript(spell_allergies); }