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 https://github.com/vmangos/core/commit/2646715596d24ba205b03a7f3e1cee1c4ffa4ab9 Co-authored-by: ratkosrb <[email protected]> (cherry picked from commit c19037900f5276105520ca8693c8c551cf2aaa13)
This commit is contained in:
@@ -323,10 +323,10 @@ Creature::Creature(bool isWorldObject) : Unit(isWorldObject), MapObject(), m_Pla
|
||||
m_boundaryCheckTime(2500), m_reactState(REACT_AGGRESSIVE),
|
||||
m_defaultMovementType(IDLE_MOTION_TYPE), m_spawnId(UI64LIT(0)), m_equipmentId(0), m_originalEquipmentId(0),
|
||||
m_AlreadyCallAssistance(false), m_AlreadySearchedAssistance(false), m_cannotReachTarget(false), m_cannotReachTimer(0),
|
||||
m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL), m_originalEntry(0), m_homePosition(), m_transportHomePosition(),
|
||||
m_creatureInfo(nullptr), m_creatureData(nullptr), m_creatureDifficulty(nullptr), m_stringIds(), _waypointPathId(0), _currentWaypointNodeInfo(0, 0),
|
||||
m_formation(nullptr), m_triggerJustAppeared(true), m_respawnCompatibilityMode(false), _aggroGracePeriodExpired(false), _lastDamagedTime(0),
|
||||
_regenerateHealth(true), _creatureImmunitiesId(0), _gossipMenuId(0), _sparringHealthPct(0)
|
||||
m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL), m_baseAttackPower(0), m_baseRangedAttackPower(0), m_originalEntry(0),
|
||||
m_homePosition(), m_transportHomePosition(), m_creatureInfo(nullptr), m_creatureData(nullptr), m_creatureDifficulty(nullptr), m_stringIds(),
|
||||
_waypointPathId(0), _currentWaypointNodeInfo(0, 0), m_formation(nullptr), m_triggerJustAppeared(true), m_respawnCompatibilityMode(false),
|
||||
_aggroGracePeriodExpired(false), _lastDamagedTime(0), _regenerateHealth(true), _creatureImmunitiesId(0), _gossipMenuId(0), _sparringHealthPct(0)
|
||||
{
|
||||
m_regenTimer = CREATURE_REGEN_INTERVAL;
|
||||
|
||||
@@ -1663,8 +1663,8 @@ void Creature::UpdateLevelDependantStats()
|
||||
SetBaseWeaponDamage(RANGED_ATTACK, MINDAMAGE, weaponBaseMinDamage);
|
||||
SetBaseWeaponDamage(RANGED_ATTACK, MAXDAMAGE, weaponBaseMaxDamage);
|
||||
|
||||
SetStatFlatModifier(UNIT_MOD_ATTACK_POWER, BASE_VALUE, stats->AttackPower);
|
||||
SetStatFlatModifier(UNIT_MOD_ATTACK_POWER_RANGED, BASE_VALUE, stats->RangedAttackPower);
|
||||
m_baseAttackPower = stats->AttackPower;
|
||||
m_baseRangedAttackPower = stats->RangedAttackPower;
|
||||
|
||||
float armor = GetBaseArmorForLevel(level);
|
||||
SetStatFlatModifier(UNIT_MOD_ARMOR, BASE_VALUE, armor);
|
||||
|
||||
@@ -549,6 +549,8 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
|
||||
uint32 m_cannotReachTimer;
|
||||
|
||||
SpellSchoolMask m_meleeDamageSchoolMask;
|
||||
uint32 m_baseAttackPower;
|
||||
uint32 m_baseRangedAttackPower;
|
||||
uint32 m_originalEntry;
|
||||
|
||||
Position m_homePosition;
|
||||
|
||||
@@ -8020,11 +8020,11 @@ void Player::_ApplyItemBonuses(Item* item, uint8 slot, bool apply)
|
||||
ApplyRatingMod(CR_EXPERTISE, int32(val), apply);
|
||||
break;
|
||||
case ITEM_MOD_ATTACK_POWER:
|
||||
HandleStatFlatModifier(UNIT_MOD_ATTACK_POWER, TOTAL_VALUE, float(val), apply);
|
||||
HandleStatFlatModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_VALUE, float(val), apply);
|
||||
HandleAttackPowerModifier(AttackPowerModIndex::Melee, (val >= 0) ? AttackPowerModType::FlatPositive : AttackPowerModType::FlatNegative, float(val), apply);
|
||||
HandleAttackPowerModifier(AttackPowerModIndex::Ranged, (val >= 0) ? AttackPowerModType::FlatPositive : AttackPowerModType::FlatNegative, float(val), apply);
|
||||
break;
|
||||
case ITEM_MOD_RANGED_ATTACK_POWER:
|
||||
HandleStatFlatModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_VALUE, float(val), apply);
|
||||
HandleAttackPowerModifier(AttackPowerModIndex::Ranged, (val >= 0) ? AttackPowerModType::FlatPositive : AttackPowerModType::FlatNegative, float(val), apply);
|
||||
break;
|
||||
case ITEM_MOD_VERSATILITY:
|
||||
ApplyRatingMod(CR_VERSATILITY_DAMAGE_DONE, int32(val), apply);
|
||||
@@ -13463,7 +13463,7 @@ void Player::ApplyEnchantment(Item* item, EnchantmentSlot slot, bool apply, bool
|
||||
for (int s = 0; s < MAX_ITEM_ENCHANTMENT_EFFECTS; ++s)
|
||||
{
|
||||
uint32 enchant_display_type = pEnchant->Effect[s];
|
||||
uint32 enchant_amount = pEnchant->EffectPointsMin[s];
|
||||
int32 enchant_amount = pEnchant->EffectPointsMin[s];
|
||||
uint32 enchant_spell_id = pEnchant->EffectArg[s];
|
||||
|
||||
switch (enchant_display_type)
|
||||
@@ -13506,9 +13506,9 @@ void Player::ApplyEnchantment(Item* item, EnchantmentSlot slot, bool apply, bool
|
||||
scalingLevel = maxLevel;
|
||||
|
||||
if (GtSpellScalingEntry const* spellScaling = sSpellScalingGameTable.GetRow(scalingLevel))
|
||||
enchant_amount = uint32(pEnchant->EffectScalingPoints[s] * GetSpellScalingColumnForClass(spellScaling, scalingClass));
|
||||
enchant_amount = int32(pEnchant->EffectScalingPoints[s] * GetSpellScalingColumnForClass(spellScaling, scalingClass));
|
||||
}
|
||||
enchant_amount = std::max(enchant_amount, 1u);
|
||||
enchant_amount = std::max(enchant_amount, 1);
|
||||
HandleStatFlatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + enchant_spell_id), TOTAL_VALUE, float(enchant_amount), apply);
|
||||
break;
|
||||
case ITEM_ENCHANTMENT_TYPE_STAT:
|
||||
@@ -13529,10 +13529,10 @@ void Player::ApplyEnchantment(Item* item, EnchantmentSlot slot, bool apply, bool
|
||||
scalingLevel = maxLevel;
|
||||
|
||||
if (GtSpellScalingEntry const* spellScaling = sSpellScalingGameTable.GetRow(scalingLevel))
|
||||
enchant_amount = uint32(pEnchant->EffectScalingPoints[s] * GetSpellScalingColumnForClass(spellScaling, scalingClass));
|
||||
enchant_amount = int32(pEnchant->EffectScalingPoints[s] * GetSpellScalingColumnForClass(spellScaling, scalingClass));
|
||||
}
|
||||
|
||||
enchant_amount = std::max(enchant_amount, 1u);
|
||||
enchant_amount = std::max(enchant_amount, 1);
|
||||
|
||||
TC_LOG_DEBUG("entities.player.items", "Adding {} to stat nb {}", enchant_amount, enchant_spell_id);
|
||||
switch (enchant_spell_id)
|
||||
@@ -13676,12 +13676,12 @@ void Player::ApplyEnchantment(Item* item, EnchantmentSlot slot, bool apply, bool
|
||||
TC_LOG_DEBUG("entities.player.items", "+ {} EXPERTISE", enchant_amount);
|
||||
break;
|
||||
case ITEM_MOD_ATTACK_POWER:
|
||||
HandleStatFlatModifier(UNIT_MOD_ATTACK_POWER, TOTAL_VALUE, float(enchant_amount), apply);
|
||||
HandleStatFlatModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_VALUE, float(enchant_amount), apply);
|
||||
HandleAttackPowerModifier(AttackPowerModIndex::Melee, (enchant_amount >= 0) ? AttackPowerModType::FlatPositive : AttackPowerModType::FlatNegative, float(enchant_amount), apply);
|
||||
HandleAttackPowerModifier(AttackPowerModIndex::Ranged, (enchant_amount >= 0) ? AttackPowerModType::FlatPositive : AttackPowerModType::FlatNegative, float(enchant_amount), apply);
|
||||
TC_LOG_DEBUG("entities.player.items", "+ {} ATTACK_POWER", enchant_amount);
|
||||
break;
|
||||
case ITEM_MOD_RANGED_ATTACK_POWER:
|
||||
HandleStatFlatModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_VALUE, float(enchant_amount), apply);
|
||||
HandleAttackPowerModifier(AttackPowerModIndex::Ranged, (enchant_amount >= 0) ? AttackPowerModType::FlatPositive : AttackPowerModType::FlatNegative, float(enchant_amount), apply);
|
||||
TC_LOG_DEBUG("entities.player.items", "+ {} RANGED_ATTACK_POWER", enchant_amount);
|
||||
break;
|
||||
case ITEM_MOD_MANA_REGENERATION:
|
||||
|
||||
@@ -355,7 +355,7 @@ void Player::UpdateAttackPowerAndDamage(bool ranged)
|
||||
float level = float(GetLevel());
|
||||
|
||||
ChrClassesEntry const* entry = sChrClassesStore.AssertEntry(GetClass());
|
||||
UnitMods unitMod = ranged ? UNIT_MOD_ATTACK_POWER_RANGED : UNIT_MOD_ATTACK_POWER;
|
||||
AttackPowerModIndex unitMod = ranged ? AttackPowerModIndex::Ranged : AttackPowerModIndex::Melee;
|
||||
|
||||
if (!HasAuraType(SPELL_AURA_OVERRIDE_ATTACK_POWER_BY_SP_PCT))
|
||||
{
|
||||
@@ -383,23 +383,24 @@ void Player::UpdateAttackPowerAndDamage(bool ranged)
|
||||
val2 = CalculatePct(float(minSpellPower), *m_activePlayerData->OverrideAPBySpellPowerPercent);
|
||||
}
|
||||
|
||||
SetStatFlatModifier(unitMod, BASE_VALUE, val2);
|
||||
|
||||
float base_attPower = GetFlatModifierValue(unitMod, BASE_VALUE) * GetPctModifierValue(unitMod, BASE_PCT);
|
||||
float attPowerMod = GetFlatModifierValue(unitMod, TOTAL_VALUE);
|
||||
float attPowerMultiplier = GetPctModifierValue(unitMod, TOTAL_PCT) - 1.0f;
|
||||
float baseAttackPower = val2;
|
||||
float attackPowerModPos = GetAttackPowerModifierValue(unitMod, AttackPowerModType::FlatPositive);
|
||||
float attackPowerModNeg = GetAttackPowerModifierValue(unitMod, AttackPowerModType::FlatNegative);
|
||||
float attackPowerMultiplier = GetAttackPowerModifierValue(unitMod, AttackPowerModType::Pct) - 1.0f;
|
||||
|
||||
if (ranged)
|
||||
{
|
||||
SetRangedAttackPower(int32(base_attPower));
|
||||
SetRangedAttackPowerModPos(int32(attPowerMod));
|
||||
SetRangedAttackPowerMultiplier(attPowerMultiplier);
|
||||
SetRangedAttackPower(int32(baseAttackPower));
|
||||
SetRangedAttackPowerModPos(int32(attackPowerModPos));
|
||||
SetRangedAttackPowerModNeg(int32(attackPowerModNeg));
|
||||
SetRangedAttackPowerMultiplier(attackPowerMultiplier);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetAttackPower(int32(base_attPower));
|
||||
SetAttackPowerModPos(int32(attPowerMod));
|
||||
SetAttackPowerMultiplier(attPowerMultiplier);
|
||||
SetAttackPower(int32(baseAttackPower));
|
||||
SetAttackPowerModPos(int32(attackPowerModPos));
|
||||
SetAttackPowerModNeg(int32(attackPowerModNeg));
|
||||
SetAttackPowerMultiplier(attackPowerMultiplier);
|
||||
}
|
||||
|
||||
Pet* pet = GetPet(); //update pet's AP
|
||||
@@ -1063,19 +1064,25 @@ void Creature::UpdateMaxPower(Powers power)
|
||||
|
||||
void Creature::UpdateAttackPowerAndDamage(bool ranged)
|
||||
{
|
||||
UnitMods unitMod = ranged ? UNIT_MOD_ATTACK_POWER_RANGED : UNIT_MOD_ATTACK_POWER;
|
||||
AttackPowerModIndex unitMod = ranged ? AttackPowerModIndex::Ranged : AttackPowerModIndex::Melee;
|
||||
|
||||
float baseAttackPower = GetFlatModifierValue(unitMod, BASE_VALUE) * GetPctModifierValue(unitMod, BASE_PCT);
|
||||
float attackPowerMultiplier = GetPctModifierValue(unitMod, TOTAL_PCT) - 1.0f;
|
||||
float baseAttackPower = ranged ? m_baseRangedAttackPower : m_baseAttackPower;
|
||||
float attackPowerModPos = GetAttackPowerModifierValue(unitMod, AttackPowerModType::FlatPositive);
|
||||
float attackPowerModNeg = GetAttackPowerModifierValue(unitMod, AttackPowerModType::FlatNegative);
|
||||
float attackPowerMultiplier = GetAttackPowerModifierValue(unitMod, AttackPowerModType::Pct) - 1.0f;
|
||||
|
||||
if (ranged)
|
||||
{
|
||||
SetRangedAttackPower(int32(baseAttackPower));
|
||||
SetRangedAttackPowerModPos(int32(attackPowerModPos));
|
||||
SetRangedAttackPowerModNeg(int32(attackPowerModNeg));
|
||||
SetRangedAttackPowerMultiplier(attackPowerMultiplier);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetAttackPower(int32(baseAttackPower));
|
||||
SetAttackPowerModPos(int32(attackPowerModPos));
|
||||
SetAttackPowerModNeg(int32(attackPowerModNeg));
|
||||
SetAttackPowerMultiplier(attackPowerMultiplier);
|
||||
}
|
||||
|
||||
@@ -1319,7 +1326,7 @@ void Guardian::UpdateAttackPowerAndDamage(bool ranged)
|
||||
|
||||
float val = 0.0f;
|
||||
float bonusAP = 0.0f;
|
||||
UnitMods unitMod = UNIT_MOD_ATTACK_POWER;
|
||||
AttackPowerModIndex unitMod = AttackPowerModIndex::Melee;
|
||||
|
||||
if (GetEntry() == ENTRY_IMP) // imp's attack power
|
||||
val = GetStat(STAT_STRENGTH) - 10.0f;
|
||||
@@ -1367,13 +1374,14 @@ void Guardian::UpdateAttackPowerAndDamage(bool ranged)
|
||||
}
|
||||
}
|
||||
|
||||
SetStatFlatModifier(UNIT_MOD_ATTACK_POWER, BASE_VALUE, val + bonusAP);
|
||||
|
||||
//in BASE_VALUE of UNIT_MOD_ATTACK_POWER for creatures we store data of meleeattackpower field in DB
|
||||
float base_attPower = GetFlatModifierValue(unitMod, BASE_VALUE) * GetPctModifierValue(unitMod, BASE_PCT);
|
||||
float attPowerMultiplier = GetPctModifierValue(unitMod, TOTAL_PCT) - 1.0f;
|
||||
float base_attPower = val + bonusAP;
|
||||
float attPowerModPos = GetAttackPowerModifierValue(unitMod, AttackPowerModType::FlatPositive);
|
||||
float attPowerModNeg = GetAttackPowerModifierValue(unitMod, AttackPowerModType::FlatNegative);
|
||||
float attPowerMultiplier = GetAttackPowerModifierValue(unitMod, AttackPowerModType::Pct) - 1.0f;
|
||||
|
||||
SetAttackPower(int32(base_attPower));
|
||||
SetAttackPowerModPos(int32(attPowerModPos));
|
||||
SetAttackPowerModNeg(int32(attPowerModNeg));
|
||||
SetAttackPowerMultiplier(attPowerMultiplier);
|
||||
|
||||
//automatically update weapon damage after attack power modification
|
||||
|
||||
@@ -350,6 +350,13 @@ Unit::Unit(bool isWorldObject) :
|
||||
// implement 50% base damage from offhand
|
||||
m_auraPctModifiersGroup[UNIT_MOD_DAMAGE_OFFHAND][TOTAL_PCT] = 0.5f;
|
||||
|
||||
for (uint32 i = 0; i < uint32(AttackPowerModIndex::End); ++i)
|
||||
{
|
||||
m_attackPowerMods[i][uint32(AttackPowerModType::FlatPositive)] = 0.0f;
|
||||
m_attackPowerMods[i][uint32(AttackPowerModType::FlatNegative)] = 0.0f;
|
||||
m_attackPowerMods[i][uint32(AttackPowerModType::Pct)] = 1.0f;
|
||||
}
|
||||
|
||||
for (uint8 i = 0; i < MAX_ATTACK; ++i)
|
||||
{
|
||||
m_weaponDamage[i][MINDAMAGE] = BASE_MINDAMAGE;
|
||||
@@ -9590,6 +9597,11 @@ bool Unit::IsDisallowedMountForm(uint32 spellId, ShapeshiftForm form, uint32 dis
|
||||
######## ########
|
||||
#######################################*/
|
||||
|
||||
void ApplyPercentModFloatVar(float& var, float val, bool apply)
|
||||
{
|
||||
var *= (apply ? (100.0f + val) / 100.0f : 100.0f / (100.0f + val));
|
||||
}
|
||||
|
||||
void Unit::HandleStatFlatModifier(UnitMods unitMod, UnitModifierFlatType modifierType, float amount, bool apply)
|
||||
{
|
||||
if (unitMod >= UNIT_MOD_END || modifierType >= MODIFIER_TYPE_FLAT_END)
|
||||
@@ -9673,7 +9685,7 @@ float Unit::GetPctModifierValue(UnitMods unitMod, UnitModifierPctType modifierTy
|
||||
if (unitMod >= UNIT_MOD_END || modifierType >= MODIFIER_TYPE_PCT_END)
|
||||
{
|
||||
TC_LOG_ERROR("entities.unit", "attempt to access non-existing modifier value from UnitMods!");
|
||||
return 0.0f;
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
return m_auraPctModifiersGroup[unitMod][modifierType];
|
||||
@@ -9729,9 +9741,6 @@ void Unit::UpdateUnitMod(UnitMods unitMod)
|
||||
case UNIT_MOD_RESISTANCE_SHADOW:
|
||||
case UNIT_MOD_RESISTANCE_ARCANE: UpdateResistances(GetSpellSchoolByAuraGroup(unitMod)); break;
|
||||
|
||||
case UNIT_MOD_ATTACK_POWER: UpdateAttackPowerAndDamage(); break;
|
||||
case UNIT_MOD_ATTACK_POWER_RANGED: UpdateAttackPowerAndDamage(true); break;
|
||||
|
||||
case UNIT_MOD_DAMAGE_MAINHAND: UpdateDamagePhysical(BASE_ATTACK); break;
|
||||
case UNIT_MOD_DAMAGE_OFFHAND: UpdateDamagePhysical(OFF_ATTACK); break;
|
||||
case UNIT_MOD_DAMAGE_RANGED: UpdateDamagePhysical(RANGED_ATTACK); break;
|
||||
@@ -9742,6 +9751,41 @@ void Unit::UpdateUnitMod(UnitMods unitMod)
|
||||
}
|
||||
}
|
||||
|
||||
void Unit::HandleAttackPowerModifier(AttackPowerModIndex index, AttackPowerModType modifierType, float amount, bool apply)
|
||||
{
|
||||
if (index >= AttackPowerModIndex::End || modifierType >= AttackPowerModType::End)
|
||||
{
|
||||
TC_LOG_ERROR("entities.unit", "ERROR in HandleAttackPowerModifier(): non-existing AttackPowerModIndex or wrong AttackPowerModType!");
|
||||
return;
|
||||
}
|
||||
|
||||
switch (modifierType)
|
||||
{
|
||||
case AttackPowerModType::Pct:
|
||||
ApplyPercentModFloatVar(m_attackPowerMods[uint32(index)][uint32(modifierType)], amount, apply);
|
||||
break;
|
||||
default:
|
||||
m_attackPowerMods[uint32(index)][uint32(modifierType)] += apply ? amount : -amount;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!CanModifyStats())
|
||||
return;
|
||||
|
||||
UpdateAttackPowerAndDamage(index == AttackPowerModIndex::Ranged);
|
||||
}
|
||||
|
||||
float Unit::GetAttackPowerModifierValue(AttackPowerModIndex index, AttackPowerModType modifierType) const
|
||||
{
|
||||
if (index >= AttackPowerModIndex::End || modifierType >= AttackPowerModType::End)
|
||||
{
|
||||
TC_LOG_ERROR("entities.unit", "ERROR in GetAttackPowerModifierValue(): non-existing AttackPowerModIndex or wrong AttackPowerModType!");
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
return m_attackPowerMods[uint32(index)][uint32(modifierType)];
|
||||
}
|
||||
|
||||
void Unit::UpdateDamageDoneMods(WeaponAttackType attackType, int32 /*skipEnchantSlot = -1*/)
|
||||
{
|
||||
UnitMods unitMod;
|
||||
@@ -10975,11 +11019,6 @@ void Unit::UpdateAttackTimeField(WeaponAttackType att)
|
||||
}
|
||||
}
|
||||
|
||||
void ApplyPercentModFloatVar(float& var, float val, bool apply)
|
||||
{
|
||||
var *= (apply ? (100.0f + val) / 100.0f : 100.0f / (100.0f + val));
|
||||
}
|
||||
|
||||
void Unit::ApplyAttackTimePercentMod(WeaponAttackType att, float val, bool apply)
|
||||
{
|
||||
float remainingTimePct = float(m_attackTimer[att]) / (m_baseAttackSpeed[att] * m_modAttackSpeedPct[att]);
|
||||
|
||||
@@ -215,8 +215,6 @@ enum UnitMods
|
||||
UNIT_MOD_RESISTANCE_FROST,
|
||||
UNIT_MOD_RESISTANCE_SHADOW,
|
||||
UNIT_MOD_RESISTANCE_ARCANE,
|
||||
UNIT_MOD_ATTACK_POWER,
|
||||
UNIT_MOD_ATTACK_POWER_RANGED,
|
||||
UNIT_MOD_DAMAGE_MAINHAND,
|
||||
UNIT_MOD_DAMAGE_OFFHAND,
|
||||
UNIT_MOD_DAMAGE_RANGED,
|
||||
@@ -249,6 +247,21 @@ enum BaseModType
|
||||
MOD_END
|
||||
};
|
||||
|
||||
enum class AttackPowerModIndex : uint8
|
||||
{
|
||||
Melee,
|
||||
Ranged,
|
||||
End
|
||||
};
|
||||
|
||||
enum class AttackPowerModType : uint8
|
||||
{
|
||||
FlatPositive,
|
||||
FlatNegative,
|
||||
Pct,
|
||||
End
|
||||
};
|
||||
|
||||
enum DeathState
|
||||
{
|
||||
ALIVE = 0,
|
||||
@@ -1533,6 +1546,9 @@ class TC_GAME_API Unit : public WorldObject
|
||||
|
||||
void UpdateUnitMod(UnitMods unitMod);
|
||||
|
||||
void HandleAttackPowerModifier(AttackPowerModIndex index, AttackPowerModType modifierType, float amount, bool apply);
|
||||
float GetAttackPowerModifierValue(AttackPowerModIndex index, AttackPowerModType modifierType) const;
|
||||
|
||||
// only players have item requirements
|
||||
virtual bool CheckAttackFitToAuraRequirement(WeaponAttackType /*attackType*/, AuraEffect const* /*aurEff*/) const { return true; }
|
||||
|
||||
@@ -1939,6 +1955,7 @@ class TC_GAME_API Unit : public WorldObject
|
||||
|
||||
float m_auraFlatModifiersGroup[UNIT_MOD_END][MODIFIER_TYPE_FLAT_END];
|
||||
float m_auraPctModifiersGroup[UNIT_MOD_END][MODIFIER_TYPE_PCT_END];
|
||||
float m_attackPowerMods[uint32(AttackPowerModIndex::End)][uint32(AttackPowerModType::End)];
|
||||
float m_weaponDamage[MAX_ATTACK][2];
|
||||
bool m_canModifyStats;
|
||||
|
||||
|
||||
@@ -4649,7 +4649,7 @@ void AuraEffect::HandleAuraModAttackPower(AuraApplication const* aurApp, uint8 m
|
||||
|
||||
Unit* target = aurApp->GetTarget();
|
||||
|
||||
target->HandleStatFlatModifier(UNIT_MOD_ATTACK_POWER, TOTAL_VALUE, float(GetAmount()), apply);
|
||||
target->HandleAttackPowerModifier(AttackPowerModIndex::Melee, GetAmount() >= 0 ? AttackPowerModType::FlatPositive : AttackPowerModType::FlatNegative, float(GetAmount()), apply);
|
||||
}
|
||||
|
||||
void AuraEffect::HandleAuraModRangedAttackPower(AuraApplication const* aurApp, uint8 mode, bool apply) const
|
||||
@@ -4662,7 +4662,7 @@ void AuraEffect::HandleAuraModRangedAttackPower(AuraApplication const* aurApp, u
|
||||
if ((target->GetClassMask() & CLASSMASK_WAND_USERS) != 0)
|
||||
return;
|
||||
|
||||
target->HandleStatFlatModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_VALUE, float(GetAmount()), apply);
|
||||
target->HandleAttackPowerModifier(AttackPowerModIndex::Ranged, GetAmount() >= 0 ? AttackPowerModType::FlatPositive : AttackPowerModType::FlatNegative, float(GetAmount()), apply);
|
||||
}
|
||||
|
||||
void AuraEffect::HandleAuraModAttackPowerPercent(AuraApplication const* aurApp, uint8 mode, bool apply) const
|
||||
@@ -4672,14 +4672,7 @@ void AuraEffect::HandleAuraModAttackPowerPercent(AuraApplication const* aurApp,
|
||||
|
||||
Unit* target = aurApp->GetTarget();
|
||||
|
||||
//UNIT_FIELD_ATTACK_POWER_MULTIPLIER = multiplier - 1
|
||||
if (apply)
|
||||
target->ApplyStatPctModifier(UNIT_MOD_ATTACK_POWER, TOTAL_PCT, float(GetAmount()));
|
||||
else
|
||||
{
|
||||
float amount = target->GetTotalAuraMultiplier(SPELL_AURA_MOD_ATTACK_POWER_PCT);
|
||||
target->SetStatPctModifier(UNIT_MOD_ATTACK_POWER, TOTAL_PCT, amount);
|
||||
}
|
||||
target->HandleAttackPowerModifier(AttackPowerModIndex::Melee, AttackPowerModType::Pct, float(GetAmount()), apply);
|
||||
}
|
||||
|
||||
void AuraEffect::HandleAuraModRangedAttackPowerPercent(AuraApplication const* aurApp, uint8 mode, bool apply) const
|
||||
@@ -4692,14 +4685,7 @@ void AuraEffect::HandleAuraModRangedAttackPowerPercent(AuraApplication const* au
|
||||
if ((target->GetClassMask() & CLASSMASK_WAND_USERS) != 0)
|
||||
return;
|
||||
|
||||
//UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER = multiplier - 1
|
||||
if (apply)
|
||||
target->ApplyStatPctModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_PCT, float(GetAmount()));
|
||||
else
|
||||
{
|
||||
float amount = target->GetTotalAuraMultiplier(SPELL_AURA_MOD_RANGED_ATTACK_POWER_PCT);
|
||||
target->SetStatPctModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_PCT, amount);
|
||||
}
|
||||
target->HandleAttackPowerModifier(AttackPowerModIndex::Ranged, AttackPowerModType::Pct, float(GetAmount()), apply);
|
||||
}
|
||||
|
||||
/********************************/
|
||||
|
||||
@@ -310,8 +310,8 @@ public:
|
||||
{
|
||||
if (AuraEffect* /* aurEff */ect = owner->GetAuraEffect(56246, EFFECT_0))
|
||||
{
|
||||
float base_attPower = pet->GetFlatModifierValue(UNIT_MOD_ATTACK_POWER, BASE_VALUE) * pet->GetPctModifierValue(UNIT_MOD_ATTACK_POWER, BASE_PCT);
|
||||
amount += CalculatePct(amount+base_attPower, /* aurEff */ect->GetAmount());
|
||||
float base_attPower = float(*pet->m_unitData->AttackPower);
|
||||
amount += CalculatePct(amount + base_attPower, /* aurEff */ect->GetAmount());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user