Example #1
0
        private void Launch()
        {
            ExecutionState = SpellExecutionState.Processing;
            Caster.SpellHistory.StartCooldown(SpellInfo);
            SelectImplicitTargets();

            for (int effectIndex = 0; effectIndex < SpellInfo.Effects.Count; effectIndex++)
            {
                SpellInfo.Effects[effectIndex].Handle(this, effectIndex, Caster, SpellEffectHandleMode.Launch);
            }

            ImplicitTargets.HandleLaunch(out bool isDelayed, out SpellProcessingToken processingToken);

            EventHandler.ExecuteEvent(EventHandler.GlobalDispatcher, GameEvents.ServerSpellLaunch, Caster, ExplicitTargets.Source, SpellInfo, processingToken);

            DropModifierCharges();

            if (!isDelayed)
            {
                foreach (var targetInfo in ImplicitTargets.Entries)
                {
                    ProcessTarget(targetInfo);
                }

                Finish();
            }
        }
Example #2
0
        private SpellCastResult Cast()
        {
            ExecutionState = SpellExecutionState.Casting;

            CastTime     = Caster.Spells.ModifySpellCastTime(this, SpellInfo.CastTime);
            CastTimeLeft = CastTime;

            // cast if needed, if already casting launch instead, should only be possible with CanCastWhileCasting
            bool instantCast = CastTime <= 0.0f || Caster.SpellCast.IsCasting || spellValue.CastFlags.HasTargetFlag(SpellCastFlags.CastDirectly);

            if (casterMovementFlags.IsMoving() && !instantCast && !SpellInfo.HasAttribute(SpellAttributes.CastableWhileMoving))
            {
                return(SpellCastResult.Moving);
            }

            if (!spellValue.CastFlags.HasTargetFlag(SpellCastFlags.IgnoreShapeShift) && SpellInfo.CanCancelForm(this))
            {
                Caster.Auras.RemoveAurasWithEffect(AuraEffectType.ShapeShift);
            }

            Caster.SpellHistory.StartGlobalCooldown(SpellInfo);

            if (!spellValue.CastFlags.HasTargetFlag(SpellCastFlags.IgnoreAuraInterruptFlags) && !SpellInfo.HasAttribute(SpellCustomAttributes.DontBreakStealth))
            {
                Caster.Auras.RemoveAurasWithInterrupt(AuraInterruptFlags.Cast);
            }

            if (instantCast)
            {
                Launch();
            }

            return(SpellCastResult.Success);
        }
Example #3
0
        private void Launch()
        {
            ExecutionState = SpellExecutionState.Processing;
            Caster.SpellHistory.HandleCooldown(SpellInfo);
            SelectImplicitTargets();

            for (int effectIndex = 0; effectIndex < SpellInfo.Effects.Count; effectIndex++)
            {
                SpellInfo.Effects[effectIndex].Handle(this, effectIndex, Caster, SpellEffectHandleMode.Launch);
            }

            ImplicitTargets.HandleLaunch(out bool isDelayed, out SpellProcessingToken processingToken);

            if (!spellValue.CastFlags.HasTargetFlag(SpellCastFlags.DontReportCastSuccess))
            {
                EventHandler.ExecuteEvent(GameEvents.ServerSpellLaunch, Caster, SpellInfo, processingToken);
            }

            DropModifierCharges();
            ConsumePowers();

            Caster.Spells.ApplySpellTriggers(SpellTriggerFlags.DoneSpellCast, Caster, this);

            if (!isDelayed)
            {
                foreach (var targetInfo in ImplicitTargets.Entries)
                {
                    ProcessTarget(targetInfo);
                }

                Finish();
            }
        }
Example #4
0
        private void Finish()
        {
            ExecutionState = SpellExecutionState.Completed;

            DropModifierCharges();

            spellManager.Remove(this);
        }
Example #5
0
        internal SpellCastResult Prepare()
        {
            ExecutionState = SpellExecutionState.Preparing;
            PrepareExplicitTarget();

            SpellCastResult result = ValidateCast();

            if (result != SpellCastResult.Success)
            {
                return(result);
            }

            return(Cast());
        }
Example #6
0
        internal SpellCastResult Prepare()
        {
            ExecutionState = SpellExecutionState.Preparing;
            PrepareExplicitTarget();
            SpellInfo.CalculatePowerCosts(Caster, powerCosts, this);

            SpellCastResult result = ValidateCast();

            if (result != SpellCastResult.Success)
            {
                return(result);
            }

            return(Cast());
        }
Example #7
0
        private SpellCastResult Cast()
        {
            ExecutionState = SpellExecutionState.Casting;

            CastTime     = Caster.Spells.ModifySpellCastTime(this, SpellInfo.CastTime);
            CastTimeLeft = CastTime;

            // cast if needed, if already casting launch instead, should only be possible with CanCastWhileCasting
            bool instantCast = CastTime <= 0.0f || Caster.SpellCast.IsCasting || spellCastFlags.HasTargetFlag(SpellCastFlags.CastDirectly);

            if (casterMovementFlags.IsMoving() && !instantCast && !SpellInfo.HasAttribute(SpellAttributes.CastableWhileMoving))
            {
                return(SpellCastResult.Moving);
            }

            Caster.SpellHistory.StartGlobalCooldown(SpellInfo);

            if (instantCast)
            {
                Launch();
            }

            return(SpellCastResult.Success);
        }