fix(Core/Items): count stats programatically instead of manually set (#22564)

Co-authored-by: heyitsbench <benjymansy123@gmail.com>
This commit is contained in:
Tereneckla
2025-08-01 13:36:01 +00:00
committed by GitHub
parent b711c55c1e
commit 9ad7cef3c4
7 changed files with 146 additions and 85 deletions

View File

@@ -318,6 +318,8 @@ Player::Player(WorldSession* session): Unit(true), m_mover(this)
m_baseRatingValue[i] = 0;
m_baseSpellPower = 0;
m_baseSpellDamage = 0;
m_baseSpellHealing = 0;
m_baseFeralAP = 0;
m_baseManaRegen = 0;
m_baseHealthRegen = 0;
@@ -6836,7 +6838,10 @@ void Player::_ApplyItemBonuses(ItemTemplate const* proto, uint8 slot, bool apply
break;
/// @deprecated item mods
case ITEM_MOD_SPELL_HEALING_DONE:
ApplySpellHealingBonus(int32(val), apply);
break;
case ITEM_MOD_SPELL_DAMAGE_DONE:
ApplySpellDamageBonus(int32(val), apply);
break;
}
}

View File

@@ -1964,6 +1964,8 @@ public:
void UpdateAttackPowerAndDamage(bool ranged = false) override;
void UpdateShieldBlockValue();
void ApplySpellPowerBonus(int32 amount, bool apply);
void ApplySpellDamageBonus(int32 amount, bool apply);
void ApplySpellHealingBonus(int32 amount, bool apply);
void UpdateSpellDamageAndHealingBonus();
void ApplyRatingMod(CombatRating cr, int32 value, bool apply);
void UpdateRating(CombatRating cr);
@@ -1982,6 +1984,8 @@ public:
[[nodiscard]] float GetRatingMultiplier(CombatRating cr) const;
[[nodiscard]] float GetRatingBonusValue(CombatRating cr) const;
uint32 GetBaseSpellPowerBonus() { return m_baseSpellPower; }
uint32 GetBaseSpellDamageBonus() { return m_baseSpellDamage; }
uint32 GetBaseSpellHealingBonus() { return m_baseSpellHealing; }
[[nodiscard]] int32 GetSpellPenetrationItemMod() const { return m_spellPenetrationItemMod; }
[[nodiscard]] float GetExpertiseDodgeOrParryReduction(WeaponAttackType attType) const;
@@ -2838,6 +2842,8 @@ protected:
float m_auraBaseMod[BASEMOD_END][MOD_END];
int32 m_baseRatingValue[MAX_COMBAT_RATING];
uint32 m_baseSpellPower;
uint32 m_baseSpellDamage;
uint32 m_baseSpellHealing;
uint32 m_baseFeralAP;
uint32 m_baseManaRegen;
uint32 m_baseHealthRegen;

View File

@@ -4616,8 +4616,15 @@ void Player::ApplyEnchantment(Item* item, EnchantmentSlot slot, bool apply, bool
HandleBaseModValue(SHIELD_BLOCK_VALUE, FLAT_MOD, float(enchant_amount), apply);
LOG_DEBUG("entities.player.items", "+ {} BLOCK_VALUE", enchant_amount);
break;
case ITEM_MOD_SPELL_HEALING_DONE: // deprecated
case ITEM_MOD_SPELL_DAMAGE_DONE: // deprecated
/// @deprecated item mods
case ITEM_MOD_SPELL_HEALING_DONE:
ApplySpellHealingBonus(enchant_amount, apply);
LOG_DEBUG("entities.player.items", "+ {} SPELL_HEALING", enchant_amount);
break;
case ITEM_MOD_SPELL_DAMAGE_DONE:
ApplySpellDamageBonus(enchant_amount, apply);
LOG_DEBUG("entities.player.items", "+ {} SPELL_DAMAGE", enchant_amount);
break;
default:
break;
}

View File

@@ -174,6 +174,23 @@ void Player::ApplySpellPowerBonus(int32 amount, bool apply)
ApplyModInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + i, amount, apply);
}
void Player::ApplySpellDamageBonus(int32 amount, bool apply)
{
apply = _ModifyUInt32(apply, m_baseSpellDamage, amount);
// For speed just update for client
for (int i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i)
ApplyModInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + i, amount, apply);
}
void Player::ApplySpellHealingBonus(int32 amount, bool apply)
{
apply = _ModifyUInt32(apply, m_baseSpellHealing, amount);
// For speed just update for client
ApplyModUInt32Value(PLAYER_FIELD_MOD_HEALING_DONE_POS, amount, apply);
}
void Player::UpdateSpellDamageAndHealingBonus()
{
// Magic damage modifiers implemented in Unit::SpellDamageBonusDone

View File

@@ -12034,6 +12034,7 @@ int32 Unit::SpellBaseDamageBonusDone(SpellSchoolMask schoolMask)
{
// Base value
DoneAdvertisedBenefit += ToPlayer()->GetBaseSpellPowerBonus();
DoneAdvertisedBenefit += ToPlayer()->GetBaseSpellDamageBonus();
// Damage bonus from stats
AuraEffectList const& mDamageDoneOfStatPercent = GetAuraEffectsByType(SPELL_AURA_MOD_SPELL_DAMAGE_OF_STAT_PERCENT);
@@ -12796,6 +12797,7 @@ int32 Unit::SpellBaseHealingBonusDone(SpellSchoolMask schoolMask)
{
// Base value
AdvertisedBenefit += ToPlayer()->GetBaseSpellPowerBonus();
AdvertisedBenefit += ToPlayer()->GetBaseSpellHealingBonus();
// Healing bonus from stats
AuraEffectList const& mHealingDoneOfStatPercent = GetAuraEffectsByType(SPELL_AURA_MOD_SPELL_HEALING_OF_STAT_PERCENT);