Esempio n. 1
0
            internal SpellCastResult CastSpell(SpellInfo spellInfo, SpellCastingOptions castOptions)
            {
                Spell spell = new Spell(unit, spellInfo, castOptions);

                ApplySpellModifier(spell, SpellModifierType.SpellValue, 1.0f);

                SpellCastResult castResult = spell.Prepare();

                if (castResult != SpellCastResult.Success)
                {
                    unit.World.SpellManager.Remove(spell);
                    return(castResult);
                }

                switch (spell.ExecutionState)
                {
                case SpellExecutionState.Casting:
                    unit.SpellCast.HandleSpellCast(spell, SpellCast.HandleMode.Started);
                    break;

                case SpellExecutionState.Processing:
                    return(castResult);

                case SpellExecutionState.Completed:
                    return(castResult);
                }

                unit.ModifyEmoteState(EmoteType.None);
                return(SpellCastResult.Success);
            }
        public override void AuraApplicationRemoved(AuraApplication application)
        {
            base.AuraApplicationRemoved(application);

            if (application.Aura.Caster == null)
            {
                return;
            }

            if (application.RemoveMode == AuraRemoveMode.Death || application.RemoveMode == AuraRemoveMode.Expired)
            {
                var explicitTargets = new SpellExplicitTargets {
                    Target = application.Aura.Owner
                };
                var castingOptions = new SpellCastingOptions(explicitTargets, SpellCastFlags.TriggeredByAura);
                application.Aura.Caster.Spells.CastSpell(livingBombExplosion, castingOptions);
            }
        }
Esempio n. 3
0
        internal Spell(Unit caster, SpellInfo info, SpellCastingOptions options)
        {
            Logging.LogSpell($"Created new spell, current count: {++SpellAliveCount}");

            spellManager         = caster.World.SpellManager;
            spellValue.CastFlags = options.SpellFlags;
            casterMovementFlags  = options.MovementFlags ?? caster.MovementInfo.Flags;
            SchoolMask           = info.SchoolMask;

            CastTime  = CastTimeLeft = EffectDamage = EffectHealing = 0;
            Caster    = OriginalCaster = caster;
            SpellInfo = info;

            IsTriggered = spellValue.CastFlags.HasTargetFlag(SpellCastFlags.TriggeredByAura);

            if (IsTriggered)
            {
                spellValue.CastFlags |= SpellCastFlags.IgnoreTargetCheck | SpellCastFlags.IgnoreRangeCheck |
                                        SpellCastFlags.IgnoreShapeShift | SpellCastFlags.IgnoreAuraInterruptFlags | SpellCastFlags.IgnoreCasterState;
            }

            if (info.HasAttribute(SpellExtraAttributes.CanCastWhileCasting))
            {
                spellValue.CastFlags |= SpellCastFlags.IgnoreCastInProgress | SpellCastFlags.CastDirectly;
            }

            if (info.HasAttribute(SpellExtraAttributes.IgnoreGcd))
            {
                spellValue.CastFlags |= SpellCastFlags.IgnoreGcd;
            }

            if (info.HasAttribute(SpellExtraAttributes.IgnoreCasterAuras))
            {
                spellValue.CastFlags |= SpellCastFlags.IgnoreCasterAuras;
            }

            CanReflect = SpellInfo.DamageClass == SpellDamageClass.Magic && !SpellInfo.HasAttribute(SpellAttributes.CantBeReflected) &&
                         !SpellInfo.HasAttribute(SpellAttributes.UnaffectedByInvulnerability) && !SpellInfo.IsPassive && !SpellInfo.IsPositive;

            ExplicitTargets = options.Targets ?? new SpellExplicitTargets();
            ImplicitTargets = new SpellImplicitTargets(this);

            spellManager.Add(this);
        }