aboutsummaryrefslogtreecommitdiff
path: root/src/game/Item.cpp
diff options
context:
space:
mode:
authorspp <none@none>2009-12-13 09:17:12 +0100
committerspp <none@none>2009-12-13 09:17:12 +0100
commitdf76273dd0f6fdfd2d3e2ba7f04e2a089ba8d4b8 (patch)
treef18035fda1c3d2003bce7cf08cf1315f1779a3d9 /src/game/Item.cpp
parent839e5624c4dfa26cffed76905864a9d761099cea (diff)
Check of required skill value and level in Item enchants, by azazel. Closes #512
* Added some cosmetic changes to the original patch --HG-- branch : trunk
Diffstat (limited to 'src/game/Item.cpp')
-rw-r--r--src/game/Item.cpp39
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;
}