From 78a01fd67844d3cfbd205415d88aa0885bf40969 Mon Sep 17 00:00:00 2001 From: p-tkachuk Date: Wed, 5 Mar 2025 03:44:57 +0100 Subject: [PATCH] fix(Scripts/Ulduar): Fix Kologarn script (#21595) Co-authored-by: Hexadecimal --- .../rev_1740514128965406500.sql | 3 + .../game/Spells/SpellInfoCorrections.cpp | 7 -- .../Northrend/Ulduar/Ulduar/boss_kologarn.cpp | 115 ++++++++++++++---- 3 files changed, 92 insertions(+), 33 deletions(-) create mode 100644 data/sql/updates/pending_db_world/rev_1740514128965406500.sql diff --git a/data/sql/updates/pending_db_world/rev_1740514128965406500.sql b/data/sql/updates/pending_db_world/rev_1740514128965406500.sql new file mode 100644 index 000000000..7b268e3da --- /dev/null +++ b/data/sql/updates/pending_db_world/rev_1740514128965406500.sql @@ -0,0 +1,3 @@ +-- +DELETE FROM `spell_script_names` WHERE `spell_id`=63342; +INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES (63342, 'spell_kologarn_focused_eyebeam'); diff --git a/src/server/game/Spells/SpellInfoCorrections.cpp b/src/server/game/Spells/SpellInfoCorrections.cpp index bbb45d557..29f9930c5 100644 --- a/src/server/game/Spells/SpellInfoCorrections.cpp +++ b/src/server/game/Spells/SpellInfoCorrections.cpp @@ -3984,13 +3984,6 @@ void SpellMgr::LoadSpellInfoCorrections() spellInfo->Effects[EFFECT_0].BasePoints = -25; }); - // Focused Eyebeam Summon Trigger - ApplySpellFix({ 63342 }, [](SpellInfo* spellInfo) - { - spellInfo->MaxAffectedTargets = 1; - spellInfo->Effects[EFFECT_0].TargetB = SpellImplicitTargetInfo(); - }); - // Eye of Kilrogg Passive (DND) ApplySpellFix({ 2585 }, [](SpellInfo* spellInfo) { diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp index 8aa696ac3..34f5cf155 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp @@ -155,7 +155,6 @@ public: boss_kologarnAI(Creature* pCreature) : ScriptedAI(pCreature), vehicle(me->GetVehicleKit()), summons(me), breathReady(false) { m_pInstance = me->GetInstanceScript(); - eyebeamTarget = nullptr; assert(vehicle); me->SetStandState(UNIT_STAND_STATE_SUBMERGED); } @@ -167,8 +166,6 @@ public: EventMap events; SummonList summons; - Unit* eyebeamTarget; - bool _looksAchievement, breathReady; uint8 _rubbleAchievement; @@ -236,6 +233,7 @@ public: _rubbleAchievement = 0; _looksAchievement = true; + me->GetMotionMaster()->MoveTargetedHome(); me->SetDisableGravity(true); me->DisableRotate(true); @@ -295,6 +293,24 @@ public: summons.Summon(cr); } + void SummonedCreatureDespawn(Creature* cr) override + { + if (m_pInstance->GetData(TYPE_KOLOGARN) > NOT_STARTED) + return; + + if (cr->GetEntry() == NPC_LEFT_ARM) + { + _left.Clear(); + AttachLeftArm(); + } + + if (cr->GetEntry() == NPC_RIGHT_ARM) + { + _right.Clear(); + AttachRightArm(); + } + } + void JustDied(Unit*) override { summons.DespawnAll(); @@ -340,7 +356,7 @@ public: void PassengerBoarded(Unit* who, int8 /*seatId*/, bool apply) override { - if (!me->IsAlive()) + if (!me->IsAlive() || m_pInstance->GetData(TYPE_KOLOGARN) != IN_PROGRESS) return; if (!apply) @@ -408,10 +424,7 @@ public: void UpdateAI(uint32 diff) override { if (!UpdateVictim()) - { - EnterEvadeMode(EVADE_REASON_OTHER); return; - } events.Update(diff); if (me->HasUnitState(UNIT_STATE_CASTING)) @@ -465,12 +478,7 @@ public: case EVENT_FOCUSED_EYEBEAM: { events.ScheduleEvent(EVENT_FOCUSED_EYEBEAM, 20s); - - if ((eyebeamTarget = SelectTarget(SelectTargetMethod::MinDistance, 0, 0, true))) - { - me->CastSpell(eyebeamTarget, SPELL_FOCUSED_EYEBEAM_SUMMON, false); - } - + me->CastSpell(me, SPELL_FOCUSED_EYEBEAM_SUMMON, false); Talk(EMOTE_EYES); return; } @@ -621,14 +629,14 @@ public: } struct boss_kologarn_eyebeamAI : public ScriptedAI { - boss_kologarn_eyebeamAI(Creature* c) : ScriptedAI(c), _timer(1), _damaged(false), justSpawned(true) + boss_kologarn_eyebeamAI(Creature* c) : ScriptedAI(c), _timer(1), _damaged(false) { m_pInstance = (InstanceScript*)c->GetInstanceScript(); } InstanceScript* m_pInstance; uint32 _timer; - bool _damaged, justSpawned; + bool _damaged; void DamageDealt(Unit* /*victim*/, uint32& damage, DamageEffectType /*damageType*/, SpellSchoolMask /*damageSchoolMask*/) override { @@ -640,24 +648,34 @@ public: } } - void UpdateAI(uint32 diff) override + void IsSummonedBy(WorldObject* summoner) override { - if (justSpawned) + if (!summoner) { - me->DespawnOrUnsummon(10000); + return; + } + + // Should only work on playable characters + if (Player* player = summoner->ToPlayer()) + { + me->Attack(player, false); + me->GetMotionMaster()->MoveChase(player); + if (Creature* cr = ObjectAccessor::GetCreature(*me, m_pInstance->GetGuidData(TYPE_KOLOGARN))) { me->CastSpell(cr, me->GetEntry() == NPC_EYE_LEFT ? SPELL_FOCUSED_EYEBEAM_LEFT : SPELL_FOCUSED_EYEBEAM_RIGHT, true); } - me->CastSpell(me, SPELL_FOCUSED_EYEBEAM, true); - justSpawned = false; } + } + + void UpdateAI(uint32 diff) override + { if (_timer) { _timer += diff; if (_timer >= 2000) { - me->CastSpell(me, (me->GetMap()->Is25ManRaid() ? SPELL_FOCUSED_EYEBEAM_25 : SPELL_FOCUSED_EYEBEAM_10), true); + me->CastSpell(me, SPELL_FOCUSED_EYEBEAM, true); _timer = 0; } } @@ -665,6 +683,52 @@ public: }; }; +class spell_kologarn_focused_eyebeam : public SpellScript +{ + PrepareSpellScript(spell_kologarn_focused_eyebeam); + + bool Load() override + { + return GetCaster()->IsCreature(); + } + + void FilterTargetsInitial(std::list& targets) + { + std::list newTargets; + Creature* creature = GetCaster()->ToCreature(); + // Select 3 most distant targets + GetCaster()->GetAI()->SelectTargetList(newTargets, 3, SelectTargetMethod::MaxDistance, 0, NonTankTargetSelector(creature, true)); + + // If no distant targets available, get 1 target from original list + if (newTargets.empty()) + { + if (!targets.empty()) + { + while (1 < targets.size()) + { + std::list::iterator itr = targets.begin(); + advance(itr, urand(0, targets.size() - 1)); + targets.erase(itr); + } + } + return; + } + + // Clear original targets + targets.clear(); + + // Select a random target + std::list::iterator head = newTargets.begin(); + advance(head, urand(0, newTargets.size() - 1)); + targets.push_back(*head); + } + + void Register() override + { + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_kologarn_focused_eyebeam::FilterTargetsInitial, EFFECT_ALL, TARGET_UNIT_SRC_AREA_ENEMY); + } +}; + struct boss_kologarn_pit_kill_bunny : public NullCreatureAI { boss_kologarn_pit_kill_bunny(Creature* creature) : NullCreatureAI(creature) { } @@ -724,18 +788,16 @@ class spell_ulduar_stone_grip_cast_target : public SpellScript bool Load() override { - if (!GetCaster()->IsCreature()) - return false; - return true; + return GetCaster()->IsCreature(); } void FilterTargetsInitial(std::list& targets) { // Remove "main tank" and non-player targets - targets.remove_if (StoneGripTargetSelector(GetCaster()->ToCreature(), GetCaster()->GetVictim())); + targets.remove_if(StoneGripTargetSelector(GetCaster()->ToCreature(), GetCaster()->GetVictim())); // Maximum affected targets per difficulty mode uint32 maxTargets = 1; - if (GetSpellInfo()->Id == 63981) + if (GetSpellInfo()->Id == SPELL_STONE_GRIP_25) maxTargets = 3; // Return a random amount of targets based on maxTargets @@ -882,6 +944,7 @@ void AddSC_boss_kologarn() RegisterSpellScript(spell_ulduar_stone_grip_cast_target); RegisterSpellScript(spell_ulduar_stone_grip_aura); RegisterSpellScript(spell_ulduar_squeezed_lifeless); + RegisterSpellScript(spell_kologarn_focused_eyebeam); RegisterSpellAndAuraScriptPair(spell_kologarn_stone_shout, spell_kologarn_stone_shout_aura); // Achievements