Core/Spells: Fixed item level requirements for enchanting spells

Port From (https://github.com/TrinityCore/TrinityCore/commit/2e4ada2d3d2a719d650ed90b4f7e7428496717a7)
This commit is contained in:
Hondacrx
2025-02-24 10:45:11 -05:00
parent 519c642cff
commit df22f4dd74
+22 -8
View File
@@ -6942,9 +6942,19 @@ namespace Game.Spells
if (targetItem == null) if (targetItem == null)
return SpellCastResult.ItemNotFound; return SpellCastResult.ItemNotFound;
// required level has to be checked also! Exploit fix // Apply item level restriction
if (targetItem.GetItemLevel(targetItem.GetOwner()) < m_spellInfo.BaseLevel || (targetItem.GetRequiredLevel() != 0 && targetItem.GetRequiredLevel() < m_spellInfo.BaseLevel)) if (!m_spellInfo.HasAttribute(SpellAttr2.AllowLowLevelBuff))
return SpellCastResult.Lowlevel; {
uint requiredLevel = (uint)targetItem.GetRequiredLevel();
if (requiredLevel == 0)
requiredLevel = targetItem.GetItemLevel(targetItem.GetOwner());
if (requiredLevel < m_spellInfo.BaseLevel)
return SpellCastResult.Lowlevel;
}
if ((m_CastItem != null || effectInfo.IsEffect(SpellEffectName.EnchantItemPrismatic))
&& m_spellInfo.MaxLevel > 0 && targetItem.GetItemLevel(targetItem.GetOwner()) > m_spellInfo.MaxLevel)
return SpellCastResult.Highlevel;
bool isItemUsable = false; bool isItemUsable = false;
foreach (ItemEffectRecord itemEffect in targetItem.GetEffects()) foreach (ItemEffectRecord itemEffect in targetItem.GetEffects())
@@ -7009,14 +7019,18 @@ namespace Game.Spells
return SpellCastResult.NotTradeable; return SpellCastResult.NotTradeable;
} }
// Apply item level restriction if the enchanting spell has max level restrition set // Apply item level restriction
if (m_CastItem != null && m_spellInfo.MaxLevel > 0) if (!m_spellInfo.HasAttribute(SpellAttr2.AllowLowLevelBuff))
{ {
if (item.GetTemplate().GetBaseItemLevel() < m_CastItem.GetTemplate().GetBaseRequiredLevel()) uint requiredLevel = (uint)item.GetRequiredLevel();
if (requiredLevel == 0)
requiredLevel = item.GetItemLevel(item.GetOwner());
if (requiredLevel < m_spellInfo.BaseLevel)
return SpellCastResult.Lowlevel; return SpellCastResult.Lowlevel;
if (item.GetTemplate().GetBaseItemLevel() > m_spellInfo.MaxLevel)
return SpellCastResult.Highlevel;
} }
if (m_CastItem != null && m_spellInfo.MaxLevel > 0 && item.GetItemLevel(item.GetOwner()) > m_spellInfo.MaxLevel)
return SpellCastResult.Highlevel;
break; break;
} }
case SpellEffectName.EnchantHeldItem: case SpellEffectName.EnchantHeldItem: