Exemple #1
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);
        }
        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);
            }
        }
        /// <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);
        }
 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);
 }