From f5711dc6f78a4d4c4a87c83aea7c6d2a8567ee5b Mon Sep 17 00:00:00 2001 From: gtkk <100208412+gutoukuaiken@users.noreply.github.com> Date: Sun, 25 Jan 2026 21:03:53 +0800 Subject: [PATCH] FIX Onyxia Crash (#2062) Solve these two problems #2043 #1981 @Regrad is the main contributor of the code, while I was just helping to submit the pull request. Express my gratitude to him. After testing, the code is proven to be effective. --- src/Ai/Raid/Onyxia/Action/RaidOnyxiaActions.cpp | 17 ++++++++++++++--- .../Raid/Onyxia/Trigger/RaidOnyxiaTriggers.cpp | 4 ++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/Ai/Raid/Onyxia/Action/RaidOnyxiaActions.cpp b/src/Ai/Raid/Onyxia/Action/RaidOnyxiaActions.cpp index c0cd4beb..9fa4612b 100644 --- a/src/Ai/Raid/Onyxia/Action/RaidOnyxiaActions.cpp +++ b/src/Ai/Raid/Onyxia/Action/RaidOnyxiaActions.cpp @@ -45,8 +45,19 @@ bool RaidOnyxiaSpreadOutAction::Execute(Event event) if (!boss) return false; - Player* target = boss->GetCurrentSpell(CURRENT_GENERIC_SPELL)->m_targets.GetUnitTarget()->ToPlayer(); - if (target != bot) + // Trigger may fire on one tick, but the action can execute on a later tick. + // By that time the cast may have finished, so current spell can be null. + Spell* currentSpell = boss->GetCurrentSpell(CURRENT_GENERIC_SPELL); + if (!currentSpell || !currentSpell->m_spellInfo) + return false; + + // Fireball + if (currentSpell->m_spellInfo->Id != 18392) + return false; + + Unit* unitTarget = currentSpell->m_targets.GetUnitTarget(); + Player* target = unitTarget ? unitTarget->ToPlayer() : nullptr; + if (!target || target != bot) return false; // bot->Yell("Spreading out — I'm the Fireball target!", LANG_UNIVERSAL); @@ -60,7 +71,7 @@ bool RaidOnyxiaMoveToSafeZoneAction::Execute(Event event) return false; Spell* currentSpell = boss->GetCurrentSpell(CURRENT_GENERIC_SPELL); - if (!currentSpell) + if (!currentSpell || !currentSpell->m_spellInfo) return false; uint32 spellId = currentSpell->m_spellInfo->Id; diff --git a/src/Ai/Raid/Onyxia/Trigger/RaidOnyxiaTriggers.cpp b/src/Ai/Raid/Onyxia/Trigger/RaidOnyxiaTriggers.cpp index aed3a826..56486ebf 100644 --- a/src/Ai/Raid/Onyxia/Trigger/RaidOnyxiaTriggers.cpp +++ b/src/Ai/Raid/Onyxia/Trigger/RaidOnyxiaTriggers.cpp @@ -17,7 +17,7 @@ bool OnyxiaDeepBreathTrigger::IsActive() // Check if Onyxia is casting Spell* currentSpell = boss->GetCurrentSpell(CURRENT_GENERIC_SPELL); - if (!currentSpell) + if (!currentSpell || !currentSpell->m_spellInfo) return false; uint32 spellId = currentSpell->m_spellInfo->Id; @@ -65,7 +65,7 @@ bool RaidOnyxiaFireballSplashTrigger::IsActive() // Check if Onyxia is casting Fireball Spell* currentSpell = boss->GetCurrentSpell(CURRENT_GENERIC_SPELL); - if (!currentSpell || currentSpell->m_spellInfo->Id != 18392) // 18392 is the classic Fireball ID + if (!currentSpell || !currentSpell->m_spellInfo || currentSpell->m_spellInfo->Id != 18392) // 18392 is the classic Fireball ID // 18392 is the classic Fireball ID return false; GuidVector nearbyUnits = AI_VALUE(GuidVector, "nearest friendly players");