Skip to content

Commit

Permalink
Core/Auras: Reimplement SPELL_AURA_MOD_ARMOR_PENETRATION_PCT, it is b…
Browse files Browse the repository at this point in the history
…ack from the dead (TrinityCore#30410)
  • Loading branch information
aquadeus authored Nov 8, 2024
1 parent c00dde7 commit 11f6576
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/server/game/Entities/Unit/Unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1661,7 +1661,7 @@ void Unit::HandleEmoteCommand(Emote emoteId, Player* target /*=nullptr*/, Trinit
return !spellInfo || !spellInfo->HasAttribute(SPELL_ATTR0_CU_IGNORE_ARMOR);
}

/*static*/ uint32 Unit::CalcArmorReducedDamage(Unit const* attacker, Unit* victim, uint32 damage, SpellInfo const* spellInfo, WeaponAttackType /*attackType*/ /*= MAX_ATTACK*/, uint8 attackerLevel /*= 0*/)
/*static*/ uint32 Unit::CalcArmorReducedDamage(Unit const* attacker, Unit* victim, uint32 damage, SpellInfo const* spellInfo, WeaponAttackType attackType /*= MAX_ATTACK*/, uint8 attackerLevel /*= 0*/)
{
float armor = float(victim->GetArmor());

Expand Down Expand Up @@ -1691,11 +1691,17 @@ void Unit::HandleEmoteCommand(Emote emoteId, Player* target /*=nullptr*/, Trinit
armor = std::floor(AddPct(armor, -aurEff->GetAmount()));
}

// Apply Player CR_ARMOR_PENETRATION rating
// Apply Player CR_ARMOR_PENETRATION rating and buffs from stances\specializations etc.
if (attacker->GetTypeId() == TYPEID_PLAYER)
{
float arpPct = attacker->ToPlayer()->GetRatingBonusValue(CR_ARMOR_PENETRATION);

Item const* weapon = attacker->ToPlayer()->GetWeaponForAttack(attackType, true);
arpPct += attacker->GetTotalAuraModifier(SPELL_AURA_MOD_ARMOR_PENETRATION_PCT, [weapon](AuraEffect const* aurEff) -> bool
{
return aurEff->GetSpellInfo()->IsItemFitToSpellRequirements(weapon);
});

// no more than 100%
RoundToInterval(arpPct, 0.f, 100.f);

Expand Down
2 changes: 1 addition & 1 deletion src/server/game/Spells/Auras/SpellAuraDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ enum AuraType : uint32
SPELL_AURA_277 = 277, // old SPELL_AURA_MOD_MAX_AFFECTED_TARGETS. unused 4.3.4
SPELL_AURA_MOD_DISARM_RANGED = 278,
SPELL_AURA_INITIALIZE_IMAGES = 279,
SPELL_AURA_280 = 280, // old SPELL_AURA_MOD_ARMOR_PENETRATION_PCT unused 4.3.4
SPELL_AURA_MOD_ARMOR_PENETRATION_PCT = 280,
SPELL_AURA_PROVIDE_SPELL_FOCUS = 281,
SPELL_AURA_MOD_BASE_HEALTH_PCT = 282,
SPELL_AURA_MOD_HEALING_RECEIVED = 283, // Possibly only for some spell family class spells
Expand Down
2 changes: 1 addition & 1 deletion src/server/game/Spells/Auras/SpellAuraEffects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ NonDefaultConstructible<pAuraEffectHandler> AuraEffectHandler[TOTAL_AURAS]=
&AuraEffect::HandleUnused, //277 unused (4.3.4) old SPELL_AURA_MOD_MAX_AFFECTED_TARGETS
&AuraEffect::HandleAuraModDisarm, //278 SPELL_AURA_MOD_DISARM_RANGED disarm ranged weapon
&AuraEffect::HandleNoImmediateEffect, //279 SPELL_AURA_INITIALIZE_IMAGES
&AuraEffect::HandleUnused, //280 unused (4.3.4) old SPELL_AURA_MOD_ARMOR_PENETRATION_PCT
&AuraEffect::HandleNoImmediateEffect, //280 SPELL_AURA_MOD_ARMOR_PENETRATION_PCT implemented in Unit::CalcArmorReducedDamage
&AuraEffect::HandleNoImmediateEffect, //281 SPELL_AURA_PROVIDE_SPELL_FOCUS implemented in Spell::CheckCast
&AuraEffect::HandleAuraIncreaseBaseHealthPercent, //282 SPELL_AURA_MOD_BASE_HEALTH_PCT
&AuraEffect::HandleNoImmediateEffect, //283 SPELL_AURA_MOD_HEALING_RECEIVED implemented in Unit::SpellHealingBonus
Expand Down

0 comments on commit 11f6576

Please sign in to comment.