Use virtual function for the hit chance.

This commit is contained in:
ratkosrb
2023-11-26 18:50:33 +02:00
parent 4bf4864f8b
commit 2f4f15df5a
5 changed files with 49 additions and 34 deletions
+46
View File
@@ -469,6 +469,31 @@ void Player::UpdateDamagePhysical(WeaponAttackType attType)
}
}
float Player::GetBonusHitChanceFromAuras(WeaponAttackType attType) const
{
float chance = 0.0f;
AuraList const& hitAurasList = GetAurasByType(SPELL_AURA_MOD_HIT_CHANCE);
if (hitAurasList.empty())
return chance;
Item* pWeapon = GetWeaponForAttack(attType);
for (auto const& i : hitAurasList)
{
SpellEntry const* pSpellEntry = i->GetSpellProto();
if (pSpellEntry->EquippedItemClass >= 0)
{
if (!pWeapon)
continue;
if (!pWeapon->IsFitToSpellRequirements(pSpellEntry))
continue;
}
chance += i->GetModifier()->m_amount;
}
return chance;
}
void Player::UpdateDefenseBonusesMod()
{
UpdateBlockPercentage();
@@ -936,6 +961,27 @@ void Creature::UpdateDamagePhysical(WeaponAttackType attType)
SetStatFloatValue(fieldmax, maxdamage);
}
float Creature::GetBonusHitChanceFromAuras(WeaponAttackType attType) const
{
float chance = 0.0f;
AuraList const& mTotalAuraList = GetAurasByType(SPELL_AURA_MOD_HIT_CHANCE);
for (auto const& i : mTotalAuraList)
{
SpellEntry const* pSpellEntry = i->GetSpellProto();
if (pSpellEntry->EquippedItemClass >= 0)
{
if (!GetVirtualItemDisplayId(attType))
continue;
if (!Item::IsFitToSpellRequirements(pSpellEntry, GetVirtualItemClass(attType), GetVirtualItemSubclass(attType), GetVirtualItemInventoryType(attType)))
continue;
}
chance += i->GetModifier()->m_amount;
}
return chance;
}
/*#######################################
######## ########
######## PETS STAT SYSTEM ########