Skip to content

Commit c190379

Browse files
ccrsratkosrb
authored andcommitted
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 Co-authored-by: ratkosrb <ratkomladic2@abv.bg>
1 parent 6d940d4 commit c190379

8 files changed

Lines changed: 130 additions & 88 deletions

File tree

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,10 @@ Creature::Creature(bool isWorldObject): Unit(isWorldObject), MapObject(), m_grou
256256
m_boundaryCheckTime(2500), m_combatPulseTime(0), m_combatPulseDelay(0), m_reactState(REACT_AGGRESSIVE),
257257
m_defaultMovementType(IDLE_MOTION_TYPE), m_spawnId(0), m_equipmentId(0), m_originalEquipmentId(0),
258258
m_AlreadyCallAssistance(false), m_AlreadySearchedAssistance(false), m_cannotReachTarget(false), m_cannotReachTimer(0),
259-
m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL), m_originalEntry(0), m_homePosition(), m_transportHomePosition(),
260-
m_creatureInfo(nullptr), m_creatureData(nullptr), m_stringIds(), _waypointPathId(0), _currentWaypointNodeInfo(0, 0),
261-
m_formation(nullptr), m_triggerJustAppeared(true), m_respawnCompatibilityMode(false), _lastDamagedTime(0),
262-
_regenerateHealth(true), _regenerateHealthLock(false), _isMissingCanSwimFlagOutOfCombat(false)
259+
m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL), m_baseAttackPower(0), m_baseRangedAttackPower(0), m_originalEntry(0),
260+
m_homePosition(), m_transportHomePosition(), m_creatureInfo(nullptr), m_creatureData(nullptr), m_stringIds(),
261+
_waypointPathId(0), _currentWaypointNodeInfo(0, 0), m_formation(nullptr), m_triggerJustAppeared(true), m_respawnCompatibilityMode(false),
262+
_lastDamagedTime(0), _regenerateHealth(true), _regenerateHealthLock(false), _isMissingCanSwimFlagOutOfCombat(false)
263263
{
264264
m_regenTimer = CREATURE_REGEN_INTERVAL;
265265
m_valuesCount = UNIT_END;
@@ -1483,8 +1483,8 @@ void Creature::UpdateLevelDependantStats()
14831483
SetBaseWeaponDamage(RANGED_ATTACK, MINDAMAGE, weaponBaseMinDamage);
14841484
SetBaseWeaponDamage(RANGED_ATTACK, MAXDAMAGE, weaponBaseMaxDamage);
14851485

1486-
SetStatFlatModifier(UNIT_MOD_ATTACK_POWER, BASE_VALUE, stats->AttackPower);
1487-
SetStatFlatModifier(UNIT_MOD_ATTACK_POWER_RANGED, BASE_VALUE, stats->RangedAttackPower);
1486+
m_baseAttackPower = stats->AttackPower;
1487+
m_baseRangedAttackPower = stats->RangedAttackPower;
14881488

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

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,8 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
417417
uint32 m_cannotReachTimer;
418418

419419
SpellSchoolMask m_meleeDamageSchoolMask;
420+
uint32 m_baseAttackPower;
421+
uint32 m_baseRangedAttackPower;
420422
uint32 m_originalEntry;
421423

422424
Position m_homePosition;

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7242,11 +7242,11 @@ void Player::_ApplyItemBonuses(ItemTemplate const* proto, uint8 slot, bool apply
72427242
ApplyRatingMod(CR_EXPERTISE, int32(val), apply);
72437243
break;
72447244
case ITEM_MOD_ATTACK_POWER:
7245-
HandleStatFlatModifier(UNIT_MOD_ATTACK_POWER, TOTAL_VALUE, float(val), apply);
7246-
HandleStatFlatModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_VALUE, float(val), apply);
7245+
HandleAttackPowerModifier(AttackPowerModIndex::Melee, (val >= 0) ? AttackPowerModType::FlatPositive : AttackPowerModType::FlatNegative, float(val), apply);
7246+
HandleAttackPowerModifier(AttackPowerModIndex::Ranged, (val >= 0) ? AttackPowerModType::FlatPositive : AttackPowerModType::FlatNegative, float(val), apply);
72477247
break;
72487248
case ITEM_MOD_RANGED_ATTACK_POWER:
7249-
HandleStatFlatModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_VALUE, float(val), apply);
7249+
HandleAttackPowerModifier(AttackPowerModIndex::Ranged, (val >= 0) ? AttackPowerModType::FlatPositive : AttackPowerModType::FlatNegative, float(val), apply);
72507250
break;
72517251
// case ITEM_MOD_FERAL_ATTACK_POWER:
72527252
// ApplyFeralAPBonus(int32(val), apply);
@@ -13450,7 +13450,7 @@ void Player::ApplyEnchantment(Item* item, EnchantmentSlot slot, bool apply, bool
1345013450
for (uint8 s = 0; s < MAX_ITEM_ENCHANTMENT_EFFECTS; ++s)
1345113451
{
1345213452
uint32 enchant_display_type = pEnchant->Effect[s];
13453-
uint32 enchant_amount = pEnchant->EffectPointsMin[s];
13453+
int32 enchant_amount = pEnchant->EffectPointsMin[s];
1345413454
uint32 enchant_spell_id = pEnchant->EffectArg[s];
1345513455

1345613456
switch (enchant_display_type)
@@ -13513,7 +13513,7 @@ void Player::ApplyEnchantment(Item* item, EnchantmentSlot slot, bool apply, bool
1351313513
{
1351413514
if (item_rand->Enchantment[k] == enchant_id)
1351513515
{
13516-
enchant_amount = uint32((item_rand->AllocationPct[k] * item->GetItemSuffixFactor()) / 10000);
13516+
enchant_amount = int32((item_rand->AllocationPct[k] * item->GetItemSuffixFactor()) / 10000);
1351713517
break;
1351813518
}
1351913519
}
@@ -13533,7 +13533,7 @@ void Player::ApplyEnchantment(Item* item, EnchantmentSlot slot, bool apply, bool
1353313533
{
1353413534
if (item_rand_suffix->Enchantment[k] == enchant_id)
1353513535
{
13536-
enchant_amount = uint32((item_rand_suffix->AllocationPct[k] * item->GetItemSuffixFactor()) / 10000);
13536+
enchant_amount = int32((item_rand_suffix->AllocationPct[k] * item->GetItemSuffixFactor()) / 10000);
1353713537
break;
1353813538
}
1353913539
}
@@ -13685,12 +13685,12 @@ void Player::ApplyEnchantment(Item* item, EnchantmentSlot slot, bool apply, bool
1368513685
TC_LOG_DEBUG("entities.player.items", "+ {} EXPERTISE", enchant_amount);
1368613686
break;
1368713687
case ITEM_MOD_ATTACK_POWER:
13688-
HandleStatFlatModifier(UNIT_MOD_ATTACK_POWER, TOTAL_VALUE, float(enchant_amount), apply);
13689-
HandleStatFlatModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_VALUE, float(enchant_amount), apply);
13688+
HandleAttackPowerModifier(AttackPowerModIndex::Melee, (enchant_amount >= 0) ? AttackPowerModType::FlatPositive : AttackPowerModType::FlatNegative, float(enchant_amount), apply);
13689+
HandleAttackPowerModifier(AttackPowerModIndex::Ranged, (enchant_amount >= 0) ? AttackPowerModType::FlatPositive : AttackPowerModType::FlatNegative, float(enchant_amount), apply);
1369013690
TC_LOG_DEBUG("entities.player.items", "+ {} ATTACK_POWER", enchant_amount);
1369113691
break;
1369213692
case ITEM_MOD_RANGED_ATTACK_POWER:
13693-
HandleStatFlatModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_VALUE, float(enchant_amount), apply);
13693+
HandleAttackPowerModifier(AttackPowerModIndex::Ranged, (enchant_amount >= 0) ? AttackPowerModType::FlatPositive : AttackPowerModType::FlatNegative, float(enchant_amount), apply);
1369413694
TC_LOG_DEBUG("entities.player.items", "+ {} RANGED_ATTACK_POWER", enchant_amount);
1369513695
break;
1369613696
// case ITEM_MOD_FERAL_ATTACK_POWER:

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

Lines changed: 40 additions & 42 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 ? AttackPowerModIndex::Ranged : AttackPowerModIndex::Melee;
346346

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

451-
SetStatFlatModifier(unitMod, BASE_VALUE, val2);
451+
float baseAttackPower = val2;
452+
float attackPowerModPos = GetAttackPowerModifierValue(unitMod, AttackPowerModType::FlatPositive);
453+
float attackPowerModNeg = GetAttackPowerModifierValue(unitMod, AttackPowerModType::FlatNegative);
454+
float attackPowerMultiplier = GetAttackPowerModifierValue(unitMod, AttackPowerModType::Pct) - 1.0f;
452455

453-
float base_attPower = GetFlatModifierValue(unitMod, BASE_VALUE) * GetPctModifierValue(unitMod, BASE_PCT);
454-
float attPowerMod = GetFlatModifierValue(unitMod, TOTAL_VALUE);
456+
// Dynamic flat mods: routed to pos or neg based on sign
457+
auto accumulateMod = [&attackPowerModPos, &attackPowerModNeg](float value)
458+
{
459+
if (value >= 0.0f)
460+
attackPowerModPos += value;
461+
else
462+
attackPowerModNeg += value;
463+
};
455464

456-
//add dynamic flat mods
457465
if (ranged)
458466
{
459467
if ((GetClassMask() & CLASSMASK_WAND_USERS) == 0)
460468
{
461469
AuraEffectList const& mRAPbyStat = GetAuraEffectsByType(SPELL_AURA_MOD_RANGED_ATTACK_POWER_OF_STAT_PERCENT);
462470
for (AuraEffect const* aurEff : mRAPbyStat)
463-
attPowerMod += CalculatePct(GetStat(Stats(aurEff->GetMiscValue())), aurEff->GetAmount());
471+
accumulateMod(CalculatePct(GetStat(Stats(aurEff->GetMiscValue())), aurEff->GetAmount()));
464472
}
465473
}
466474
else
467475
{
468476
AuraEffectList const& mAPbyStat = GetAuraEffectsByType(SPELL_AURA_MOD_ATTACK_POWER_OF_STAT_PERCENT);
469477
for (AuraEffect const* aurEff : mAPbyStat)
470-
attPowerMod += CalculatePct(GetStat(Stats(aurEff->GetMiscValue())), aurEff->GetAmount());
478+
accumulateMod(CalculatePct(GetStat(Stats(aurEff->GetMiscValue())), aurEff->GetAmount()));
471479
}
472480

473481
// 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;
482+
accumulateMod(GetTotalAuraModifier(SPELL_AURA_MOD_ATTACK_POWER_OF_ARMOR));
477483

478484
if (ranged)
479485
{
480-
SetRangedAttackPower(int32(base_attPower));
481-
if (attPowerMod >= 0)
482-
SetRangedAttackPowerModPos(int32(attPowerMod));
483-
if (attPowerMod <= 0)
484-
SetRangedAttackPowerModNeg(int32(attPowerMod));
485-
SetRangedAttackPowerMultiplier(attPowerMultiplier);
486+
SetRangedAttackPower(int32(baseAttackPower));
487+
SetRangedAttackPowerModPos(int32(attackPowerModPos));
488+
SetRangedAttackPowerModNeg(int32(attackPowerModNeg));
489+
SetRangedAttackPowerMultiplier(attackPowerMultiplier);
486490
}
487491
else
488492
{
489-
SetAttackPower(int32(base_attPower));
490-
if (attPowerMod >= 0)
491-
SetAttackPowerModPos(int32(attPowerMod));
492-
if (attPowerMod <= 0)
493-
SetAttackPowerModNeg(int32(attPowerMod));
494-
SetAttackPowerMultiplier(attPowerMultiplier);
493+
SetAttackPower(int32(baseAttackPower));
494+
SetAttackPowerModPos(int32(attackPowerModPos));
495+
SetAttackPowerModNeg(int32(attackPowerModNeg));
496+
SetAttackPowerMultiplier(attackPowerMultiplier);
495497
}
496498

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

11241126
void Creature::UpdateAttackPowerAndDamage(bool ranged)
11251127
{
1126-
UnitMods unitMod = ranged ? UNIT_MOD_ATTACK_POWER_RANGED : UNIT_MOD_ATTACK_POWER;
1128+
AttackPowerModIndex unitMod = ranged ? AttackPowerModIndex::Ranged : AttackPowerModIndex::Melee;
11271129

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;
1130+
float baseAttackPower = ranged ? m_baseRangedAttackPower : m_baseAttackPower;
1131+
float attackPowerModPos = GetAttackPowerModifierValue(unitMod, AttackPowerModType::FlatPositive);
1132+
float attackPowerModNeg = GetAttackPowerModifierValue(unitMod, AttackPowerModType::FlatNegative);
1133+
float attackPowerMultiplier = GetAttackPowerModifierValue(unitMod, AttackPowerModType::Pct) - 1.0f;
11311134

11321135
if (ranged)
11331136
{
11341137
SetRangedAttackPower(int32(baseAttackPower));
1135-
if (attackPowerMod >= 0)
1136-
SetRangedAttackPowerModPos(int32(attackPowerMod));
1137-
if (attackPowerMod <= 0)
1138-
SetRangedAttackPowerModNeg(int32(attackPowerMod));
1138+
SetRangedAttackPowerModPos(int32(attackPowerModPos));
1139+
SetRangedAttackPowerModNeg(int32(attackPowerModNeg));
11391140
SetRangedAttackPowerMultiplier(attackPowerMultiplier);
11401141
}
11411142
else
11421143
{
11431144
SetAttackPower(int32(baseAttackPower));
1144-
if (attackPowerMod >= 0)
1145-
SetAttackPowerModPos(int32(attackPowerMod));
1146-
if (attackPowerMod <= 0)
1147-
SetAttackPowerModNeg(int32(attackPowerMod));
1145+
SetAttackPowerModPos(int32(attackPowerModPos));
1146+
SetAttackPowerModNeg(int32(attackPowerModNeg));
11481147
SetAttackPowerMultiplier(attackPowerMultiplier);
11491148
}
11501149

@@ -1434,7 +1433,7 @@ void Guardian::UpdateAttackPowerAndDamage(bool ranged)
14341433

14351434
float val = 0.0f;
14361435
float bonusAP = 0.0f;
1437-
UnitMods unitMod = UNIT_MOD_ATTACK_POWER;
1436+
AttackPowerModIndex unitMod = AttackPowerModIndex::Melee;
14381437

14391438
if (GetEntry() == ENTRY_IMP) // imp's attack power
14401439
val = GetStat(STAT_STRENGTH) - 10.0f;
@@ -1502,15 +1501,14 @@ void Guardian::UpdateAttackPowerAndDamage(bool ranged)
15021501
}
15031502
}
15041503

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;
1504+
float base_attPower = val + bonusAP;
1505+
float attPowerModPos = GetAttackPowerModifierValue(unitMod, AttackPowerModType::FlatPositive);
1506+
float attPowerModNeg = GetAttackPowerModifierValue(unitMod, AttackPowerModType::FlatNegative);
1507+
float attPowerMultiplier = GetAttackPowerModifierValue(unitMod, AttackPowerModType::Pct) - 1.0f;
15111508

15121509
SetAttackPower(int32(base_attPower));
1513-
SetAttackPowerModPos(int32(attPowerMod));
1510+
SetAttackPowerModPos(int32(attPowerModPos));
1511+
SetAttackPowerModNeg(int32(attPowerModNeg));
15141512
SetAttackPowerMultiplier(attPowerMultiplier);
15151513

15161514
//automatically update weapon damage after attack power modification

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

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,13 @@ Unit::Unit(bool isWorldObject) :
350350
// implement 50% base damage from offhand
351351
m_auraPctModifiersGroup[UNIT_MOD_DAMAGE_OFFHAND][TOTAL_PCT] = 0.5f;
352352

353+
for (uint32 i = 0; i < uint32(AttackPowerModIndex::End); ++i)
354+
{
355+
m_attackPowerMods[i][uint32(AttackPowerModType::FlatPositive)] = 0.0f;
356+
m_attackPowerMods[i][uint32(AttackPowerModType::FlatNegative)] = 0.0f;
357+
m_attackPowerMods[i][uint32(AttackPowerModType::Pct)] = 1.0f;
358+
}
359+
353360
for (uint8 i = 0; i < MAX_ATTACK; ++i)
354361
{
355362
m_weaponDamage[i][MINDAMAGE][0] = BASE_MINDAMAGE;
@@ -8953,6 +8960,11 @@ bool Unit::IsInDisallowedMountForm() const
89538960
######## ########
89548961
#######################################*/
89558962

8963+
void ApplyPercentModFloatVar(float& var, float val, bool apply)
8964+
{
8965+
var *= (apply ? (100.0f + val) / 100.0f : 100.0f / (100.0f + val));
8966+
}
8967+
89568968
void Unit::HandleStatFlatModifier(UnitMods unitMod, UnitModifierFlatType modifierType, float amount, bool apply)
89578969
{
89588970
if (unitMod >= UNIT_MOD_END || modifierType >= MODIFIER_TYPE_FLAT_END)
@@ -9035,7 +9047,7 @@ float Unit::GetPctModifierValue(UnitMods unitMod, UnitModifierPctType modifierTy
90359047
if (unitMod >= UNIT_MOD_END || modifierType >= MODIFIER_TYPE_PCT_END)
90369048
{
90379049
TC_LOG_ERROR("entities.unit", "attempt to access non-existing modifier value from UnitMods!");
9038-
return 0.0f;
9050+
return 1.0f;
90399051
}
90409052

90419053
return m_auraPctModifiersGroup[unitMod][modifierType];
@@ -9072,9 +9084,6 @@ void Unit::UpdateUnitMod(UnitMods unitMod)
90729084
case UNIT_MOD_RESISTANCE_SHADOW:
90739085
case UNIT_MOD_RESISTANCE_ARCANE: UpdateResistances(GetSpellSchoolByAuraGroup(unitMod)); break;
90749086

9075-
case UNIT_MOD_ATTACK_POWER: UpdateAttackPowerAndDamage(); break;
9076-
case UNIT_MOD_ATTACK_POWER_RANGED: UpdateAttackPowerAndDamage(true); break;
9077-
90789087
case UNIT_MOD_DAMAGE_MAINHAND: UpdateDamagePhysical(BASE_ATTACK); break;
90799088
case UNIT_MOD_DAMAGE_OFFHAND: UpdateDamagePhysical(OFF_ATTACK); break;
90809089
case UNIT_MOD_DAMAGE_RANGED: UpdateDamagePhysical(RANGED_ATTACK); break;
@@ -9084,6 +9093,41 @@ void Unit::UpdateUnitMod(UnitMods unitMod)
90849093
}
90859094
}
90869095

9096+
void Unit::HandleAttackPowerModifier(AttackPowerModIndex index, AttackPowerModType modifierType, float amount, bool apply)
9097+
{
9098+
if (index >= AttackPowerModIndex::End || modifierType >= AttackPowerModType::End)
9099+
{
9100+
TC_LOG_ERROR("entities.unit", "ERROR in HandleAttackPowerModifier(): non-existing AttackPowerModIndex or wrong AttackPowerModType!");
9101+
return;
9102+
}
9103+
9104+
switch (modifierType)
9105+
{
9106+
case AttackPowerModType::Pct:
9107+
ApplyPercentModFloatVar(m_attackPowerMods[uint32(index)][uint32(modifierType)], amount, apply);
9108+
break;
9109+
default:
9110+
m_attackPowerMods[uint32(index)][uint32(modifierType)] += apply ? amount : -amount;
9111+
break;
9112+
}
9113+
9114+
if (!CanModifyStats())
9115+
return;
9116+
9117+
UpdateAttackPowerAndDamage(index == AttackPowerModIndex::Ranged);
9118+
}
9119+
9120+
float Unit::GetAttackPowerModifierValue(AttackPowerModIndex index, AttackPowerModType modifierType) const
9121+
{
9122+
if (index >= AttackPowerModIndex::End || modifierType >= AttackPowerModType::End)
9123+
{
9124+
TC_LOG_ERROR("entities.unit", "ERROR in GetAttackPowerModifierValue(): non-existing AttackPowerModIndex or wrong AttackPowerModType!");
9125+
return 0.0f;
9126+
}
9127+
9128+
return m_attackPowerMods[uint32(index)][uint32(modifierType)];
9129+
}
9130+
90879131
void Unit::UpdateDamageDoneMods(WeaponAttackType attackType, int32 /*skipEnchantSlot = -1*/)
90889132
{
90899133
UnitMods unitMod;
@@ -10557,11 +10601,6 @@ Unit* Unit::SelectNearbyTarget(Unit* exclude, float dist) const
1055710601
return Trinity::Containers::SelectRandomContainerElement(targets);
1055810602
}
1055910603

10560-
void ApplyPercentModFloatVar(float& var, float val, bool apply)
10561-
{
10562-
var *= (apply ? (100.0f + val) / 100.0f : 100.0f / (100.0f + val));
10563-
}
10564-
1056510604
void Unit::ApplyAttackTimePercentMod(WeaponAttackType att, float val, bool apply)
1056610605
{
1056710606
float amount = GetFloatValue(UNIT_FIELD_BASEATTACKTIME + AsUnderlyingType(att));

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

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,6 @@ enum UnitMods
176176
UNIT_MOD_RESISTANCE_FROST,
177177
UNIT_MOD_RESISTANCE_SHADOW,
178178
UNIT_MOD_RESISTANCE_ARCANE,
179-
UNIT_MOD_ATTACK_POWER,
180-
UNIT_MOD_ATTACK_POWER_RANGED,
181179
UNIT_MOD_DAMAGE_MAINHAND,
182180
UNIT_MOD_DAMAGE_OFFHAND,
183181
UNIT_MOD_DAMAGE_RANGED,
@@ -207,6 +205,21 @@ enum BaseModType
207205
MOD_END
208206
};
209207

208+
enum class AttackPowerModIndex : uint8
209+
{
210+
Melee,
211+
Ranged,
212+
End
213+
};
214+
215+
enum class AttackPowerModType : uint8
216+
{
217+
FlatPositive,
218+
FlatNegative,
219+
Pct,
220+
End
221+
};
222+
210223
enum DeathState
211224
{
212225
ALIVE = 0,
@@ -1514,6 +1527,9 @@ class TC_GAME_API Unit : public WorldObject
15141527

15151528
void UpdateUnitMod(UnitMods unitMod);
15161529

1530+
void HandleAttackPowerModifier(AttackPowerModIndex index, AttackPowerModType modifierType, float amount, bool apply);
1531+
float GetAttackPowerModifierValue(AttackPowerModIndex index, AttackPowerModType modifierType) const;
1532+
15171533
// only players have item requirements
15181534
virtual bool CheckAttackFitToAuraRequirement(WeaponAttackType /*attackType*/, AuraEffect const* /*aurEff*/) const { return true; }
15191535

@@ -1877,6 +1893,7 @@ class TC_GAME_API Unit : public WorldObject
18771893

18781894
float m_auraFlatModifiersGroup[UNIT_MOD_END][MODIFIER_TYPE_FLAT_END];
18791895
float m_auraPctModifiersGroup[UNIT_MOD_END][MODIFIER_TYPE_PCT_END];
1896+
float m_attackPowerMods[uint32(AttackPowerModIndex::End)][uint32(AttackPowerModType::End)];
18801897
float m_weaponDamage[MAX_ATTACK][2][2];
18811898
bool m_canModifyStats;
18821899

0 commit comments

Comments
 (0)