fix(Scripts/Ulduar): Fix Kologarn script (#21595)

Co-authored-by: Hexadecimal <hd@hd.hd>
This commit is contained in:
p-tkachuk
2025-03-05 03:44:57 +01:00
committed by GitHub
parent 82bc814858
commit 78a01fd678
3 changed files with 92 additions and 33 deletions
@@ -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');
@@ -3984,13 +3984,6 @@ void SpellMgr::LoadSpellInfoCorrections()
spellInfo->Effects[EFFECT_0].BasePoints = -25; 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) // Eye of Kilrogg Passive (DND)
ApplySpellFix({ 2585 }, [](SpellInfo* spellInfo) ApplySpellFix({ 2585 }, [](SpellInfo* spellInfo)
{ {
@@ -155,7 +155,6 @@ public:
boss_kologarnAI(Creature* pCreature) : ScriptedAI(pCreature), vehicle(me->GetVehicleKit()), summons(me), breathReady(false) boss_kologarnAI(Creature* pCreature) : ScriptedAI(pCreature), vehicle(me->GetVehicleKit()), summons(me), breathReady(false)
{ {
m_pInstance = me->GetInstanceScript(); m_pInstance = me->GetInstanceScript();
eyebeamTarget = nullptr;
assert(vehicle); assert(vehicle);
me->SetStandState(UNIT_STAND_STATE_SUBMERGED); me->SetStandState(UNIT_STAND_STATE_SUBMERGED);
} }
@@ -167,8 +166,6 @@ public:
EventMap events; EventMap events;
SummonList summons; SummonList summons;
Unit* eyebeamTarget;
bool _looksAchievement, breathReady; bool _looksAchievement, breathReady;
uint8 _rubbleAchievement; uint8 _rubbleAchievement;
@@ -236,6 +233,7 @@ public:
_rubbleAchievement = 0; _rubbleAchievement = 0;
_looksAchievement = true; _looksAchievement = true;
me->GetMotionMaster()->MoveTargetedHome();
me->SetDisableGravity(true); me->SetDisableGravity(true);
me->DisableRotate(true); me->DisableRotate(true);
@@ -295,6 +293,24 @@ public:
summons.Summon(cr); 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 void JustDied(Unit*) override
{ {
summons.DespawnAll(); summons.DespawnAll();
@@ -340,7 +356,7 @@ public:
void PassengerBoarded(Unit* who, int8 /*seatId*/, bool apply) override void PassengerBoarded(Unit* who, int8 /*seatId*/, bool apply) override
{ {
if (!me->IsAlive()) if (!me->IsAlive() || m_pInstance->GetData(TYPE_KOLOGARN) != IN_PROGRESS)
return; return;
if (!apply) if (!apply)
@@ -408,10 +424,7 @@ public:
void UpdateAI(uint32 diff) override void UpdateAI(uint32 diff) override
{ {
if (!UpdateVictim()) if (!UpdateVictim())
{
EnterEvadeMode(EVADE_REASON_OTHER);
return; return;
}
events.Update(diff); events.Update(diff);
if (me->HasUnitState(UNIT_STATE_CASTING)) if (me->HasUnitState(UNIT_STATE_CASTING))
@@ -465,12 +478,7 @@ public:
case EVENT_FOCUSED_EYEBEAM: case EVENT_FOCUSED_EYEBEAM:
{ {
events.ScheduleEvent(EVENT_FOCUSED_EYEBEAM, 20s); events.ScheduleEvent(EVENT_FOCUSED_EYEBEAM, 20s);
me->CastSpell(me, SPELL_FOCUSED_EYEBEAM_SUMMON, false);
if ((eyebeamTarget = SelectTarget(SelectTargetMethod::MinDistance, 0, 0, true)))
{
me->CastSpell(eyebeamTarget, SPELL_FOCUSED_EYEBEAM_SUMMON, false);
}
Talk(EMOTE_EYES); Talk(EMOTE_EYES);
return; return;
} }
@@ -621,14 +629,14 @@ public:
} }
struct boss_kologarn_eyebeamAI : public ScriptedAI 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(); m_pInstance = (InstanceScript*)c->GetInstanceScript();
} }
InstanceScript* m_pInstance; InstanceScript* m_pInstance;
uint32 _timer; uint32 _timer;
bool _damaged, justSpawned; bool _damaged;
void DamageDealt(Unit* /*victim*/, uint32& damage, DamageEffectType /*damageType*/, SpellSchoolMask /*damageSchoolMask*/) override 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))) 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(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) if (_timer)
{ {
_timer += diff; _timer += diff;
if (_timer >= 2000) 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; _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<WorldObject*>& targets)
{
std::list<Unit*> 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<WorldObject*>::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<Unit*>::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 struct boss_kologarn_pit_kill_bunny : public NullCreatureAI
{ {
boss_kologarn_pit_kill_bunny(Creature* creature) : NullCreatureAI(creature) { } 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 bool Load() override
{ {
if (!GetCaster()->IsCreature()) return GetCaster()->IsCreature();
return false;
return true;
} }
void FilterTargetsInitial(std::list<WorldObject*>& targets) void FilterTargetsInitial(std::list<WorldObject*>& targets)
{ {
// Remove "main tank" and non-player 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 // Maximum affected targets per difficulty mode
uint32 maxTargets = 1; uint32 maxTargets = 1;
if (GetSpellInfo()->Id == 63981) if (GetSpellInfo()->Id == SPELL_STONE_GRIP_25)
maxTargets = 3; maxTargets = 3;
// Return a random amount of targets based on maxTargets // 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_cast_target);
RegisterSpellScript(spell_ulduar_stone_grip_aura); RegisterSpellScript(spell_ulduar_stone_grip_aura);
RegisterSpellScript(spell_ulduar_squeezed_lifeless); RegisterSpellScript(spell_ulduar_squeezed_lifeless);
RegisterSpellScript(spell_kologarn_focused_eyebeam);
RegisterSpellAndAuraScriptPair(spell_kologarn_stone_shout, spell_kologarn_stone_shout_aura); RegisterSpellAndAuraScriptPair(spell_kologarn_stone_shout, spell_kologarn_stone_shout_aura);
// Achievements // Achievements