diff options
| author | Shauren <shauren.trinity@gmail.com> | 2021-05-13 00:38:09 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2025-11-17 18:22:43 +0100 |
| commit | 4997e316d9e4bf529e131d45528fff404d99b836 (patch) | |
| tree | 633bf20758ce902a91b4000f8694e7f271c85cd6 /src/server/game/Spells/Spell.cpp | |
| parent | 5e691c0d5f5fdc9f45d5c06525f6c0334ff0818e (diff) | |
Core/Spells: Expose number of targets selected for each spell effect to scripts to allow implementing spells that do something depending on number of targets hit
(cherry picked from commit 1a7779a6e6464d9bc5b367e02820213edd60f704)
Diffstat (limited to 'src/server/game/Spells/Spell.cpp')
| -rw-r--r-- | src/server/game/Spells/Spell.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 5f024a813ea..e523ce7c111 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -2362,6 +2362,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::TargetInfo::PreprocessTarget(Spell* spell) { Unit* unit = spell->m_caster->GetGUID() == TargetGUID ? spell->m_caster->ToUnit() : ObjectAccessor::GetUnit(*spell->m_caster, TargetGUID); @@ -7784,7 +7808,7 @@ void Spell::DoEffectOnLaunchTarget(TargetInfo& targetInfo, float multiplier, Spe if (m_originalCaster->GetTypeId() == TYPEID_PLAYER) { // cap damage of player AOE - uint32 targetAmount = m_UniqueTargetInfo.size(); + int64 targetAmount = GetUnitTargetCountForEffect(spellEffectInfo.EffectIndex); if (targetAmount > 10) m_damage = m_damage * 10 / targetAmount; } |
