From f3931c0a33282a405a123dfa07103fc58084b9f9 Mon Sep 17 00:00:00 2001 From: Andrew <47818697+Nyeriah@users.noreply.github.com> Date: Fri, 24 Oct 2025 03:53:40 -0300 Subject: [PATCH] fix(Scripts/Gundrak): Update Galdarah script (#23206) --- .../rev_1760732509449091300.sql | 2 + .../Northrend/Gundrak/boss_gal_darah.cpp | 255 +++++++----------- .../scripts/Northrend/Gundrak/gundrak.h | 2 + 3 files changed, 105 insertions(+), 154 deletions(-) create mode 100644 data/sql/updates/pending_db_world/rev_1760732509449091300.sql diff --git a/data/sql/updates/pending_db_world/rev_1760732509449091300.sql b/data/sql/updates/pending_db_world/rev_1760732509449091300.sql new file mode 100644 index 000000000..b19c22111 --- /dev/null +++ b/data/sql/updates/pending_db_world/rev_1760732509449091300.sql @@ -0,0 +1,2 @@ +-- +UPDATE `creature_template` SET `flags_extra` = `flags_extra`|2147483648 WHERE `entry` IN (29306, 31368); diff --git a/src/server/scripts/Northrend/Gundrak/boss_gal_darah.cpp b/src/server/scripts/Northrend/Gundrak/boss_gal_darah.cpp index 492ceb008..50f1e5919 100644 --- a/src/server/scripts/Northrend/Gundrak/boss_gal_darah.cpp +++ b/src/server/scripts/Northrend/Gundrak/boss_gal_darah.cpp @@ -49,175 +49,124 @@ enum Yells enum Events { - EVENT_STAMPEDE = 1, - EVENT_WHIRLING_SLASH = 2, - EVENT_PUNCTURE = 3, - EVENT_ENRAGE = 4, - EVENT_IMPALING_CHARGE = 5, - EVENT_UNSUMMON_RHINO = 6, - EVENT_STOMP = 7, - EVENT_KILL_TALK = 8 + EVENT_KILL_TALK = 1 }; -class boss_gal_darah : public CreatureScript +struct boss_gal_darah : public BossAI { -public: - boss_gal_darah() : CreatureScript("boss_gal_darah") { } + boss_gal_darah(Creature* creature) : BossAI(creature, DATA_GAL_DARAH) { } - CreatureAI* GetAI(Creature* creature) const override + void Reset() override { - return GetGundrakAI(creature); + BossAI::Reset(); + DoCastSelf(SPELL_START_VISUAL); + impaledList.clear(); + _stampedeVictim.Clear(); } - struct boss_gal_darahAI : public BossAI + void JustReachedHome() override { - boss_gal_darahAI(Creature* creature) : BossAI(creature, DATA_GAL_DARAH) + BossAI::JustReachedHome(); + DoCastSelf(SPELL_START_VISUAL); + } + + void SpellHit(Unit* /*caster*/, SpellInfo const* spellInfo) override + { + if (spellInfo->Id == SPELL_TRANSFORM_TO_RHINO) { + ScheduleTimedEvent(8s, 11s, [&] { + if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 100.0f, true)) + { + DoCast(target, SPELL_IMPALING_CHARGE); + impaledList.insert(target->GetGUID()); + } + }, 16s, 17s); + + ScheduleTimedEvent(6s, 8s, [&] { + DoCastSelf(SPELL_ENRAGE); + }, 16s, 17s); + + ScheduleTimedEvent(7s, 10s, [&] { + DoCastAOE(SPELL_STOMP); + }, 10s, 12s); + + me->m_Events.AddEventAtOffset([&] { + scheduler.CancelAll(); + DoCastSelf(SPELL_TRANSFORM_TO_TROLL); + }, 32s); } - - uint8 phaseCounter; - GuidSet impaledList; - - void Reset() override + else if (spellInfo->Id == SPELL_TRANSFORM_TO_TROLL) { - BossAI::Reset(); - impaledList.clear(); - phaseCounter = 0; + ScheduleEvents(); } + } - void InitializeAI() override - { - BossAI::InitializeAI(); - me->CastSpell(me, SPELL_START_VISUAL, false); - } - - void JustReachedHome() override - { - BossAI::JustReachedHome(); - me->CastSpell(me, SPELL_START_VISUAL, false); - } - - void ScheduleEvents(bool troll) - { - events.Reset(); - if (troll) + void ScheduleEvents() + { + ScheduleTimedEvent(10s, [&] { + Talk(SAY_SUMMON_RHINO); + if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 100.0f)) { - events.RescheduleEvent(EVENT_STAMPEDE, 10s); - events.RescheduleEvent(EVENT_WHIRLING_SLASH, 21s); + _stampedeVictim = target->GetGUID(); + DoCast(target, SPELL_STAMPEDE); } - else - { - events.RescheduleEvent(EVENT_PUNCTURE, 10s); - events.RescheduleEvent(EVENT_ENRAGE, 15s); - events.RescheduleEvent(EVENT_IMPALING_CHARGE, 21s); - events.RescheduleEvent(EVENT_STOMP, 5s); - } - } + }, 15s); - void JustEngagedWith(Unit* who) override + ScheduleTimedEvent(10s, 16s, [&] { + DoCastVictim(SPELL_PUNCTURE); + }, 15s, 18s); + + ScheduleTimedEvent(11s, 19s, [&] { + DoCastAOE(SPELL_WHIRLING_SLASH); + }, 17s, 19s); + + me->m_Events.AddEventAtOffset([&] { + scheduler.CancelAll(); + DoCastSelf(SPELL_TRANSFORM_TO_RHINO); + }, 32s); + } + + void JustEngagedWith(Unit* who) override + { + Talk(SAY_AGGRO); + BossAI::JustEngagedWith(who); + + ScheduleEvents(); + me->RemoveAurasDueToSpell(SPELL_START_VISUAL); + me->InterruptNonMeleeSpells(true); + } + + void JustSummoned(Creature* summon) override + { + if (Unit* target = ObjectAccessor::GetUnit(*me, _stampedeVictim)) + summon->CastSpell(target, SPELL_STAMPEDE_DMG, true); + + summons.Summon(summon); + } + + uint32 GetData(uint32 /*type*/) const override + { + return impaledList.size(); + } + + void JustDied(Unit* killer) override + { + Talk(SAY_DEATH); + BossAI::JustDied(killer); + } + + void KilledUnit(Unit*) override + { + if (!events.HasTimeUntilEvent(EVENT_KILL_TALK)) { - Talk(SAY_AGGRO); - BossAI::JustEngagedWith(who); - - ScheduleEvents(true); - me->RemoveAurasDueToSpell(SPELL_START_VISUAL); - me->InterruptNonMeleeSpells(true); + Talk(SAY_SLAY); + events.ScheduleEvent(EVENT_KILL_TALK, 6s); } + } - void JustSummoned(Creature* summon) override - { - uint32 despawnTime = 0; - if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 60.0f, true)) - { - summon->CastSpell(target, SPELL_STAMPEDE_DMG, true); - despawnTime = (summon->GetDistance(target) / 40.0f * 1000) + 500; - } - - summon->DespawnOrUnsummon(Milliseconds(despawnTime)); - } - - uint32 GetData(uint32 /*type*/) const override - { - return impaledList.size(); - } - - void JustDied(Unit* killer) override - { - Talk(SAY_DEATH); - BossAI::JustDied(killer); - } - - void KilledUnit(Unit*) override - { - if (!events.HasTimeUntilEvent(EVENT_KILL_TALK)) - { - Talk(SAY_SLAY); - events.ScheduleEvent(EVENT_KILL_TALK, 6s); - } - } - - void UpdateAI(uint32 diff) override - { - if (!UpdateVictim()) - return; - - events.Update(diff); - if (me->HasUnitState(UNIT_STATE_CASTING | UNIT_STATE_CHARGING)) - return; - - switch (events.ExecuteEvent()) - { - case EVENT_STAMPEDE: - Talk(SAY_SUMMON_RHINO); - me->CastSpell(me->GetVictim(), SPELL_STAMPEDE, false); - events.ScheduleEvent(EVENT_STAMPEDE, 15s); - break; - case EVENT_WHIRLING_SLASH: - if (++phaseCounter >= 3) - { - ScheduleEvents(false); - me->CastSpell(me, SPELL_TRANSFORM_TO_RHINO, false); - Talk(SAY_TRANSFORM_1); - phaseCounter = 0; - return; - } - events.ScheduleEvent(EVENT_WHIRLING_SLASH, 21s); - me->CastSpell(me, SPELL_WHIRLING_SLASH, false); - break; - case EVENT_PUNCTURE: - me->CastSpell(me->GetVictim(), SPELL_PUNCTURE, false); - events.ScheduleEvent(EVENT_PUNCTURE, 8s); - break; - case EVENT_ENRAGE: - me->CastSpell(me, SPELL_ENRAGE, false); - events.ScheduleEvent(EVENT_ENRAGE, 20s); - break; - case EVENT_STOMP: - if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 30.0f, true)) - me->CastSpell(target, SPELL_STOMP, false); - events.ScheduleEvent(EVENT_STOMP, 20s); - break; - case EVENT_IMPALING_CHARGE: - if (++phaseCounter >= 3) - { - ScheduleEvents(true); - me->CastSpell(me, SPELL_TRANSFORM_TO_TROLL, false); - Talk(SAY_TRANSFORM_2); - phaseCounter = 0; - return; - } - events.ScheduleEvent(EVENT_IMPALING_CHARGE, 21s); - if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 100.0f, true, false)) - { - me->CastSpell(target, SPELL_IMPALING_CHARGE, false); - impaledList.insert(target->GetGUID()); - } - break; - } - - DoMeleeAttackIfReady(); - } - }; +private: + GuidSet impaledList; + ObjectGuid _stampedeVictim; }; class spell_galdarah_impaling_charge : public SpellScript @@ -265,9 +214,7 @@ class spell_galdarah_transform : public SpellScript class achievement_share_the_love : public AchievementCriteriaScript { public: - achievement_share_the_love() : AchievementCriteriaScript("achievement_share_the_love") - { - } + achievement_share_the_love() : AchievementCriteriaScript("achievement_share_the_love") { } bool OnCheck(Player* /*player*/, Unit* target, uint32 /*criteria_id*/) override { @@ -280,7 +227,7 @@ public: void AddSC_boss_gal_darah() { - new boss_gal_darah(); + RegisterGundrakCreatureAI(boss_gal_darah); RegisterSpellScript(spell_galdarah_impaling_charge); RegisterSpellScript(spell_galdarah_transform); new achievement_share_the_love(); diff --git a/src/server/scripts/Northrend/Gundrak/gundrak.h b/src/server/scripts/Northrend/Gundrak/gundrak.h index ea340b4c0..7e0ffa41a 100644 --- a/src/server/scripts/Northrend/Gundrak/gundrak.h +++ b/src/server/scripts/Northrend/Gundrak/gundrak.h @@ -71,4 +71,6 @@ inline AI* GetGundrakAI(T* obj) return GetInstanceAI(obj, GundrakScriptName); } +#define RegisterGundrakCreatureAI(ai_name) RegisterCreatureAIWithFactory(ai_name, GetGundrakAI) + #endif