Core/Spells: Damage and healing bonus calculation fixes

* Spells with SPELL_DAMAGE_CLASS_NONE are now allowed to benefit from spellmods
* Fixed SPELL_AURA_MOD_DAMAGE_DONE_VERSUS_AURASTATE and SPELL_AURA_MOD_HEALING_DONE_PCT_VERSUS_TARGET_HEALTH not working for players
This commit is contained in:
Shauren
2023-08-14 13:34:40 +02:00
parent 0c9e46629c
commit ac1c041944
+8 -20
View File
@@ -6553,17 +6553,11 @@ int32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, int3
APbonus += GetTotalAttackPowerValue(attType);
DoneTotal += int32(stack * ApCoeffMod * APbonus);
}
else
{
// No bonus damage for SPELL_DAMAGE_CLASS_NONE class spells by default
if (spellProto->DmgClass == SPELL_DAMAGE_CLASS_NONE)
return uint32(std::max(pdamage * DoneTotalMod, 0.0f));
}
// Default calculation
float coeff = spellEffectInfo.BonusCoefficient;
if (DoneAdvertisedBenefit)
{
float coeff = spellEffectInfo.BonusCoefficient;
if (Player* modOwner = GetSpellModOwner())
{
coeff *= 100.0f;
@@ -7038,7 +7032,6 @@ int32 Unit::SpellHealingBonusDone(Unit* victim, SpellInfo const* spellProto, int
DoneAdvertisedBenefit += static_cast<Guardian const*>(this)->GetBonusDamage();
// Check for table values
float coeff = spellEffectInfo.BonusCoefficient;
if (spellEffectInfo.BonusCoefficientFromAP > 0.0f)
{
WeaponAttackType const attType = (spellProto->IsRangedWeaponSpell() && spellProto->DmgClass != SPELL_DAMAGE_CLASS_MELEE) ? RANGED_ATTACK : BASE_ATTACK;
@@ -7047,16 +7040,11 @@ int32 Unit::SpellHealingBonusDone(Unit* victim, SpellInfo const* spellProto, int
DoneTotal += int32(spellEffectInfo.BonusCoefficientFromAP * stack * APbonus);
}
else if (coeff <= 0.0f) // no AP and no SP coefs, skip
{
// No bonus healing for SPELL_DAMAGE_CLASS_NONE class spells by default
if (spellProto->DmgClass == SPELL_DAMAGE_CLASS_NONE)
return uint32(std::max(healamount * DoneTotalMod, 0.0f));
}
// Default calculation
if (DoneAdvertisedBenefit)
{
float coeff = spellEffectInfo.BonusCoefficient;
if (Player* modOwner = GetSpellModOwner())
{
coeff *= 100.0f;
@@ -7116,6 +7104,9 @@ float Unit::SpellHealingPctDone(Unit* victim, SpellInfo const* spellProto) const
if (spellProto->SpellFamilyName == SPELLFAMILY_POTION)
return 1.0f;
float DoneTotalMod = 1.0f;
// Healing done percent
if (Player const* thisPlayer = ToPlayer())
{
float maxModDamagePercentSchool = 0.0f;
@@ -7123,10 +7114,10 @@ float Unit::SpellHealingPctDone(Unit* victim, SpellInfo const* spellProto) const
if (spellProto->GetSchoolMask() & (1 << i))
maxModDamagePercentSchool = std::max(maxModDamagePercentSchool, thisPlayer->m_activePlayerData->ModHealingDonePercent[i]);
return maxModDamagePercentSchool;
DoneTotalMod *= maxModDamagePercentSchool;
}
float DoneTotalMod = 1.0f;
else // SPELL_AURA_MOD_HEALING_DONE_PERCENT is included in m_activePlayerData->ModHealingDonePercent for players
DoneTotalMod *= GetTotalAuraMultiplier(SPELL_AURA_MOD_HEALING_DONE_PERCENT);
// bonus against aurastate
DoneTotalMod *= GetTotalAuraMultiplier(SPELL_AURA_MOD_DAMAGE_DONE_VERSUS_AURASTATE, [victim](AuraEffect const* aurEff) -> bool
@@ -7136,9 +7127,6 @@ float Unit::SpellHealingPctDone(Unit* victim, SpellInfo const* spellProto) const
return false;
});
// Healing done percent
DoneTotalMod *= GetTotalAuraMultiplier(SPELL_AURA_MOD_HEALING_DONE_PERCENT);
// bonus from missing health of target
float healthPctDiff = 100.0f - victim->GetHealthPct();
for (AuraEffect const* healingDonePctVsTargetHealth : GetAuraEffectsByType(SPELL_AURA_MOD_HEALING_DONE_PCT_VERSUS_TARGET_HEALTH))