/// <summary>
 /// Constructs a new pulsing action
 /// </summary>
 /// <param name="actionSource"></param>
 /// <param name="effect"></param>
 public SpellPulseAction(GameObject actionSource, PulsingSpellEffect effect) : base(actionSource)
 {
     if (effect == null)
     {
         throw new ArgumentNullException("effect");
     }
     m_effect = effect;
 }
        /// <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);
        }
            /// <summary>
            /// Callback for spell pulses
            /// </summary>
            protected override void OnTick()
            {
                PulsingSpellEffect effect = m_effect;

                effect.m_spellHandler.OnSpellPulse(effect);
            }
Пример #4
0
        /// <summary>
        /// When spell pulses
        /// </summary>
        public virtual void OnSpellPulse(PulsingSpellEffect effect)
        {
            if (Caster.IsMoving && Spell.IsFocus)
            {
                MessageToCaster("Your spell was cancelled.", eChatType.CT_SpellExpires);
                effect.Cancel(false);
                return;
            }
            if (Caster.IsAlive == false)
            {
                effect.Cancel(false);
                return;
            }
            if (Caster.ObjectState != GameObject.eObjectState.Active)
                return;
            if (Caster.IsStunned || Caster.IsMezzed)
                return;

            // no instrument anymore = stop the song
            if (m_spell.InstrumentRequirement != 0 && !CheckInstrument())
            {
                MessageToCaster("You stop playing your song.", eChatType.CT_Spell);
                effect.Cancel(false);
                return;
            }

            if (Caster.Mana >= Spell.PulsePower)
            {
                Caster.Mana -= Spell.PulsePower;
                if (Spell.InstrumentRequirement != 0 || !HasPositiveEffect)
                {
                    SendEffectAnimation(Caster, 0, true, 1); // pulsing auras or songs
                }

                StartSpell(m_spellTarget);
            }
            else
            {
                MessageToCaster("You do not have enough mana and your spell was cancelled.", eChatType.CT_SpellExpires);
                effect.Cancel(false);
            }
        }
Пример #5
0
        /// <summary>
        /// called after normal spell cast is completed and effect has to be started
        /// </summary>
        public virtual void FinishSpellCast(GameLiving target)
        {
            if (Caster is GamePlayer && ((GamePlayer)Caster).IsOnHorse && !HasPositiveEffect)
                ((GamePlayer)Caster).IsOnHorse = false;

            //[Stryve]: Do not break stealth if spell never breaks stealth.
            if ((Caster is GamePlayer) && UnstealthCasterOnFinish )
                ((GamePlayer)Caster).Stealth(false);

            if (Caster is GamePlayer && !HasPositiveEffect)
            {
                if (Caster.AttackWeapon != null && Caster.AttackWeapon is GameInventoryItem)
                {
                    (Caster.AttackWeapon as GameInventoryItem).OnSpellCast(Caster, target, Spell);
                }
            }

            // messages
            if (Spell.InstrumentRequirement == 0 && Spell.ClientEffect != 0 && Spell.CastTime > 0)
            {
                MessageToCaster("You cast a " + m_spell.Name + " spell!", eChatType.CT_Spell);
                foreach (GamePlayer player in m_caster.GetPlayersInRadius(WorldMgr.INFO_DISTANCE))
                {
                    if (player != m_caster)
                        player.MessageFromArea(m_caster, m_caster.GetName(0, true) + " casts a spell!", eChatType.CT_Spell, eChatLoc.CL_SystemWindow);
                }
            }

            if (m_spell.Pulse != 0 && m_spell.Frequency > 0)
            {
                CancelAllPulsingSpells(Caster);
                PulsingSpellEffect pulseeffect = new PulsingSpellEffect(this);
                pulseeffect.Start();
                // show animation on caster for positive spells, negative shows on every StartSpell
                if (m_spell.Target == "Self" || m_spell.Target == "Group")
                    SendEffectAnimation(Caster, 0, false, 1);
                if (m_spell.Target == "Pet")
                    SendEffectAnimation(target, 0, false,1);
            }

            StartSpell(target); // and action

            //Dinberg: This is where I moved the warlock part (previously found in gameplayer) to prevent
            //cancelling before the spell was fired.
            if (m_spell.SpellType != "Powerless" && m_spell.SpellType != "Range" && m_spell.SpellType != "Uninterruptable")
            {
                GameSpellEffect effect = SpellHandler.FindEffectOnTarget(m_caster, "Powerless");
                if (effect == null)
                    effect = SpellHandler.FindEffectOnTarget(m_caster, "Range");
                if (effect == null)
                    effect = SpellHandler.FindEffectOnTarget(m_caster, "Uninterruptable");

                //if we found an effect, cancel it!
                if (effect != null)
                    effect.Cancel(false);
            }

            //the quick cast is unallowed whenever you miss the spell
            //set the time when casting to can not quickcast during a minimum time
            if (m_caster is GamePlayer)
            {
                QuickCastEffect quickcast = m_caster.EffectList.GetOfType<QuickCastEffect>();
                if (quickcast != null && Spell.CastTime > 0)
                {
                    m_caster.TempProperties.setProperty(GamePlayer.QUICK_CAST_CHANGE_TICK, m_caster.CurrentRegion.Time);
                    ((GamePlayer)m_caster).DisableSkill(SkillBase.GetAbility(Abilities.Quickcast), QuickCastAbilityHandler.DISABLE_DURATION);
                    quickcast.Cancel(false);
                }
            }

            if (m_ability != null)
                m_caster.DisableSkill(m_ability.Ability, (m_spell.RecastDelay == 0 ? 3000 : m_spell.RecastDelay));

            // disable spells with recasttimer (Disables group of same type with same delay)
            if (m_spell.RecastDelay > 0 && m_startReuseTimer)
            {
                if (m_caster is GamePlayer)
                {
                    ICollection<Tuple<Skill, int>> toDisable = new List<Tuple<Skill, int>>();

                    GamePlayer gp_caster = m_caster as GamePlayer;
                    foreach (var skills in gp_caster.GetAllUsableSkills())
                        if (skills.Item1 is Spell &&
                            (((Spell)skills.Item1).ID == m_spell.ID || ( ((Spell)skills.Item1).SharedTimerGroup != 0 && ( ((Spell)skills.Item1).SharedTimerGroup == m_spell.SharedTimerGroup) ) ))
                            toDisable.Add(new Tuple<Skill, int>((Spell)skills.Item1, m_spell.RecastDelay));

                    foreach (var sl in gp_caster.GetAllUsableListSpells())
                        foreach(var sp in sl.Item2)
                            if (sp is Spell &&
                                ( ((Spell)sp).ID == m_spell.ID || ( ((Spell)sp).SharedTimerGroup != 0 && ( ((Spell)sp).SharedTimerGroup == m_spell.SharedTimerGroup) ) ))
                            toDisable.Add(new Tuple<Skill, int>((Spell)sp, m_spell.RecastDelay));

                    m_caster.DisableSkill(toDisable);
                }
                else if (m_caster is GameNPC)
                    m_caster.DisableSkill(m_spell, m_spell.RecastDelay);
            }

            GameEventMgr.Notify(GameLivingEvent.CastFinished, m_caster, new CastingEventArgs(this, target, m_lastAttackData));
        }
Пример #6
0
		/// <summary>
		/// When spell pulses
		/// </summary>
		public virtual void OnSpellPulse(PulsingSpellEffect effect)
		{
			if (Caster.IsMoving && Spell.IsFocus)
			{
				MessageToCaster("Your spell was cancelled.", eChatType.CT_SpellExpires);
				effect.Cancel(false);
				return;
			}
			if (Caster.IsAlive == false)
			{
				effect.Cancel(false);
				return;
			}
			if (Caster.ObjectState != GameObject.eObjectState.Active)
				return;
			if (Caster.IsStunned || Caster.IsMezzed)
				return;

			// no instrument anymore = stop the song
			if (m_spell.InstrumentRequirement != 0 && !CheckInstrument())
			{
				MessageToCaster("You stop playing your song.", eChatType.CT_Spell);
				effect.Cancel(false);
				return;
			}

			if (Caster.Mana >= Spell.PulsePower)
			{
				Caster.Mana -= Spell.PulsePower;
				if (Spell.InstrumentRequirement != 0 || !HasPositiveEffect)
				{
					SendEffectAnimation(Caster, 0, true, 1); // pulsing auras or songs
				}

				StartSpell(m_spellTarget);

				if (m_spell.SubSpellID > 0 && Spell.SpellType != "Archery" && Spell.SpellType != "Bomber" && Spell.SpellType != "SummonAnimistFnF" && Spell.SpellType != "SummonAnimistPet" && Spell.SpellType != "Grapple")
				{
					Spell spell = SkillBase.GetSpellByID(m_spell.SubSpellID);
					//we need subspell ID to be 0, we don't want spells linking off the subspell
					if (spell != null && spell.SubSpellID == 0)
					{
						ISpellHandler spellhandler = ScriptMgr.CreateSpellHandler(m_caster, spell, SkillBase.GetSpellLine(GlobalSpellsLines.Reserved_Spells));
						spellhandler.StartSpell(m_spellTarget);
					}
				}

			}
			else
			{
				MessageToCaster("You do not have enough mana and your spell was cancelled.", eChatType.CT_SpellExpires);
				effect.Cancel(false);
			}
		}
Пример #7
0
		/// <summary>
		/// called after normal spell cast is completed and effect has to be started
		/// </summary>
		public virtual void FinishSpellCast(GameLiving target)
		{
			//turn into wraith
			if (m_caster is GamePlayer
			    && ((m_caster as GamePlayer).CharacterClass.ID == (int)eCharacterClass.Bainshee)
			    && (m_caster as GamePlayer).InWraithForm == false
			    && !HasPositiveEffect)
			{
				(m_caster as GamePlayer).InWraithForm = true;
			}

			if (Caster is GamePlayer && ((GamePlayer)Caster).IsOnHorse && !HasPositiveEffect)
				((GamePlayer)Caster).IsOnHorse = false;
			
			//[Stryve]: Do not break stealth if spell never breaks stealth.
			if ((Caster is GamePlayer) && UnstealthCasterOnFinish )
				((GamePlayer)Caster).Stealth(false);

			if (Caster is GamePlayer && !HasPositiveEffect)
			{
				if (Caster.AttackWeapon != null && Caster.AttackWeapon is GameInventoryItem)
				{
					(Caster.AttackWeapon as GameInventoryItem).OnSpellCast(Caster, target, Spell);
				}
			}

			// messages
			if (Spell.InstrumentRequirement == 0 && Spell.ClientEffect != 0 && Spell.CastTime > 0)
			{
				MessageToCaster("You cast a " + m_spell.Name + " spell!", eChatType.CT_Spell);
				foreach (GamePlayer player in m_caster.GetPlayersInRadius(WorldMgr.INFO_DISTANCE))
				{
					if (player != m_caster)
						player.Out.SendMessage(m_caster.GetName(0, true) + " casts a spell!", eChatType.CT_Spell, eChatLoc.CL_SystemWindow);
				}
			}

			if (m_spell.Pulse != 0 && m_spell.Frequency > 0)
			{
				CancelAllPulsingSpells(Caster);
				PulsingSpellEffect pulseeffect = new PulsingSpellEffect(this);
				pulseeffect.Start();
				// show animation on caster for positive spells, negative shows on every StartSpell
				if (m_spell.Target == "Self" || m_spell.Target == "Group")
					SendEffectAnimation(Caster, 0, false, 1);
				if (m_spell.Target == "Pet")
					SendEffectAnimation(target, 0, false,1);
			}

			StartSpell(target); // and action

			//Dinberg: This is where I moved the warlock part (previously found in gameplayer) to prevent
			//cancelling before the spell was fired.
			if (m_spell.SpellType != "Powerless" && m_spell.SpellType != "Range" && m_spell.SpellType != "Uninterruptable")
			{
				GameSpellEffect effect = SpellHandler.FindEffectOnTarget(m_caster, "Powerless");
				if (effect == null)
					effect = SpellHandler.FindEffectOnTarget(m_caster, "Range");
				if (effect == null)
					effect = SpellHandler.FindEffectOnTarget(m_caster, "Uninterruptable");

				//if we found an effect, cancel it!
				if (effect != null)
					effect.Cancel(false);
			}


			//Subspells
			if (m_spell.SubSpellID > 0 && Spell.SpellType != "Archery" && Spell.SpellType != "Bomber" && Spell.SpellType != "SummonAnimistFnF" && Spell.SpellType != "SummonAnimistPet" && Spell.SpellType != "Grapple")
			{
				Spell spell = SkillBase.GetSpellByID(m_spell.SubSpellID);
				//we need subspell ID to be 0, we don't want spells linking off the subspell
				if (target != null && spell != null && spell.SubSpellID == 0)
				{
					ISpellHandler spellhandler = ScriptMgr.CreateSpellHandler(m_caster, spell, SkillBase.GetSpellLine(GlobalSpellsLines.Reserved_Spells));
					spellhandler.StartSpell(target);
				}
			}

			//the quick cast is unallowed whenever you miss the spell
			//set the time when casting to can not quickcast during a minimum time
			if (m_caster is GamePlayer)
			{
				QuickCastEffect quickcast = m_caster.EffectList.GetOfType<QuickCastEffect>();
				if (quickcast != null && Spell.CastTime > 0)
				{
					m_caster.TempProperties.setProperty(GamePlayer.QUICK_CAST_CHANGE_TICK, m_caster.CurrentRegion.Time);
					((GamePlayer)m_caster).DisableSkill(SkillBase.GetAbility(Abilities.Quickcast), QuickCastAbilityHandler.DISABLE_DURATION);
					quickcast.Cancel(false);
				}
			}


			if (m_ability != null)
				m_caster.DisableSkill(m_ability.Ability, (m_spell.RecastDelay == 0 ? 3 : m_spell.RecastDelay));

			// disable spells with recasttimer (Disables group of same type with same delay)
			if (m_spell.RecastDelay > 0 && m_startReuseTimer)
			{
				if (m_caster is GamePlayer)
				{
					GamePlayer gp_caster = m_caster as GamePlayer;
					foreach (SpellLine spellline in gp_caster.GetSpellLines())
						foreach (Spell sp in SkillBase.GetSpellList(spellline.KeyName))
							if (sp == m_spell || (sp.SharedTimerGroup != 0 && (sp.SharedTimerGroup == m_spell.SharedTimerGroup)))
								m_caster.DisableSkill(sp, sp.RecastDelay);
				}
				else if (m_caster is GameNPC)
					m_caster.DisableSkill(m_spell, m_spell.RecastDelay);
			}

			GameEventMgr.Notify(GameLivingEvent.CastFinished, m_caster, new CastingEventArgs(this, target, m_lastAttackData));
		}
Пример #8
0
			/// <summary>
			/// Constructs a new pulsing action
			/// </summary>
			/// <param name="actionSource"></param>
			/// <param name="effect"></param>
			public SpellPulseAction(GameObject actionSource, PulsingSpellEffect effect) : base(actionSource)
			{
				if (effect == null)
					throw new ArgumentNullException("effect");
				m_effect = effect;
			}
Пример #9
0
        /// <summary>
        /// When spell pulses
        /// </summary>
        public virtual void OnSpellPulse(PulsingSpellEffect effect)
        {
            // WHRIA
            // Cure Poison , Cure Disease

            if (Spell.SpellType == "CurePoison"
                    || Spell.SpellType == "CureDisease")
            {

                if (!m_spellTarget.IsAlive)
                {
                    MessageToCaster("Target is dead. Your spell is cancelled.", eChatType.CT_SpellExpires);
                    effect.Cancel(false);
                    CancelPulsingSpell(Caster, Spell.SpellType);
                    return;
                }

                if (Spell.Range != 0)
                {
                    if (!Caster.IsWithinRadius(m_spellTarget, Spell.Range))
                    {
            //                    MessageToCaster("WHRIA // Target is too far away.", eChatType.CT_SpellExpires);
            //                    effect.Cancel(false);
            //                    CancelPulsingSpell(Caster, Spell.SpellType);
                        return;
                    }
                }
            }
            // END

            // WHRIA CHECK LOS , PULSE SPELLS

            if (ServerProperties.Properties.CHECK_LOS_DURING_CAST)
            {
                if (Spell.SpellType == "CurePoison"
                        || Spell.SpellType == "CureDisease"
                        || Spell.SpellType == "Mesmerize"
                    )
                {
                    if (Caster is GamePlayer)
                    {
                        GamePlayer playerChecker = Caster as GamePlayer;
                        playerChecker.Out.SendCheckLOS(Caster, m_spellTarget, new CheckLOSResponse(CheckLOSPlayerToTarget));
                    }
                }
            }

            if (Caster.IsMoving && Spell.IsFocus)
            {
                MessageToCaster("Your spell was cancelled.", eChatType.CT_SpellExpires);
                effect.Cancel(false);
                return;
            }
            if (Caster.IsAlive == false)
            {
                effect.Cancel(false);
                return;
            }
            if (Caster.ObjectState != GameObject.eObjectState.Active)
                return;
            if (Caster.IsStunned || Caster.IsMezzed)
                return;

            // no instrument anymore = stop the song
            if (m_spell.InstrumentRequirement != 0 && !CheckInstrument())
            {
                MessageToCaster("You stop playing your song.", eChatType.CT_Spell);
                effect.Cancel(false);
                return;
            }

            if (Caster.Mana >= Spell.PulsePower)
            {
                Caster.Mana -= Spell.PulsePower;
                if (Spell.InstrumentRequirement != 0 || !HasPositiveEffect)
                {
                    SendEffectAnimation(Caster, 0, true, 1); // pulsing auras or songs
                }

            // WHRIA
                if (Caster.TargetObject != null)
                {
                    if ((Spell.SpellType == "CurePoison"
                            || Spell.SpellType == "CureDisease") && Caster.TargetObject is GameLiving)
                    {
                        m_spellTarget = (GameLiving)Caster.TargetObject;
                        MessageToCaster(Util.MakeSentence(Spell.Message2, Caster.TargetObject.Name), eChatType.CT_Spell);
                    }
                }

                StartSpell(m_spellTarget);
                m_pulsecount++;

                if (m_pulsecount >= (Spell.Pulse-1) && Spell.Pulse > 1
                    && (Spell.SpellType == "CurePoison"
                    || Spell.SpellType == "CureDisease"))
                {
                    CancelPulsingSpell(Caster, Spell.SpellType);
                    return;
                }

                /*
                if (Spell.SpellType == "CurePoison"
                        || Spell.SpellType == "CureDisease")
                {
                    // Only up to three pulses
                    if ((Spell.ID == 14380 || Spell.ID == 14381) && (Caster.CurrentRegion.Time - m_started - Spell.CastTime) > 4000)
                    {
                        CancelPulsingSpell(Caster, Spell.SpellType);
                        return;
                    }
                    // Only up to two pulses
                    if ((Spell.ID == 14379 || Spell.ID == 14378) && (Caster.CurrentRegion.Time - m_started - Spell.CastTime) > 1000)
                    {
                        CancelPulsingSpell(Caster, Spell.SpellType);
                        return;
                    }
                }
                */
            // END

                if (m_spell.SubSpellID > 0 && Spell.SpellType != "Archery" && Spell.SpellType != "Bomber" && Spell.SpellType != "SummonAnimistFnF" && Spell.SpellType != "SummonAnimistPet" && Spell.SpellType != "Grapple")
                {
                    Spell spell = SkillBase.GetSpellByID(m_spell.SubSpellID);
                    //we need subspell ID to be 0, we don't want spells linking off the subspell
                    if (spell != null && spell.SubSpellID == 0)
                    {
                        ISpellHandler spellhandler = ScriptMgr.CreateSpellHandler(m_caster, spell, SkillBase.GetSpellLine(GlobalSpellsLines.Reserved_Spells));
                        spellhandler.StartSpell(m_spellTarget);
                    }
                }

            }
            else
            {
                MessageToCaster("You do not have enough mana and your spell was cancelled.", eChatType.CT_SpellExpires);
                effect.Cancel(false);
            }
        }