aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Spells/Spell.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/game/Spells/Spell.cpp')
-rw-r--r--src/server/game/Spells/Spell.cpp39
1 files changed, 28 insertions, 11 deletions
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index 4a07cde7670..1cdcd9128e6 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -7584,6 +7584,9 @@ void Spell::HandleLaunchPhase()
TakeAmmo();
}
+ for (TargetInfo& target : m_UniqueTargetInfo)
+ PreprocessSpellLaunch(target);
+
for (SpellEffectInfo const& spellEffectInfo : m_spellInfo->GetEffects())
{
float multiplier = 1.0f;
@@ -7603,7 +7606,7 @@ void Spell::HandleLaunchPhase()
FinishTargetProcessing();
}
-void Spell::DoEffectOnLaunchTarget(TargetInfo& targetInfo, float multiplier, SpellEffectInfo const& spellEffectInfo)
+void Spell::PreprocessSpellLaunch(TargetInfo& targetInfo)
{
Unit* targetUnit = m_caster->GetGUID() == targetInfo.TargetGUID ? m_caster->ToUnit() : ObjectAccessor::GetUnit(*m_caster, targetInfo.TargetGUID);
if (!targetUnit)
@@ -7624,6 +7627,30 @@ void Spell::DoEffectOnLaunchTarget(TargetInfo& targetInfo, float multiplier, Spe
if (!unit)
return;
+ float critChance = m_spellValue->CriticalChance;
+ if (m_originalCaster)
+ {
+ if (!critChance)
+ critChance = m_originalCaster->SpellCritChanceDone(m_spellInfo, m_spellSchoolMask, m_attackType);
+ critChance = unit->SpellCritChanceTaken(m_originalCaster, m_spellInfo, m_spellSchoolMask, critChance, m_attackType);
+ }
+
+ targetInfo.IsCrit = roll_chance_f(critChance);
+}
+
+void Spell::DoEffectOnLaunchTarget(TargetInfo& targetInfo, float multiplier, SpellEffectInfo const& spellEffectInfo)
+{
+ Unit* unit = nullptr;
+ // In case spell hit target, do all effect on that target
+ if (targetInfo.MissCondition == SPELL_MISS_NONE)
+ unit = m_caster->GetGUID() == targetInfo.TargetGUID ? m_caster->ToUnit() : ObjectAccessor::GetUnit(*m_caster, targetInfo.TargetGUID);
+ // In case spell reflect from target, do all effect on caster (if hit)
+ else if (targetInfo.MissCondition == SPELL_MISS_REFLECT && targetInfo.ReflectResult == SPELL_MISS_NONE)
+ unit = m_caster->ToUnit();
+
+ if (!unit)
+ return;
+
m_damage = 0;
m_healing = 0;
@@ -7655,16 +7682,6 @@ void Spell::DoEffectOnLaunchTarget(TargetInfo& targetInfo, float multiplier, Spe
targetInfo.Damage += m_damage;
targetInfo.Healing += m_healing;
-
- float critChance = m_spellValue->CriticalChance;
- if (m_originalCaster)
- {
- if (!critChance)
- critChance = m_originalCaster->SpellCritChanceDone(m_spellInfo, m_spellSchoolMask, m_attackType);
- critChance = unit->SpellCritChanceTaken(m_originalCaster, m_spellInfo, m_spellSchoolMask, critChance, m_attackType);
- }
-
- targetInfo.IsCrit = roll_chance_f(critChance);
}
SpellCastResult Spell::CanOpenLock(SpellEffectInfo const& spellEffectInfo, uint32 lockId, SkillType& skillId, int32& reqSkillValue, int32& skillValue)