Exemple #1
0
            internal bool IsImmuneToSpellEffect(SpellEffectInfo spellEffectInfo, Unit caster)
            {
                if (spellEffectInfo is EffectApplyAura spellEffectApplyAura)
                {
                    return(IsImmuneToAura(spellEffectApplyAura.AuraInfo, caster));
                }

                return(false);
            }
        private void SelectImplicitTargets()
        {
            // select explicit potentially redirected target
            SelectRedirectedTargets();

            // also select targets based on spell effects
            int processedAreaEffectsMask = 0;

            for (var effectIndex = 0; effectIndex < SpellInfo.Effects.Count; effectIndex++)
            {
                if (processedAreaEffectsMask.HasBit(effectIndex))
                {
                    continue;
                }

                SpellEffectInfo effect = SpellInfo.Effects[effectIndex];
                // avoid recalculating similar effects
                int effectMask = 1 << effectIndex;
                for (int otherEffectIndex = 0; otherEffectIndex < SpellInfo.Effects.Count; otherEffectIndex++)
                {
                    if (effect.Targeting == SpellInfo.Effects[otherEffectIndex].Targeting)
                    {
                        effectMask |= 1 << otherEffectIndex;
                    }
                }

                processedAreaEffectsMask |= effectMask;
                effect.Targeting.SelectTargets(this);
            }

            void SelectRedirectedTargets()
            {
                Unit target = ExplicitTargets.Target;

                if (target == null)
                {
                    return;
                }

                if (SpellInfo.ExplicitCastTargets.HasAnyFlag(SpellCastTargetFlags.UnitEnemy) && Caster.IsHostileTo(target))
                {
                    Unit redirectTarget;
                    switch (SpellInfo.DamageClass)
                    {
                    case SpellDamageClass.Magic:
                        redirectTarget = Caster.Spells.GetMagicHitRedirectTarget(target, SpellInfo);
                        break;

                    case SpellDamageClass.Melee:
                    case SpellDamageClass.Ranged:
                        redirectTarget = Caster.Spells.GetMeleeHitRedirectTarget(target, SpellInfo);
                        break;

                    default:
                        redirectTarget = null;
                        break;
                    }
                    if (redirectTarget != null && redirectTarget != target)
                    {
                        ExplicitTargets.Target = redirectTarget;
                    }
                }
            }
        }