diff options
-rwxr-xr-x | src/server/game/Entities/Unit/Unit.cpp | 34 | ||||
-rw-r--r-- | src/server/game/Spells/Auras/SpellAuraEffects.h | 1 |
2 files changed, 14 insertions, 21 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 5a9456be6c8..2e2f5591a5d 100755 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -1512,44 +1512,36 @@ uint32 Unit::CalcArmorReducedDamage(Unit* victim, const uint32 damage, SpellInfo armor = floor(AddPctN(armor, -(*j)->GetAmount())); } + // Apply Player CR_ARMOR_PENETRATION rating and buffs from stances\specializations etc. if (GetTypeId() == TYPEID_PLAYER) { - AuraEffectList const& ArPenAuras = GetAuraEffectsByType(SPELL_AURA_MOD_ARMOR_PENETRATION_PCT); - for (AuraEffectList::const_iterator itr = ArPenAuras.begin(); itr != ArPenAuras.end(); ++itr) + float bonusPct = 0; + AuraEffectList const& ResIgnoreAuras = GetAuraEffectsByType(SPELL_AURA_MOD_ARMOR_PENETRATION_PCT); + for (AuraEffectList::const_iterator itr = ResIgnoreAuras.begin(); itr != ResIgnoreAuras.end(); ++itr) { - // item neutral spell if ((*itr)->GetSpellInfo()->EquippedItemClass == -1) { - armor = floor(AddPctN(armor, -(*itr)->GetAmount())); - continue; + if (!spellInfo || (*itr)->IsAffectedOnSpell(spellInfo) || (*itr)->GetMiscValue() & spellInfo->GetSchoolMask()) + bonusPct += (*itr)->GetAmount(); + else if (!(*itr)->GetMiscValue() && !(*itr)->HasSpellClassMask()) + bonusPct += (*itr)->GetAmount(); } - - // item dependent spell - check current weapons - for (int i = 0; i < MAX_ATTACK; ++i) + else { - Item* weapon = ToPlayer()->GetWeaponForAttack(WeaponAttackType(i), true); - - if (weapon && weapon->IsFitToSpellRequirements((*itr)->GetSpellInfo())) - { - armor = floor(AddPctN(armor, -(*itr)->GetAmount())); - break; - } + if (ToPlayer() && ToPlayer()->HasItemFitToSpellRequirements((*itr)->GetSpellInfo())) + bonusPct += (*itr)->GetAmount(); } } - } - // Apply Player CR_ARMOR_PENETRATION rating - if (GetTypeId() == TYPEID_PLAYER) - { float maxArmorPen = 0; - if (getLevel() < 60) + if (victim->getLevel() < 60) maxArmorPen = float(400 + 85 * victim->getLevel()); else maxArmorPen = 400 + 85 * victim->getLevel() + 4.5f * 85 * (victim->getLevel() - 59); // Cap armor penetration to this number maxArmorPen = std::min((armor + maxArmorPen) / 3, armor); // Figure out how much armor do we ignore - float armorPen = CalculatePctF(maxArmorPen, ToPlayer()->GetRatingBonusValue(CR_ARMOR_PENETRATION)); + float armorPen = CalculatePctF(maxArmorPen, bonusPct + ToPlayer()->GetRatingBonusValue(CR_ARMOR_PENETRATION)); // Got the value, apply it armor -= std::min(armorPen, maxArmorPen); } diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.h b/src/server/game/Spells/Auras/SpellAuraEffects.h index c34391471d7..7f754253719 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.h +++ b/src/server/game/Spells/Auras/SpellAuraEffects.h @@ -80,6 +80,7 @@ class AuraEffect bool IsPeriodic() const { return m_isPeriodic; } void SetPeriodic(bool isPeriodic) { m_isPeriodic = isPeriodic; } bool IsAffectedOnSpell(SpellInfo const* spell) const; + bool HasSpellClassMask() const { return m_spellInfo->Effects[m_effIndex].SpellClassMask; } void SendTickImmune(Unit* target, Unit* caster) const; void PeriodicTick(AuraApplication * aurApp, Unit* caster) const; |