From 22b1d072c26133fbb6d53f8b867736c7b4cc9b93 Mon Sep 17 00:00:00 2001 From: Jelle Meeus Date: Thu, 22 May 2025 00:26:28 +0200 Subject: [PATCH] fix(Core/Player): aura removal logic to equipped "Use" items (#22164) Co-authored-by: itslovelol Co-authored-by: VladimirMangos --- src/server/game/Entities/Player/Player.cpp | 37 ++++------------------ 1 file changed, 7 insertions(+), 30 deletions(-) diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 435bdadcd..974a6120e 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -7125,37 +7125,26 @@ void Player::ApplyItemEquipSpell(Item* item, bool apply, bool form_change) if (!proto) return; - for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i) + for (auto const& spellData : proto->Spells) { - _Spell const& spellData = proto->Spells[i]; - - // no spell + // no spell if (!spellData.SpellId) continue; - // Spells that should stay on the caster after removing the item. - constexpr std::array spellExceptions = - { - 11826, //Electromagnetic Gigaflux Reactivator - 17490 //Book of the Dead - Summon Skeleton - }; - const auto found = std::find(std::begin(spellExceptions), std::end(spellExceptions), spellData.SpellId); - // wrong triggering type if (apply) { + // Only apply "On Equip" spells if (spellData.SpellTrigger != ITEM_SPELLTRIGGER_ON_EQUIP) - { continue; - } } else { - // If the spell is an exception do not remove it. - if (found != std::end(spellExceptions)) - { + // Do not remove "Use" spells in these special cases: + // 1. During form changes (e.g., druid shapeshifting) + // 2. When the spell comes from an item with negative charges, which means its effect should persist after the item is consumed or removed. + if (spellData.SpellTrigger == ITEM_SPELLTRIGGER_ON_USE && (form_change || spellData.SpellCharges < 0)) continue; - } } // check if it is valid spell @@ -7204,18 +7193,6 @@ void Player::ApplyEquipSpell(SpellInfo const* spellInfo, Item* item, bool apply, RemoveAurasDueToItemSpell(spellInfo->Id, item->GetGUID()); // un-apply all spells, not only at-equipped else RemoveAurasDueToSpell(spellInfo->Id); // un-apply spell (item set case) - - // Xinef: Remove Proc Spells and Summons - for (uint8 i = EFFECT_0; i < MAX_SPELL_EFFECTS; ++i) - { - // Xinef: Remove procs - if (spellInfo->Effects[i].TriggerSpell) - RemoveAurasDueToSpell(spellInfo->Effects[i].TriggerSpell); - - // Xinef: remove minions summoned by item - if (spellInfo->Effects[i].Effect == SPELL_EFFECT_SUMMON) - RemoveAllMinionsByEntry(spellInfo->Effects[i].MiscValue); - } } }