Skip to content

fix(Scripts/MoltenCore): Ragnaros melee retarget on knockback#25390

Merged
Nyeriah merged 3 commits intoazerothcore:masterfrom
Nyeriah:fix/ragnaros-melee-retarget
Apr 10, 2026
Merged

fix(Scripts/MoltenCore): Ragnaros melee retarget on knockback#25390
Nyeriah merged 3 commits intoazerothcore:masterfrom
Nyeriah:fix/ragnaros-melee-retarget

Conversation

@Nyeriah
Copy link
Copy Markdown
Member

@Nyeriah Nyeriah commented Apr 7, 2026

Changes Proposed:

This PR proposes changes to:

  • Core (units, players, creatures, game systems).
  • Scripts (bosses, spell scripts, creature scripts).
  • Database (SAI, creatures, etc).

This PR implements that faithfully:

  • A repeating EVENT_MELEE_SCAN (500ms) on the existing EventMap, scheduled in ScheduleCombatEvents and auto-cleaned via CancelEventGroup(PHASE_EMERGED) on submerge.
  • When the current victim is out of melee range, Ragnaros walks the sorted threat list and switches to the highest-threat target within melee range.
  • If none exists, EVENT_MAGMA_BLAST is scheduled in 4s. If a melee target appears before then, the cast is cancelled.
  • EVENT_MAGMA_BLAST re-checks on fire (in case a melee target arrived in the same tick), targets the current victim (not random), and re-arms itself in 4s only while no one is in melee range.
  • CanAIAttack and the custom EnterEvadeMode are removed entirely so the threat system operates normally — ShouldBeOffline only checks visibility/CanCreatureAttack/flags, not melee range, so the threat list stays populated and Ragnaros never evades.

AI-assisted Pull Requests

Important

While the use of AI tools when preparing pull requests is not prohibited, contributors must clearly disclose when such tools have been used and specify the model involved.

  • AI tools (e.g. ChatGPT, Claude, or similar) were used entirely or partially in preparing this pull request. Please specify which tools were used, if any.
    • Claude Code (Opus 4.6)

Issues Addressed:

SOURCE:

The changes have been validated through:

  • Live research (checked on live servers, e.g Classic WotLK, Retail, etc.)
  • Sniffs (remember to share them with the open source community!)
  • Video evidence, knowledge databases or other public sources (e.g forums, Wowhead, etc.)
  • The changes promoted by this pull request come partially or entirely from another project (cherry-pick).

Behavior specified by @Nyeriah in review of #25326.

Tests Performed:

This PR has been:

  • Tested in-game by the author.
  • Tested in-game by other community members/someone else other than the author/has been live on production servers.
  • This pull request requires further testing and may have edge cases to be tested.

How to Test the Changes:

  • This pull request requires further testing. Provide steps to test your changes.
  1. .go xyz 838.31 -831.47 -232.19 409
  2. .instance setbossstate 8 3
  3. .npc add temp 12018
  4. .npc set faction 1080
  5. .npc set flag 1
  6. Talk to Majordomo to trigger Ragnaros summon
  7. Engage Ragnaros in melee
  8. Wait for Wrath of Ragnaros (20566) knockback
  9. Verify Ragnaros does not evade
  10. Verify Ragnaros switches to the nearest in-melee-range player if any exists
  11. Verify Ragnaros casts Magma Blast (20565) on the current victim only after 4s with no melee target
  12. Verify the Magma Blast cast is cancelled if a player re-enters melee range during the 4s window
  13. Verify Magma Blast does not fire while a player is in melee range (no longer part of normal rotation)

Known Issues and TODO List:

  • Verify submerge/emerge cycle still functions correctly
  • Verify behavior with multiple knockbacks in quick succession

Reimplements Ragnaros' out-of-melee-range behavior to be compatible
with the new threat system. Removes the CanAIAttack/EnterEvadeMode
overrides (which marked all threat refs offline on knockback and
caused a full evade) and instead drives target switching through a
500ms repeating EVENT_MELEE_SCAN scheduled on the existing EventMap.

When the current victim is out of melee range, Ragnaros switches to
the highest-threat target within melee range. If none exists, Magma
Blast is scheduled in 4s; if a melee target appears before then, the
cast is cancelled. Magma Blast targets the current victim (not a
random unit) and only repeats while no one is in melee range.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 7, 2026 12:23
@github-actions github-actions Bot added Script Refers to C++ Scripts for the Core file-cpp Used to trigger the matrix build labels Apr 7, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Reimplements Ragnaros’ “no melee targets available” behavior to work correctly with the updated threat system (retarget in-melee when possible; otherwise cast Magma Blast after a delay, cancelling if melee becomes available).

Changes:

  • Removes the custom EnterEvadeMode and CanAIAttack overrides previously used to drive Magma Blast behavior.
  • Adds a fast repeating EVENT_MELEE_SCAN to retarget to an in-melee threat target, or arm/cancel EVENT_MAGMA_BLAST depending on melee availability.
  • Updates EVENT_MAGMA_BLAST to re-check for a melee target on fire and to target the current victim rather than a random target.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +333 to +350
if (meleeTarget != me->GetVictim())
AttackStart(meleeTarget);
if (_processingMagmaBurst)
{
events.CancelEvent(EVENT_MAGMA_BLAST);
_processingMagmaBurst = false;
}
}
else if (!_processingMagmaBurst)
{
_processingMagmaBurst = true;
events.ScheduleEvent(EVENT_MAGMA_BLAST, 4s, PHASE_EMERGED, PHASE_EMERGED);
}
}
else if (_processingMagmaBurst)
{
events.CancelEvent(EVENT_MAGMA_BLAST);
_processingMagmaBurst = false;
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EVENT_MELEE_SCAN calls AttackStart(meleeTarget) to temporarily swap the victim, but on the next AI update CreatureAI::UpdateVictim() will call me->SelectVictim() (driven by ThreatManager::GetCurrentVictim()) and may immediately switch the victim back to the highest-threat target (even if out of melee). This can cause the target to flap and other events in the same/next tick to cast on the out-of-melee victim. To make the retarget stable while the current victim is out of melee, consider explicitly updating threat selection (e.g., me->GetThreatMgr().FixateTarget(meleeTarget) while out-of-melee, and ClearFixate() once a valid melee victim exists / original victim is back in range).

Suggested change
if (meleeTarget != me->GetVictim())
AttackStart(meleeTarget);
if (_processingMagmaBurst)
{
events.CancelEvent(EVENT_MAGMA_BLAST);
_processingMagmaBurst = false;
}
}
else if (!_processingMagmaBurst)
{
_processingMagmaBurst = true;
events.ScheduleEvent(EVENT_MAGMA_BLAST, 4s, PHASE_EMERGED, PHASE_EMERGED);
}
}
else if (_processingMagmaBurst)
{
events.CancelEvent(EVENT_MAGMA_BLAST);
_processingMagmaBurst = false;
me->GetThreatMgr().FixateTarget(meleeTarget);
if (meleeTarget != me->GetVictim())
AttackStart(meleeTarget);
if (_processingMagmaBurst)
{
events.CancelEvent(EVENT_MAGMA_BLAST);
_processingMagmaBurst = false;
}
}
else
{
me->GetThreatMgr().ClearFixate();
if (!_processingMagmaBurst)
{
_processingMagmaBurst = true;
events.ScheduleEvent(EVENT_MAGMA_BLAST, 4s, PHASE_EMERGED, PHASE_EMERGED);
}
}
}
else
{
me->GetThreatMgr().ClearFixate();
if (_processingMagmaBurst)
{
events.CancelEvent(EVENT_MAGMA_BLAST);
_processingMagmaBurst = false;
}

Copilot uses AI. Check for mistakes.
Comment on lines +359 to +363
if (Unit* meleeTarget = SelectMeleeThreatTarget())
{
DoCastRandomTarget(SPELL_MAGMA_BLAST);
if (meleeTarget != me->GetVictim())
AttackStart(meleeTarget);
break;
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue as in EVENT_MELEE_SCAN: calling AttackStart(meleeTarget) here does not update the threat manager’s selected victim, so the next UpdateVictim() can immediately revert to ThreatManager::GetCurrentVictim() (often the out-of-melee target you were trying to avoid). If the intent is to force melee retargeting until someone is back in range, use a threat-level mechanism (e.g. temporary FixateTarget/ClearFixate) rather than only swapping me->GetVictim().

Copilot uses AI. Check for mistakes.
@Nyeriah
Copy link
Copy Markdown
Member Author

Nyeriah commented Apr 9, 2026

Doesn't work good enough, boss keeps flickering to next melee target instead of switching fully
Need deeper redesign of threat system to support this kind of boss

Nyeriah and others added 2 commits April 9, 2026 02:53
ThreatManager::ReselectVictim() already prefers in-melee-range
targets when the highest-threat target is out of range, so the
manual threat-list scan and target switching in the script were
redundant. Drop SelectMeleeThreatTarget and rely on the core
threat system for target selection; the script now only owns the
Magma Blast fallback (scheduled in 4s when the victim is out of
melee range, cancelled if a melee target becomes available).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Nyeriah
Copy link
Copy Markdown
Member Author

Nyeriah commented Apr 9, 2026

...actually seems like this will do

@chauusie
Copy link
Copy Markdown
Contributor

chauusie commented Apr 9, 2026

He knocksback, and casts magma blast on highest threat if no one in range. If there is something in range, in this case a ghoul pet, he turns to attack that when knocking me away.

Magma blast stops being cast if back close to him within 4seconds. Magma blast is not cast when I had ghoul pet in range of him.

So in terms of the above then he is working grand and the PR fixes this.

Additional thing I noticed, unsure if he should be like this or what:

If I use gm invisibility with summoned ghouls around, but the ghouls are not in range of him, he continues to target me and attacks me in melee range, until his threat reset between stages then he completely resets if I'm still invisible.

Using gm invisibility without the ghouls around and he resets.

I repeated this with shadowmeld.

You can see in this screen, I am shadowmelded, not the .gm visible here, there are summoned pets around but not in range, but he continues to target me in shadowmeld. Is this how this is supposed to work?
bonker 4

Again with the shadowmeld, as with the gm invisibility, once he resets threat in the phase change after the adds kill the summoned ghouls, he resets normally if I'm still shadowmeld

@Nyeriah
Copy link
Copy Markdown
Member Author

Nyeriah commented Apr 9, 2026

Unsure, but shadowmeld works fairly different than what you would expect when used inside instances/raids e.g it doesn't put you out of combat

@Nyeriah
Copy link
Copy Markdown
Member Author

Nyeriah commented Apr 9, 2026

Pet ghoul seems to be broken, it is just evading all attacks
There might be some shadowmeld issues as well
I think this PR is good to go, issues are not related to the boss script.

@Nyeriah Nyeriah added To Be Merged Tested This PR has been tested and is working. and removed Waiting to be Tested labels Apr 9, 2026
@Nyeriah Nyeriah merged commit dbae464 into azerothcore:master Apr 10, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

file-cpp Used to trigger the matrix build Ready to be Reviewed Script Refers to C++ Scripts for the Core Tested This PR has been tested and is working. To Be Merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Raid] Molten Core - Ragnaros Combat Bug (General) [Raid] Molten Core - Ragnaros Combat Bug (Wrath of Ragnaros)

3 participants