Core/Items: ported several enchantment flag implementations from master branch
This commit is contained in:
1 parent
009e1dba37
commit
3ff8840fe2
8 files changed
+35
-63
No files matched your search
@@ -515,14 +515,16 @@ DEFINE_ENUM_FLAG(SpellCategoryFlags);
|
||||
#define MAX_EFFECT_MASK 7
|
||||
#define MAX_SPELL_REAGENTS 8
|
||||
|
||||
enum EnchantmentSlotMask
|
||||
enum class SpellItemEnchantmentFlags : uint32
|
||||
{
|
||||
ENCHANTMENT_CAN_SOULBOUND = 0x01,
|
||||
ENCHANTMENT_UNK1 = 0x02,
|
||||
ENCHANTMENT_UNK2 = 0x04,
|
||||
ENCHANTMENT_UNK3 = 0x08
|
||||
Soulbound = 0x001,
|
||||
DoNotLog = 0x002,
|
||||
MainhandOnly = 0x004,
|
||||
AllowEnteringArena = 0x008
|
||||
};
|
||||
|
||||
DEFINE_ENUM_FLAG(SpellItemEnchantmentFlags);
|
||||
|
||||
#define MAX_TALENT_RANK 5
|
||||
#define MAX_PET_TALENT_RANK 3 // use in calculations, expected <= MAX_TALENT_RANK
|
||||
#define MAX_TALENT_TABS 3
|
||||
|
||||
@@ -2337,6 +2337,8 @@ struct SpellItemEnchantmentEntry
|
||||
uint32 RequiredSkillRank; // 20
|
||||
uint32 MinLevel; // 21
|
||||
//uint32 ItemLevel; // 22
|
||||
|
||||
EnumFlag<SpellItemEnchantmentFlags> GetFlags() const { return static_cast<SpellItemEnchantmentFlags>(Flags); }
|
||||
};
|
||||
|
||||
struct SpellItemEnchantmentConditionEntry
|
||||
|
||||
@@ -748,7 +748,7 @@ bool Item::IsBoundByEnchant() const
|
||||
|
||||
if (uint32 enchant_id = GetEnchantmentId(EnchantmentSlot(enchant_slot)))
|
||||
if (SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id))
|
||||
if (enchantEntry->Flags & ENCHANTMENT_CAN_SOULBOUND)
|
||||
if (enchantEntry->GetFlags().HasFlag(SpellItemEnchantmentFlags::Soulbound))
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -817,11 +817,13 @@ void Item::SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint
|
||||
Player* owner = GetOwner();
|
||||
if (slot < MAX_INSPECTED_ENCHANTMENT_SLOT)
|
||||
{
|
||||
if (uint32 oldEnchant = GetEnchantmentId(slot))
|
||||
owner->GetSession()->SendEnchantmentLog(GetOwnerGUID(), ObjectGuid::Empty, GetEntry(), oldEnchant);
|
||||
if (SpellItemEnchantmentEntry const* oldEnchant = sSpellItemEnchantmentStore.LookupEntry(GetEnchantmentId(slot)))
|
||||
if (!oldEnchant->GetFlags().HasFlag(SpellItemEnchantmentFlags::DoNotLog))
|
||||
owner->GetSession()->SendEnchantmentLog(GetOwnerGUID(), ObjectGuid::Empty, GetEntry(), oldEnchant->ID);
|
||||
|
||||
if (id)
|
||||
owner->GetSession()->SendEnchantmentLog(GetOwnerGUID(), caster, GetEntry(), id);
|
||||
if (SpellItemEnchantmentEntry const* newEnchant = sSpellItemEnchantmentStore.LookupEntry(id))
|
||||
if (!newEnchant->GetFlags().HasFlag(SpellItemEnchantmentFlags::DoNotLog))
|
||||
owner->GetSession()->SendEnchantmentLog(GetOwnerGUID(), caster, GetEntry(), id);
|
||||
}
|
||||
|
||||
SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_ID_OFFSET, id);
|
||||
|
||||
@@ -11848,6 +11848,15 @@ void Player::RemoveItem(uint8 bag, uint8 slot, bool update)
|
||||
SetVisibleItemSlot(slot, nullptr);
|
||||
if (slot == EQUIPMENT_SLOT_MAINHAND || slot == EQUIPMENT_SLOT_OFFHAND)
|
||||
CheckTitanGripPenalty();
|
||||
|
||||
if (slot == EQUIPMENT_SLOT_MAINHAND)
|
||||
{
|
||||
// clear main hand only enchantments
|
||||
for (uint32 enchantSlot = 0; enchantSlot < MAX_ENCHANTMENT_SLOT; ++enchantSlot)
|
||||
if (SpellItemEnchantmentEntry const* enchantment = sSpellItemEnchantmentStore.LookupEntry(pItem->GetEnchantmentId(EnchantmentSlot(enchantSlot))))
|
||||
if (enchantment->GetFlags().HasFlag(SpellItemEnchantmentFlags::MainhandOnly))
|
||||
pItem->ClearEnchantment(EnchantmentSlot(enchantSlot));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (Bag* pBag = GetBagByPos(bag))
|
||||
@@ -13117,7 +13126,7 @@ void Player::RemoveArenaEnchantments(EnchantmentSlot slot)
|
||||
// in inventory
|
||||
for (uint8 i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; ++i)
|
||||
if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i))
|
||||
if (pItem->GetEnchantmentId(slot))
|
||||
if (!sSpellMgr->IsArenaAllowedEnchancment(pItem->GetEnchantmentId(slot)))
|
||||
pItem->ClearEnchantment(slot);
|
||||
|
||||
// in inventory bags
|
||||
@@ -13125,7 +13134,7 @@ void Player::RemoveArenaEnchantments(EnchantmentSlot slot)
|
||||
if (Bag* pBag = GetBagByPos(i))
|
||||
for (uint32 j = 0; j < pBag->GetBagSize(); j++)
|
||||
if (Item* pItem = pBag->GetItemByPos(j))
|
||||
if (pItem->GetEnchantmentId(slot))
|
||||
if (!sSpellMgr->IsArenaAllowedEnchancment(pItem->GetEnchantmentId(slot)))
|
||||
pItem->ClearEnchantment(slot);
|
||||
}
|
||||
|
||||
|
||||
@@ -7124,7 +7124,7 @@ SpellCastResult Spell::CheckItems(uint32* param1 /*= nullptr*/, uint32* param2 /
|
||||
{
|
||||
if (!enchantEntry)
|
||||
return SPELL_FAILED_ERROR;
|
||||
if (enchantEntry->Flags & ENCHANTMENT_CAN_SOULBOUND)
|
||||
if (enchantEntry->GetFlags().HasFlag(SpellItemEnchantmentFlags::Soulbound))
|
||||
return SPELL_FAILED_NOT_TRADEABLE;
|
||||
}
|
||||
break;
|
||||
@@ -7138,10 +7138,10 @@ SpellCastResult Spell::CheckItems(uint32* param1 /*= nullptr*/, uint32* param2 /
|
||||
if (item->GetOwner() != m_caster)
|
||||
{
|
||||
uint32 enchant_id = m_spellInfo->Effects[i].MiscValue;
|
||||
SpellItemEnchantmentEntry const* pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id);
|
||||
if (!pEnchant)
|
||||
SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id);
|
||||
if (!enchantEntry)
|
||||
return SPELL_FAILED_ERROR;
|
||||
if (pEnchant->Flags & ENCHANTMENT_CAN_SOULBOUND)
|
||||
if (enchantEntry->GetFlags().HasFlag(SpellItemEnchantmentFlags::Soulbound))
|
||||
return SPELL_FAILED_NOT_TRADEABLE;
|
||||
}
|
||||
|
||||
|
||||
@@ -637,7 +637,10 @@ SpellEnchantProcEntry const* SpellMgr::GetSpellEnchantProcEvent(uint32 enchId) c
|
||||
|
||||
bool SpellMgr::IsArenaAllowedEnchancment(uint32 ench_id) const
|
||||
{
|
||||
return mEnchantCustomAttr[ench_id];
|
||||
if (SpellItemEnchantmentEntry const* enchantment = sSpellItemEnchantmentStore.LookupEntry(ench_id))
|
||||
return enchantment->GetFlags().HasFlag(SpellItemEnchantmentFlags::AllowEnteringArena);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
const std::vector<int32>* SpellMgr::GetSpellLinked(int32 spell_id) const
|
||||
@@ -2098,46 +2101,6 @@ void SpellMgr::LoadSpellPetAuras()
|
||||
TC_LOG_INFO("server.loading", ">> Loaded %u spell pet auras in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
}
|
||||
|
||||
// Fill custom data about enchancments
|
||||
void SpellMgr::LoadEnchantCustomAttr()
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
uint32 size = sSpellItemEnchantmentStore.GetNumRows();
|
||||
mEnchantCustomAttr.resize(size);
|
||||
|
||||
for (uint32 i = 0; i < size; ++i)
|
||||
mEnchantCustomAttr[i] = 0;
|
||||
|
||||
uint32 count = 0;
|
||||
for (uint32 i = 0; i < GetSpellInfoStoreSize(); ++i)
|
||||
{
|
||||
SpellInfo const* spellInfo = GetSpellInfo(i);
|
||||
if (!spellInfo)
|
||||
continue;
|
||||
|
||||
/// @todo find a better check
|
||||
if (!spellInfo->HasAttribute(SPELL_ATTR2_PRESERVE_ENCHANT_IN_ARENA) || !spellInfo->HasAttribute(SPELL_ATTR0_NOT_SHAPESHIFT))
|
||||
continue;
|
||||
|
||||
for (uint32 j = 0; j < MAX_SPELL_EFFECTS; ++j)
|
||||
{
|
||||
if (spellInfo->Effects[j].Effect == SPELL_EFFECT_ENCHANT_ITEM_TEMPORARY)
|
||||
{
|
||||
uint32 enchId = spellInfo->Effects[j].MiscValue;
|
||||
SpellItemEnchantmentEntry const* ench = sSpellItemEnchantmentStore.LookupEntry(enchId);
|
||||
if (!ench)
|
||||
continue;
|
||||
mEnchantCustomAttr[enchId] = true;
|
||||
++count;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TC_LOG_INFO("server.loading", ">> Loaded %u custom enchant attributes in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
}
|
||||
|
||||
void SpellMgr::LoadSpellEnchantProcData()
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
@@ -557,7 +557,6 @@ struct PetDefaultSpellsEntry
|
||||
typedef std::map<int32, PetDefaultSpellsEntry> PetDefaultSpellsMap;
|
||||
|
||||
typedef std::vector<uint32> SpellCustomAttribute;
|
||||
typedef std::vector<bool> EnchantCustomAttribute;
|
||||
|
||||
typedef std::vector<SpellInfo*> SpellInfoMap;
|
||||
|
||||
@@ -698,7 +697,6 @@ class TC_GAME_API SpellMgr
|
||||
void LoadSpellThreats();
|
||||
void LoadSkillLineAbilityMap();
|
||||
void LoadSpellPetAuras();
|
||||
void LoadEnchantCustomAttr();
|
||||
void LoadSpellEnchantProcData();
|
||||
void LoadSpellLinked();
|
||||
void LoadPetLevelupSpellMap();
|
||||
@@ -732,7 +730,6 @@ class TC_GAME_API SpellMgr
|
||||
SpellPetAuraMap mSpellPetAuraMap;
|
||||
SpellLinkedMap mSpellLinkedMap;
|
||||
SpellEnchantProcEventMap mSpellEnchantProcEventMap;
|
||||
EnchantCustomAttribute mEnchantCustomAttr;
|
||||
SpellAreaMap mSpellAreaMap;
|
||||
SpellAreaForQuestMap mSpellAreaForQuestMap;
|
||||
SpellAreaForQuestMap mSpellAreaForQuestEndMap;
|
||||
|
||||
@@ -1997,9 +1997,6 @@ void World::SetInitialWorldSettings()
|
||||
TC_LOG_INFO("server.loading", "Loading Spell target coordinates...");
|
||||
sSpellMgr->LoadSpellTargetPositions();
|
||||
|
||||
TC_LOG_INFO("server.loading", "Loading enchant custom attributes...");
|
||||
sSpellMgr->LoadEnchantCustomAttr();
|
||||
|
||||
TC_LOG_INFO("server.loading", "Loading linked spells...");
|
||||
sSpellMgr->LoadSpellLinked();
|
||||
|
||||
|
||||
Reference in new issue
Block a user