mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-22 10:05:32 +01:00
Core/Spells: merged damage calculation spell mod order fix for weapon damage
This commit is contained in:
@@ -7933,11 +7933,6 @@ uint32 Unit::MeleeDamageBonusDone(Unit* victim, uint32 pdamage, WeaponAttackType
|
||||
|
||||
float tmpDamage = float(int32(pdamage) + DoneFlatBenefit) * DoneTotalMod;
|
||||
|
||||
// apply spellmod to Done damage
|
||||
if (spellProto)
|
||||
if (Player* modOwner = GetSpellModOwner())
|
||||
modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_DAMAGE, tmpDamage);
|
||||
|
||||
// bonus result can be negative
|
||||
return uint32(std::max(tmpDamage, 0.0f));
|
||||
}
|
||||
|
||||
@@ -2856,7 +2856,7 @@ void Spell::EffectWeaponDmg(SpellEffIndex effIndex)
|
||||
// multiple weapon dmg effect workaround
|
||||
// execute only the last weapon damage
|
||||
// and handle all effects at once
|
||||
for (uint32 j = effIndex + 1; j < MAX_SPELL_EFFECTS; ++j)
|
||||
for (uint8 j = effIndex + 1; j < MAX_SPELL_EFFECTS; ++j)
|
||||
{
|
||||
switch (m_spellInfo->Effects[j].Effect)
|
||||
{
|
||||
@@ -2985,7 +2985,7 @@ void Spell::EffectWeaponDmg(SpellEffIndex effIndex)
|
||||
|
||||
bool normalized = false;
|
||||
float weaponDamagePercentMod = 1.0f;
|
||||
for (int j = 0; j < MAX_SPELL_EFFECTS; ++j)
|
||||
for (uint8 j = 0; j < MAX_SPELL_EFFECTS; ++j)
|
||||
{
|
||||
switch (m_spellInfo->Effects[j].Effect)
|
||||
{
|
||||
@@ -3029,7 +3029,7 @@ void Spell::EffectWeaponDmg(SpellEffIndex effIndex)
|
||||
int32 weaponDamage = m_caster->CalculateDamage(m_attackType, normalized, addPctMods);
|
||||
|
||||
// Sequence is important
|
||||
for (int j = 0; j < MAX_SPELL_EFFECTS; ++j)
|
||||
for (uint8 j = 0; j < MAX_SPELL_EFFECTS; ++j)
|
||||
{
|
||||
// We assume that a spell have at most one fixed_bonus
|
||||
// and at most one weaponDamagePercentMod
|
||||
@@ -3042,6 +3042,7 @@ void Spell::EffectWeaponDmg(SpellEffIndex effIndex)
|
||||
break;
|
||||
case SPELL_EFFECT_WEAPON_PERCENT_DAMAGE:
|
||||
weaponDamage = int32(weaponDamage * weaponDamagePercentMod);
|
||||
break;
|
||||
default:
|
||||
break; // not weapon damage effect, just skip
|
||||
}
|
||||
@@ -3050,13 +3051,16 @@ void Spell::EffectWeaponDmg(SpellEffIndex effIndex)
|
||||
weaponDamage += spell_bonus;
|
||||
weaponDamage = int32(weaponDamage * totalDamagePercentMod);
|
||||
|
||||
// apply spellmod to Done damage
|
||||
if (Player* modOwner = m_caster->GetSpellModOwner())
|
||||
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_DAMAGE, weaponDamage);
|
||||
|
||||
// prevent negative damage
|
||||
uint32 eff_damage(std::max(weaponDamage, 0));
|
||||
weaponDamage = std::max(weaponDamage, 0);
|
||||
|
||||
// Add melee damage bonuses (also check for negative)
|
||||
uint32 damageBonusDone = m_caster->MeleeDamageBonusDone(unitTarget, eff_damage, m_attackType, m_spellInfo);
|
||||
|
||||
m_damage += unitTarget->MeleeDamageBonusTaken(m_caster, damageBonusDone, m_attackType, m_spellInfo);
|
||||
weaponDamage = m_caster->MeleeDamageBonusDone(unitTarget, weaponDamage, m_attackType, m_spellInfo);
|
||||
m_damage += unitTarget->MeleeDamageBonusTaken(m_caster, weaponDamage, m_attackType, m_spellInfo);
|
||||
}
|
||||
|
||||
void Spell::EffectThreat(SpellEffIndex /*effIndex*/)
|
||||
|
||||
Reference in New Issue
Block a user