@@ -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
11241129void 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
0 commit comments