Core/Spells: Move duplicated code for proc flag selection to separate function
Signed-off-by: luis <[email protected]>
This commit is contained in:
@@ -2368,6 +2368,31 @@ void Spell::prepareDataForTriggerSystem()
|
||||
}
|
||||
}
|
||||
|
||||
std::pair<ProcFlagsInit /*attacker*/, ProcFlagsInit /*victim*/> 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();
|
||||
@@ -2829,51 +2854,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!
|
||||
@@ -3956,29 +3937,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;
|
||||
|
||||
@@ -4239,29 +4198,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);
|
||||
}
|
||||
|
||||
@@ -836,6 +836,7 @@ class TC_GAME_API Spell
|
||||
ProcFlagsHit m_hitMask;
|
||||
ProcFlagsSpellType m_procSpellType; // for finish procs
|
||||
void prepareDataForTriggerSystem();
|
||||
std::pair<ProcFlagsInit /*attacker*/, ProcFlagsInit /*victim*/> FinalizeDataForTriggerSystem(bool positive) const;
|
||||
|
||||
// *****************************************
|
||||
// Spell target subsystem
|
||||
|
||||
Reference in New Issue
Block a user