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

Port From (https://github.com/TrinityCore/TrinityCore/commit/1a7779a6e6464d9bc5b367e02820213edd60f704)
This commit is contained in:
hondacrx
2021-05-13 20:35:45 -04:00
parent 031cde7cb2
commit 1509cdfded
3 changed files with 61 additions and 7 deletions
+17 -2
View File
@@ -1758,6 +1758,21 @@ namespace Game.Spells
m_destTargets[effIndex] = dest;
}
public long GetUnitTargetCountForEffect(uint effect)
{
return m_UniqueTargetInfo.Count(targetInfo => (targetInfo.effectMask & (1 << (int)effect)) != 0);
}
public long GetGameObjectTargetCountForEffect(uint effect)
{
return m_UniqueGOTargetInfo.Count(targetInfo => (targetInfo.effectMask & (1 << (int)effect)) != 0);
}
public long GetItemTargetCountForEffect(uint effect)
{
return m_UniqueItemInfo.Count(targetInfo => (targetInfo.effectMask & (1 << (int)effect)) != 0);
}
void DoAllEffectOnTarget(TargetInfo target)
{
if (target == null || target.processed)
@@ -6853,9 +6868,9 @@ namespace Game.Spells
if (m_caster.IsTypeId(TypeId.Player))
{
int targetAmount = m_UniqueTargetInfo.Count;
long targetAmount = GetUnitTargetCountForEffect(effect.EffectIndex);
if (targetAmount > 20)
m_damage = m_damage * 20 / targetAmount;
m_damage = (int)(m_damage * 20 / targetAmount);
}
}
}
+2 -2
View File
@@ -153,11 +153,11 @@ namespace Game.Spells
// Meteor like spells (divided damage to targets)
if (m_spellInfo.HasAttribute(SpellCustomAttributes.ShareDamage))
{
int count = m_UniqueTargetInfo.Count(targetInfo => Convert.ToBoolean(targetInfo.effectMask & (1 << (int)effIndex)));
long count = GetUnitTargetCountForEffect(effIndex);
// divide to all targets
if (count != 0)
damage /= count;
damage /= (int)count;
}
switch (m_spellInfo.SpellFamilyName)