diff options
| author | Shauren <shauren.trinity@gmail.com> | 2022-01-09 16:31:12 +0100 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2022-01-09 16:31:12 +0100 |
| commit | 241193cd0287c3d7a2cbaf7f2c5775d414b4d0b3 (patch) | |
| tree | 01b863fd5bf6bbfdc048293f4d7c181315f2ae11 /src/server/game/Entities | |
| parent | 6df3cb0995d6bcb28998ca14fd39c9afe9d939b2 (diff) | |
Core/Items: Implemented many new enchantment flags
Diffstat (limited to 'src/server/game/Entities')
| -rw-r--r-- | src/server/game/Entities/Item/Item.cpp | 26 | ||||
| -rw-r--r-- | src/server/game/Entities/Player/Player.cpp | 16 |
2 files changed, 31 insertions, 11 deletions
diff --git a/src/server/game/Entities/Item/Item.cpp b/src/server/game/Entities/Item/Item.cpp index 744dda953cc..5e3ef4a6588 100644 --- a/src/server/game/Entities/Item/Item.cpp +++ b/src/server/game/Entities/Item/Item.cpp @@ -580,9 +580,17 @@ void Item::SaveToDB(CharacterDatabaseTransaction& trans) std::ostringstream ssEnchants; for (uint8 i = 0; i < MAX_ENCHANTMENT_SLOT; ++i) { - ssEnchants << GetEnchantmentId(EnchantmentSlot(i)) << ' '; - ssEnchants << GetEnchantmentDuration(EnchantmentSlot(i)) << ' '; - ssEnchants << GetEnchantmentCharges(EnchantmentSlot(i)) << ' '; + if (SpellItemEnchantmentEntry const* enchantment = sSpellItemEnchantmentStore.LookupEntry(GetEnchantmentId(EnchantmentSlot(i))); + enchantment && !enchantment->GetFlags().HasFlag(SpellItemEnchantmentFlags::DoNotSaveToDB)) + { + ssEnchants << GetEnchantmentId(EnchantmentSlot(i)) << ' '; + ssEnchants << GetEnchantmentDuration(EnchantmentSlot(i)) << ' '; + ssEnchants << GetEnchantmentCharges(EnchantmentSlot(i)) << ' '; + } + else + { + ssEnchants << "0 0 0 "; + } } stmt->setString(++index, ssEnchants.str()); @@ -1303,7 +1311,7 @@ bool Item::IsBoundByEnchant() const 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->Flags & ENCHANTMENT_CAN_SOULBOUND) + if (enchantEntry->GetFlags().HasFlag(SpellItemEnchantmentFlags::Soulbound)) return true; return false; @@ -1369,11 +1377,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, GetGUID(), GetEntry(), oldEnchant, slot); + if (SpellItemEnchantmentEntry const* oldEnchant = sSpellItemEnchantmentStore.LookupEntry(GetEnchantmentId(slot))) + if (!oldEnchant->GetFlags().HasFlag(SpellItemEnchantmentFlags::DoNotLog)) + owner->GetSession()->SendEnchantmentLog(GetOwnerGUID(), ObjectGuid::Empty, GetGUID(), GetEntry(), oldEnchant->ID, slot); - if (id) - owner->GetSession()->SendEnchantmentLog(GetOwnerGUID(), caster, GetGUID(), GetEntry(), id, slot); + if (SpellItemEnchantmentEntry const* newEnchant = sSpellItemEnchantmentStore.LookupEntry(id)) + if (!newEnchant->GetFlags().HasFlag(SpellItemEnchantmentFlags::DoNotLog)) + owner->GetSession()->SendEnchantmentLog(GetOwnerGUID(), caster, GetGUID(), GetEntry(), id, slot); } ApplyArtifactPowerEnchantmentBonuses(slot, GetEnchantmentId(slot), false, owner); diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 70ca1340b31..c2f677c250d 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -12365,6 +12365,7 @@ Item* Player::EquipItem(uint16 pos, Item* pItem, bool update) case EQUIPMENT_SLOT_MAINHAND: case EQUIPMENT_SLOT_OFFHAND: RecalculateRating(CR_ARMOR_PENETRATION); + break; default: break; } @@ -12621,9 +12622,17 @@ void Player::RemoveItem(uint8 bag, uint8 slot, bool update) // remove item dependent auras and casts (only weapon and armor slots) if (slot < EQUIPMENT_SLOT_END) { - // remove held enchantments, update expertise + // update expertise 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)); + UpdateExpertise(BASE_ATTACK); + } else if (slot == EQUIPMENT_SLOT_OFFHAND) UpdateExpertise(OFF_ATTACK); // update armor penetration - passive auras may need it @@ -12632,6 +12641,7 @@ void Player::RemoveItem(uint8 bag, uint8 slot, bool update) case EQUIPMENT_SLOT_MAINHAND: case EQUIPMENT_SLOT_OFFHAND: RecalculateRating(CR_ARMOR_PENETRATION); + break; default: break; } @@ -14056,7 +14066,7 @@ void Player::RemoveArenaEnchantments(EnchantmentSlot slot) uint8 inventoryEnd = INVENTORY_SLOT_ITEM_START + GetInventorySlotCount(); for (uint8 i = INVENTORY_SLOT_ITEM_START; i < inventoryEnd; ++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 @@ -14064,7 +14074,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); } |
