mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-19 08:55:32 +01:00
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
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -733,22 +733,37 @@ bool Item::CanBeTraded(bool mail) const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Item::HasEnchantRequiredSkill(const Player *pPlayer) const
|
||||
{
|
||||
// Check all enchants for required skill
|
||||
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->requiredSkill && pPlayer->GetSkillValue(enchantEntry->requiredSkill) < enchantEntry->requiredSkillValue)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
bool Item::IsBoundByEnchant() const
|
||||
{
|
||||
// Check all enchants for soulbound
|
||||
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;
|
||||
|
||||
SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id);
|
||||
if(!enchantEntry)
|
||||
continue;
|
||||
|
||||
if(enchantEntry->slot & ENCHANTMENT_CAN_SOULBOUND)
|
||||
return true;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user