Core/Scripts: fix wrong uses of SetHitDamage hook.

This hook modifies damage AFTER it has been reduced by target auras/armor/resistances etc, it's useful if you want to scale damage by a factor, but not to add flat bonuses.
We're fixing those by moving calculation to Launch phase, where target taken bonuses haven't been used yet.

- Bronjahm: Magic's Bane
- BPC: Shadow Prison
- Oculus: Shock Lance
- Ymiron: Dark Slash (extra fix, it was wrongly damaging half of total health, it's supposed to be half of CURRENT health!)
- DK: Raise Ally Thrash spell (also extra fix: corrected formula)
- Warrior: Bloodthirst (shouldn't matter much as it's damage class none and those don't get bonuses by default)
- Warrior: Concussion Blow
- Warlock: extra fix for Haunt, healing part shouldn't scale with spell power

Closes #9560
This commit is contained in:
ariel-
2018-01-20 21:00:53 -03:00
parent cb75105434
commit 9f5d1e2b10
10 changed files with 72 additions and 35 deletions

View File

@@ -0,0 +1,8 @@
DELETE FROM `spell_bonus_data` WHERE `entry`=48210;
INSERT INTO `spell_bonus_data` (`entry`, `direct_bonus`, `dot_bonus`, `ap_bonus`, `ap_dot_bonus`, `comments`) VALUES
(48210, 0, 0, 0, 0, 'Warlock - Haunt heal');
DELETE FROM `spell_script_names` WHERE `ScriptName`='spell_gen_50pct_count_pct_from_max_hp' AND `spell_id`=48292;
DELETE FROM `spell_script_names` WHERE `ScriptName`='spell_dark_slash';
INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES
(48292, 'spell_dark_slash');

View File

@@ -4811,29 +4811,28 @@ uint32 Unit::GetDiseasesByCaster(ObjectGuid casterGUID, bool remove)
static const AuraType diseaseAuraTypes[] =
{
SPELL_AURA_PERIODIC_DAMAGE, // Frost Fever and Blood Plague
SPELL_AURA_LINKED, // Crypt Fever and Ebon Plague
SPELL_AURA_NONE
SPELL_AURA_LINKED // Crypt Fever and Ebon Plague
};
uint32 diseases = 0;
for (AuraType const* itr = diseaseAuraTypes; *itr != SPELL_AURA_NONE; ++itr)
for (AuraType aType : diseaseAuraTypes)
{
for (AuraEffectList::iterator i = m_modAuras[*itr].begin(); i != m_modAuras[*itr].end();)
for (auto itr = m_modAuras[aType].begin(); itr != m_modAuras[aType].end();)
{
// Get auras with disease dispel type by caster
if ((*i)->GetSpellInfo()->Dispel == DISPEL_DISEASE
&& (*i)->GetCasterGUID() == casterGUID)
if ((*itr)->GetSpellInfo()->Dispel == DISPEL_DISEASE
&& (*itr)->GetCasterGUID() == casterGUID)
{
++diseases;
if (remove)
{
RemoveAura((*i)->GetId(), (*i)->GetCasterGUID());
i = m_modAuras[*itr].begin();
RemoveAura((*itr)->GetId(), (*itr)->GetCasterGUID());
itr = m_modAuras[aType].begin();
continue;
}
}
++i;
++itr;
}
}
return diseases;

View File

@@ -899,7 +899,7 @@ class spell_impale : public SpellScriptLoader
// make sure Impale doesnt do damage if we are standing on permafrost
if (target && target->HasAura(permafrost))
SetHitDamage(0);
PreventHitDamage();
}
void Register() override

View File

@@ -269,20 +269,19 @@ class spell_bronjahm_magic_bane : public SpellScriptLoader
{
PrepareSpellScript(spell_bronjahm_magic_bane_SpellScript);
void RecalculateDamage()
void RecalculateDamage(SpellEffIndex /*effIndex*/)
{
if (GetHitUnit()->getPowerType() != POWER_MANA)
return;
int32 const maxDamage = GetCaster()->GetMap()->IsHeroic() ? 15000 : 10000;
int32 newDamage = GetHitDamage() + (GetHitUnit()->GetMaxPower(POWER_MANA) / 2);
SetHitDamage(std::min<int32>(maxDamage, newDamage));
int32 newDamage = GetEffectValue() + (GetHitUnit()->GetMaxPower(POWER_MANA) / 2);
SetEffectValue(std::min<int32>(maxDamage, newDamage));
}
void Register() override
{
OnHit += SpellHitFn(spell_bronjahm_magic_bane_SpellScript::RecalculateDamage);
OnEffectLaunchTarget += SpellEffectFn(spell_bronjahm_magic_bane_SpellScript::RecalculateDamage, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE);
}
};

View File

@@ -1496,16 +1496,16 @@ class spell_blood_council_shadow_prison_damage : public SpellScriptLoader
{
PrepareSpellScript(spell_blood_council_shadow_prison_SpellScript);
void AddExtraDamage()
void AddExtraDamage(SpellEffIndex /*effIndex*/)
{
if (Aura* aur = GetHitUnit()->GetAura(GetSpellInfo()->Id))
if (AuraEffect const* eff = aur->GetEffect(EFFECT_1))
SetHitDamage(GetHitDamage() + eff->GetAmount());
SetEffectValue(GetEffectValue() + eff->GetAmount());
}
void Register() override
{
OnHit += SpellHitFn(spell_blood_council_shadow_prison_SpellScript::AddExtraDamage);
OnEffectLaunchTarget += SpellEffectFn(spell_blood_council_shadow_prison_SpellScript::AddExtraDamage, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE);
}
};

View File

@@ -519,22 +519,24 @@ class spell_oculus_shock_lance : public SpellScriptLoader
return ValidateSpellInfo({ SPELL_AMBER_SHOCK_CHARGE });
}
void CalcDamage()
void CalcDamage(SpellEffIndex /*effIndex*/)
{
int32 damage = GetHitDamage();
int32 damage = GetEffectValue();
if (Unit* target = GetHitUnit())
{
if (AuraEffect const* shockCharges = target->GetAuraEffect(SPELL_AMBER_SHOCK_CHARGE, EFFECT_0, GetCaster()->GetGUID()))
{
damage += shockCharges->GetAmount();
shockCharges->GetBase()->Remove();
shockCharges->GetBase()->Remove(AURA_REMOVE_BY_ENEMY_SPELL);
}
}
SetHitDamage(damage);
SetEffectValue(damage);
}
void Register() override
{
OnHit += SpellHitFn(spell_oculus_shock_lance_SpellScript::CalcDamage);
OnEffectLaunchTarget += SpellEffectFn(spell_oculus_shock_lance_SpellScript::CalcDamage, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE);
}
};

View File

@@ -311,6 +311,23 @@ public:
}
};
// 48292 - Dark Slash
class spell_dark_slash : public SpellScript
{
PrepareSpellScript(spell_dark_slash);
void CalculateDamage()
{
// Slashes the target with darkness, dealing damage equal to half the target's current health.
SetHitDamage(int32(ceil(GetHitUnit()->GetHealth() / 2.f)));
}
void Register() override
{
OnHit += SpellHitFn(spell_dark_slash::CalculateDamage);
}
};
class achievement_kings_bane : public AchievementCriteriaScript
{
public:
@@ -332,5 +349,6 @@ class achievement_kings_bane : public AchievementCriteriaScript
void AddSC_boss_ymiron()
{
new boss_ymiron();
RegisterSpellScript(spell_dark_slash);
new achievement_kings_bane();
}

View File

@@ -210,7 +210,7 @@ class spell_capacitus_polarity_charge : public SpellScriptLoader
Unit* target = GetHitUnit();
if (target->HasAura(GetTriggeringSpell()->Id))
SetHitDamage(0);
PreventHitDamage();
}
void Register() override

View File

@@ -2975,14 +2975,25 @@ public:
return ValidateSpellInfo({ SPELL_GHOUL_FRENZY });
}
void CalcDamage()
void CalcDamage(SpellEffIndex /*effIndex*/)
{
if (Aura* aur = GetCaster()->GetAura(SPELL_GHOUL_FRENZY))
/*
Causes more damage per frenzy point:
1 point : ${$AP*$m1*0.01+$AP*0.05}-${$AP*$m1*0.01+$AP*0.10} damage
2 points : ${$AP*$m1*0.01+$AP*0.10}-${$AP*$m1*0.01+$AP*0.20} damage
3 points : ${$AP*$m1*0.01+$AP*0.15}-${$AP*$m1*0.01+$AP*0.30} damage
4 points : ${$AP*$m1*0.01+$AP*0.20}-${$AP*$m1*0.01+$AP*0.40} damage
5 points : ${$AP*$m1*0.01+$AP*0.25}-${$AP*$m1*0.01+$AP*0.50} damage
*/
if (Aura* frenzy = GetCaster()->GetAura(SPELL_GHOUL_FRENZY))
{
int32 damage = GetHitDamage();
damage += int32(GetCaster()->GetTotalAttackPowerValue(BASE_ATTACK) * 0.05f * aur->GetStackAmount());
aur->Remove();
SetHitDamage(damage);
float APBonus = GetCaster()->GetTotalAttackPowerValue(BASE_ATTACK);
float fixedDamageBonus = APBonus * GetEffectValue() * 0.01f;
APBonus *= 0.05f * frenzy->GetStackAmount();
frenzy->Remove(AURA_REMOVE_BY_ENEMY_SPELL);
SetEffectValue(fixedDamageBonus + irand(int32(APBonus), int32(APBonus * 2.f)));
}
/*
@@ -2995,7 +3006,7 @@ public:
void Register() override
{
OnHit += SpellHitFn(spell_dk_ghoul_thrash_SpellScript::CalcDamage);
OnEffectLaunchTarget += SpellEffectFn(spell_dk_ghoul_thrash_SpellScript::CalcDamage, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE);
}
};

View File

@@ -143,12 +143,12 @@ class spell_warr_bloodthirst_heal : public SpellScriptLoader
{
SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(SPELL_WARRIOR_BLOODTHIRST_DAMAGE);
int32 const healPct = spellInfo->Effects[EFFECT_1].CalcValue(GetCaster());
SetHitHeal(GetCaster()->CountPctFromMaxHealth(healPct));
SetEffectValue(GetCaster()->CountPctFromMaxHealth(healPct));
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_warr_bloodthirst_heal_SpellScript::HandleHeal, EFFECT_0, SPELL_EFFECT_HEAL);
OnEffectLaunchTarget += SpellEffectFn(spell_warr_bloodthirst_heal_SpellScript::HandleHeal, EFFECT_0, SPELL_EFFECT_HEAL);
}
};
@@ -209,12 +209,12 @@ class spell_warr_concussion_blow : public SpellScriptLoader
void HandleDummy(SpellEffIndex /*effIndex*/)
{
SetHitDamage(CalculatePct(GetCaster()->GetTotalAttackPowerValue(BASE_ATTACK), GetEffectValue()));
SetEffectValue(CalculatePct(GetCaster()->GetTotalAttackPowerValue(BASE_ATTACK), GetSpellInfo()->Effects[EFFECT_2].CalcValue()));
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_warr_concussion_blow_SpellScript::HandleDummy, EFFECT_2, SPELL_EFFECT_DUMMY);
OnEffectLaunchTarget += SpellEffectFn(spell_warr_concussion_blow_SpellScript::HandleDummy, EFFECT_1, SPELL_EFFECT_SCHOOL_DAMAGE);
}
};