mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-24 02:46:33 +01:00
Core/Items: fixed gem socket bonus checks
This commit is contained in:
@@ -1127,9 +1127,17 @@ void Item::SetGem(uint16 slot, ItemDynamicFieldGems const* gem)
|
||||
SetUpdateFieldValue(gemField.ModifyValue(&UF::SocketedGem::BonusListIDs, i), gem->BonusListIDs[i]);
|
||||
}
|
||||
|
||||
bool Item::GemsFitSockets() const
|
||||
bool Item::HasAllSocketsFilledWithMatchingColors() const
|
||||
{
|
||||
uint32 gemSlot = 0;
|
||||
uint8 gemSlots = 0;
|
||||
for (uint8 i = 0; i < MAX_ITEM_PROTO_SOCKETS; ++i)
|
||||
if (GetTemplate()->GetSocketColor(i) != SOCKET_COLOR_NONE)
|
||||
++gemSlots;
|
||||
|
||||
if (gemSlots > m_itemData->Gems.size())
|
||||
return false;
|
||||
|
||||
uint8 gemSlot = 0;
|
||||
for (UF::SocketedGem const& gemData : m_itemData->Gems)
|
||||
{
|
||||
SocketColor color = GetTemplate()->GetSocketColor(gemSlot);
|
||||
@@ -1137,19 +1145,20 @@ bool Item::GemsFitSockets() const
|
||||
if (!color) // no socket slot
|
||||
continue;
|
||||
|
||||
uint32 GemColor = 0;
|
||||
uint32 gemColor = 0;
|
||||
|
||||
ItemTemplate const* gemProto = sObjectMgr->GetItemTemplate(gemData.ItemID);
|
||||
if (gemProto)
|
||||
{
|
||||
GemPropertiesEntry const* gemProperty = sGemPropertiesStore.LookupEntry(gemProto->GetGemProperties());
|
||||
if (gemProperty)
|
||||
GemColor = gemProperty->Type;
|
||||
gemColor = gemProperty->Type;
|
||||
}
|
||||
|
||||
if (!(GemColor & SocketColorToGemTypeMask[color])) // bad gem color on this socket
|
||||
if (!(gemColor & SocketColorToGemTypeMask[color])) // bad gem color on this socket
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -200,7 +200,7 @@ class TC_GAME_API Item : public Object
|
||||
|
||||
bool IsFitToSpellRequirements(SpellInfo const* spellInfo) const;
|
||||
bool IsLimitedToAnotherMapOrZone(uint32 cur_mapId, uint32 cur_zoneId) const;
|
||||
bool GemsFitSockets() const;
|
||||
bool HasAllSocketsFilledWithMatchingColors() const;
|
||||
|
||||
uint32 GetCount() const { return m_itemData->StackCount; }
|
||||
void SetCount(uint32 value);
|
||||
|
||||
@@ -343,6 +343,7 @@ enum BAG_FAMILY_MASK
|
||||
|
||||
enum SocketColor
|
||||
{
|
||||
SOCKET_COLOR_NONE = 0x000000,
|
||||
SOCKET_COLOR_META = 0x000001,
|
||||
SOCKET_COLOR_RED = 0x000002,
|
||||
SOCKET_COLOR_YELLOW = 0x000004,
|
||||
|
||||
@@ -1054,7 +1054,7 @@ void WorldSession::HandleSocketGems(WorldPackets::Item::SocketGems& socketGems)
|
||||
}
|
||||
}
|
||||
|
||||
bool SocketBonusActivated = itemTarget->GemsFitSockets(); //save state of socketbonus
|
||||
bool hadSocketBonusActive = itemTarget->HasAllSocketsFilledWithMatchingColors(); //save state of socketbonus
|
||||
_player->ToggleMetaGemsActive(slot, false); //turn off all metagems (except for the target item)
|
||||
|
||||
//if a meta gem is being equipped, all information has to be written to the item before testing if the conditions for the gem are met
|
||||
@@ -1080,11 +1080,11 @@ void WorldSession::HandleSocketGems(WorldPackets::Item::SocketGems& socketGems)
|
||||
for (uint32 enchantmentSlot = SOCK_ENCHANTMENT_SLOT; enchantmentSlot < SOCK_ENCHANTMENT_SLOT + MAX_GEM_SOCKETS; ++enchantmentSlot)
|
||||
_player->ApplyEnchantment(itemTarget, EnchantmentSlot(enchantmentSlot), true);
|
||||
|
||||
bool SocketBonusToBeActivated = itemTarget->GemsFitSockets();//current socketbonus state
|
||||
if (SocketBonusActivated ^ SocketBonusToBeActivated) //if there was a change...
|
||||
bool socketBonusToBeActivated = itemTarget->HasAllSocketsFilledWithMatchingColors();//current socketbonus state
|
||||
if (hadSocketBonusActive != socketBonusToBeActivated) //if there was a change...
|
||||
{
|
||||
_player->ApplyEnchantment(itemTarget, BONUS_ENCHANTMENT_SLOT, false);
|
||||
itemTarget->SetEnchantment(BONUS_ENCHANTMENT_SLOT, (SocketBonusToBeActivated ? itemTarget->GetTemplate()->GetSocketBonus() : 0), 0, 0, _player->GetGUID());
|
||||
itemTarget->SetEnchantment(BONUS_ENCHANTMENT_SLOT, (socketBonusToBeActivated ? itemTarget->GetTemplate()->GetSocketBonus() : 0), 0, 0, _player->GetGUID());
|
||||
_player->ApplyEnchantment(itemTarget, BONUS_ENCHANTMENT_SLOT, true);
|
||||
//it is not displayed, client has an inbuilt system to determine if the bonus is activated
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user