[8458] Re-implement SPELL_AURA_MOD_TARGET_ARMOR_PCT in more porper way for weapon dependent cases.

(cherry picked from commit 7efab7fd38c3a753e967648ca8ef1f2cdfbac76c)

Signed-off-by: VladimirMangos <vladimir@getmangos.com>

With some fixes and rewrites.
This commit is contained in:
sixsixnine 2009-09-04 02:14:37 +04:00 committed by VladimirMangos
parent 57158e9185
commit 63e7c092f1
7 changed files with 61 additions and 8 deletions

View file

@ -439,6 +439,7 @@ Player::Player (WorldSession *session): Unit(), m_achievementMgr(this), m_reputa
m_baseSpellPower = 0; m_baseSpellPower = 0;
m_baseFeralAP = 0; m_baseFeralAP = 0;
m_baseManaRegen = 0; m_baseManaRegen = 0;
m_armorPenetrationPct = 0.0f;
// Honor System // Honor System
m_lastHonorUpdateTime = time(NULL); m_lastHonorUpdateTime = time(NULL);
@ -4972,6 +4973,8 @@ void Player::ApplyRatingMod(CombatRating cr, int32 value, bool apply)
} }
break; break;
case CR_ARMOR_PENETRATION: case CR_ARMOR_PENETRATION:
if(affectStats)
UpdateArmorPenetration();
break; break;
} }
} }
@ -10441,9 +10444,15 @@ Item* Player::EquipItem( uint16 pos, Item *pItem, bool update )
ApplyEquipCooldown(pItem); ApplyEquipCooldown(pItem);
if( slot == EQUIPMENT_SLOT_MAINHAND ) if( slot == EQUIPMENT_SLOT_MAINHAND )
{
UpdateExpertise(BASE_ATTACK); UpdateExpertise(BASE_ATTACK);
UpdateArmorPenetration();
}
else if( slot == EQUIPMENT_SLOT_OFFHAND ) else if( slot == EQUIPMENT_SLOT_OFFHAND )
{
UpdateExpertise(OFF_ATTACK); UpdateExpertise(OFF_ATTACK);
UpdateArmorPenetration();
}
} }
else else
{ {
@ -10583,9 +10592,13 @@ void Player::RemoveItem( uint8 bag, uint8 slot, bool update )
} }
UpdateExpertise(BASE_ATTACK); UpdateExpertise(BASE_ATTACK);
UpdateArmorPenetration();
} }
else if( slot == EQUIPMENT_SLOT_OFFHAND ) else if( slot == EQUIPMENT_SLOT_OFFHAND )
{
UpdateExpertise(OFF_ATTACK); UpdateExpertise(OFF_ATTACK);
UpdateArmorPenetration();
}
} }
} }
// need update known currency // need update known currency
@ -10694,10 +10707,16 @@ void Player::DestroyItem( uint8 bag, uint8 slot, bool update )
RemoveItemDependentAurasAndCasts(pItem); RemoveItemDependentAurasAndCasts(pItem);
// update expertise // update expertise
if ( slot == EQUIPMENT_SLOT_MAINHAND ) if( slot == EQUIPMENT_SLOT_MAINHAND )
{
UpdateExpertise(BASE_ATTACK); UpdateExpertise(BASE_ATTACK);
UpdateArmorPenetration();
}
else if( slot == EQUIPMENT_SLOT_OFFHAND ) else if( slot == EQUIPMENT_SLOT_OFFHAND )
{
UpdateExpertise(OFF_ATTACK); UpdateExpertise(OFF_ATTACK);
UpdateArmorPenetration();
}
// equipment visual show // equipment visual show
SetVisibleItemSlot(slot, NULL); SetVisibleItemSlot(slot, NULL);

View file

@ -1719,6 +1719,7 @@ class MANGOS_DLL_SPEC Player : public Unit
void UpdateAllSpellCritChances(); void UpdateAllSpellCritChances();
void UpdateSpellCritChance(uint32 school); void UpdateSpellCritChance(uint32 school);
void UpdateExpertise(WeaponAttackType attType); void UpdateExpertise(WeaponAttackType attType);
void UpdateArmorPenetration();
void ApplyManaRegenBonus(int32 amount, bool apply); void ApplyManaRegenBonus(int32 amount, bool apply);
void UpdateManaRegen(); void UpdateManaRegen();
@ -1882,6 +1883,7 @@ class MANGOS_DLL_SPEC Player : public Unit
float GetTotalPercentageModValue(BaseModGroup modGroup) const { return m_auraBaseMod[modGroup][FLAT_MOD] + m_auraBaseMod[modGroup][PCT_MOD]; } float GetTotalPercentageModValue(BaseModGroup modGroup) const { return m_auraBaseMod[modGroup][FLAT_MOD] + m_auraBaseMod[modGroup][PCT_MOD]; }
void _ApplyAllStatBonuses(); void _ApplyAllStatBonuses();
void _RemoveAllStatBonuses(); void _RemoveAllStatBonuses();
float GetArmorPenetrationPct() const { return m_armorPenetrationPct; }
void _ApplyWeaponDependentAuraMods(Item *item, WeaponAttackType attackType, bool apply); void _ApplyWeaponDependentAuraMods(Item *item, WeaponAttackType attackType, bool apply);
void _ApplyWeaponDependentAuraCritMod(Item *item, WeaponAttackType attackType, Aura* aura, bool apply); void _ApplyWeaponDependentAuraCritMod(Item *item, WeaponAttackType attackType, Aura* aura, bool apply);
@ -2349,6 +2351,7 @@ class MANGOS_DLL_SPEC Player : public Unit
uint16 m_baseSpellPower; uint16 m_baseSpellPower;
uint16 m_baseFeralAP; uint16 m_baseFeralAP;
uint16 m_baseManaRegen; uint16 m_baseManaRegen;
float m_armorPenetrationPct;
SpellModList m_spellMods[MAX_SPELLMOD]; SpellModList m_spellMods[MAX_SPELLMOD];
int32 m_SpellModRemoveCount; int32 m_SpellModRemoveCount;

View file

@ -330,7 +330,7 @@ pAuraHandler AuraHandler[TOTAL_AURAS]=
&Aura::HandleNoImmediateEffect, //277 SPELL_AURA_MOD_MAX_AFFECTED_TARGETS Use SpellClassMask for spell select &Aura::HandleNoImmediateEffect, //277 SPELL_AURA_MOD_MAX_AFFECTED_TARGETS Use SpellClassMask for spell select
&Aura::HandleNULL, //278 SPELL_AURA_MOD_DISARM_RANGED disarm ranged weapon &Aura::HandleNULL, //278 SPELL_AURA_MOD_DISARM_RANGED disarm ranged weapon
&Aura::HandleNULL, //279 visual effects? 58836 and 57507 &Aura::HandleNULL, //279 visual effects? 58836 and 57507
&Aura::HandleNoImmediateEffect, //280 SPELL_AURA_MOD_TARGET_ARMOR_PCT implemented in Unit::CalcArmorReducedDamage &Aura::HandleModTargetArmorPct, //280 SPELL_AURA_MOD_TARGET_ARMOR_PCT
&Aura::HandleNULL, //281 SPELL_AURA_MOD_HONOR_GAIN &Aura::HandleNULL, //281 SPELL_AURA_MOD_HONOR_GAIN
&Aura::HandleAuraIncreaseBaseHealthPercent, //282 SPELL_AURA_INCREASE_BASE_HEALTH_PERCENT &Aura::HandleAuraIncreaseBaseHealthPercent, //282 SPELL_AURA_INCREASE_BASE_HEALTH_PERCENT
&Aura::HandleNoImmediateEffect, //283 SPELL_AURA_MOD_HEALING_RECEIVED implemented in Unit::SpellHealingBonus &Aura::HandleNoImmediateEffect, //283 SPELL_AURA_MOD_HEALING_RECEIVED implemented in Unit::SpellHealingBonus
@ -7275,3 +7275,11 @@ bool Aura::IsCritFromAbilityAura(Unit* caster, uint32& damage)
} }
return false; return false;
} }
void Aura::HandleModTargetArmorPct(bool apply, bool Real)
{
if(m_target->GetTypeId() != TYPEID_PLAYER)
return;
((Player*)m_target)->UpdateArmorPenetration();
}

View file

@ -211,6 +211,7 @@ class MANGOS_DLL_SPEC Aura
void HandleAuraIncreaseBaseHealthPercent(bool Apply, bool Real); void HandleAuraIncreaseBaseHealthPercent(bool Apply, bool Real);
void HandleNoReagentUseAura(bool Apply, bool Real); void HandleNoReagentUseAura(bool Apply, bool Real);
void HandlePhase(bool Apply, bool Real); void HandlePhase(bool Apply, bool Real);
void HandleModTargetArmorPct(bool Apply, bool Real);
virtual ~Aura(); virtual ~Aura();

View file

@ -132,6 +132,7 @@ bool Player::UpdateAllStats()
UpdateAllSpellCritChances(); UpdateAllSpellCritChances();
UpdateDefenseBonusesMod(); UpdateDefenseBonusesMod();
UpdateShieldBlockValue(); UpdateShieldBlockValue();
UpdateArmorPenetration();
UpdateSpellDamageAndHealingBonus(); UpdateSpellDamageAndHealingBonus();
UpdateManaRegen(); UpdateManaRegen();
UpdateExpertise(BASE_ATTACK); UpdateExpertise(BASE_ATTACK);
@ -648,6 +649,30 @@ void Player::UpdateExpertise(WeaponAttackType attack)
} }
} }
void Player::UpdateArmorPenetration()
{
m_armorPenetrationPct = GetRatingBonusValue(CR_ARMOR_PENETRATION);
AuraList const& armorAuras = GetAurasByType(SPELL_AURA_MOD_TARGET_ARMOR_PCT);
for(AuraList::const_iterator itr = armorAuras.begin(); itr != armorAuras.end(); ++itr)
{
// affects all weapons
if((*itr)->GetSpellProto()->EquippedItemClass == -1)
{
m_armorPenetrationPct += (*itr)->GetModifier()->m_amount;
continue;
}
// dependent on weapon class
for(uint8 i = 0; i < MAX_ATTACK; ++i)
{
Item *weapon = GetWeaponForAttack(WeaponAttackType(i));
if(weapon && weapon->IsFitToSpellRequirements((*itr)->GetSpellProto()))
m_armorPenetrationPct += (*itr)->GetModifier()->m_amount;
}
}
}
void Player::ApplyManaRegenBonus(int32 amount, bool apply) void Player::ApplyManaRegenBonus(int32 amount, bool apply)
{ {
m_baseManaRegen+= apply ? amount : -amount; m_baseManaRegen+= apply ? amount : -amount;

View file

@ -1569,12 +1569,9 @@ uint32 Unit::CalcArmorReducedDamage(Unit* pVictim, const uint32 damage)
// Ignore enemy armor by SPELL_AURA_MOD_TARGET_RESISTANCE aura // Ignore enemy armor by SPELL_AURA_MOD_TARGET_RESISTANCE aura
armor += GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_TARGET_RESISTANCE, SPELL_SCHOOL_MASK_NORMAL); armor += GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_TARGET_RESISTANCE, SPELL_SCHOOL_MASK_NORMAL);
// Apply Player CR_ARMOR_PENETRATION rating // Apply Player CR_ARMOR_PENETRATION rating and percent talents
if (GetTypeId()==TYPEID_PLAYER) if (GetTypeId()==TYPEID_PLAYER)
armor *= 1.0f - ((Player*)this)->GetRatingBonusValue(CR_ARMOR_PENETRATION) / 100.0f; armor *= 1.0f - ((Player*)this)->GetArmorPenetrationPct() / 100.0f;
// Ignore enemy armor by SPELL_AURA_MOD_TARGET_ARMOR_PCT
armor *= 1.0f - GetTotalAuraModifier(SPELL_AURA_MOD_TARGET_ARMOR_PCT) / 100.0f;
if (armor < 0.0f) if (armor < 0.0f)
armor = 0.0f; armor = 0.0f;

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "8457" #define REVISION_NR "8458"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__