Core/Entities: Remove gem bonuses if requirements of prismatic sockets are not met

Closes issue 4949.

--HG--
branch : trunk
This commit is contained in:
leak
2010-12-18 15:56:55 +01:00
parent 04e4561134
commit 525a1e0ff0
@@ -13182,6 +13182,17 @@ void Player::ApplyEnchantment(Item *item, EnchantmentSlot slot, bool apply, bool
if (pEnchant->requiredSkill > 0 && pEnchant->requiredSkillValue > GetSkillValue(pEnchant->requiredSkill)) if (pEnchant->requiredSkill > 0 && pEnchant->requiredSkillValue > GetSkillValue(pEnchant->requiredSkill))
return; return;
// If we're dealing with a gem inside a prismatic socket we need to check the prismatic socket requirements
// rather than the gem requirements itself. If the socket has no color it is a prismatic socket.
if((slot == SOCK_ENCHANTMENT_SLOT || slot == SOCK_ENCHANTMENT_SLOT_2 || slot == SOCK_ENCHANTMENT_SLOT_3)
&& !item->GetProto()->Socket[slot-SOCK_ENCHANTMENT_SLOT].Color)
{
// Check if the requirements for the prismatic socket are met before applying the gem stats
SpellItemEnchantmentEntry const *pPrismaticEnchant = sSpellItemEnchantmentStore.LookupEntry(item->GetEnchantmentId(PRISMATIC_ENCHANTMENT_SLOT));
if(pPrismaticEnchant->requiredSkill > 0 && pPrismaticEnchant->requiredSkillValue > GetSkillValue(pPrismaticEnchant->requiredSkill))
return;
}
if (!item->IsBroken()) if (!item->IsBroken())
{ {
for (int s = 0; s < MAX_ITEM_ENCHANTMENT_EFFECTS; ++s) for (int s = 0; s < MAX_ITEM_ENCHANTMENT_EFFECTS; ++s)
@@ -13542,6 +13553,22 @@ void Player::UpdateSkillEnchantments(uint16 skill_id, uint16 curr_value, uint16
else if (new_value < Enchant->requiredSkillValue && curr_value >= Enchant->requiredSkillValue) else if (new_value < Enchant->requiredSkillValue && curr_value >= Enchant->requiredSkillValue)
ApplyEnchantment(m_items[i], EnchantmentSlot(slot), false); ApplyEnchantment(m_items[i], EnchantmentSlot(slot), false);
} }
// If we're dealing with a gem inside a prismatic socket we need to check the prismatic socket requirements
// rather than the gem requirements itself. If the socket has no color it is a prismatic socket.
if ((slot == SOCK_ENCHANTMENT_SLOT || slot == SOCK_ENCHANTMENT_SLOT_2 || slot == SOCK_ENCHANTMENT_SLOT_3)
&& !m_items[i]->GetProto()->Socket[slot-SOCK_ENCHANTMENT_SLOT].Color)
{
SpellItemEnchantmentEntry const *pPrismaticEnchant = sSpellItemEnchantmentStore.LookupEntry(m_items[i]->GetEnchantmentId(PRISMATIC_ENCHANTMENT_SLOT));
if (pPrismaticEnchant->requiredSkill == skill_id)
{
if (curr_value < pPrismaticEnchant->requiredSkillValue && new_value >= pPrismaticEnchant->requiredSkillValue)
ApplyEnchantment(m_items[i], EnchantmentSlot(slot), true);
else if (new_value < pPrismaticEnchant->requiredSkillValue && curr_value >= pPrismaticEnchant->requiredSkillValue)
ApplyEnchantment(m_items[i], EnchantmentSlot(slot), false);
}
}
} }
} }
} }