Core/Spells: Move duplicated code for proc flag selection to separate function

This commit is contained in:
Shauren
2026-02-28 14:41:52 +01:00
parent b49b15c94d
commit b0eef35616
2 changed files with 29 additions and 91 deletions

View File

@@ -2367,6 +2367,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();
@@ -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);
}

View File

@@ -813,6 +813,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