diff options
Diffstat (limited to 'src/server/game/Spells/Spell.cpp')
-rw-r--r-- | src/server/game/Spells/Spell.cpp | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 97cd6f64d20..f4e058fad08 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -2276,6 +2276,30 @@ void Spell::AddDestTarget(SpellDestination const& dest, uint32 effIndex) m_destTargets[effIndex] = dest; } +int64 Spell::GetUnitTargetCountForEffect(SpellEffIndex effect) const +{ + return std::count_if(m_UniqueTargetInfo.begin(), m_UniqueTargetInfo.end(), [effect](TargetInfo const& targetInfo) + { + return targetInfo.effectMask & (1 << effect); + }); +} + +int64 Spell::GetGameObjectTargetCountForEffect(SpellEffIndex effect) const +{ + return std::count_if(m_UniqueGOTargetInfo.begin(), m_UniqueGOTargetInfo.end(), [effect](GOTargetInfo const& targetInfo) + { + return targetInfo.effectMask & (1 << effect); + }); +} + +int64 Spell::GetItemTargetCountForEffect(SpellEffIndex effect) const +{ + return std::count_if(m_UniqueItemInfo.begin(), m_UniqueItemInfo.end(), [effect](ItemTargetInfo const& targetInfo) + { + return targetInfo.effectMask & (1 << effect); + }); +} + void Spell::DoAllEffectOnTarget(TargetInfo* target) { if (!target || target->processed) @@ -7454,9 +7478,9 @@ void Spell::DoAllEffectOnLaunchTarget(TargetInfo& targetInfo, float* multiplier) if (m_caster->GetTypeId() == TYPEID_PLAYER) { - uint32 targetAmount = m_UniqueTargetInfo.size(); + int64 targetAmount = GetUnitTargetCountForEffect(SpellEffIndex(effect->EffectIndex)); if (targetAmount > 20) - m_damage = m_damage * 20/targetAmount; + m_damage = m_damage * 20 / targetAmount; } } } |