Core/Spells: unclusterfuck weapon damage spell effect handler

* weapon effect values can now be manipulated via spell scripts
* moved Kill Shot attack power bonus to spell_bonus_data
* converted Warrior's Devastate effect handler hack to spell script
This commit is contained in:
Ovahlord committed 2019-11-08 03:38:11 +01:00
1 parent 4215720f8d
commit c949e12f80
5 files changed
+97 -91

No files matched your search

+56 -86
View File
@@ -2758,42 +2758,44 @@ void Spell::EffectWeaponDmg(SpellEffIndex effIndex)
if (!unitTarget || !unitTarget->IsAlive())
return;
// multiple weapon dmg effect workaround
// execute only the last weapon damage
// and handle all effects at once
for (uint8 j = effIndex + 1; j < MAX_SPELL_EFFECTS; ++j)
uint32 effectType = m_spellInfo->Effects[effIndex].Effect;
bool useWeaponDamage = true;
/*
Multiple weapon damage effect case. SPELL_EFFECT_WEAPON_PERCENT_DAMAGE is being prioritized for calculating weapon damage values.
The other effects only add their fixed bonus to the damage sum.
*/
if (m_spellInfo->HasEffect(SPELL_EFFECT_WEAPON_PERCENT_DAMAGE) && effectType != SPELL_EFFECT_WEAPON_PERCENT_DAMAGE)
useWeaponDamage = false;
// some spell specific modifiers
float totalDamagePercentMod = 1.0f; // applied to final bonus+weapon damage
int32 fixed_bonus = 0;
bool normalized = false;
float weaponDamagePercentMod = 1.0f;
for (uint8 j = 0; j < MAX_SPELL_EFFECTS; ++j)
{
switch (m_spellInfo->Effects[j].Effect)
{
case SPELL_EFFECT_WEAPON_DAMAGE:
case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL:
fixed_bonus += damage;
break;
case SPELL_EFFECT_NORMALIZED_WEAPON_DMG:
fixed_bonus += damage;
normalized = true;
break;
case SPELL_EFFECT_WEAPON_PERCENT_DAMAGE:
return; // we must calculate only at last weapon effect
break;
ApplyPct(weaponDamagePercentMod, damage);
break;
default:
break; // not weapon damage effect, just skip
}
}
// some spell specific modifiers
float totalDamagePercentMod = 1.0f; // applied to final bonus+weapon damage
int32 fixed_bonus = 0;
int32 spell_bonus = 0; // bonus specific for spell
switch (m_spellInfo->SpellFamilyName)
{
case SPELLFAMILY_WARRIOR:
{
// Devastate
if (m_spellInfo->SpellFamilyFlags[1] & 0x40 && effIndex == EFFECT_1)
{
if (Aura* aur = unitTarget->GetAura(58567, m_caster->GetGUID()))
fixed_bonus += aur->GetStackAmount() * CalculateDamage(EFFECT_1, unitTarget);
// Devastate applies Sunder Armor on the target
m_caster->CastSpell(unitTarget, 58567, true);
}
break;
}
case SPELLFAMILY_ROGUE:
{
// Hemorrhage
@@ -2833,13 +2835,6 @@ void Spell::EffectWeaponDmg(SpellEffIndex effIndex)
}
break;
}
case SPELLFAMILY_HUNTER:
{
// Kill Shot - bonus damage from Ranged Attack Power
if (m_spellInfo->SpellFamilyFlags[1] & 0x800000)
spell_bonus += int32(0.45f * m_caster->GetTotalAttackPowerValue(RANGED_ATTACK));
break;
}
case SPELLFAMILY_DEATHKNIGHT:
{
// Death Strike
@@ -2851,6 +2846,7 @@ void Spell::EffectWeaponDmg(SpellEffIndex effIndex)
if (uint32 runic = std::min<uint32>(uint32(m_caster->GetPower(POWER_RUNIC_POWER) / 2.5f), aurEff->GetSpellInfo()->Effects[EFFECT_1].CalcValue(m_caster)))
AddPct(totalDamagePercentMod, runic);
}
// Obliterate / Blood Strike / Blood-Caked Strike (12.5% more damage per disease) / Heart Strike (15% more damage per disease)
if (m_spellInfo->SpellFamilyFlags[1] & 0x20000 || m_spellInfo->SpellFamilyFlags[0] & 0x400000
|| m_spellInfo->SpellFamilyFlags[0] & 0x1000000 || m_spellInfo->Id == 50463)
@@ -2858,7 +2854,7 @@ void Spell::EffectWeaponDmg(SpellEffIndex effIndex)
float bonusPct = m_spellInfo->Effects[EFFECT_2].CalcValue(m_caster);
uint8 diseaseCount = unitTarget->GetDiseasesByCaster(m_caster->GetGUID(), false);
if (m_spellInfo->SpellFamilyFlags[1] & 0x20000) // Obliterate - Half amount of Basepoints as bonus
if (m_spellInfo->SpellFamilyFlags[1] & 0x20000) // Obliterate - 50% of Basepoints as bonus
bonusPct *= 0.5f;
else if (m_spellInfo->SpellFamilyFlags[0] & 0x400000) // Blood Strike - 10% of Basepoints as bonus
bonusPct *= 0.1f;
@@ -2867,6 +2863,7 @@ void Spell::EffectWeaponDmg(SpellEffIndex effIndex)
// Death Knight T8 Melee 4P Bonus
if (AuraEffect const* aurEff = m_caster->GetAuraEffect(64736, EFFECT_0))
AddPct(bonusAmount, aurEff->GetAmount());
AddPct(totalDamagePercentMod, bonusAmount);
}
@@ -2883,44 +2880,26 @@ void Spell::EffectWeaponDmg(SpellEffIndex effIndex)
}
case SPELLFAMILY_WARLOCK:
{
// Felstorm and Legion Strike
if (m_spellInfo->Id == 89753)
if (useWeaponDamage)
{
if (m_caster->IsPet())
if (Unit* owner = m_caster->GetOwner())
m_damage += ((owner->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_SHADOW) * 0.5f) * 2) * 0.231f;
}
else if (m_spellInfo->Id == 30213)
{
if (m_caster->IsPet())
if (Unit* owner = m_caster->GetOwner())
m_damage += ((owner->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_SHADOW) * 0.5f) * 2) * 0.264f;
// Felstorm and Legion Strike
if (m_spellInfo->Id == 89753)
{
if (m_caster->IsPet())
if (Unit* owner = m_caster->GetOwner())
m_damage += ((owner->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_SHADOW) * 0.5f) * 2) * 0.231f;
}
else if (m_spellInfo->Id == 30213)
{
if (m_caster->IsPet())
if (Unit* owner = m_caster->GetOwner())
m_damage += ((owner->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_SHADOW) * 0.5f) * 2) * 0.264f;
}
}
break;
}
}
bool normalized = false;
float weaponDamagePercentMod = 1.0f;
for (uint8 j = 0; j < MAX_SPELL_EFFECTS; ++j)
{
switch (m_spellInfo->Effects[j].Effect)
{
case SPELL_EFFECT_WEAPON_DAMAGE:
case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL:
fixed_bonus += CalculateDamage(j, unitTarget);
break;
case SPELL_EFFECT_NORMALIZED_WEAPON_DMG:
fixed_bonus += CalculateDamage(j, unitTarget);
normalized = true;
break;
case SPELL_EFFECT_WEAPON_PERCENT_DAMAGE:
ApplyPct(weaponDamagePercentMod, CalculateDamage(j, unitTarget));
break;
default:
break; // not weapon damage effect, just skip
}
}
// if (addPctMods) { percent mods are added in Unit::CalculateDamage } else { percent mods are added in Unit::MeleeDamageBonusDone }
// this distinction is neccessary to properly inform the client about his autoattack damage values from Script_UnitDamage
@@ -2939,33 +2918,24 @@ void Spell::EffectWeaponDmg(SpellEffIndex effIndex)
float weapon_total_pct = m_caster->GetModifierValue(unitMod, TOTAL_PCT);
if (fixed_bonus)
fixed_bonus = int32(fixed_bonus * weapon_total_pct);
if (spell_bonus)
spell_bonus = int32(spell_bonus * weapon_total_pct);
}
int32 weaponDamage = m_caster->CalculateDamage(m_attackType, normalized, addPctMods);
int32 weaponDamage = useWeaponDamage ? m_caster->CalculateDamage(m_attackType, normalized, addPctMods) : 0;
// Sequence is important
for (uint8 j = 0; j < MAX_SPELL_EFFECTS; ++j)
switch (effectType)
{
// We assume that a spell have at most one fixed_bonus
// and at most one weaponDamagePercentMod
switch (m_spellInfo->Effects[j].Effect)
{
case SPELL_EFFECT_WEAPON_DAMAGE:
case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL:
case SPELL_EFFECT_NORMALIZED_WEAPON_DMG:
weaponDamage += fixed_bonus;
break;
case SPELL_EFFECT_WEAPON_PERCENT_DAMAGE:
weaponDamage = int32(weaponDamage * weaponDamagePercentMod);
break;
default:
break; // not weapon damage effect, just skip
}
case SPELL_EFFECT_WEAPON_DAMAGE:
case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL:
case SPELL_EFFECT_NORMALIZED_WEAPON_DMG:
weaponDamage += fixed_bonus;
break;
case SPELL_EFFECT_WEAPON_PERCENT_DAMAGE:
weaponDamage = int32(weaponDamage * weaponDamagePercentMod);
break;
default:
break;
}
weaponDamage += spell_bonus;
weaponDamage = int32(weaponDamage * totalDamagePercentMod);
// apply spellmod to Done damage
@@ -2976,7 +2946,7 @@ void Spell::EffectWeaponDmg(SpellEffIndex effIndex)
weaponDamage = std::max(weaponDamage, 0);
// Add melee damage bonuses (also check for negative)
weaponDamage = m_caster->MeleeDamageBonusDone(unitTarget, weaponDamage, m_attackType, m_spellInfo);
weaponDamage = m_caster->MeleeDamageBonusDone(unitTarget, weaponDamage, m_attackType, m_spellInfo, !useWeaponDamage);
m_damage += unitTarget->MeleeDamageBonusTaken(m_caster, weaponDamage, m_attackType, m_spellInfo);
}