diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index 87dab0cc43..d5abf7f75a 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -2367,6 +2367,31 @@ void Spell::prepareDataForTriggerSystem()
}
}
+std::pair Spell::FinalizeDataForTriggerSystem(bool positive) const
+{
+ if (m_spellInfo->HasAttribute(SPELL_ATTR3_TREAT_AS_PERIODIC))
+ {
+ if (positive)
+ return { PROC_FLAG_DEAL_HELPFUL_PERIODIC, PROC_FLAG_TAKE_HELPFUL_PERIODIC };
+ else
+ return { PROC_FLAG_DEAL_HARMFUL_PERIODIC, PROC_FLAG_TAKE_HARMFUL_PERIODIC };
+ }
+ if (m_spellInfo->HasAttribute(SPELL_ATTR0_IS_ABILITY))
+ {
+ if (positive)
+ return { PROC_FLAG_DEAL_HELPFUL_ABILITY, PROC_FLAG_TAKE_HELPFUL_ABILITY };
+ else
+ return { PROC_FLAG_DEAL_HARMFUL_ABILITY, PROC_FLAG_TAKE_HARMFUL_ABILITY };
+ }
+ else
+ {
+ if (positive)
+ return { PROC_FLAG_DEAL_HELPFUL_SPELL, PROC_FLAG_TAKE_HELPFUL_SPELL };
+ else
+ return { PROC_FLAG_DEAL_HARMFUL_SPELL, PROC_FLAG_TAKE_HARMFUL_SPELL };
+ }
+}
+
void Spell::CleanupTargetList()
{
m_UniqueTargetInfo.clear();
@@ -2828,51 +2853,7 @@ void Spell::TargetInfo::DoDamageAndTriggers(Spell* spell)
}
}
- switch (spell->m_spellInfo->DmgClass)
- {
- case SPELL_DAMAGE_CLASS_NONE:
- case SPELL_DAMAGE_CLASS_MAGIC:
- if (spell->m_spellInfo->HasAttribute(SPELL_ATTR3_TREAT_AS_PERIODIC))
- {
- if (positive)
- {
- procAttacker |= PROC_FLAG_DEAL_HELPFUL_PERIODIC;
- procVictim |= PROC_FLAG_TAKE_HELPFUL_PERIODIC;
- }
- else
- {
- procAttacker |= PROC_FLAG_DEAL_HARMFUL_PERIODIC;
- procVictim |= PROC_FLAG_TAKE_HARMFUL_PERIODIC;
- }
- }
- else if (spell->m_spellInfo->HasAttribute(SPELL_ATTR0_IS_ABILITY))
- {
- if (positive)
- {
- procAttacker |= PROC_FLAG_DEAL_HELPFUL_ABILITY;
- procVictim |= PROC_FLAG_TAKE_HELPFUL_ABILITY;
- }
- else
- {
- procAttacker |= PROC_FLAG_DEAL_HARMFUL_ABILITY;
- procVictim |= PROC_FLAG_TAKE_HARMFUL_ABILITY;
- }
- }
- else
- {
- if (positive)
- {
- procAttacker |= PROC_FLAG_DEAL_HELPFUL_SPELL;
- procVictim |= PROC_FLAG_TAKE_HELPFUL_SPELL;
- }
- else
- {
- procAttacker |= PROC_FLAG_DEAL_HARMFUL_SPELL;
- procVictim |= PROC_FLAG_TAKE_HARMFUL_SPELL;
- }
- }
- break;
- }
+ std::tie(procAttacker, procVictim) = spell->FinalizeDataForTriggerSystem(positive);
}
// All calculated do it!
@@ -3948,29 +3929,7 @@ void Spell::_cast(bool skipCheck)
// Handle procs on cast
ProcFlagsInit procAttacker = m_procAttacker;
if (!procAttacker)
- {
- if (m_spellInfo->HasAttribute(SPELL_ATTR3_TREAT_AS_PERIODIC))
- {
- if (IsPositive())
- procAttacker |= PROC_FLAG_DEAL_HELPFUL_PERIODIC;
- else
- procAttacker |= PROC_FLAG_DEAL_HARMFUL_PERIODIC;
- }
- else if (m_spellInfo->HasAttribute(SPELL_ATTR0_IS_ABILITY))
- {
- if (IsPositive())
- procAttacker |= PROC_FLAG_DEAL_HELPFUL_ABILITY;
- else
- procAttacker |= PROC_FLAG_DEAL_HARMFUL_ABILITY;
- }
- else
- {
- if (IsPositive())
- procAttacker |= PROC_FLAG_DEAL_HELPFUL_SPELL;
- else
- procAttacker |= PROC_FLAG_DEAL_HARMFUL_SPELL;
- }
- }
+ procAttacker = FinalizeDataForTriggerSystem(IsPositive()).first;
procAttacker |= PROC_FLAG_2_CAST_SUCCESSFUL;
@@ -4231,29 +4190,7 @@ void Spell::_handle_finish_phase()
ProcFlagsInit procAttacker = m_procAttacker;
if (!procAttacker)
- {
- if (m_spellInfo->HasAttribute(SPELL_ATTR3_TREAT_AS_PERIODIC))
- {
- if (IsPositive())
- procAttacker |= PROC_FLAG_DEAL_HELPFUL_PERIODIC;
- else
- procAttacker |= PROC_FLAG_DEAL_HARMFUL_PERIODIC;
- }
- else if (m_spellInfo->HasAttribute(SPELL_ATTR0_IS_ABILITY))
- {
- if (IsPositive())
- procAttacker |= PROC_FLAG_DEAL_HELPFUL_ABILITY;
- else
- procAttacker |= PROC_FLAG_DEAL_HARMFUL_ABILITY;
- }
- else
- {
- if (IsPositive())
- procAttacker |= PROC_FLAG_DEAL_HELPFUL_SPELL;
- else
- procAttacker |= PROC_FLAG_DEAL_HARMFUL_SPELL;
- }
- }
+ procAttacker = FinalizeDataForTriggerSystem(IsPositive()).first;
Unit::ProcSkillsAndAuras(m_originalCaster, nullptr, procAttacker, PROC_FLAG_NONE, m_procSpellType, PROC_SPELL_PHASE_FINISH, m_hitMask, this, nullptr, nullptr);
}
diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h
index a600f48b0b..fa23ba101f 100644
--- a/src/server/game/Spells/Spell.h
+++ b/src/server/game/Spells/Spell.h
@@ -813,6 +813,7 @@ class TC_GAME_API Spell
ProcFlagsHit m_hitMask;
ProcFlagsSpellType m_procSpellType; // for finish procs
void prepareDataForTriggerSystem();
+ std::pair FinalizeDataForTriggerSystem(bool positive) const;
// *****************************************
// Spell target subsystem