diff options
Diffstat (limited to 'src/game/Item.cpp')
-rw-r--r-- | src/game/Item.cpp | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/src/game/Item.cpp b/src/game/Item.cpp index 8174fe7029b..f26106cb452 100644 --- a/src/game/Item.cpp +++ b/src/game/Item.cpp @@ -733,22 +733,37 @@ bool Item::CanBeTraded(bool mail) const return true; } -bool Item::IsBoundByEnchant() const +bool Item::HasEnchantRequiredSkill(const Player *pPlayer) const { - // Check all enchants for soulbound + // Check all enchants for required skill for (uint32 enchant_slot = PERM_ENCHANTMENT_SLOT; enchant_slot < MAX_ENCHANTMENT_SLOT; ++enchant_slot) - { - uint32 enchant_id = GetEnchantmentId(EnchantmentSlot(enchant_slot)); - if(!enchant_id) - continue; + if (uint32 enchant_id = GetEnchantmentId(EnchantmentSlot(enchant_slot))) + if (SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id)) + if (enchantEntry->requiredSkill && pPlayer->GetSkillValue(enchantEntry->requiredSkill) < enchantEntry->requiredSkillValue) + return false; + return true; +} - SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id); - if(!enchantEntry) - continue; +uint32 Item::GetEnchantRequiredLevel() const +{ + uint32 level = 0; + // Check all enchants for required level + for (uint32 enchant_slot = PERM_ENCHANTMENT_SLOT; enchant_slot < MAX_ENCHANTMENT_SLOT; ++enchant_slot) + if (uint32 enchant_id = GetEnchantmentId(EnchantmentSlot(enchant_slot))) + if (SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id)) + if (enchantEntry->RequiredLevel > level) + level = enchantEntry->RequiredLevel; + return level; +} - if(enchantEntry->slot & ENCHANTMENT_CAN_SOULBOUND) - return true; - } +bool Item::IsBoundByEnchant() const +{ + // Check all enchants for soulbound + for (uint32 enchant_slot = PERM_ENCHANTMENT_SLOT; enchant_slot < MAX_ENCHANTMENT_SLOT; ++enchant_slot) + if (uint32 enchant_id = GetEnchantmentId(EnchantmentSlot(enchant_slot))) + if (SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id)) + if (enchantEntry->slot & ENCHANTMENT_CAN_SOULBOUND) + return true; return false; } |