Skip to content

Commit 1ebcf61

Browse files
committed
Core/StatSystem: fix stale UNIT_FIELD_ATTACK_POWER_MODS on AP modifier sign change
based on, with several tweaks and adjustments https://github.com/zana244/TrinityCore/commit/8a2c15a53d85df883857e1c0322dafce03f64a3c.diff vmangos/core@2646715
1 parent 80175b1 commit 1ebcf61

8 files changed

Lines changed: 138 additions & 77 deletions

File tree

src/server/game/Entities/Creature/Creature.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,8 @@ Creature::Creature(bool isWorldObject): Unit(isWorldObject), MapObject(), m_grou
258258
m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL), m_originalEntry(0), m_homePosition(), m_transportHomePosition(),
259259
m_creatureInfo(nullptr), m_creatureData(nullptr), m_stringIds(), _waypointPathId(0), _currentWaypointNodeInfo(0, 0),
260260
m_formation(nullptr), m_triggerJustAppeared(true), m_respawnCompatibilityMode(false), _lastDamagedTime(0),
261-
_regenerateHealth(true), _regenerateHealthLock(false), _isMissingCanSwimFlagOutOfCombat(false)
261+
_regenerateHealth(true), _regenerateHealthLock(false), _isMissingCanSwimFlagOutOfCombat(false),
262+
_baseAttackPower(0), _baseRangedAttackPower(0)
262263
{
263264
m_regenTimer = CREATURE_REGEN_INTERVAL;
264265
m_valuesCount = UNIT_END;
@@ -1482,8 +1483,8 @@ void Creature::UpdateLevelDependantStats()
14821483
SetBaseWeaponDamage(RANGED_ATTACK, MINDAMAGE, weaponBaseMinDamage);
14831484
SetBaseWeaponDamage(RANGED_ATTACK, MAXDAMAGE, weaponBaseMaxDamage);
14841485

1485-
SetStatFlatModifier(UNIT_MOD_ATTACK_POWER, BASE_VALUE, stats->AttackPower);
1486-
SetStatFlatModifier(UNIT_MOD_ATTACK_POWER_RANGED, BASE_VALUE, stats->RangedAttackPower);
1486+
_baseAttackPower = stats->AttackPower;
1487+
_baseRangedAttackPower = stats->RangedAttackPower;
14871488

14881489
float armor = (float)stats->GenerateArmor(cInfo); /// @todo Why is this treated as uint32 when it's a float?
14891490
SetStatFlatModifier(UNIT_MOD_ARMOR, BASE_VALUE, armor);

src/server/game/Entities/Creature/Creature.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,10 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
456456
bool _regenerateHealthLock; // Dynamically set
457457

458458
bool _isMissingCanSwimFlagOutOfCombat;
459+
460+
// set in UpdateLevelDependantStats, read in UpdateAttackPowerAndDamage
461+
uint32 _baseAttackPower;
462+
uint32 _baseRangedAttackPower;
459463
};
460464

461465
class TC_GAME_API AssistDelayEvent : public BasicEvent

src/server/game/Entities/Player/Player.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7278,11 +7278,11 @@ void Player::_ApplyItemBonuses(ItemTemplate const* proto, uint8 slot, bool apply
72787278
ApplyRatingMod(CR_EXPERTISE, int32(val), apply);
72797279
break;
72807280
case ITEM_MOD_ATTACK_POWER:
7281-
HandleStatFlatModifier(UNIT_MOD_ATTACK_POWER, TOTAL_VALUE, float(val), apply);
7282-
HandleStatFlatModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_VALUE, float(val), apply);
7281+
HandleAttackPowerModifier(MELEE_AP_MODS, (val > 0) ? AP_MOD_POSITIVE_FLAT : AP_MOD_NEGATIVE_FLAT, float(val), apply);
7282+
HandleAttackPowerModifier(RANGED_AP_MODS, (val > 0) ? AP_MOD_POSITIVE_FLAT : AP_MOD_NEGATIVE_FLAT, float(val), apply);
72837283
break;
72847284
case ITEM_MOD_RANGED_ATTACK_POWER:
7285-
HandleStatFlatModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_VALUE, float(val), apply);
7285+
HandleAttackPowerModifier(RANGED_AP_MODS, (val > 0) ? AP_MOD_POSITIVE_FLAT : AP_MOD_NEGATIVE_FLAT, float(val), apply);
72867286
break;
72877287
// case ITEM_MOD_FERAL_ATTACK_POWER:
72887288
// ApplyFeralAPBonus(int32(val), apply);
@@ -13728,12 +13728,12 @@ void Player::ApplyEnchantment(Item* item, EnchantmentSlot slot, bool apply, bool
1372813728
TC_LOG_DEBUG("entities.player.items", "+ {} EXPERTISE", enchant_amount);
1372913729
break;
1373013730
case ITEM_MOD_ATTACK_POWER:
13731-
HandleStatFlatModifier(UNIT_MOD_ATTACK_POWER, TOTAL_VALUE, float(enchant_amount), apply);
13732-
HandleStatFlatModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_VALUE, float(enchant_amount), apply);
13731+
HandleAttackPowerModifier(MELEE_AP_MODS, (enchant_amount > 0) ? AP_MOD_POSITIVE_FLAT : AP_MOD_NEGATIVE_FLAT, float(enchant_amount), apply);
13732+
HandleAttackPowerModifier(RANGED_AP_MODS, (enchant_amount > 0) ? AP_MOD_POSITIVE_FLAT : AP_MOD_NEGATIVE_FLAT, float(enchant_amount), apply);
1373313733
TC_LOG_DEBUG("entities.player.items", "+ {} ATTACK_POWER", enchant_amount);
1373413734
break;
1373513735
case ITEM_MOD_RANGED_ATTACK_POWER:
13736-
HandleStatFlatModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_VALUE, float(enchant_amount), apply);
13736+
HandleAttackPowerModifier(RANGED_AP_MODS, (enchant_amount > 0) ? AP_MOD_POSITIVE_FLAT : AP_MOD_NEGATIVE_FLAT, float(enchant_amount), apply);
1373713737
TC_LOG_DEBUG("entities.player.items", "+ {} RANGED_ATTACK_POWER", enchant_amount);
1373813738
break;
1373913739
// case ITEM_MOD_FERAL_ATTACK_POWER:

src/server/game/Entities/Unit/StatSystem.cpp

Lines changed: 44 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ void Player::UpdateAttackPowerAndDamage(bool ranged)
342342
float val2 = 0.0f;
343343
float level = float(GetLevel());
344344

345-
UnitMods unitMod = ranged ? UNIT_MOD_ATTACK_POWER_RANGED : UNIT_MOD_ATTACK_POWER;
345+
AttackPowerModIndex unitMod = ranged ? RANGED_AP_MODS : MELEE_AP_MODS;
346346

347347
if (ranged)
348348
{
@@ -448,50 +448,55 @@ void Player::UpdateAttackPowerAndDamage(bool ranged)
448448
}
449449
}
450450

451-
SetStatFlatModifier(unitMod, BASE_VALUE, val2);
451+
float baseAttackPower = val2;
452+
float attackPowerModPos = GetAttackPowerModifierValue(unitMod, AP_MOD_POSITIVE_FLAT);
453+
float attackPowerModNeg = GetAttackPowerModifierValue(unitMod, AP_MOD_NEGATIVE_FLAT);
454+
float attackPowerMultiplier = GetAttackPowerModifierValue(unitMod, AP_MOD_PCT) - 1.0f;
452455

453-
float base_attPower = GetFlatModifierValue(unitMod, BASE_VALUE) * GetPctModifierValue(unitMod, BASE_PCT);
454-
float attPowerMod = GetFlatModifierValue(unitMod, TOTAL_VALUE);
455-
456-
//add dynamic flat mods
456+
// Dynamic flat mods: routed to pos or neg based on sign
457+
float dynMod = 0.0f;
457458
if (ranged)
458459
{
459460
if ((GetClassMask() & CLASSMASK_WAND_USERS) == 0)
460461
{
461462
AuraEffectList const& mRAPbyStat = GetAuraEffectsByType(SPELL_AURA_MOD_RANGED_ATTACK_POWER_OF_STAT_PERCENT);
462463
for (AuraEffect const* aurEff : mRAPbyStat)
463-
attPowerMod += CalculatePct(GetStat(Stats(aurEff->GetMiscValue())), aurEff->GetAmount());
464+
{
465+
dynMod = CalculatePct(GetStat(Stats(aurEff->GetMiscValue())), aurEff->GetAmount());
466+
if (dynMod > 0.0f) attackPowerModPos += dynMod;
467+
else attackPowerModNeg += dynMod;
468+
}
464469
}
465470
}
466471
else
467472
{
468473
AuraEffectList const& mAPbyStat = GetAuraEffectsByType(SPELL_AURA_MOD_ATTACK_POWER_OF_STAT_PERCENT);
469474
for (AuraEffect const* aurEff : mAPbyStat)
470-
attPowerMod += CalculatePct(GetStat(Stats(aurEff->GetMiscValue())), aurEff->GetAmount());
475+
{
476+
dynMod = CalculatePct(GetStat(Stats(aurEff->GetMiscValue())), aurEff->GetAmount());
477+
if (dynMod > 0.0f) attackPowerModPos += dynMod;
478+
else attackPowerModNeg += dynMod;
479+
}
471480
}
472481

473482
// applies to both, amount updated in PeriodicTick each 30 seconds
474-
attPowerMod += GetTotalAuraModifier(SPELL_AURA_MOD_ATTACK_POWER_OF_ARMOR);
475-
476-
float attPowerMultiplier = GetPctModifierValue(unitMod, TOTAL_PCT) - 1.0f;
483+
dynMod = GetTotalAuraModifier(SPELL_AURA_MOD_ATTACK_POWER_OF_ARMOR);
484+
if (dynMod > 0.0f) attackPowerModPos += dynMod;
485+
else attackPowerModNeg += dynMod;
477486

478487
if (ranged)
479488
{
480-
SetRangedAttackPower(int32(base_attPower));
481-
if (attPowerMod >= 0)
482-
SetRangedAttackPowerModPos(int32(attPowerMod));
483-
if (attPowerMod <= 0)
484-
SetRangedAttackPowerModNeg(int32(attPowerMod));
485-
SetRangedAttackPowerMultiplier(attPowerMultiplier);
489+
SetRangedAttackPower(int32(baseAttackPower));
490+
SetRangedAttackPowerModPos(int32(attackPowerModPos));
491+
SetRangedAttackPowerModNeg(int32(attackPowerModNeg));
492+
SetRangedAttackPowerMultiplier(attackPowerMultiplier);
486493
}
487494
else
488495
{
489-
SetAttackPower(int32(base_attPower));
490-
if (attPowerMod >= 0)
491-
SetAttackPowerModPos(int32(attPowerMod));
492-
if (attPowerMod <= 0)
493-
SetAttackPowerModNeg(int32(attPowerMod));
494-
SetAttackPowerMultiplier(attPowerMultiplier);
496+
SetAttackPower(int32(baseAttackPower));
497+
SetAttackPowerModPos(int32(attackPowerModPos));
498+
SetAttackPowerModNeg(int32(attackPowerModNeg));
499+
SetAttackPowerMultiplier(attackPowerMultiplier);
495500
}
496501

497502
Pet* pet = GetPet(); //update pet's AP
@@ -1123,28 +1128,25 @@ void Creature::UpdateMaxPower(Powers power)
11231128

11241129
void Creature::UpdateAttackPowerAndDamage(bool ranged)
11251130
{
1126-
UnitMods unitMod = ranged ? UNIT_MOD_ATTACK_POWER_RANGED : UNIT_MOD_ATTACK_POWER;
1131+
AttackPowerModIndex unitMod = ranged ? RANGED_AP_MODS : MELEE_AP_MODS;
11271132

1128-
float baseAttackPower = GetFlatModifierValue(unitMod, BASE_VALUE) * GetPctModifierValue(unitMod, BASE_PCT);
1129-
float attackPowerMod = GetFlatModifierValue(unitMod, TOTAL_VALUE);
1130-
float attackPowerMultiplier = GetPctModifierValue(unitMod, TOTAL_PCT) - 1.0f;
1133+
float baseAttackPower = ranged ? _baseRangedAttackPower : _baseAttackPower;
1134+
float attackPowerModPos = GetAttackPowerModifierValue(unitMod, AP_MOD_POSITIVE_FLAT);
1135+
float attackPowerModNeg = GetAttackPowerModifierValue(unitMod, AP_MOD_NEGATIVE_FLAT);
1136+
float attackPowerMultiplier = GetAttackPowerModifierValue(unitMod, AP_MOD_PCT) - 1.0f;
11311137

11321138
if (ranged)
11331139
{
11341140
SetRangedAttackPower(int32(baseAttackPower));
1135-
if (attackPowerMod >= 0)
1136-
SetRangedAttackPowerModPos(int32(attackPowerMod));
1137-
if (attackPowerMod <= 0)
1138-
SetRangedAttackPowerModNeg(int32(attackPowerMod));
1141+
SetRangedAttackPowerModPos(int32(attackPowerModPos));
1142+
SetRangedAttackPowerModNeg(int32(attackPowerModNeg));
11391143
SetRangedAttackPowerMultiplier(attackPowerMultiplier);
11401144
}
11411145
else
11421146
{
11431147
SetAttackPower(int32(baseAttackPower));
1144-
if (attackPowerMod >= 0)
1145-
SetAttackPowerModPos(int32(attackPowerMod));
1146-
if (attackPowerMod <= 0)
1147-
SetAttackPowerModNeg(int32(attackPowerMod));
1148+
SetAttackPowerModPos(int32(attackPowerModPos));
1149+
SetAttackPowerModNeg(int32(attackPowerModNeg));
11481150
SetAttackPowerMultiplier(attackPowerMultiplier);
11491151
}
11501152

@@ -1434,7 +1436,7 @@ void Guardian::UpdateAttackPowerAndDamage(bool ranged)
14341436

14351437
float val = 0.0f;
14361438
float bonusAP = 0.0f;
1437-
UnitMods unitMod = UNIT_MOD_ATTACK_POWER;
1439+
AttackPowerModIndex unitMod = MELEE_AP_MODS;
14381440

14391441
if (GetEntry() == ENTRY_IMP) // imp's attack power
14401442
val = GetStat(STAT_STRENGTH) - 10.0f;
@@ -1502,15 +1504,14 @@ void Guardian::UpdateAttackPowerAndDamage(bool ranged)
15021504
}
15031505
}
15041506

1505-
SetStatFlatModifier(UNIT_MOD_ATTACK_POWER, BASE_VALUE, val + bonusAP);
1506-
1507-
//in BASE_VALUE of UNIT_MOD_ATTACK_POWER for creatures we store data of meleeattackpower field in DB
1508-
float base_attPower = GetFlatModifierValue(unitMod, BASE_VALUE) * GetPctModifierValue(unitMod, BASE_PCT);
1509-
float attPowerMod = GetFlatModifierValue(unitMod, TOTAL_VALUE);
1510-
float attPowerMultiplier = GetPctModifierValue(unitMod, TOTAL_PCT) - 1.0f;
1507+
float base_attPower = val + bonusAP;
1508+
float attPowerModPos = GetAttackPowerModifierValue(unitMod, AP_MOD_POSITIVE_FLAT);
1509+
float attPowerModNeg = GetAttackPowerModifierValue(unitMod, AP_MOD_NEGATIVE_FLAT);
1510+
float attPowerMultiplier = GetAttackPowerModifierValue(unitMod, AP_MOD_PCT) - 1.0f;
15111511

15121512
SetAttackPower(int32(base_attPower));
1513-
SetAttackPowerModPos(int32(attPowerMod));
1513+
SetAttackPowerModPos(int32(attPowerModPos));
1514+
SetAttackPowerModNeg(int32(attPowerModNeg));
15141515
SetAttackPowerMultiplier(attPowerMultiplier);
15151516

15161517
//automatically update weapon damage after attack power modification

src/server/game/Entities/Unit/Unit.cpp

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9015,6 +9015,54 @@ bool Unit::IsInDisallowedMountForm() const
90159015
######## ########
90169016
#######################################*/
90179017

9018+
void ApplyPercentModFloatVar(float& var, float val, bool apply);
9019+
9020+
void Unit::HandleAttackPowerModifier(AttackPowerModIndex index, AttackPowerModType modifierType, float amount, bool apply)
9021+
{
9022+
if (index >= AP_MODS_COUNT || modifierType >= AP_MOD_TYPE_COUNT)
9023+
{
9024+
TC_LOG_ERROR("entities.unit", "ERROR in HandleAttackPowerModifier(): non-existing AttackPowerModIndex or wrong AttackPowerModType!");
9025+
return;
9026+
}
9027+
9028+
switch (modifierType)
9029+
{
9030+
case AP_MOD_POSITIVE_FLAT:
9031+
m_attackPowerMods[index].PositiveMods += apply ? amount : -amount;
9032+
break;
9033+
case AP_MOD_NEGATIVE_FLAT:
9034+
m_attackPowerMods[index].NegativeMods += apply ? amount : -amount;
9035+
break;
9036+
case AP_MOD_PCT:
9037+
ApplyPercentModFloatVar(m_attackPowerMods[index].Multiplier, amount, apply);
9038+
break;
9039+
default:
9040+
break;
9041+
}
9042+
9043+
if (!CanModifyStats())
9044+
return;
9045+
9046+
UpdateAttackPowerAndDamage(index == RANGED_AP_MODS);
9047+
}
9048+
9049+
float Unit::GetAttackPowerModifierValue(AttackPowerModIndex index, AttackPowerModType modifierType) const
9050+
{
9051+
if (index >= AP_MODS_COUNT || modifierType >= AP_MOD_TYPE_COUNT)
9052+
{
9053+
TC_LOG_ERROR("entities.unit", "ERROR in GetAttackPowerModifierValue(): non-existing AttackPowerModIndex or wrong AttackPowerModType!");
9054+
return 0.0f;
9055+
}
9056+
9057+
switch (modifierType)
9058+
{
9059+
case AP_MOD_POSITIVE_FLAT: return m_attackPowerMods[index].PositiveMods;
9060+
case AP_MOD_NEGATIVE_FLAT: return m_attackPowerMods[index].NegativeMods;
9061+
case AP_MOD_PCT: return std::max(0.0f, m_attackPowerMods[index].Multiplier);
9062+
default: return 0.0f;
9063+
}
9064+
}
9065+
90189066
void Unit::HandleStatFlatModifier(UnitMods unitMod, UnitModifierFlatType modifierType, float amount, bool apply)
90199067
{
90209068
if (unitMod >= UNIT_MOD_END || modifierType >= MODIFIER_TYPE_FLAT_END)
@@ -9134,9 +9182,6 @@ void Unit::UpdateUnitMod(UnitMods unitMod)
91349182
case UNIT_MOD_RESISTANCE_SHADOW:
91359183
case UNIT_MOD_RESISTANCE_ARCANE: UpdateResistances(GetSpellSchoolByAuraGroup(unitMod)); break;
91369184

9137-
case UNIT_MOD_ATTACK_POWER: UpdateAttackPowerAndDamage(); break;
9138-
case UNIT_MOD_ATTACK_POWER_RANGED: UpdateAttackPowerAndDamage(true); break;
9139-
91409185
case UNIT_MOD_DAMAGE_MAINHAND: UpdateDamagePhysical(BASE_ATTACK); break;
91419186
case UNIT_MOD_DAMAGE_OFFHAND: UpdateDamagePhysical(OFF_ATTACK); break;
91429187
case UNIT_MOD_DAMAGE_RANGED: UpdateDamagePhysical(RANGED_ATTACK); break;

src/server/game/Entities/Unit/Unit.h

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,6 @@ enum UnitMods
175175
UNIT_MOD_RESISTANCE_FROST,
176176
UNIT_MOD_RESISTANCE_SHADOW,
177177
UNIT_MOD_RESISTANCE_ARCANE,
178-
UNIT_MOD_ATTACK_POWER,
179-
UNIT_MOD_ATTACK_POWER_RANGED,
180178
UNIT_MOD_DAMAGE_MAINHAND,
181179
UNIT_MOD_DAMAGE_OFFHAND,
182180
UNIT_MOD_DAMAGE_RANGED,
@@ -599,6 +597,28 @@ struct SpellPeriodicAuraLogInfo
599597
bool critical;
600598
};
601599

600+
struct AttackPowerModInfo
601+
{
602+
float PositiveMods = 0; // int16 in client
603+
float NegativeMods = 0; // int16 in client
604+
float Multiplier = 1.0f;
605+
};
606+
607+
enum AttackPowerModType
608+
{
609+
AP_MOD_POSITIVE_FLAT,
610+
AP_MOD_NEGATIVE_FLAT,
611+
AP_MOD_PCT,
612+
AP_MOD_TYPE_COUNT,
613+
};
614+
615+
enum AttackPowerModIndex
616+
{
617+
MELEE_AP_MODS,
618+
RANGED_AP_MODS,
619+
AP_MODS_COUNT,
620+
};
621+
602622
uint32 createProcHitMask(SpellNonMeleeDamage* damageInfo, SpellMissInfo missCondition);
603623

604624
enum CurrentSpellTypes : uint8
@@ -1506,6 +1526,9 @@ class TC_GAME_API Unit : public WorldObject
15061526
uint32 m_attackTimer[MAX_ATTACK];
15071527

15081528
// stat system
1529+
void HandleAttackPowerModifier(AttackPowerModIndex index, AttackPowerModType modifierType, float amount, bool apply);
1530+
float GetAttackPowerModifierValue(AttackPowerModIndex index, AttackPowerModType modifierType) const;
1531+
15091532
void HandleStatFlatModifier(UnitMods unitMod, UnitModifierFlatType modifierType, float amount, bool apply);
15101533
void ApplyStatPctModifier(UnitMods unitMod, UnitModifierPctType modifierType, float amount);
15111534

@@ -1880,6 +1903,7 @@ class TC_GAME_API Unit : public WorldObject
18801903

18811904
float m_auraFlatModifiersGroup[UNIT_MOD_END][MODIFIER_TYPE_FLAT_END];
18821905
float m_auraPctModifiersGroup[UNIT_MOD_END][MODIFIER_TYPE_PCT_END];
1906+
AttackPowerModInfo m_attackPowerMods[AP_MODS_COUNT];
18831907
float m_weaponDamage[MAX_ATTACK][2][2];
18841908
bool m_canModifyStats;
18851909

src/server/game/Spells/Auras/SpellAuraEffects.cpp

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4096,7 +4096,7 @@ void AuraEffect::HandleAuraModAttackPower(AuraApplication const* aurApp, uint8 m
40964096

40974097
Unit* target = aurApp->GetTarget();
40984098

4099-
target->HandleStatFlatModifier(UNIT_MOD_ATTACK_POWER, TOTAL_VALUE, float(GetAmount()), apply);
4099+
target->HandleAttackPowerModifier(MELEE_AP_MODS, GetSpellInfo()->IsPositive() ? AP_MOD_POSITIVE_FLAT : AP_MOD_NEGATIVE_FLAT, float(GetAmount()), apply);
41004100
}
41014101

41024102
void AuraEffect::HandleAuraModRangedAttackPower(AuraApplication const* aurApp, uint8 mode, bool apply) const
@@ -4109,7 +4109,7 @@ void AuraEffect::HandleAuraModRangedAttackPower(AuraApplication const* aurApp, u
41094109
if ((target->GetClassMask() & CLASSMASK_WAND_USERS) != 0)
41104110
return;
41114111

4112-
target->HandleStatFlatModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_VALUE, float(GetAmount()), apply);
4112+
target->HandleAttackPowerModifier(RANGED_AP_MODS, GetSpellInfo()->IsPositive() ? AP_MOD_POSITIVE_FLAT : AP_MOD_NEGATIVE_FLAT, float(GetAmount()), apply);
41134113
}
41144114

41154115
void AuraEffect::HandleAuraModAttackPowerPercent(AuraApplication const* aurApp, uint8 mode, bool apply) const
@@ -4119,14 +4119,7 @@ void AuraEffect::HandleAuraModAttackPowerPercent(AuraApplication const* aurApp,
41194119

41204120
Unit* target = aurApp->GetTarget();
41214121

4122-
//UNIT_FIELD_ATTACK_POWER_MULTIPLIER = multiplier - 1
4123-
if (apply)
4124-
target->ApplyStatPctModifier(UNIT_MOD_ATTACK_POWER, TOTAL_PCT, float(GetAmount()));
4125-
else
4126-
{
4127-
float amount = target->GetTotalAuraMultiplier(SPELL_AURA_MOD_ATTACK_POWER_PCT);
4128-
target->SetStatPctModifier(UNIT_MOD_ATTACK_POWER, TOTAL_PCT, amount);
4129-
}
4122+
target->HandleAttackPowerModifier(MELEE_AP_MODS, AP_MOD_PCT, float(GetAmount()), apply);
41304123
}
41314124

41324125
void AuraEffect::HandleAuraModRangedAttackPowerPercent(AuraApplication const* aurApp, uint8 mode, bool apply) const
@@ -4139,14 +4132,7 @@ void AuraEffect::HandleAuraModRangedAttackPowerPercent(AuraApplication const* au
41394132
if ((target->GetClassMask() & CLASSMASK_WAND_USERS) != 0)
41404133
return;
41414134

4142-
//UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER = multiplier - 1
4143-
if (apply)
4144-
target->ApplyStatPctModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_PCT, float(GetAmount()));
4145-
else
4146-
{
4147-
float amount = target->GetTotalAuraMultiplier(SPELL_AURA_MOD_RANGED_ATTACK_POWER_PCT);
4148-
target->SetStatPctModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_PCT, amount);
4149-
}
4135+
target->HandleAttackPowerModifier(RANGED_AP_MODS, AP_MOD_PCT, float(GetAmount()), apply);
41504136
}
41514137

41524138
void AuraEffect::HandleAuraModRangedAttackPowerOfStatPercent(AuraApplication const* aurApp, uint8 mode, bool /*apply*/) const

0 commit comments

Comments
 (0)