aboutsummaryrefslogtreecommitdiff
path: root/src/server/scripts/Spells
diff options
context:
space:
mode:
authorariel- <ariel-@users.noreply.github.com>2018-01-13 06:45:21 -0300
committerariel- <ariel-@users.noreply.github.com>2018-01-13 06:45:21 -0300
commitcb9e72e521d3cc415dd15bf6912c87f89e41b92a (patch)
treebe9e692f0ddf9f080f923c7396de19e4ca869c6f /src/server/scripts/Spells
parent1c60af632888433b29a27bee76e82e96632d4096 (diff)
Core/Auras: removed caster dependency from core
- Decoupled Unit logic: split of spell critical chance into done (caster bonuses) and taken (target bonuses), this allows to precalculate caster bonuses on aura apply and then check victim's auras on damage/healing calc - Made static a bunch of methods (they no longer have this pointer because they are now called from periodic handlers which may or may not have an active caster in world) - Simplified all AuraEffect bonuses into AuraEffect::_amount, no more duplicated code - Critical chance and whether or not caster is player owned unit (for resilience calcs) is now saved one level upper, on Aura itself (it's impossible as of 3.3.5 to have different effects with different critical chances) - Minor cleanup of SPELL_DAMAGE_CLASS_NONE and Arcane Potency (#18813) crit handling Closes #19876
Diffstat (limited to 'src/server/scripts/Spells')
-rw-r--r--src/server/scripts/Spells/spell_dk.cpp30
-rw-r--r--src/server/scripts/Spells/spell_druid.cpp2
-rw-r--r--src/server/scripts/Spells/spell_hunter.cpp5
-rw-r--r--src/server/scripts/Spells/spell_priest.cpp7
-rw-r--r--src/server/scripts/Spells/spell_shaman.cpp4
-rw-r--r--src/server/scripts/Spells/spell_warlock.cpp2
-rw-r--r--src/server/scripts/Spells/spell_warrior.cpp2
7 files changed, 21 insertions, 31 deletions
diff --git a/src/server/scripts/Spells/spell_dk.cpp b/src/server/scripts/Spells/spell_dk.cpp
index de0d34c59c0..bda0a4257ce 100644
--- a/src/server/scripts/Spells/spell_dk.cpp
+++ b/src/server/scripts/Spells/spell_dk.cpp
@@ -781,7 +781,7 @@ class spell_dk_dancing_rune_weapon : public SpellScriptLoader
int32 amount = static_cast<int32>(damageInfo->GetDamage()) / 2;
drw->SendSpellNonMeleeDamageLog(drw->GetVictim(), spellInfo->Id, amount, spellInfo->GetSchoolMask(), 0, 0, false, 0, false);
- drw->DealDamage(drw->GetVictim(), amount, nullptr, SPELL_DIRECT_DAMAGE, spellInfo->GetSchoolMask(), spellInfo, true);
+ Unit::DealDamage(drw, drw->GetVictim(), amount, nullptr, SPELL_DIRECT_DAMAGE, spellInfo->GetSchoolMask(), spellInfo, true);
}
void Register() override
@@ -1278,7 +1278,7 @@ class spell_dk_hysteria : public AuraScript
void PeriodicTick(AuraEffect const* aurEff)
{
uint32 const damage = GetTarget()->CountPctFromMaxHealth(GetTarget()->CalculateSpellDamage(nullptr, GetSpellInfo(), aurEff->GetEffIndex()));
- GetTarget()->DealDamage(GetTarget(), damage, nullptr, NODAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false);
+ Unit::DealDamage(GetTarget(), GetTarget(), damage, nullptr, SELF_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false);
}
void Register() override
@@ -1733,40 +1733,36 @@ class spell_dk_pestilence : public SpellScriptLoader
{
if (Aura* aurOld = victim->GetAura(SPELL_DK_BLOOD_PLAGUE, caster->GetGUID())) // Check Blood Plague application on victim.
{
+ float donePct = aurOld->GetDonePct();
+ float critChance = aurOld->GetCritChance();
+
if (AuraEffect* aurEffOld = aurOld->GetEffect(EFFECT_0))
{
- float donePct = aurEffOld->GetDonePct();
- float critChance = aurEffOld->GetCritChance();
-
caster->CastSpell(hitUnit, SPELL_DK_BLOOD_PLAGUE, true); // Spread the disease to hitUnit.
if (Aura* aurNew = hitUnit->GetAura(SPELL_DK_BLOOD_PLAGUE, caster->GetGUID())) // Check Blood Plague application on hitUnit.
{
+ aurNew->SetCritChance(critChance); // Blood Plague can crit if caster has T9.
+ aurNew->SetDonePct(donePct);
if (AuraEffect* aurEffNew = aurNew->GetEffect(EFFECT_0))
- {
- aurEffNew->SetCritChance(critChance); // Blood Plague can crit if caster has T9.
- aurEffNew->SetDonePct(donePct);
- aurEffNew->SetBonusAmount(caster->SpellDamageBonusDone(hitUnit, aurEffNew->GetSpellInfo(), 0, DOT));
- }
+ aurEffNew->ChangeAmount(aurEffNew->CalculateAmount(aurEffNew->GetCaster()), false);
}
}
}
if (Aura* aurOld = victim->GetAura(SPELL_DK_FROST_FEVER, caster->GetGUID())) // Check Frost Fever application on victim.
{
+ float donePct = aurOld->GetDonePct();
+
if (AuraEffect* aurEffOld = aurOld->GetEffect(EFFECT_0))
{
- float donePct = aurEffOld->GetDonePct();
-
caster->CastSpell(hitUnit, SPELL_DK_FROST_FEVER, true); // Spread the disease to hitUnit.
if (Aura* aurNew = hitUnit->GetAura(SPELL_DK_FROST_FEVER, caster->GetGUID())) // Check Frost Fever application on hitUnit.
{
+ aurNew->SetDonePct(donePct);
if (AuraEffect* aurEffNew = aurNew->GetEffect(EFFECT_0))
- {
- aurEffNew->SetDonePct(donePct);
- aurEffNew->SetBonusAmount(caster->SpellDamageBonusDone(hitUnit, aurEffNew->GetSpellInfo(), 0, DOT));
- }
+ aurEffNew->ChangeAmount(aurEffNew->CalculateAmount(aurEffNew->GetCaster()), false);
}
}
}
@@ -2569,7 +2565,7 @@ class spell_dk_wandering_plague : public SpellScriptLoader
PreventDefaultAction();
Unit* caster = eventInfo.GetActor();
Unit* target = eventInfo.GetProcTarget();
- if (!roll_chance_f(caster->GetUnitCriticalChance(BASE_ATTACK, target)))
+ if (!roll_chance_f(caster->GetUnitCriticalChanceAgainst(BASE_ATTACK, target)))
return;
DamageInfo* damageInfo = eventInfo.GetDamageInfo();
diff --git a/src/server/scripts/Spells/spell_druid.cpp b/src/server/scripts/Spells/spell_druid.cpp
index fdedfa6124a..9f349f223f8 100644
--- a/src/server/scripts/Spells/spell_druid.cpp
+++ b/src/server/scripts/Spells/spell_druid.cpp
@@ -1012,7 +1012,7 @@ class spell_dru_lifebloom : public SpellScriptLoader
int32 healAmount = aurEff->GetAmount();
if (Unit* caster = GetCaster())
{
- healAmount = caster->SpellHealingBonusDone(target, GetSpellInfo(), healAmount, HEAL, stack);
+ healAmount = caster->SpellHealingBonusDone(target, GetSpellInfo(), healAmount, HEAL, { }, stack);
healAmount = target->SpellHealingBonusTaken(caster, GetSpellInfo(), healAmount, HEAL, stack);
// restore mana
diff --git a/src/server/scripts/Spells/spell_hunter.cpp b/src/server/scripts/Spells/spell_hunter.cpp
index 89b14f71ccb..bb741a94819 100644
--- a/src/server/scripts/Spells/spell_hunter.cpp
+++ b/src/server/scripts/Spells/spell_hunter.cpp
@@ -254,10 +254,7 @@ class spell_hun_chimera_shot : public SpellScriptLoader
spellId = SPELL_HUNTER_CHIMERA_SHOT_SERPENT;
// first, calculate damage of basic tick (C&P from AuraEffect::HandlePeriodicDamageAurasTick)
- basePoint = (aurEff->GetAmount() + aurEff->GetBonusAmount()) * aurEff->GetDonePct();
- if (Player* modOwner = caster->GetSpellModOwner())
- modOwner->ApplySpellMod(aurEff->GetId(), SPELLMOD_DOT, basePoint);
-
+ basePoint = aurEff->GetAmount();
basePoint = unitTarget->SpellDamageBonusTaken(caster, aurEff->GetSpellInfo(), basePoint, DOT, aura->GetStackAmount());
// then, multiply to get damage potential
diff --git a/src/server/scripts/Spells/spell_priest.cpp b/src/server/scripts/Spells/spell_priest.cpp
index bc7219a1e03..e3664c16f3f 100644
--- a/src/server/scripts/Spells/spell_priest.cpp
+++ b/src/server/scripts/Spells/spell_priest.cpp
@@ -880,7 +880,7 @@ class spell_pri_pain_and_suffering_proc : public SpellScriptLoader
{
if (AuraEffect* aur = target->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_PRIEST, 0x8000, 0, 0, caster->GetGUID()))
{
- aur->SetBonusAmount(caster->SpellDamageBonusDone(target, aur->GetSpellInfo(), 0, DOT));
+ aur->ChangeAmount(aur->CalculateAmount(aur->GetCaster()), false);
aur->CalculatePeriodic(caster, false, false);
aur->GetBase()->RefreshDuration();
}
@@ -1112,10 +1112,7 @@ class spell_pri_renew : public SpellScriptLoader
// Empowered Renew
if (AuraEffect const* empoweredRenewAurEff = caster->GetDummyAuraEffect(SPELLFAMILY_PRIEST, PRIEST_ICON_ID_EMPOWERED_RENEW_TALENT, EFFECT_1))
{
- int32 heal = (aurEff->GetAmount() + aurEff->GetBonusAmount()) * aurEff->GetDonePct();
- if (Player* modOwner = caster->GetSpellModOwner())
- modOwner->ApplySpellMod(GetId(), SPELLMOD_DOT, heal);
-
+ int32 heal = aurEff->GetAmount();
heal = GetTarget()->SpellHealingBonusTaken(caster, GetSpellInfo(), heal, DOT);
heal *= GetSpellInfo()->GetMaxTicks();
diff --git a/src/server/scripts/Spells/spell_shaman.cpp b/src/server/scripts/Spells/spell_shaman.cpp
index c8cb24336ae..be2e27ab540 100644
--- a/src/server/scripts/Spells/spell_shaman.cpp
+++ b/src/server/scripts/Spells/spell_shaman.cpp
@@ -435,7 +435,7 @@ class spell_sha_earth_shield : public SpellScriptLoader
void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/)
{
if (Unit* caster = GetCaster())
- amount = caster->SpellHealingBonusDone(GetUnitOwner(), GetSpellInfo(), amount, HEAL);
+ amount = caster->SpellHealingBonusDone(GetUnitOwner(), GetSpellInfo(), amount, HEAL, { });
// SpellHealingBonusTaken will be called on Heal
}
@@ -996,7 +996,7 @@ class spell_sha_healing_stream_totem : public SpellScriptLoader
if (Unit* owner = caster->GetOwner())
{
if (triggeringSpell)
- damage = int32(owner->SpellHealingBonusDone(target, triggeringSpell, damage, HEAL));
+ damage = int32(owner->SpellHealingBonusDone(target, triggeringSpell, damage, HEAL, { }));
// Restorative Totems
if (AuraEffect* dummy = owner->GetAuraEffect(SPELL_AURA_DUMMY, SPELLFAMILY_SHAMAN, SHAMAN_ICON_ID_RESTORATIVE_TOTEMS, 1))
diff --git a/src/server/scripts/Spells/spell_warlock.cpp b/src/server/scripts/Spells/spell_warlock.cpp
index 38772874e0e..bd82af3bd8b 100644
--- a/src/server/scripts/Spells/spell_warlock.cpp
+++ b/src/server/scripts/Spells/spell_warlock.cpp
@@ -524,7 +524,7 @@ class spell_warl_everlasting_affliction : public SpellScriptLoader
// Refresh corruption on target
if (AuraEffect* aur = target->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_WARLOCK, 0x2, 0, 0, caster->GetGUID()))
{
- aur->SetBonusAmount(caster->SpellDamageBonusDone(target, aur->GetSpellInfo(), 0, DOT));
+ aur->ChangeAmount(aur->CalculateAmount(aur->GetCaster()), false);
aur->CalculatePeriodic(caster, false, false);
aur->GetBase()->RefreshDuration(true);
}
diff --git a/src/server/scripts/Spells/spell_warrior.cpp b/src/server/scripts/Spells/spell_warrior.cpp
index 929bdb8fac3..0a735e39fea 100644
--- a/src/server/scripts/Spells/spell_warrior.cpp
+++ b/src/server/scripts/Spells/spell_warrior.cpp
@@ -102,7 +102,7 @@ class spell_warr_bloodthirst : public SpellScriptLoader
if (Unit* target = GetHitUnit())
{
- damage = GetCaster()->SpellDamageBonusDone(target, GetSpellInfo(), uint32(damage), SPELL_DIRECT_DAMAGE);
+ damage = GetCaster()->SpellDamageBonusDone(target, GetSpellInfo(), uint32(damage), SPELL_DIRECT_DAMAGE, { });
damage = target->SpellDamageBonusTaken(GetCaster(), GetSpellInfo(), uint32(damage), SPELL_DIRECT_DAMAGE);
}
SetHitDamage(damage);