Exemplo n.º 1
0
        public override void OnSpellPulse(PulsingSpellEffect effect)
        {
            if (Caster.ObjectState != GameObject.eObjectState.Active)
            {
                return;
            }
            if (Caster.IsStunned || Caster.IsMezzed)
            {
                return;
            }

            (Caster as GamePlayer).Out.SendCheckLOS(Caster, m_spellTarget, CheckLOSPlayerToTarget);

            if (Caster.Mana >= Spell.PulsePower)
            {
                Caster.Mana -= Spell.PulsePower;
                SendEffectAnimation(Caster, 0, true, 1);                 // pulsing auras or songs
                pulseCount += 1;
                OnDirectEffect(Target, CurrentEffectiveness);
            }
            else
            {
                MessageToCaster("You do not have enough mana and your spell was cancelled.", eChatType.CT_SpellExpires);
                FocusSpellAction(null, Caster, null);
                effect.Cancel(false);
            }
        }
Exemplo n.º 2
0
        private void ReleaseEventHandler(DOLEvent e, object sender, EventArgs arguments)
        {
            IControlledBrain npc = null;

            if (e == GameLivingEvent.PetReleased)
            {
                npc = ((GameNPC)sender).Brain as IControlledBrain;
            }
            else if (e == GameLivingEvent.Dying)
            {
                npc = ((GameNPC)sender).Brain as IControlledBrain;
            }

            if (npc == null)
            {
                return;
            }

            PulsingSpellEffect concEffect = FindPulsingSpellOnTarget(npc.Owner, this);

            if (concEffect != null)
            {
                concEffect.Cancel(false);
            }

            GameSpellEffect charm = FindEffectOnTarget(npc.Body, this);

            if (charm == null)
            {
                log.Warn("charm effect is already canceled");
                return;
            }

            charm.Cancel(false);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Find pulsing spell effect by spell handler
        /// </summary>
        /// <param name="target">Living to find effect on</param>
        /// <param name="handler">Spell Handler to find (Exact Object Match)</param>
        /// <returns>First occurence of PulsingSpellEffect in targets' concentration list or null</returns>
        public static PulsingSpellEffect FindPulsingSpellOnTarget(this GameLiving target, ISpellHandler handler)
        {
            PulsingSpellEffect effect = null;

            lock (target.ConcentrationEffects)
            {
                effect = target.PulsingSpellsOnTarget(handler).FirstOrDefault();
            }
            return(effect);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Find Pulsing Spell Effect by spell object
        /// </summary>
        /// <param name="target">Living to find effect on</param>
        /// <param name="spell">Spell Object to Find (Spell.ID Match)</param>
        /// <returns>First occurence PulsingSpellEffect build from spell in target's concentration list or null</returns>
        public static PulsingSpellEffect FindPulsingSpellOnTarget(this GameLiving target, Spell spell)
        {
            PulsingSpellEffect pulsingSpell = null;

            lock (target.ConcentrationEffects)
            {
                pulsingSpell = target.PulsingSpellsOnTarget(spell).FirstOrDefault();
            }

            return(pulsingSpell);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Find pulsing spell by spell handler
 /// </summary>
 /// <param name="living">Living to find effect on</param>
 /// <param name="handler">Spell Handler to find (Exact Object Match)</param>
 /// <returns>first occurance of spellhandler in targets' conc list or null</returns>
 public static PulsingSpellEffect FindPulsingSpellOnTarget(GameLiving living, ISpellHandler handler)
 {
     lock (living.ConcentrationEffects)
     {
         foreach (IConcentrationEffect concEffect in living.ConcentrationEffects)
         {
             PulsingSpellEffect pulsingSpell = concEffect as PulsingSpellEffect;
             if (pulsingSpell == null)
             {
                 continue;
             }
             if (pulsingSpell.SpellHandler == handler)
             {
                 return(pulsingSpell);
             }
         }
         return(null);
     }
 }
 public override bool CancelPulsingSpell(GameLiving living, string spellType)
 {
     lock (living.ConcentrationEffects)
     {
         for (int i = 0; i < living.ConcentrationEffects.Count; i++)
         {
             PulsingSpellEffect effect = living.ConcentrationEffects[i] as PulsingSpellEffect;
             if (effect == null)
             {
                 continue;
             }
             if (effect.SpellHandler.Spell.SpellType == spellType)
             {
                 effect.Cancel(false);
                 GameEventMgr.RemoveHandler(Caster, GamePlayerEvent.Moving, new DOLEventHandler(EventAction));
                 GameEventMgr.RemoveHandler(Caster, GamePlayerEvent.Dying, new DOLEventHandler(EventAction));
                 return(true);
             }
         }
     }
     return(false);
 }
Exemplo n.º 7
0
        /// <summary>
        /// This spell is a pulsing spell, not a pulsing effect, so we check spell pulse
        /// </summary>
        /// <param name="effect"></param>
        public override void OnSpellPulse(PulsingSpellEffect effect)
        {
            if (m_originalTarget == null || Caster.ObjectState != GameObject.eObjectState.Active || m_originalTarget.ObjectState != GameObject.eObjectState.Active)
            {
                MessageToCaster("Your spell was cancelled.", eChatType.CT_SpellExpires);
                effect.Cancel(false);
                return;
            }

            if (!Caster.IsAlive ||
                !m_originalTarget.IsAlive ||
                Caster.IsMezzed ||
                Caster.IsStunned ||
                Caster.IsSitting ||
                (Caster.TargetObject is GameLiving ? m_originalTarget != Caster.TargetObject as GameLiving : true))
            {
                MessageToCaster("Your spell was cancelled.", eChatType.CT_SpellExpires);
                effect.Cancel(false);
                return;
            }

            if (!Caster.IsWithinRadius(m_originalTarget, CalculateSpellRange()))
            {
                MessageToCaster("Your target is no longer in range.", eChatType.CT_SpellExpires);
                effect.Cancel(false);
                return;
            }

            if (!Caster.TargetInView)
            {
                MessageToCaster("Your target is no longer in view.", eChatType.CT_SpellExpires);
                effect.Cancel(false);
                return;
            }

            base.OnSpellPulse(effect);
        }