From 92bc564d883742ff12c6838bdeeca387e9762304 Mon Sep 17 00:00:00 2001 From: Andrew <47818697+Nyeriah@users.noreply.github.com> Date: Sat, 18 Jul 2026 21:23:51 -0300 Subject: [PATCH] fix(Core/Players): charmed players cast highest known spell rank (#26674) Co-authored-by: Claude Opus 4.8 --- src/server/game/Entities/Player/Player.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 8728e5252..47d095b17 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -15838,6 +15838,24 @@ void Player::PrepareCharmAISpells() } } } + + // The selection above can leave a lower rank of a spell chain in a slot (e.g. the + // secondary damage slot for a caster whose top spells are ranks of one chain). While + // charmed the player should cast the highest rank it knows, so walk each slot up its + // chain to the top learned rank. + for (uint32& charmSpellId : m_charmAISpells) + { + if (!charmSpellId) + continue; + + while (uint32 nextRank = sSpellMgr->GetNextSpellInChain(charmSpellId)) + { + if (!HasActiveSpell(nextRank)) + break; + + charmSpellId = nextRank; + } + } } void Player::AddRefundReference(ObjectGuid itemGUID)