From d47e93830f54b6221daf145aeb57a48743471e28 Mon Sep 17 00:00:00 2001 From: Skjalf <47818697+Nyeriah@users.noreply.github.com> Date: Sun, 9 Apr 2023 15:37:04 -0300 Subject: [PATCH] =?UTF-8?q?feat(Core/Scripts):=20Allow=20scheduling=20mult?= =?UTF-8?q?iple=20hp=20checks=20at=20once=20for=20i=E2=80=A6=20(#15897)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit feat(Core/Scripts): Allow scheduling multiple hp checks at once for identical phases --- .../game/AI/ScriptedAI/ScriptedCreature.cpp | 8 ++++ .../game/AI/ScriptedAI/ScriptedCreature.h | 1 + .../SethekkHalls/boss_talon_king_ikiss.cpp | 37 ++++++------------- 3 files changed, 21 insertions(+), 25 deletions(-) diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp index fa19acaeb..25ed7b439 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp @@ -691,6 +691,14 @@ void BossAI::ScheduleHealthCheckEvent(uint32 healthPct, std::function ex _healthCheckEvents.push_back(HealthCheckEventData(healthPct, exec)); }; +void BossAI::ScheduleHealthCheckEvent(std::initializer_list healthPct, std::function exec) +{ + for (auto const& checks : healthPct) + { + _healthCheckEvents.push_back(HealthCheckEventData(checks, exec)); + } +} + bool BossAI::_ProccessHealthCheckEvent(uint8 healthPct, uint32 damage, std::function exec) const { if (me->HealthBelowPctDamaged(healthPct, damage)) diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.h b/src/server/game/AI/ScriptedAI/ScriptedCreature.h index 744d2d75d..f260a39e4 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedCreature.h +++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.h @@ -470,6 +470,7 @@ public: void UpdateAI(uint32 diff) override; void ScheduleHealthCheckEvent(uint32 healthPct, std::function exec); + void ScheduleHealthCheckEvent(std::initializer_list healthPct, std::function exec); // Hook used to execute events scheduled into EventMap without the need // to override UpdateAI diff --git a/src/server/scripts/Outland/Auchindoun/SethekkHalls/boss_talon_king_ikiss.cpp b/src/server/scripts/Outland/Auchindoun/SethekkHalls/boss_talon_king_ikiss.cpp index 6794a1db7..869260040 100644 --- a/src/server/scripts/Outland/Auchindoun/SethekkHalls/boss_talon_king_ikiss.cpp +++ b/src/server/scripts/Outland/Auchindoun/SethekkHalls/boss_talon_king_ikiss.cpp @@ -56,16 +56,19 @@ struct boss_talon_king_ikiss : public BossAI _Reset(); _spoken = false; - ScheduleHealthCheckEvent(80, [&] { - TeleportAndCastExplosion(); - }); + ScheduleHealthCheckEvent({ 80, 50, 25 }, [&] { + me->InterruptNonMeleeSpells(false); + DoCastAOE(SPELL_BLINK); + DoCastSelf(SPELL_ARCANE_BUBBLE, true); + Talk(EMOTE_ARCANE_EXP); - ScheduleHealthCheckEvent(50, [&] { - TeleportAndCastExplosion(); - }); - - ScheduleHealthCheckEvent(25, [&] { - TeleportAndCastExplosion(); + scheduler.Schedule(1s, [this](TaskContext) + { + DoCastAOE(SPELL_ARCANE_EXPLOSION); + }).Schedule(6500ms, [this](TaskContext /*context*/) + { + me->GetThreatMgr().ResetAllThreat(); + }); }); ScheduleHealthCheckEvent(20, [&] { @@ -79,22 +82,6 @@ struct boss_talon_king_ikiss : public BossAI return _spoken; } - void TeleportAndCastExplosion() - { - me->InterruptNonMeleeSpells(false); - DoCastAOE(SPELL_BLINK); - DoCastSelf(SPELL_ARCANE_BUBBLE, true); - Talk(EMOTE_ARCANE_EXP); - - scheduler.Schedule(1s, [this](TaskContext) - { - DoCastAOE(SPELL_ARCANE_EXPLOSION); - }).Schedule(6500ms, [this](TaskContext /*context*/) - { - me->GetThreatMgr().ResetAllThreat(); - }); - } - void MoveInLineOfSight(Unit* who) override { if (!_spoken && who->IsPlayer())