Skip to content

fix(Core/Players): charmed players cast highest known spell rank - #33

Closed
Nyeriah wants to merge 33 commits into
masterfrom
fix/charmed-player-spell-rank
Closed

Nyeriah wants to merge 33 commits into
masterfrom
fix/charmed-player-spell-rank

Conversation

@Nyeriah

@Nyeriah Nyeriah commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Changes Proposed:

This PR proposes changes to:

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

While a player is mind controlled (reported for Chains of Kel'Thuzad in Naxxramas, but this is generic charm-AI behaviour), Player::UpdateCharmedAI picks between a primary and a secondary spell slot at random (m_charmAISpells[... + rnd], rnd = urand(0, 1)). Player::PrepareCharmAISpells can leave a lower rank of the same spell chain in the secondary slot, so a caster whose top damage comes from a single chain (Frostbolt, Shadow Bolt, etc.) casts a reduced rank roughly half the time.

The fix normalizes every cached charm-AI spell to the highest rank the player has actually learned, by walking its spell chain with GetNextSpellInChain + HasSpell at the end of PrepareCharmAISpells. Distinct spells stay distinct (different chains are never merged); only same-chain lower ranks collapse up to the max known rank. This mirrors TrinityCore's rank resolution in PlayerAI::VerifySpellCast, applied once to AC's existing cache rather than porting the whole SimpleCharmedPlayerAI system.

AI-assisted Pull Requests

  • AI tools (e.g. Claude, ChatGPT, or similar) were used entirely or partially to prepare this pull request. If checked, specify which tools and models below.
    • Tools/models used: Claude Code (Opus 4.8)
  • I have read and understood the AC guidelines for AI Agentic Engineering

Issues Addressed:

SOURCE:

The changes have been validated through:

  • Video evidence, knowledge databases or other public sources (e.g forums, Wowhead, etc.)

Mind controlled players on retail cast the maximum rank of their spells. The rank-resolution approach mirrors TrinityCore's PlayerAI::VerifySpellCast, which walks the spell chain up to the highest known rank before casting.

Tests Performed:

  • Tested in-game by the author.
  • This pull request requires further testing and may have edge cases to be tested.

Builds and passes apps/codestyle/codestyle-cpp.py. The change only reuses symbols already present in the same function (sSpellMgr) plus the existing Player::HasSpell.

How to Test the Changes:

  • This pull request can be tested by following the reproduction steps provided in the linked issue
  1. Have a raid member run a spell rank watch addon.
  2. Engage Kel'Thuzad (25-man) and reach phase 2; wait for Chains of Kel'Thuzad to mind control players.
  3. Confirm the mind controlled players only cast maximum ranks (no low-rank alerts).

Known Issues and TODO List:

  • The two-slot charm-AI selection design (primary/secondary) is left untouched; a fuller port of TrinityCore's SimpleCharmedPlayerAI could replace it later if desired.

Kitzunu and others added 30 commits July 15, 2026 10:43
…26624)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
…om Flame Leviathan AoE (azerothcore#26622)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com>
Co-authored-by: sudlud <sudlud@users.noreply.github.com>
…e#26650)

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
…ng (azerothcore#26473)

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com>
…azerothcore#26625)

Co-authored-by: Unholychick <lucas__jensen@hotmail.com>
Co-authored-by: Chaouki Dhib <chaodhib@gmail.com>
Co-authored-by: sirikfoll <sirikfoll@hotmail.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
github-actions Bot and others added 3 commits July 18, 2026 15:59
While a player is mind controlled (e.g. Chains of Kel'Thuzad), the charm
AI in UpdateCharmedAI picks between a primary and a secondary spell slot
at random. PrepareCharmAISpells could leave a lower rank of the same
spell chain in the secondary slot, so casters whose top spells are ranks
of a single chain (Frostbolt, Shadow Bolt, etc.) cast a reduced rank
roughly half the time.

Normalize every cached charm-AI spell to the highest rank the player has
learned by walking its spell chain, mirroring TrinityCore's rank
resolution in PlayerAI::VerifySpellCast. Distinct spells stay distinct;
only same-chain lower ranks collapse to the max rank.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Nyeriah

Nyeriah commented Jul 18, 2026

Copy link
Copy Markdown
Owner Author

Retargeting to azerothcore/azerothcore-wotlk upstream.

@Nyeriah Nyeriah closed this Jul 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Naxxramas] KT mind control uses lower spell ranks sometimes