From 6462b7baf4177cc3a61af7989ac45e527012af15 Mon Sep 17 00:00:00 2001 From: Hondacrx Date: Sun, 25 Aug 2024 23:42:13 -0400 Subject: [PATCH] Core/Spells: Implemented SPELL_ATTR9_IGNORE_TOTEM_REQUIREMENTS_FOR_CASTING - fixes some totems requiring legacy items in inventory Port From (https://github.com/TrinityCore/TrinityCore/commit/8142ab20b7495ca87a135e08e473f5a33a40e5a4) --- .../Framework/Constants/Spells/SpellConst.cs | 2 +- Source/Game/Spells/Spell.cs | 37 ++++++------------- 2 files changed, 12 insertions(+), 27 deletions(-) diff --git a/Source/Framework/Constants/Spells/SpellConst.cs b/Source/Framework/Constants/Spells/SpellConst.cs index 914d58e6e..e095ff580 100644 --- a/Source/Framework/Constants/Spells/SpellConst.cs +++ b/Source/Framework/Constants/Spells/SpellConst.cs @@ -1971,7 +1971,7 @@ namespace Framework.Constants OnlyWhenIllegallyMounted = 0x04, // Only When Illegally Mounted DoNotLogAuraRefresh = 0x08, // Do Not Log Aura Refresh (client only) MissileSpeedIsDelayInSec = 0x10, // Missile Speed is Delay (in sec) - SummonPlayerTotem = 0x20, // 5 + IgnoreTotemRequirementsForCasting = 0x20, // Ignore Totem Requirements for Casting Unk6 = 0x40, // 6 Unk7 = 0x80, // 7 AimedShot = 0x100, // 8 diff --git a/Source/Game/Spells/Spell.cs b/Source/Game/Spells/Spell.cs index 8780acd47..1b83e3e02 100644 --- a/Source/Game/Spells/Spell.cs +++ b/Source/Game/Spells/Spell.cs @@ -6814,42 +6814,27 @@ namespace Game.Spells } } - // check totem-item requirements (items presence in inventory) - uint totems = 2; - for (int i = 0; i < 2; ++i) + if (!m_spellInfo.HasAttribute(SpellAttr9.IgnoreTotemRequirementsForCasting)) { - if (m_spellInfo.Totem[i] != 0) + // check totem-item requirements (items presence in inventory) + foreach (uint totem in m_spellInfo.Totem) { - if (player.HasItemCount(m_spellInfo.Totem[i])) + if (totem != 0 && player.HasItemCount(totem)) { - totems -= 1; - continue; + param1 = (int)totem; + return SpellCastResult.Totems; } } - else - totems -= 1; - } - if (totems != 0) - return SpellCastResult.Totems; - - // Check items for TotemCategory (items presence in inventory) - uint totemCategory = 2; - for (byte i = 0; i < 2; ++i) - { - if (m_spellInfo.TotemCategory[i] != 0) + // Check items for TotemCategory (items presence in inventory) + foreach (uint totemCategory in m_spellInfo.TotemCategory) { - if (player.HasItemTotemCategory(m_spellInfo.TotemCategory[i])) + if (totemCategory != 0 && player.HasItemTotemCategory(totemCategory)) { - totemCategory -= 1; - continue; + param1 = (int)totemCategory; + return SpellCastResult.TotemCategory; } } - else - totemCategory -= 1; } - - if (totemCategory != 0) - return SpellCastResult.TotemCategory; } // special checks for spell effects