aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/game/DBCStructure.h6
-rw-r--r--src/game/DBCfmt.h2
-rw-r--r--src/game/Item.cpp39
-rw-r--r--src/game/Item.h3
-rw-r--r--src/game/Player.cpp6
5 files changed, 40 insertions, 16 deletions
diff --git a/src/game/DBCStructure.h b/src/game/DBCStructure.h
index 9e44687e867..8c60c28980e 100644
--- a/src/game/DBCStructure.h
+++ b/src/game/DBCStructure.h
@@ -1536,9 +1536,9 @@ struct SpellItemEnchantmentEntry
uint32 slot; // 32 m_flags
uint32 GemID; // 33 m_src_itemID
uint32 EnchantmentCondition; // 34 m_condition_id
- //uint32 requiredSkill; // 35 m_requiredSkillID
- //uint32 requiredSkillValue; // 36 m_requiredSkillRank
- // 37 new in 3.1
+ uint32 requiredSkill; // 35 m_requiredSkillID
+ uint32 requiredSkillValue; // 36 m_requiredSkillRank
+ uint32 RequiredLevel; // 37 m_requiredLevel - new in 3.1
};
struct SpellItemEnchantmentConditionEntry
diff --git a/src/game/DBCfmt.h b/src/game/DBCfmt.h
index 7487ac116a2..0e5fb8b83cf 100644
--- a/src/game/DBCfmt.h
+++ b/src/game/DBCfmt.h
@@ -90,7 +90,7 @@ const char SpellEntryfmt[]="niiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiifxiiiiii
const std::string CustomSpellEntryfmt="pappppppppaaapaaaaaaaaaaapaaapapppppppaaaaapaapaaaaaaaaaaaaaaaaaappppppppppppppppppppppppppppppppppppppppppaaaaaapppppppppaaapppppppppaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaappppppppapppaaaaappaaa";
const std::string CustomSpellEntryIndex = "Id";
const char SpellFocusObjectfmt[]="nxxxxxxxxxxxxxxxxx";
-const char SpellItemEnchantmentfmt[]="nxiiiiiixxxiiissssssssssssssssxiiiixxx";
+const char SpellItemEnchantmentfmt[]="nxiiiiiixxxiiissssssssssssssssxiiiiiii";
const char SpellItemEnchantmentConditionfmt[]="nbbbbbxxxxxbbbbbbbbbbiiiiiXXXXX";
const char SpellRadiusfmt[]="nfxf";
const char SpellRangefmt[]="nffffixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
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;
}
diff --git a/src/game/Item.h b/src/game/Item.h
index 2988707a464..a26b9148f21 100644
--- a/src/game/Item.h
+++ b/src/game/Item.h
@@ -250,6 +250,9 @@ class TRINITY_DLL_SPEC Item : public Object
void SetInTrade(bool b = true) { mb_in_trade = b; }
bool IsInTrade() const { return mb_in_trade; }
+ bool HasEnchantRequiredSkill(const Player *pPlayer) const;
+ uint32 GetEnchantRequiredLevel() const;
+
bool IsFitToSpellRequirements(SpellEntry const* spellInfo) const;
bool IsTargetValidForItemUse(Unit* pUnitTarget);
bool IsLimitedToAnotherMapOrZone( uint32 cur_mapId, uint32 cur_zoneId) const;
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index bf9f1f63c62..c6e762d7950 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -10666,6 +10666,12 @@ uint8 Player::CanUseItem( Item *pItem, bool not_loading ) const
if (getLevel() < pProto->RequiredLevel)
return EQUIP_ERR_CANT_EQUIP_LEVEL_I;
+ if (getLevel() < pItem->GetEnchantRequiredLevel())
+ return EQUIP_ERR_CANT_EQUIP_LEVEL_I;
+
+ if (!pItem->HasEnchantRequiredSkill(this))
+ return EQUIP_ERR_NO_REQUIRED_PROFICIENCY;
+
return EQUIP_ERR_OK;
}
}