Beispiel #1
0
        public virtual bool Cast()
        {
            m_StartCastTime = DateTime.Now;

            if (canCast())
            {
                State        = SpellState.Casting;
                Caster.Spell = this;

                if (RevealOnCast)
                {
                    Caster.RevealingAction();
                }

                SayMantra();

                TimeSpan castTime = Info.castTime;

                double time = castTime.TotalSeconds;

                castTime = TimeSpan.FromSeconds(Vitesse.instance.CalculerVitesse(Caster, time));

                if (Caster.Body.IsHuman)
                {
                    int count = (int)Math.Ceiling(castTime.TotalSeconds / AnimateDelay.TotalSeconds);

                    if (count != 0 && AnimateOnCast)
                    {
                        m_AnimTimer = new AnimTimer(this, count);
                        m_AnimTimer.Start();
                    }

                    if (m_Info.LeftHandEffect > 0)
                    {
                        Effects.SendTargetParticles(Caster, 0, 10, 5, Info.LeftHandEffect, EffectLayer.LeftHand);
                    }

                    if (m_Info.RightHandEffect > 0)
                    {
                        Effects.SendTargetParticles(Caster, 0, 10, 5, Info.RightHandEffect, EffectLayer.RightHand);
                    }
                }

                if (ClearHandsOnCast)
                {
                    Caster.ClearHands();
                }

                m_CastTimer = new CastTimer(this, castTime);
                m_CastTimer.Start();

                OnBeginCast();

                return(true);
            }

            return(false);
        }
Beispiel #2
0
        public bool Cast()
        {
            m_StartCastTime = DateTime.Now;

            if ( m_Caster.Spell is Spell && ( (Spell) m_Caster.Spell ).State == SpellState.Sequencing )
                ( (Spell) m_Caster.Spell ).Disturb( DisturbType.NewCast );

            if ( !m_Caster.CheckAlive() )
            {
                return false;
            }
            else if ( m_Caster.Spell != null && m_Caster.Spell.IsCasting )
            {
                m_Caster.SendLocalizedMessage( 502642 ); // You are already casting a spell.
            }
            else if ( BlockedByHorrificBeast && TransformationSpell.UnderTransformation( m_Caster, typeof( HorrificBeastSpell ) ) )
            {
                m_Caster.SendLocalizedMessage( 1061091 ); // You cannot cast that spell in this form.
            }
            else if ( BlockedByAnimalForm && AnimalForm.UnderTransformation( m_Caster ) )
            {
                m_Caster.SendLocalizedMessage( 1061091 ); // You cannot cast that spell in this form.
            }
            else if ( !( m_Scroll is BaseWand ) && ( m_Caster.Paralyzed || m_Caster.Frozen ) )
            {
                m_Caster.SendLocalizedMessage( 502643 ); // You can not cast a spell while frozen.
            }
            else if ( CheckNextSpellTime && DateTime.Now < m_Caster.NextSpellTime )
            {
                m_Caster.SendLocalizedMessage( 502644 ); // You have not yet recovered from casting a spell.
            }
            else if ( BaseBardCreature.IsCalmed( m_Caster ) )
            {
                m_Caster.SendLocalizedMessage( 1072060 ); // You cannot cast a spell while calmed.
            }
            else if ( m_Caster.Mana >= ScaleMana( GetMana() ) )
            {
                if ( m_Caster.Spell == null && m_Caster.CheckSpellCast( this ) && CheckCast() && m_Caster.Region.OnBeginSpellCast( m_Caster, this ) )
                {
                    m_State = SpellState.Casting;
                    m_Caster.Spell = this;

                    if ( RevealOnCast )
                        m_Caster.RevealingAction();

                    SayMantra();

                    TimeSpan castDelay = this.GetCastDelay();

                    /*
                     * OSI cast delay is computed with a global timer based on ticks. There is
                     * one tick per 0.25 seconds, so every tick the timer computes all the
                     * spells ready to cast. This introduces a random additional delay of 0-0.25
                     * seconds due to fact that the first tick is always incomplete. We add this
                     * manually here to enhance the gameplay to get the real OSI feeling.
                     */
                    castDelay += TimeSpan.FromSeconds( 0.25 * Utility.RandomDouble() );

                    if ( ShowHandMovement && m_Caster.Body.IsHuman && !( m_Scroll is SpellStone ) )
                    {
                        int count = (int) Math.Ceiling( castDelay.TotalSeconds / AnimateDelay.TotalSeconds );

                        if ( count != 0 )
                        {
                            m_AnimTimer = new AnimTimer( this, count );
                            m_AnimTimer.Start();
                        }

                        if ( m_Info.LeftHandEffect > 0 )
                            Caster.FixedParticles( 0, 10, 5, m_Info.LeftHandEffect, EffectLayer.LeftHand );

                        if ( m_Info.RightHandEffect > 0 )
                            Caster.FixedParticles( 0, 10, 5, m_Info.RightHandEffect, EffectLayer.RightHand );
                    }

                    if ( ClearHandsOnCast )
                        m_Caster.ClearHands();

                    m_CastTimer = new CastTimer( this, castDelay );
                    m_CastTimer.Start();

                    SpecialMove.ClearCurrentMove( m_Caster );
                    WeaponAbility.ClearCurrentAbility( m_Caster );

                    OnBeginCast();

                    return true;
                }
                else
                {
                    return false;
                }
            }
            else
            {
                m_Caster.LocalOverheadMessage( MessageType.Regular, 0x22, 502625 ); // Insufficient mana
            }

            return false;
        }
Beispiel #3
0
        public bool Cast()
        {
            m_StartCastTime = DateTime.Now;

            if (Core.AOS && m_Caster.Spell is Spell && ((Spell)m_Caster.Spell).State == SpellState.Sequencing)
            {
                ((Spell)m_Caster.Spell).Disturb(DisturbType.NewCast);
            }

            if (!m_Caster.CheckAlive())
            {
                return(false);
            }
            #region Mondain's Legacy
            else if (m_Caster is PlayerMobile && ((PlayerMobile)m_Caster).Peaced)
            {
                m_Caster.SendLocalizedMessage(1072060);                   // You cannot cast a spell while calmed.
            }
            #endregion
            else if (m_Caster.Spell != null && m_Caster.Spell.IsCasting)
            {
                m_Caster.SendLocalizedMessage(502642);                   // You are already casting a spell.
            }
            else if (BlockedByHorrificBeast && TransformationSpellHelper.UnderTransformation(m_Caster, typeof(HorrificBeastSpell)) || (BlockedByAnimalForm && AnimalForm.UnderTransformation(m_Caster)))
            {
                m_Caster.SendLocalizedMessage(1061091);                   // You cannot cast that spell in this form.
            }
            else if (!(m_Scroll is BaseWand) && (m_Caster.Paralyzed || m_Caster.Frozen))
            {
                m_Caster.SendLocalizedMessage(502643);                   // You can not cast a spell while frozen.
            }
            else if (CheckNextSpellTime && DateTime.Now < m_Caster.NextSpellTime)
            {
                m_Caster.SendLocalizedMessage(502644);                   // You have not yet recovered from casting a spell.
            }
            else if (m_Caster.Mana >= ScaleMana(GetMana()))
            {
                if (m_Caster.Spell == null && m_Caster.CheckSpellCast(this) && CheckCast() && m_Caster.Region.OnBeginSpellCast(m_Caster, this))
                {
                    m_State        = SpellState.Casting;
                    m_Caster.Spell = this;

                    if (RevealOnCast)
                    {
                        m_Caster.RevealingAction();
                    }

                    SayMantra();

                    TimeSpan castDelay = this.GetCastDelay();

                    if (ShowHandMovement && m_Caster.Body.IsHuman)
                    {
                        int count = (int)Math.Ceiling(castDelay.TotalSeconds / AnimateDelay.TotalSeconds);

                        if (count != 0)
                        {
                            m_AnimTimer = new AnimTimer(this, count);
                            m_AnimTimer.Start();
                        }

                        if (m_Info.LeftHandEffect > 0)
                        {
                            Caster.FixedParticles(0, 10, 5, m_Info.LeftHandEffect, EffectLayer.LeftHand);
                        }

                        if (m_Info.RightHandEffect > 0)
                        {
                            Caster.FixedParticles(0, 10, 5, m_Info.RightHandEffect, EffectLayer.RightHand);
                        }
                    }

                    if (ClearHandsOnCast)
                    {
                        m_Caster.ClearHands();
                    }

                    m_CastTimer = new CastTimer(this, castDelay);
                    m_CastTimer.Start();

                    OnBeginCast();

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                m_Caster.LocalOverheadMessage(MessageType.Regular, 0x22, 502625);                   // Insufficient mana
            }

            return(false);
        }
Beispiel #4
0
        public bool Cast()
        {
            m_StartCastTime = DateTime.Now;

            if ( Core.AOS && m_Caster.Spell is Spell && ((Spell)m_Caster.Spell).State == SpellState.Sequencing )
                ((Spell)m_Caster.Spell).Disturb( DisturbType.NewCast );

            if ( !m_Caster.CheckAlive() )
            {
                return false;
            }
            else if ( m_Caster.Spell != null && m_Caster.Spell.IsCasting )
            {
                m_Caster.SendAsciiMessage( "You are already casting a spell." ); // You are already casting a spell.
            }
            else if ( BlockedByHorrificBeast && TransformationSpellHelper.UnderTransformation( m_Caster, typeof( HorrificBeastSpell ) ) || ( BlockedByAnimalForm && AnimalForm.UnderTransformation( m_Caster ) ))
            {
                m_Caster.SendAsciiMessage( "You cannot cast that spell in this form." ); // You cannot cast that spell in this form.
            }
            else if (!(m_Scroll is BaseWand || m_Scroll is GnarledStaff || m_Scroll is BaseJewel || m_Scroll is BaseStationary) && (m_Caster.Paralyzed || m_Caster.Frozen))
            {
                m_Caster.SendAsciiMessage( "You can not cast a spell while frozen." ); // You can not cast a spell while frozen.
            }
            else if ( CheckNextSpellTime && DateTime.Now < m_Caster.NextSpellTime )
            {
                m_Caster.SendAsciiMessage( "You have not yet recovered from casting a spell." ); // You have not yet recovered from casting a spell.
            }
            else if (!(m_Scroll is BaseJewel) && (m_Caster.FindItemOnLayer(Layer.OneHanded) != null && !(m_Caster.FindItemOnLayer(Layer.OneHanded) is Spellbook) && !(m_Scroll is BaseWand)) || (m_Caster.FindItemOnLayer(Layer.TwoHanded) != null && (!(m_Caster.FindItemOnLayer(Layer.TwoHanded) is OrderShield) && !(m_Scroll is GnarledStaff) && !(m_Caster.FindItemOnLayer(Layer.TwoHanded) is ChaosShield))))
            {
                m_Caster.LocalOverheadMessage(MessageType.Regular, 0x22, true, "Your hands must be free to cast spells.");
                //m_Caster.SendAsciiMessage("Your hands must be free to cast spells.");
            }
            else if (m_Caster.Mana >= ScaleMana(GetMana()))
            {
                if (m_Caster.Spell == null && m_Caster.CheckSpellCast(this) && CheckCast() && m_Caster.Region.OnBeginSpellCast(m_Caster, this))
                {
                    m_State = SpellState.Casting;
                    m_Caster.Spell = this;

                    if (RevealOnCast)
                        m_Caster.RevealingAction();

                    SayMantra();

                    TimeSpan castDelay = this.GetCastDelay();

                    if (ShowHandMovement && m_Caster.Body.IsHuman)
                    {
                        int count = (int)Math.Ceiling( castDelay.TotalSeconds );//(int)Math.Ceiling( castDelay.TotalSeconds / ( AnimateDelay.TotalSeconds ) );

                        if (count != 0)
                        {
                            m_AnimTimer = new AnimTimer(this, count);
                            m_AnimTimer.Start();
                        }

                        if (m_Info.LeftHandEffect > 0)
                            Caster.FixedParticles(0, 10, 5, m_Info.LeftHandEffect, EffectLayer.LeftHand);

                        if (m_Info.RightHandEffect > 0)
                            Caster.FixedParticles(0, 10, 5, m_Info.RightHandEffect, EffectLayer.RightHand);
                    }

                    if (ClearHandsOnCast)
                        m_Caster.ClearHands();

                    m_CastTimer = new CastTimer(this, castDelay);
                    m_CastTimer.Start();

                    OnBeginCast();

                    return true;
                }
                else
                {
                    return false;
                }
            }
            else
            {
                m_Caster.LocalOverheadMessage(MessageType.Regular, 0x22, true, "Insufficient mana for this spell."); // Insufficient mana
            }

            return false;
        }
Beispiel #5
0
        public bool Cast()
        {
            m_StartCastTime = DateTime.Now;

            if (Core.AOS && m_Caster.Spell is Spell && ((Spell)m_Caster.Spell).State == SpellState.Sequencing)
            {
                ((Spell)m_Caster.Spell).Disturb(DisturbType.NewCast);
            }

            if (!m_Caster.CheckAlive())
            {
                return(false);
            }
            else if (m_Caster.Spell != null && m_Caster.Spell.IsCasting)
            {
                m_Caster.SendLocalizedMessage(502642);                 // You are already casting a spell.
            }
            //else if ( BlockedByHorrificBeast && TransformationSpell.UnderTransformation( m_Caster, typeof( HorrificBeastSpell ) ) )
            //{
            //	m_Caster.SendLocalizedMessage( 1061091 ); // You cannot cast that spell in this form.
            //}
            else if (!(m_Scroll is BaseWand) && (m_Caster.Paralyzed || m_Caster.Frozen))
            {
                m_Caster.SendLocalizedMessage(502643);                 // You can not cast a spell while frozen.
            }
            //else if ( CheckNextSpellTime && DateTime.Now < m_Caster.NextSpellTime )
            else if (DateTime.Now < m_Caster.NextSpellTime)
            {
                m_Caster.SendLocalizedMessage(502644);                 // You must wait for that spell to have an effect.
            }
            else if (m_Caster.Mana >= ScaleMana(GetMana()))
            {
                if (m_Caster.Spell == null && m_Caster.CheckSpellCast(this) && CheckCast() && m_Caster.Region.OnBeginSpellCast(m_Caster, this))
                {
                    m_State        = SpellState.Casting;
                    m_Caster.Spell = this;

                    if (RevealOnCast)
                    {
                        m_Caster.RevealingAction();
                    }

                    SayMantra();

                    TimeSpan castDelay = this.GetCastDelay();

                    // -- casting speed --
                    // ---- Individual spell timing alterations ----

                    // For FC ----
                    // adam: reverting MB to standard 5th circle casting speed.
                    //	see damage-scale  modifications to the spell
                    //if ( m_Info.Name == "Mind Blast" )
                    //castDelay = this.GetCastDelay() + TimeSpan.FromSeconds( 0.45 );
                    if (m_Info.Name == "Cure")
                    {
                        castDelay = this.GetCastDelay() + TimeSpan.FromSeconds(0.02);
                    }

                    // For FCR ----
                    if (m_Info.Name == "Heal")
                    {
                        NextSpellDelay = TimeSpan.FromSeconds(0.95);
                    }
                    else
                    {
                        NextSpellDelay = TimeSpan.FromSeconds(0.80);
                    }
                    // ----

                    if (m_Caster.Body.IsHuman)
                    {
                        int count = (int)Math.Ceiling(castDelay.TotalSeconds / AnimateDelay.TotalSeconds);

                        if (count != 0)
                        {
                            m_AnimTimer = new AnimTimer(this, count);
                            m_AnimTimer.Start();
                        }

                        if (m_Info.LeftHandEffect > 0)
                        {
                            Caster.FixedParticles(0, 10, 5, m_Info.LeftHandEffect, EffectLayer.LeftHand);
                        }

                        if (m_Info.RightHandEffect > 0)
                        {
                            Caster.FixedParticles(0, 10, 5, m_Info.RightHandEffect, EffectLayer.RightHand);
                        }
                    }

                    if (ClearHandsOnCast)
                    {
                        m_Caster.ClearHands();

                        if (m_Scroll == null && EquipSpellbookOnCast)
                        {
                            Item item = m_Caster.FindItemOnLayer(Layer.OneHanded);
                            if (item is Spellbook == false)
                            {
                                //m_Caster.SendMessage("Equipping spell book.");
                                if (m_Caster.Backpack != null)
                                {
                                    Item spellbook = m_Caster.Backpack.FindItemByType(typeof(Spellbook), false);
                                    if (spellbook != null)
                                    {
                                        m_Caster.EquipItem(spellbook);
                                    }
                                }
                            }
                        }
                    }

                    m_CastTimer = new CastTimer(this, castDelay);
                    m_CastTimer.Start();

                    OnBeginCast();

                    // If the caster is a staffmember, log the spellcasting.
                    if (m_Caster.AccessLevel > AccessLevel.Player)
                    {
                        Server.Commands.CommandLogging.LogCastSpell(m_Caster, this.Name);
                    }

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                m_Caster.LocalOverheadMessage(MessageType.Regular, 0x22, 502625);                 // Insufficient mana
            }

            return(false);
        }
Beispiel #6
0
        public bool SphereCast(Mobile from, object obj)
        {
            m_StartCastTime = DateTime.Now;

            if (m_PlayerCaster.Paralyzed && !m_PlayerCaster.HasFreeHand())
            {
                m_Caster.SendAsciiMessage(33, "You must have your hands free to cast while paralyzed!");
                return false;
            }

            if (IsCastPossible())
            {
                m_SphereSpellTarget = obj;

                if (m_Caster.CheckSpellCast(this) && CheckCast() && m_Caster.Region.OnBeginSpellCast(m_Caster, this))
                {
                    if (m_Caster is PlayerMobile && ClearHandsOnCast) //Mobiles don't need to disarm
                        m_Caster.ClearHands();

                    m_State = SpellState.Casting;

                    m_Caster.Spell = this;

                    m_PlayerCaster.WeaponTimerCheck();
                    m_PlayerCaster.BandageCheck();

                    m_PlayerCaster.AbortCurrentPlayerAction();

                    //Maka
                    if (RevealOnCast && !m_PlayerCaster.HiddenWithSpell)
                        m_Caster.RevealingAction();

                    SayMantra();

                    var castDelay = GetCastDelay();

                    var count = (int)Math.Ceiling(castDelay.TotalSeconds / AnimateDelay.TotalSeconds);

                    if (count != 0)
                    {
                        m_AnimTimer = new AnimTimer(this, 1);
                        m_AnimTimer.Start();
                    }

                    if (m_Info.LeftHandEffect > 0)
                        Caster.FixedParticles(0, 10, 5, m_Info.LeftHandEffect, EffectLayer.LeftHand);

                    if (m_Info.RightHandEffect > 0)
                        Caster.FixedParticles(0, 10, 5, m_Info.RightHandEffect, EffectLayer.RightHand);

                    if (Core.ML)
                        WeaponAbility.ClearCurrentAbility(m_Caster);

                    m_CastTimer = new CastTimer(this, castDelay);
                    m_CastTimer.Start();

                    OnBeginCast();
                    return true;
                }
                return false;
            }
            return false;
        }
Beispiel #7
0
		public bool Cast()
		{
			m_StartCastTime = Core.TickCount;

			if (Core.AOS && m_Caster.Spell is Spell && ((Spell)m_Caster.Spell).State == SpellState.Sequencing)
			{
				((Spell)m_Caster.Spell).Disturb(DisturbType.NewCast);
			}

			if (!m_Caster.CheckAlive())
			{
				return false;
			}
			else if (m_Caster is PlayerMobile && ((PlayerMobile)m_Caster).Peaced)
			{
				m_Caster.SendLocalizedMessage(1072060); // You cannot cast a spell while calmed.
			}
			else if (m_Scroll is BaseWand && m_Caster.Spell != null && m_Caster.Spell.IsCasting)
			{
				m_Caster.SendLocalizedMessage(502643); // You can not cast a spell while frozen.
			}
			else if (m_Caster.Spell != null && m_Caster.Spell.IsCasting)
			{
				m_Caster.SendLocalizedMessage(502642); // You are already casting a spell.
			}
			else if (BlockedByHorrificBeast && TransformationSpellHelper.UnderTransformation(m_Caster, typeof(HorrificBeastSpell)) ||
					 (BlockedByAnimalForm && AnimalForm.UnderTransformation(m_Caster)))
			{
				m_Caster.SendLocalizedMessage(1061091); // You cannot cast that spell in this form.
			}
			else if (!(m_Scroll is BaseWand) && (m_Caster.Paralyzed || m_Caster.Frozen))
			{
				m_Caster.SendLocalizedMessage(502643); // You can not cast a spell while frozen.
			}
			else if (CheckNextSpellTime && Core.TickCount - m_Caster.NextSpellTime < 0)
			{
				m_Caster.SendLocalizedMessage(502644); // You have not yet recovered from casting a spell.
			}
			else if (m_Caster is PlayerMobile && ((PlayerMobile)m_Caster).PeacedUntil > DateTime.UtcNow)
			{
				m_Caster.SendLocalizedMessage(1072060); // You cannot cast a spell while calmed.
			}
				#region Dueling
			else if (m_Caster is PlayerMobile && ((PlayerMobile)m_Caster).DuelContext != null &&
					 !((PlayerMobile)m_Caster).DuelContext.AllowSpellCast(m_Caster, this))
			{ }
				#endregion

			else if (m_Caster.Mana >= ScaleMana(GetMana()))
			{
				#region Stygian Abyss
				if (m_Caster.Race == Race.Gargoyle && m_Caster.Flying)
				{
					var tiles = Caster.Map.Tiles.GetStaticTiles(Caster.X, Caster.Y, true);
					ItemData itemData;
					bool cancast = true;

					for (int i = 0; i < tiles.Length && cancast; ++i)
					{
						itemData = TileData.ItemTable[tiles[i].ID & TileData.MaxItemValue];
						cancast = !(itemData.Name == "hover over");
					}

					if (!cancast)
					{
						if (m_Caster.IsPlayer())
						{
							m_Caster.SendLocalizedMessage(1113750); // You may not cast spells while flying over such precarious terrain.
							return false;
						}
						else
						{
							m_Caster.SendMessage("Your staff level allows you to cast while flying over precarious terrain.");
						}
					}
				}
				#endregion

				if (m_Caster.Spell == null && m_Caster.CheckSpellCast(this) && CheckCast() &&
					m_Caster.Region.OnBeginSpellCast(m_Caster, this))
				{
					m_State = SpellState.Casting;
					m_Caster.Spell = this;

					if (!(m_Scroll is BaseWand) && RevealOnCast)
					{
						m_Caster.RevealingAction();
					}

					SayMantra();

					TimeSpan castDelay = GetCastDelay();

					if (ShowHandMovement && (m_Caster.Body.IsHuman || (m_Caster.Player && m_Caster.Body.IsMonster)))
					{
						int count = (int)Math.Ceiling(castDelay.TotalSeconds / AnimateDelay.TotalSeconds);

						if (count != 0)
						{
							m_AnimTimer = new AnimTimer(this, count);
							m_AnimTimer.Start();
						}

						if (m_Info.LeftHandEffect > 0)
						{
							Caster.FixedParticles(0, 10, 5, m_Info.LeftHandEffect, EffectLayer.LeftHand);
						}

						if (m_Info.RightHandEffect > 0)
						{
							Caster.FixedParticles(0, 10, 5, m_Info.RightHandEffect, EffectLayer.RightHand);
						}
					}

					if (ClearHandsOnCast)
					{
						m_Caster.ClearHands();
					}

					if (Core.ML)
					{
						WeaponAbility.ClearCurrentAbility(m_Caster);
					}

					m_CastTimer = new CastTimer(this, castDelay);
					//m_CastTimer.Start();

					OnBeginCast();

					if (castDelay > TimeSpan.Zero)
					{
						m_CastTimer.Start();
					}
					else
					{
						m_CastTimer.Tick();
					}

					return true;
				}
				else
				{
					return false;
				}
			}
			else
			{
				m_Caster.LocalOverheadMessage(MessageType.Regular, 0x22, 502625); // Insufficient mana
			}

			return false;
		}
Beispiel #8
0
        public bool Cast()
        {
            m_StartCastTime = DateTime.Now;
            Spellbook book = Caster.FindItemOnLayer(Layer.OneHanded) as Spellbook;

            if (Core.AOS && m_Caster.Spell is Spell && ((Spell)m_Caster.Spell).State == SpellState.Sequencing)
            {
                ((Spell)m_Caster.Spell).Disturb(DisturbType.NewCast);
            }

            if (!m_Caster.CheckAlive())
            {
                return(false);
            }
            else if (m_Caster.Spell != null && m_Caster.Spell.IsCasting)
            {
                m_Caster.SendAsciiMessage("You are already casting a spell.");
            }
            else if (BlockedByHorrificBeast && TransformationSpell.UnderTransformation(m_Caster, typeof(HorrificBeastSpell)))
            {
                m_Caster.SendAsciiMessage("You cannot cast that spell in this form.");
            }
            else if (!(m_Scroll is BaseWand) && (m_Caster.Paralyzed || m_Caster.Frozen))
            {
                m_Caster.SendAsciiMessage("You can not cast a spell while frozen.");
            }
            else if (CheckNextSpellTime && DateTime.Now < m_Caster.NextSpellTime)
            {
                m_Caster.SendAsciiMessage("You must wait for that spell to have an effect.");
            }
            else if (m_Caster.Mana >= ScaleMana(GetMana()))
            {
                if (m_Caster.Spell == null && m_Caster.CheckSpellCast(this) && CheckCast() && m_Caster.Region.OnBeginSpellCast(m_Caster, this))
                {
                    if (Caster.Player == true && book != null && CheckSpellbook == true || Caster.Player == false || CheckSpellbook == false || (m_Scroll is BaseWand) || (m_Scroll is Items.IceStaff) || (m_Scroll is Runebook))
                    {
                        m_State        = SpellState.Casting;
                        m_Caster.Spell = this;

                        if (RevealOnCast)
                        {
                            m_Caster.RevealingAction();
                        }

                        SayMantra();

                        TimeSpan castDelay = this.GetCastDelay();

                        if (m_Caster.Body.IsHuman)
                        {
                            int count = (int)Math.Ceiling(castDelay.TotalSeconds / AnimateDelay.TotalSeconds);

                            if (count != 0)
                            {
                                m_AnimTimer = new AnimTimer(this, count);
                                m_AnimTimer.Start();
                            }

                            if (m_Info.LeftHandEffect > 0)
                            {
                                Caster.FixedParticles(0, 10, 5, m_Info.LeftHandEffect, EffectLayer.LeftHand);
                            }

                            if (m_Info.RightHandEffect > 0)
                            {
                                Caster.FixedParticles(0, 10, 5, m_Info.RightHandEffect, EffectLayer.RightHand);
                            }
                        }

                        if (ClearHandsOnCast)
                        {
                            m_Caster.ClearHands();
                        }

                        m_CastTimer = new CastTimer(this, castDelay);
                        m_CastTimer.Start();

                        OnBeginCast();

                        return(true);
                    }
                    else if (Caster.Player == true)
                    {
                        Container backpack = Caster.Backpack;

                        Spellbook spbook = (Spellbook)backpack.FindItemByType(typeof(Spellbook));
                        if (spbook != null)
                        {
                            m_Caster.ClearHands();
                            Caster.EquipItem(spbook);
                            Cast();
                        }
                    }
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                m_Caster.LocalOverheadMessage(MessageType.Regular, 0x22, 502625);                   // Insufficient mana
            }

            return(false);
        }
Beispiel #9
0
        public bool Cast()
        {
            m_StartCastTime = DateTime.Now;
            Spellbook book = Caster.FindItemOnLayer( Layer.OneHanded ) as Spellbook;

            if ( Core.AOS && m_Caster.Spell is Spell && ((Spell)m_Caster.Spell).State == SpellState.Sequencing )
                ((Spell)m_Caster.Spell).Disturb( DisturbType.NewCast );

            if ( !m_Caster.CheckAlive() )
            {
                return false;
            }
            else if ( m_Caster.Spell != null && m_Caster.Spell.IsCasting )
            {
                m_Caster.SendAsciiMessage( "You are already casting a spell." );
            }
            else if ( BlockedByHorrificBeast && TransformationSpell.UnderTransformation( m_Caster, typeof( HorrificBeastSpell ) ) )
            {
                m_Caster.SendAsciiMessage( "You cannot cast that spell in this form." );
            }
            else if ( !(m_Scroll is BaseWand) && (m_Caster.Paralyzed || m_Caster.Frozen) )
            {
                m_Caster.SendAsciiMessage( "You can not cast a spell while frozen." );
            }
            else if ( CheckNextSpellTime && DateTime.Now < m_Caster.NextSpellTime )
            {
                m_Caster.SendAsciiMessage( "You must wait for that spell to have an effect." );
            }
            else if ( m_Caster.Mana >= ScaleMana( GetMana() ) )
            {
                if ( m_Caster.Spell == null && m_Caster.CheckSpellCast( this ) && CheckCast() && m_Caster.Region.OnBeginSpellCast( m_Caster, this ) )
                {
                    if ( Caster.Player == true && book != null && CheckSpellbook == true || Caster.Player == false || CheckSpellbook == false || ( m_Scroll is BaseWand ) || ( m_Scroll is Items.IceStaff ) || ( m_Scroll is Runebook ) )
                    {
                        m_State = SpellState.Casting;
                        m_Caster.Spell = this;

                        if ( RevealOnCast )
                            m_Caster.RevealingAction();

                        SayMantra();

                        TimeSpan castDelay = this.GetCastDelay();

                        if ( m_Caster.Body.IsHuman )
                        {
                            int count = (int)Math.Ceiling( castDelay.TotalSeconds / AnimateDelay.TotalSeconds );

                            if ( count != 0 )
                            {
                                m_AnimTimer = new AnimTimer( this, count );
                                m_AnimTimer.Start();
                            }

                            if ( m_Info.LeftHandEffect > 0 )
                                Caster.FixedParticles( 0, 10, 5, m_Info.LeftHandEffect, EffectLayer.LeftHand );

                            if ( m_Info.RightHandEffect > 0 )
                                Caster.FixedParticles( 0, 10, 5, m_Info.RightHandEffect, EffectLayer.RightHand );
                        }

                        if ( ClearHandsOnCast )
                            m_Caster.ClearHands();

                        m_CastTimer = new CastTimer( this, castDelay );
                        m_CastTimer.Start();

                        OnBeginCast();

                        return true;
                    }
                    else if ( Caster.Player == true )
                    {
                          			Container backpack = Caster.Backpack;

                           			Spellbook spbook = (Spellbook) backpack.FindItemByType( typeof( Spellbook ) );
                        if ( spbook != null )
                        {
                            m_Caster.ClearHands();
                            Caster.EquipItem( spbook );
                            Cast();
                        }
                    }
                }
                else
                {
                    return false;
                }
            }
            else
            {
                m_Caster.LocalOverheadMessage( MessageType.Regular, 0x22, 502625 ); // Insufficient mana
            }

            return false;
        }
Beispiel #10
0
        public override bool Cast()
        {
            PlayerMobile pm = Caster as PlayerMobile;

            m_StartCastTime = DateTime.Now;

            Item item = Caster.FindItemOnLayer(Layer.TwoHanded);

            foreach (Item i in Caster.Backpack.Items)
            {
                if (i is BaseInstrument)
                {
                    m_Instrument = (BaseInstrument)i;
                }
            }

            if (item is BaseInstrument)
            {
                m_Instrument = (BaseInstrument)item;
            }

            if (!Caster.CheckAlive())
            {
                return(false);
            }
            else if (Caster.Spell != null && Caster.Spell.IsCasting)
            {
                Caster.SendLocalizedMessage(502642); // You are already casting a spell.
            }
            else if (Caster.Frozen)
            {
                Caster.SendLocalizedMessage(502643); // You can not cast a spell while frozen.
            }
            else if (CheckNextSpellTime && Core.TickCount < Caster.NextSpellTime)
            {
                Caster.SendLocalizedMessage(502644); // You must wait for that spell to have an effect.
            }
            else if (!(this is BardeSpell) || m_Instrument == null || (!(item is BaseInstrument) && !(item == null)))
            {
                Caster.SendMessage("Vous devez avoir un instrument dans les mains pour utiliser cette faculté.");
            }
            else if (CheckFizzle())
            {
                if (m_Instrument != null && Caster.Spell == null && Caster.CheckSpellCast(this) && CheckCast() && Caster.Region.OnBeginSpellCast(Caster, this))
                {
                    State        = SpellState.Casting;
                    Caster.Spell = this;

                    if (RevealOnCast)
                    {
                        Caster.RevealingAction();
                    }

                    TimeSpan castDelay = this.GetCastDelay();

                    m_Instrument.PlayInstrumentWell(Caster);

                    m_CastTimer = new CastTimer(this, castDelay);
                    m_CastTimer.Start();

                    return(true);
                }
                else
                {
                    Caster.Freeze(TimeSpan.FromSeconds(4));
                    m_Instrument.PlayInstrumentBadly(Caster);
                    return(false);
                }
            }
            else if (m_Instrument != null)
            {
                Caster.Freeze(TimeSpan.FromSeconds(4));
                m_Instrument.PlayInstrumentBadly(Caster);
            }

            return(false);
        }
Beispiel #11
0
        public bool Cast()
        {
            m_StartCastTime = DateTime.Now;

            if (Core.AOS && m_Caster.Spell is Spell && ((Spell)m_Caster.Spell).State == SpellState.Sequencing)
            {
                ((Spell)m_Caster.Spell).Disturb(DisturbType.NewCast);
            }

            if (!m_Caster.CheckAlive())
            {
                return(false);
            }
            else if (m_Caster.Spell != null && m_Caster.Spell.IsCasting)
            {
                m_Caster.SendAsciiMessage("You are already casting a spell.");                   // You are already casting a spell.
            }
            else if (BlockedByHorrificBeast && TransformationSpellHelper.UnderTransformation(m_Caster, typeof(HorrificBeastSpell)) || (BlockedByAnimalForm && AnimalForm.UnderTransformation(m_Caster)))
            {
                m_Caster.SendAsciiMessage("You cannot cast that spell in this form.");                   // You cannot cast that spell in this form.
            }
            else if (!(m_Scroll is BaseWand || m_Scroll is GnarledStaff || m_Scroll is BaseJewel || m_Scroll is BaseStationary) && (m_Caster.Paralyzed || m_Caster.Frozen))
            {
                m_Caster.SendAsciiMessage("You can not cast a spell while frozen.");                   // You can not cast a spell while frozen.
            }
            else if (CheckNextSpellTime && DateTime.Now < m_Caster.NextSpellTime)
            {
                m_Caster.SendAsciiMessage("You have not yet recovered from casting a spell.");                   // You have not yet recovered from casting a spell.
            }
            else if (!(m_Scroll is BaseJewel) && (m_Caster.FindItemOnLayer(Layer.OneHanded) != null && !(m_Caster.FindItemOnLayer(Layer.OneHanded) is Spellbook) && !(m_Scroll is BaseWand)) || (m_Caster.FindItemOnLayer(Layer.TwoHanded) != null && (!(m_Caster.FindItemOnLayer(Layer.TwoHanded) is OrderShield) && !(m_Scroll is GnarledStaff) && !(m_Caster.FindItemOnLayer(Layer.TwoHanded) is ChaosShield))))
            {
                m_Caster.LocalOverheadMessage(MessageType.Regular, 0x22, true, "Your hands must be free to cast spells.");
                //m_Caster.SendAsciiMessage("Your hands must be free to cast spells.");
            }
            else if (m_Caster.Mana >= ScaleMana(GetMana()))
            {
                if (m_Caster.Spell == null && m_Caster.CheckSpellCast(this) && CheckCast() && m_Caster.Region.OnBeginSpellCast(m_Caster, this))
                {
                    m_State        = SpellState.Casting;
                    m_Caster.Spell = this;

                    if (RevealOnCast)
                    {
                        m_Caster.RevealingAction();
                    }

                    SayMantra();

                    TimeSpan castDelay = this.GetCastDelay();

                    if (ShowHandMovement && m_Caster.Body.IsHuman)
                    {
                        int count = (int)Math.Ceiling(castDelay.TotalSeconds);  //(int)Math.Ceiling( castDelay.TotalSeconds / ( AnimateDelay.TotalSeconds ) );

                        if (count != 0)
                        {
                            m_AnimTimer = new AnimTimer(this, count);
                            m_AnimTimer.Start();
                        }

                        if (m_Info.LeftHandEffect > 0)
                        {
                            Caster.FixedParticles(0, 10, 5, m_Info.LeftHandEffect, EffectLayer.LeftHand);
                        }

                        if (m_Info.RightHandEffect > 0)
                        {
                            Caster.FixedParticles(0, 10, 5, m_Info.RightHandEffect, EffectLayer.RightHand);
                        }
                    }

                    if (ClearHandsOnCast)
                    {
                        m_Caster.ClearHands();
                    }

                    m_CastTimer = new CastTimer(this, castDelay);
                    m_CastTimer.Start();

                    OnBeginCast();

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                m_Caster.LocalOverheadMessage(MessageType.Regular, 0x22, true, "Insufficient mana for this spell."); // Insufficient mana
            }

            return(false);
        }
        public bool Cast()
        {
            this.m_StartCastTime = DateTime.UtcNow;

            if (Core.AOS && this.m_Caster.Spell is Spell && ((Spell)this.m_Caster.Spell).State == SpellState.Sequencing)
            {
                ((Spell)this.m_Caster.Spell).Disturb(DisturbType.NewCast);
            }

            if (!this.m_Caster.CheckAlive())
            {
                return(false);
            }

            /*else if (this.m_Caster is PlayerMobile && ((PlayerMobile)this.m_Caster).Peaced)
             * {
             *      this.m_Caster.SendLocalizedMessage(1072060); // You cannot cast a spell while calmed.
             * }
             */
            else if (this.m_Scroll is BaseWand && this.m_Caster.Spell != null && this.m_Caster.Spell.IsCasting)
            {
                this.m_Caster.SendLocalizedMessage(502643);                 // You can not cast a spell while frozen.
            }
            else if (this.m_Caster.Spell != null && this.m_Caster.Spell.IsCasting)
            {
                this.m_Caster.SendLocalizedMessage(502642);                 // You are already casting a spell.
            }
            else if (this.BlockedByHorrificBeast && TransformationSpellHelper.UnderTransformation(this.m_Caster, typeof(HorrificBeastSpell)) || (this.BlockedByAnimalForm && AnimalForm.UnderTransformation(this.m_Caster)))
            {
                this.m_Caster.SendLocalizedMessage(1061091);                 // You cannot cast that spell in this form.
            }
            else if (!(this.m_Scroll is BaseWand) && (this.m_Caster.Paralyzed || this.m_Caster.Frozen))
            {
                this.m_Caster.SendLocalizedMessage(502643);                 // You can not cast a spell while frozen.
            }
            else if (m_Caster.Spell != null && m_Caster.Spell.IsCasting)
            {
                this.m_Caster.SendLocalizedMessage(502644);                 // You have not yet recovered from casting a spell.
            }

            /**	else if (this.m_Caster is PlayerMobile && ((PlayerMobile)this.m_Caster).PeacedUntil > DateTime.Now)
             *      {
             *              this.m_Caster.SendLocalizedMessage(1072060); // You cannot cast a spell while calmed.
             *      }*/

            #region Dueling
            else if (this.m_Caster is PlayerMobile && ((PlayerMobile)this.m_Caster).DuelContext != null && !((PlayerMobile)this.m_Caster).DuelContext.AllowSpellCast(this.m_Caster, this))
            {
            }
            #endregion
            else if (this.m_Caster.Mana >= this.ScaleMana(this.GetMana()))
            {
                #region Stygian Abyss
                if (this.m_Caster.Race == Race.Gargoyle && this.m_Caster.Flying)
                {
                    StaticTile[] tiles = this.Caster.Map.Tiles.GetStaticTiles(this.Caster.X, this.Caster.Y, true);
                    ItemData     itemData;
                    bool         cancast = true;

                    for (int i = 0; i < tiles.Length && cancast; ++i)
                    {
                        itemData = TileData.ItemTable[tiles[i].ID & TileData.MaxItemValue];
                        cancast  = !(itemData.Name == "hover over");
                    }

                    if (!cancast)
                    {
                        if (this.m_Caster.IsPlayer())
                        {
                            this.m_Caster.SendLocalizedMessage(1113750);                             // You may not cast spells while flying over such precarious terrain.
                            return(false);
                        }
                        else
                        {
                            this.m_Caster.SendMessage("Your staff level allows you to cast while flying over precarious terrain.");
                        }
                    }
                }
                #endregion

                if (this.m_Caster.Spell == null && this.m_Caster.CheckSpellCast(this) && this.CheckCast() && this.m_Caster.Region.OnBeginSpellCast(this.m_Caster, this))
                {
                    this.m_State        = SpellState.Casting;
                    this.m_Caster.Spell = this;

                    if (!(this.m_Scroll is BaseWand) && this.RevealOnCast)
                    {
                        this.m_Caster.RevealingAction();
                    }

                    this.SayMantra();

                    TimeSpan castDelay = this.GetCastDelay();

                    if (this.ShowHandMovement && (this.m_Caster.Body.IsHuman || (this.m_Caster.Player && this.m_Caster.Body.IsMonster)))
                    {
                        int count = (int)Math.Ceiling(castDelay.TotalSeconds / AnimateDelay.TotalSeconds);

                        if (count != 0)
                        {
                            this.m_AnimTimer = new AnimTimer(this, count);
                            this.m_AnimTimer.Start();
                        }

                        if (this.m_Info.LeftHandEffect > 0)
                        {
                            this.Caster.FixedParticles(0, 10, 5, this.m_Info.LeftHandEffect, EffectLayer.LeftHand);
                        }

                        if (this.m_Info.RightHandEffect > 0)
                        {
                            this.Caster.FixedParticles(0, 10, 5, this.m_Info.RightHandEffect, EffectLayer.RightHand);
                        }
                    }

                    if (this.ClearHandsOnCast)
                    {
                        this.m_Caster.ClearHands();
                    }

                    if (Core.ML)
                    {
                        WeaponAbility.ClearCurrentAbility(this.m_Caster);
                    }

                    this.m_CastTimer = new CastTimer(this, castDelay);
                    //this.m_CastTimer.Start();

                    this.OnBeginCast();

                    if (castDelay > TimeSpan.Zero)
                    {
                        this.m_CastTimer.Start();
                    }
                    else
                    {
                        this.m_CastTimer.Tick();
                    }

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                this.m_Caster.LocalOverheadMessage(MessageType.Regular, 0x22, 502625);                 // Insufficient mana
            }

            return(false);
        }
      public bool Cast()
      {
         if ( Core.AOS && m_Caster.Spell is Spell && ((Spell)m_Caster.Spell).State == SpellState.Sequencing )
            ((Spell)m_Caster.Spell).Disturb( DisturbType.NewCast );

         if ( !m_Caster.CheckAlive() )
         {
            return false;
         }
         else if ( m_Caster.Spell != null && m_Caster.Spell.IsCasting )
         {
            m_Caster.SendLocalizedMessage( 502642 ); // You are already casting a spell.
         }
         else if ( BlockedByHorrificBeast && TransformationSpell.UnderTransformation( m_Caster, typeof( HorrificBeastSpell ) ) )
         {
            m_Caster.SendLocalizedMessage( 1061091 ); // You cannot cast that spell in this form.
         }
         else if ( !(m_Scroll is BaseWand) && (m_Caster.Paralyzed || m_Caster.Frozen) )
         {
            m_Caster.SendLocalizedMessage( 502643 ); // You can not cast a spell while frozen.
         }
         else if ( !(m_Scroll is BaseWand) && DateTime.Now < m_Caster.NextSpellTime )
         {
            m_Caster.SendLocalizedMessage( 502642 ); // You must wait for that spell to have an effect.
         }
            //ADDED FOR STAFF ENDLESS MANA
         else if (m_Caster.Mana >= ScaleMana(GetMana()) || m_Caster.AccessLevel > AccessLevel.Player)
         {
            if ( m_Caster.Spell == null && m_Caster.CheckSpellCast( this ) && CheckCast() && m_Caster.Region.OnBeginSpellCast( m_Caster, this ) )
            {
               m_State = SpellState.Casting;
               m_Caster.Spell = this;

               if ( RevealOnCast )
                  m_Caster.RevealingAction();

               SayMantra();

               TimeSpan castDelay = this.GetCastDelay();

               if ( m_Caster.Body.IsHuman )
               {
                  int count = (int)Math.Ceiling( castDelay.TotalSeconds / AnimateDelay.TotalSeconds );

                  if ( count != 0 )
                  {
                     m_AnimTimer = new AnimTimer( this, count );
                     m_AnimTimer.Start();
                  }

                  if ( m_Info.LeftHandEffect > 0 )
                     Caster.FixedParticles( 0, 10, 5, m_Info.LeftHandEffect, EffectLayer.LeftHand );

                  if ( m_Info.RightHandEffect > 0 )
                     Caster.FixedParticles( 0, 10, 5, m_Info.RightHandEffect, EffectLayer.RightHand );
               }

               if ( ClearHandsOnCast )
                  m_Caster.ClearHands();

               m_CastTimer = new CastTimer( this, castDelay );
               m_CastTimer.Start();

               m_CastStartTime = DateTime.Now;

               OnBeginCast();

               return true;
            }
            else
            {
               return false;
            }
         }
         else
         {
            m_Caster.LocalOverheadMessage( MessageType.Regular, 0x22, 502625 ); // Insufficient mana
         }

         return false;
      }
Beispiel #14
0
        public bool Cast()
        {
            m_StartCastTime = DateTime.UtcNow;

            if (m_Caster.Player)
            {
                PlayerMobile player = m_Caster as PlayerMobile;

                if (!ArenaFight.AttemptSpellUsage(player, this.GetType()))
                {
                    return(false);
                }

                Item item = m_Caster.FindItemOnLayer(Layer.OneHanded);

                if (item != null && !(item is Spellbook) && !(item is Runebook) && !(item is BaseWand))
                {
                    m_Caster.SendLocalizedMessage(502626); // Your hands must be free to cast spells or meditate
                    return(false);
                }

                item = m_Caster.FindItemOnLayer(Layer.TwoHanded);

                if (item != null && !(item is Spellbook) && !(item is Runebook))
                {
                    m_Caster.SendLocalizedMessage(502626); // Your hands must be free to cast spells or meditate
                    return(false);
                }
            }

            if (!m_Caster.CheckAlive())
            {
                return(false);
            }

            else if (m_Scroll is BaseWand && m_Caster.Spell != null && m_Caster.Spell.IsCasting)
            {
                m_Caster.SendLocalizedMessage(502643); // You can not cast a spell while frozen.
            }
            else if (m_Caster.Spell != null && m_Caster.Spell.IsCasting)
            {
                m_Caster.SendLocalizedMessage(502642); // You are already casting a spell.
            }
            else if (!(m_Scroll is BaseWand) && (m_Caster.Paralyzed || m_Caster.Frozen || m_Caster.IsHindered()))
            {
                m_Caster.SendLocalizedMessage(502643); // You can not cast a spell while frozen.
            }
            else if (CheckNextSpellTime && DateTime.UtcNow < m_Caster.NextSpellTime)
            {
                m_Caster.SendLocalizedMessage(502644); // You have not yet recovered from casting a spell.
            }
            else if (m_Caster.Mana >= ScaleMana(GetMana()))
            {
                if (m_Caster.Spell == null && m_Caster.CheckSpellCast(this) && CheckCast() && m_Caster.Region.OnBeginSpellCast(m_Caster, this))
                {
                    m_State        = SpellState.Casting;
                    m_Caster.Spell = this;

                    if (RevealOnCast)
                    {
                        m_Caster.RevealingAction();
                    }

                    SayMantra();

                    TimeSpan castDelay = this.GetCastDelay();

                    int count = (int)Math.Ceiling(castDelay.TotalSeconds / AnimateDelay.TotalSeconds);

                    if (ShowHandMovement && m_Caster.Body.IsHuman && m_Caster.Player)
                    {
                        if (count != 0)
                        {
                            m_AnimTimer = new AnimTimer(this, count);
                            m_AnimTimer.Start();
                        }

                        if (m_Info.LeftHandEffect > 0)
                        {
                            Caster.FixedParticles(0, 10, 5, m_Info.LeftHandEffect, EffectLayer.LeftHand);
                        }

                        if (m_Info.RightHandEffect > 0)
                        {
                            Caster.FixedParticles(0, 10, 5, m_Info.RightHandEffect, EffectLayer.RightHand);
                        }
                    }

                    //Creature Casting
                    else if (m_Caster is BaseCreature)
                    {
                        if (count != 0)
                        {
                            BaseCreature creature = m_Caster as BaseCreature;

                            //Animation Duration
                            double castDelayInSeconds = castDelay.TotalSeconds;
                            double spellSpeedSCalar   = creature.SpellSpeedScalar;

                            castDelay = castDelay + TimeSpan.FromSeconds(castDelayInSeconds * .4 * spellSpeedSCalar);

                            count = (int)Math.Ceiling((castDelay.TotalSeconds) / AnimateDelay.TotalSeconds);

                            if (count > 0)
                            {
                                m_AnimTimer = new AnimTimer(this, count);
                                m_AnimTimer.Start();
                            }

                            //Next Spellcast Allowed Delay
                            double speedScalar = 1 + creature.GetSpecialAbilityEntryValue(SpecialAbilityEffect.Cripple);

                            double mageryModifier     = 1.0;
                            double experienceModifier = 1.0;

                            if (creature.Controlled && creature.ControlMaster is PlayerMobile)
                            {
                                mageryModifier     = 1 / creature.TamedBaseMageryCreationScalar;
                                experienceModifier = 1 - (.20 * creature.GetExperienceScalar());
                            }

                            double SpellDelay = (creature.SpellDelayMin + ((creature.SpellDelayMax - creature.SpellDelayMin) * Utility.RandomDouble())) * speedScalar * mageryModifier * experienceModifier;

                            if (SpellDelay < .1)
                            {
                                SpellDelay = .1;
                            }

                            creature.NextSpellTime = DateTime.UtcNow + TimeSpan.FromSeconds(castDelay.TotalSeconds) + TimeSpan.FromSeconds(SpellDelay);
                        }
                    }

                    //Players Clear Hands / NPCs keep weapons equipped when casting
                    if (ClearHandsOnCast && m_Caster is PlayerMobile)
                    {
                        m_Caster.ClearHands();
                    }

                    //Increase SwingDelay for BaseCreatures While Casting
                    if (m_Caster is BaseCreature)
                    {
                        BaseWeapon weapon = m_Caster.Weapon as BaseWeapon;

                        if (weapon != null)
                        {
                            m_Caster.LastSwingTime = DateTime.UtcNow + TimeSpan.FromSeconds((double)count);
                        }
                    }

                    m_CastTimer = new CastTimer(this, castDelay);

                    OnBeginCast();

                    if (castDelay > TimeSpan.Zero)
                    {
                        m_CastTimer.Start();
                    }

                    else
                    {
                        m_CastTimer.Tick();
                    }

                    return(true);
                }

                else
                {
                    return(false);
                }
            }

            else
            {
                m_Caster.LocalOverheadMessage(MessageType.Regular, 0x22, 502625); // Insufficient mana
            }
            return(false);
        }
Beispiel #15
0
        public bool Cast()
        {
            m_StartCastTime = DateTime.Now;

            if ( !m_Caster.CheckAlive() )
            {
                return false;
            }
            else if ( m_Caster.Spell != null && m_Caster.Spell.IsCasting )
            {
                m_Caster.SendLocalizedMessage( 502642 ); // You are already casting a spell.
            }
            else if ( m_Caster.Paralyzed || m_Caster.Frozen )
            {
                m_Caster.SendLocalizedMessage( 502643 ); // You can not cast a spell while frozen.
            }
            else if ( CheckNextSpellTime && DateTime.Now < m_Caster.NextSpellTime )
            {
                m_Caster.SendLocalizedMessage( 502644 ); // You must wait for that spell to have an effect.
            }
            else if ( m_Caster.Mana >= ScaleMana( GetMana() ) )
            {
                if ( m_Caster.Spell == null && m_Caster.CheckSpellCast( this ) && CheckCast() && m_Caster.Region.OnBeginSpellCast( m_Caster, this ) )
                {
                    m_State = SpellState.Casting;
                    m_Caster.Spell = this;

                    if ( RevealOnCast )
                        m_Caster.RevealingAction();

                    SayMantra();

                    TimeSpan castDelay = this.GetCastDelay();

                    if ( m_Caster.Body.IsHuman )
                    {
                        int count = (int)Math.Ceiling( castDelay.TotalSeconds / AnimateDelay.TotalSeconds );

                        if ( count != 0 )
                        {
                            m_AnimTimer = new AnimTimer( this, count );
                            m_AnimTimer.Start();
                        }

                        if ( m_Info.LeftHandEffect > 0 )
                            Caster.FixedParticles( 0, 10, 5, m_Info.LeftHandEffect, EffectLayer.LeftHand );

                        if ( m_Info.RightHandEffect > 0 )
                            Caster.FixedParticles( 0, 10, 5, m_Info.RightHandEffect, EffectLayer.RightHand );
                    }

                    if ( ClearHandsOnCast )
                        m_Caster.ClearHands();

                    m_CastTimer = new CastTimer( this, castDelay );
                    m_CastTimer.Start();

                    OnBeginCast();

                    return true;
                }
                else
                {
                    return false;
                }
            }
            else
            {
                m_Caster.LocalOverheadMessage( MessageType.Regular, 0x22, 502625 ); // Insufficient mana
            }

            return false;
        }
Beispiel #16
0
        public bool Cast()
        {
            m_StartCastTime = DateTime.Now;

            if( Core.AOS && m_Caster.Spell is Spell && ((Spell)m_Caster.Spell).State == SpellState.Sequencing )
                ((Spell)m_Caster.Spell).Disturb(DisturbType.NewCast);

            if( !m_Caster.CheckAlive() )
            {
                return false;
            }
            else if( m_Caster.Spell != null && m_Caster.Spell.IsCasting )
            {
                m_Caster.SendLocalizedMessage(502642); // You are already casting a spell.
            }
            else if( !(m_Scroll is BaseWand) && (m_Caster.Paralyzed || m_Caster.Frozen) )
            {
                m_Caster.SendLocalizedMessage(502643); // You can not cast a spell while frozen.
            }
            else if( CheckNextSpellTime && DateTime.Now < m_Caster.NextSpellTime )
            {
                m_Caster.SendLocalizedMessage(502644); // You have not yet recovered from casting a spell.
            }
            else if( m_Caster is PlayerMobile && ((PlayerMobile)m_Caster).PeacedUntil > DateTime.Now )
            {
                m_Caster.SendLocalizedMessage(1072060); // You cannot cast a spell while calmed.
            }
            else if( m_Caster.Mana >= ScaleMana(GetMana()) )
            {
                if( m_Caster.Spell == null && m_Caster.CheckSpellCast(this) && CheckCast() && m_Caster.Region.OnBeginSpellCast(m_Caster, this) )
                {
                    if( m_Caster.Player )
                    {
                        SpellCastEventArgs args = new SpellCastEventArgs((Player)Caster, this);
                        EventDispatcher.InvokeSpellCast(args);

                        if( args.Blocked )
                            return false;
                    }

                    m_State = SpellState.Casting;
                    m_Caster.Spell = this;

                    if( !(m_Scroll is BaseWand) && RevealOnCast )
                        m_Caster.RevealingAction();

                    SayMantra();

                    TimeSpan castDelay = this.GetCastDelay();

                    if( ShowHandMovement && (m_Caster.Body.IsHuman || (m_Caster.Player && m_Caster.Body.IsMonster)) )
                    {
                        int count = (int)Math.Ceiling(castDelay.TotalSeconds / AnimateDelay.TotalSeconds);
                        bool animate = true;

                        if (m_Caster is Player)
                        {
                            Arcanite arc = Perk.GetByType<Arcanite>((Player)m_Caster);

                            if (arc != null)
                            {
                                if (arc.EtherealKenetics())
                                    animate = false;
                            }
                        }

                        if( count != 0 && animate )
                        {
                            m_AnimTimer = new AnimTimer(this, count);
                            m_AnimTimer.Start();
                        }

                        if( m_Info.LeftHandEffect > 0 )
                            Caster.FixedParticles(0, 10, 5, m_Info.LeftHandEffect, EffectLayer.LeftHand);

                        if( m_Info.RightHandEffect > 0 )
                            Caster.FixedParticles(0, 10, 5, m_Info.RightHandEffect, EffectLayer.RightHand);
                    }

                    if( ClearHandsOnCast )
                        m_Caster.ClearHands();

                    m_CastTimer = new CastTimer(this, castDelay);
                    //m_CastTimer.Start();

                    OnBeginCast();

                    if( castDelay > TimeSpan.Zero )
                    {
                        m_CastTimer.Start();
                    }
                    else
                    {
                        m_CastTimer.Tick();
                    }

                    return true;
                }
                else
                {
                    return false;
                }
            }
            else
            {
                m_Caster.LocalOverheadMessage(MessageType.Regular, 0x22, 502625); // Insufficient mana
            }

            return false;
        }
Beispiel #17
0
        public bool Cast()
        {
            m_StartCastTime = DateTime.Now;

            if (!m_Caster.CheckAlive())
            {
                return(false);
            }
            else if (m_Scroll is BaseWand && m_Caster.Spell != null && m_Caster.Spell.IsCasting)
            {
                m_Caster.SendLocalizedMessage(502643);                   // You can not cast a spell while frozen.
            }
            else if (m_Caster.Spell != null && m_Caster.Spell.IsCasting)
            {
                m_Caster.SendLocalizedMessage(502642);                   // You are already casting a spell.
            }
            else if (!(m_Scroll is BaseWand) && (m_Caster.Paralyzed || m_Caster.Frozen))
            {
                m_Caster.SendLocalizedMessage(502643);                   // You can not cast a spell while frozen.
            }
            else if (CheckNextSpellTime && DateTime.Now < m_Caster.NextSpellTime)
            {
                m_Caster.SendLocalizedMessage(502644);                   // You have not yet recovered from casting a spell.
            }
            else if (m_Caster is PlayerMobile && ((PlayerMobile)m_Caster).PeacedUntil > DateTime.Now)
            {
                m_Caster.SendLocalizedMessage(1072060);                   // You cannot cast a spell while calmed.
            }
            else if (m_Caster.Mana >= GetMana())
            {
                if (m_Caster.Spell == null && m_Caster.CheckSpellCast(this) && CheckCast() && m_Caster.Region.OnBeginSpellCast(m_Caster, this))
                {
                    m_State        = SpellState.Casting;
                    m_Caster.Spell = this;

                    if (!(m_Scroll is BaseWand) && RevealOnCast)
                    {
                        m_Caster.RevealingAction();
                    }

                    SayMantra();

                    TimeSpan castDelay = this.GetCastDelay();

                    if (ShowHandMovement && (m_Caster.Body.IsHuman || m_Caster.Player && m_Caster.Body.IsMonster))
                    {
                        int count = (int)Math.Ceiling(castDelay.TotalSeconds / AnimateDelay.TotalSeconds);

                        if (count != 0)
                        {
                            m_AnimTimer = new AnimTimer(this, count);
                            m_AnimTimer.Start();
                        }

                        if (m_Info.LeftHandEffect > 0)
                        {
                            Caster.FixedParticles(0, 10, 5, m_Info.LeftHandEffect, EffectLayer.LeftHand);
                        }

                        if (m_Info.RightHandEffect > 0)
                        {
                            Caster.FixedParticles(0, 10, 5, m_Info.RightHandEffect, EffectLayer.RightHand);
                        }
                    }

                    if (ClearHandsOnCast)
                    {
                        m_Caster.ClearHands();
                    }

                    m_CastTimer = new CastTimer(this, castDelay);
                    //m_CastTimer.Start();

                    OnBeginCast();

                    if (castDelay > TimeSpan.Zero)
                    {
                        m_CastTimer.Start();
                    }
                    else
                    {
                        m_CastTimer.Tick();
                    }

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                m_Caster.LocalOverheadMessage(MessageType.Regular, 0x22, 502625);                   // Insufficient mana
            }

            return(false);
        }
Beispiel #18
0
        public bool Cast()
        {
            bool GoblinHarm   = false;
            bool TalathasHarm = false;

            if (m_Caster.Player)
            {
                TeiravonMobile m_Person = (TeiravonMobile)m_Caster;

                if (this is HarmSpell && m_Person.Faith == TeiravonMobile.Deity.Jareth)
                {
                    GoblinHarm = true;
                }

                if (this is HarmSpell && m_Person.Faith == TeiravonMobile.Deity.Talathas)
                {
                    TalathasHarm = true;
                }
                //m_Person.SendMessage( "Type: {0}", this /*, m_Caster.Spell.GetType() */ );

                if (!m_Person.Magicable && !(m_Scroll is BaseWand) && !m_Person.HasFeat(TeiravonMobile.Feats.UseMagicDevice))
                {
                    m_Caster.SendMessage("You cannot cast spells.");
                    return(false);
                }
//				else if ( (this is NecromancerSpell) && !m_Person.IsNecromancer() )
//				{
//					m_Caster.SendMessage( "Only necromancers can cast that." );
//					return false;
//				}
                else if ((this is PaladinSpell) && m_Person.Skills.Chivalry.Base < 25.0)
                {
                    m_Caster.SendMessage("Only a true paladin can cast that.");
                    return(false);
                }
                else if ((this is NecromancerSpell) && !m_Person.HasFeat(TeiravonMobile.Feats.NecroSpellbook))
                {
                    m_Caster.SendMessage("You have not learned advanced necromancy.");
                    return(false);
                }
                else if (!(this is NecromancerSpell) && !(this is PaladinSpell) && !m_Person.CanCast(m_Info.Name) && !m_Person.HasFeat(TeiravonMobile.Feats.UseMagicDevice))
                {
                    m_Caster.SendMessage("You cannot cast this spell!");
                    return(false);
                }

                if (m_Person.Mounted)
                {
                    int fallchance = 0;

                    if (m_Person.RidingSkill == 0)
                    {
                        fallchance = 20;
                    }
                    else if (m_Person.RidingSkill == 1)
                    {
                        fallchance = 10;
                    }
                    else if (m_Person.RidingSkill == 2)
                    {
                        fallchance = 5;
                    }

                    if (fallchance > Utility.RandomMinMax(1, 100))
                    {
                        m_Person.OnDoubleClick(m_Person);
                        m_Person.Damage(Utility.RandomMinMax(1, 10), m_Person);
                        m_Person.SendMessage("You fall off your mount while casting");
                    }
                }
            }

            m_StartCastTime = DateTime.Now;

            if (Core.AOS && m_Caster.Spell is Spell && ((Spell)m_Caster.Spell).State == SpellState.Sequencing)
            {
                ((Spell)m_Caster.Spell).Disturb(DisturbType.NewCast);
            }

            if (!m_Caster.CheckAlive())
            {
                return(false);
            }
            else if (XmlAttach.FindAttachmentOnMobile(m_Caster, typeof(XmlData), "silenced") != null)
            {
                m_Caster.SendMessage("You cannot cast spells right now.");
                return(false);
            }
            else if (m_Caster.Spell != null && m_Caster.Spell.IsCasting)
            {
                m_Caster.SendLocalizedMessage(502642);                   // You are already casting a spell.
            }
            else if (BlockedByHorrificBeast && TransformationSpell.UnderTransformation(m_Caster, typeof(HorrificBeastSpell)))
            {
                m_Caster.SendLocalizedMessage(1061091);                   // You cannot cast that spell in this form.
            }
            else if (!(m_Scroll is BaseWand) && (m_Caster.Paralyzed || m_Caster.Frozen))
            {
                m_Caster.SendLocalizedMessage(502643);                   // You can not cast a spell while frozen.
            }
            else if (CheckNextSpellTime && DateTime.Now < m_Caster.NextSpellTime)
            {
                m_Caster.SendLocalizedMessage(502644);                   // You must wait for that spell to have an effect.
            }
            else if (m_Caster.Mana >= ScaleMana(GetMana()))
            {
                if (m_Caster.Spell == null && m_Caster.CheckSpellCast(this) && CheckCast() && m_Caster.Region.OnBeginSpellCast(m_Caster, this))
                {
                    m_State        = SpellState.Casting;
                    m_Caster.Spell = this;

                    if (RevealOnCast)
                    {
                        m_Caster.RevealingAction();
                    }

                    //SayMantra();

                    TimeSpan castDelay = this.GetCastDelay();

                    if (GoblinHarm)
                    {
                        castDelay = TimeSpan.FromSeconds(.25);
                    }

                    if (TalathasHarm)
                    {
                        castDelay = TimeSpan.FromSeconds(.5);
                    }

                    if (m_Caster.Body.IsHuman)
                    {
                        int count = (int)Math.Ceiling(castDelay.TotalSeconds / AnimateDelay.TotalSeconds);

                        if (count != 0)
                        {
                            m_AnimTimer = new AnimTimer(this, count);
                            m_AnimTimer.Start();
                        }

                        if (m_Info.LeftHandEffect > 0)
                        {
                            Caster.FixedParticles(0, 10, 5, m_Info.LeftHandEffect, EffectLayer.LeftHand);
                        }

                        if (m_Info.RightHandEffect > 0)
                        {
                            Caster.FixedParticles(0, 10, 5, m_Info.RightHandEffect, EffectLayer.RightHand);
                        }
                    }

                    if (ClearHandsOnCast)
                    {
                        m_Caster.ClearHands();
                    }

                    m_CastTimer = new CastTimer(this, castDelay);
                    m_CastTimer.Start();

                    OnBeginCast();

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                m_Caster.LocalOverheadMessage(MessageType.Regular, 0x22, 502625);                   // Insufficient mana
            }

            return(false);
        }
Beispiel #19
0
        }                                                                     //return !(m_Scroll is BaseWand); } }

        public bool Cast()
        {
            m_StartCastTime = DateTime.Now;

            if (!m_Caster.CheckAlive())
            {
                return(false);
            }
            else if (m_Caster.Spell != null && m_Caster.Spell.IsCasting)
            {
                m_Caster.SendLocalizedMessage(502642);                   // You are already casting a spell.
            }
            else if (m_Caster.Paralyzed || m_Caster.Frozen)
            {
                m_Caster.SendLocalizedMessage(502643);                   // You can not cast a spell while frozen.
            }
            else if (CheckNextSpellTime && DateTime.Now < m_Caster.NextSpellTime)
            {
                m_Caster.SendLocalizedMessage(502644);                   // You must wait for that spell to have an effect.
            }
            else if (m_Caster.Mana >= ScaleMana(GetMana()))
            {
                if (m_Caster.Spell == null && m_Caster.CheckSpellCast(this) && CheckCast() && m_Caster.Region.OnBeginSpellCast(m_Caster, this))
                {
                    m_State        = SpellState.Casting;
                    m_Caster.Spell = this;

                    if (RevealOnCast)
                    {
                        m_Caster.RevealingAction();
                    }

                    SayMantra();

                    TimeSpan castDelay = this.GetCastDelay();

                    if (m_Caster.Body.IsHuman)
                    {
                        int count = (int)Math.Ceiling(castDelay.TotalSeconds / AnimateDelay.TotalSeconds);

                        if (count != 0)
                        {
                            m_AnimTimer = new AnimTimer(this, count);
                            m_AnimTimer.Start();
                        }

                        if (m_Info.LeftHandEffect > 0)
                        {
                            Caster.FixedParticles(0, 10, 5, m_Info.LeftHandEffect, EffectLayer.LeftHand);
                        }

                        if (m_Info.RightHandEffect > 0)
                        {
                            Caster.FixedParticles(0, 10, 5, m_Info.RightHandEffect, EffectLayer.RightHand);
                        }
                    }

                    if (ClearHandsOnCast)
                    {
                        m_Caster.ClearHands();
                    }

                    m_CastTimer = new CastTimer(this, castDelay);
                    m_CastTimer.Start();

                    OnBeginCast();

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                m_Caster.LocalOverheadMessage(MessageType.Regular, 0x22, 502625);                   // Insufficient mana
            }

            return(false);
        }
Beispiel #20
0
        public bool SphereCast(Mobile from, object obj)
        {
            m_StartCastTime = DateTime.UtcNow;

            if (m_PlayerCaster.Paralyzed && !m_PlayerCaster.HasFreeHand())
            {
                m_Caster.SendAsciiMessage(33, "You must have your hands free to cast while paralyzed!");
                return(false);
            }

            if (IsCastPossible())
            {
                m_SphereSpellTarget = obj;

                if (m_Caster.CheckSpellCast(this) && CheckCast() && m_Caster.Region.OnBeginSpellCast(m_Caster, this))
                {
                    if (m_Caster is PlayerMobile && ClearHandsOnCast) //Mobiles don't need to disarm
                    {
                        m_Caster.ClearHands();
                    }

                    m_State = SpellState.Casting;

                    m_Caster.Spell = this;

                    //m_PlayerCaster.WeaponTimerCheck();
                    //m_PlayerCaster.BandageCheck();

                    //m_PlayerCaster.AbortCurrentPlayerAction();

                    //Maka
                    //if (RevealOnCast && !m_PlayerCaster.HiddenWithSpell)
                    //     m_Caster.RevealingAction();

                    SayMantra();

                    var castDelay = GetCastDelay();

                    var count = (int)Math.Ceiling(castDelay.TotalSeconds / AnimateDelay.TotalSeconds);

                    if (count != 0)
                    {
                        m_AnimTimer = new AnimTimer(this, 1);
                        m_AnimTimer.Start();
                    }

                    if (m_Info.LeftHandEffect > 0)
                    {
                        Caster.FixedParticles(0, 10, 5, m_Info.LeftHandEffect, EffectLayer.LeftHand);
                    }

                    if (m_Info.RightHandEffect > 0)
                    {
                        Caster.FixedParticles(0, 10, 5, m_Info.RightHandEffect, EffectLayer.RightHand);
                    }

                    if (Core.ML)
                    {
                        WeaponAbility.ClearCurrentAbility(m_Caster);
                    }

                    m_CastTimer = new CastTimer(this, castDelay);
                    m_CastTimer.Start();

                    OnBeginCast();
                    return(true);
                }
                return(false);
            }
            return(false);
        }
Beispiel #21
0
        public bool Cast()
        {
            m_StartCastTime = Core.TickCount;

            if (Core.AOS && m_Caster.Spell is Spell && ((Spell)m_Caster.Spell).State == SpellState.Sequencing)
            {
                ((Spell)m_Caster.Spell).Disturb(DisturbType.NewCast);
            }

            if (!m_Caster.CheckAlive())
            {
                return(false);
            }
            else if (m_Caster is PlayerMobile && ((PlayerMobile)m_Caster).Peaced)
            {
                m_Caster.SendLocalizedMessage(1072060);                 // You cannot cast a spell while calmed.
            }
            else if (m_Scroll is BaseWand && m_Caster.Spell != null && m_Caster.Spell.IsCasting)
            {
                m_Caster.SendLocalizedMessage(502643);                 // You can not cast a spell while frozen.
            }
            else if (m_Caster.Spell != null && m_Caster.Spell.IsCasting)
            {
                m_Caster.SendLocalizedMessage(502642);                 // You are already casting a spell.
            }
            else if (!(m_Scroll is BaseWand) && (m_Caster.Paralyzed || m_Caster.Frozen))
            {
                m_Caster.SendLocalizedMessage(502643);                 // You can not cast a spell while frozen.
            }
            else if (CheckNextSpellTime && Core.TickCount - m_Caster.NextSpellTime < 0)
            {
                m_Caster.SendLocalizedMessage(502644);                 // You have not yet recovered from casting a spell.
            }
            else if (m_Caster is PlayerMobile && ((PlayerMobile)m_Caster).PeacedUntil > DateTime.UtcNow)
            {
                m_Caster.SendLocalizedMessage(1072060);                 // You cannot cast a spell while calmed.
            }
            #region Dueling
            else if (m_Caster is PlayerMobile && ((PlayerMobile)m_Caster).DuelContext != null &&
                     !((PlayerMobile)m_Caster).DuelContext.AllowSpellCast(m_Caster, this))
            {
            }
            #endregion

            else if (m_Caster.Mana >= ScaleMana(GetMana()))
            {
                #region Stygian Abyss
                if (m_Caster.Race == Race.Gargoyle && m_Caster.Flying)
                {
                    var      tiles = Caster.Map.Tiles.GetStaticTiles(Caster.X, Caster.Y, true);
                    ItemData itemData;
                    bool     cancast = true;

                    for (int i = 0; i < tiles.Length && cancast; ++i)
                    {
                        itemData = TileData.ItemTable[tiles[i].ID & TileData.MaxItemValue];
                        cancast  = !(itemData.Name == "hover over");
                    }

                    if (!cancast)
                    {
                        if (m_Caster.IsPlayer())
                        {
                            m_Caster.SendLocalizedMessage(1113750);                             // You may not cast spells while flying over such precarious terrain.
                            return(false);
                        }
                        else
                        {
                            m_Caster.SendMessage("Your staff level allows you to cast while flying over precarious terrain.");
                        }
                    }
                }
                #endregion

                if (m_Caster.Spell == null && m_Caster.CheckSpellCast(this) && CheckCast() &&
                    m_Caster.Region.OnBeginSpellCast(m_Caster, this))
                {
                    m_State        = SpellState.Casting;
                    m_Caster.Spell = this;

                    if (!(m_Scroll is BaseWand) && RevealOnCast)
                    {
                        m_Caster.RevealingAction();
                    }

                    SayMantra();

                    TimeSpan castDelay = GetCastDelay();

                    if (ShowHandMovement && (m_Caster.Body.IsHuman || (m_Caster.Player && m_Caster.Body.IsMonster)))
                    {
                        int count = (int)Math.Ceiling(castDelay.TotalSeconds / AnimateDelay.TotalSeconds);

                        if (count != 0)
                        {
                            m_AnimTimer = new AnimTimer(this, count);
                            m_AnimTimer.Start();
                        }

                        if (m_Info.LeftHandEffect > 0)
                        {
                            Caster.FixedParticles(0, 10, 5, m_Info.LeftHandEffect, EffectLayer.LeftHand);
                        }

                        if (m_Info.RightHandEffect > 0)
                        {
                            Caster.FixedParticles(0, 10, 5, m_Info.RightHandEffect, EffectLayer.RightHand);
                        }
                    }

                    if (ClearHandsOnCast)
                    {
                        m_Caster.ClearHands();
                    }

                    m_CastTimer = new CastTimer(this, castDelay);
                    //m_CastTimer.Start();

                    OnBeginCast();

                    if (castDelay > TimeSpan.Zero)
                    {
                        m_CastTimer.Start();
                    }
                    else
                    {
                        m_CastTimer.Tick();
                    }

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                m_Caster.LocalOverheadMessage(MessageType.Regular, 0x22, 502625);                 // Insufficient mana
            }

            return(false);
        }
Beispiel #22
0
        public bool Cast()
        {
            if (Caster.Spell is Spell && ((Spell)Caster.Spell).State == SpellState.Sequencing)
            {
                ((Spell)Caster.Spell).Disturb(DisturbType.NewCast);
            }

            if (!Caster.CheckAlive())
            {
                return(false);
            }
            else if (Caster.Spell != null && Caster.Spell.IsCasting)
            {
                Caster.SendLocalizedMessage(502642);                   // You are already casting a spell.
            }
            else if (BlockedByHorrificBeast && TransformationSpell.UnderTransformation(Caster, typeof(HorrificBeastSpell)))
            {
                Caster.SendLocalizedMessage(1061091);                   // You cannot cast that spell in this form.
            }
            else if (BlockedByAnimalForm && AnimalForm.UnderTransformation(Caster))
            {
                Caster.SendLocalizedMessage(1061091);                   // You cannot cast that spell in this form.
            }
            else if (!(Scroll is BaseWand) && (Caster.Paralyzed || Caster.Frozen))
            {
                Caster.SendLocalizedMessage(502643);                   // You can not cast a spell while frozen.
            }
            else if (CheckNextSpellTime && DateTime.UtcNow < Caster.NextSpellTime)
            {
                Caster.SendLocalizedMessage(502644);                   // You have not yet recovered from casting a spell.
            }
            else if (BaseBardCreature.IsCalmed(Caster))
            {
                Caster.SendLocalizedMessage(1072060);                   // You cannot cast a spell while calmed.
            }
            else if (Caster.Mana >= ScaleMana(GetMana()))
            {
                if (Caster.Spell == null && Caster.CheckSpellCast(this) && CheckCast() && Caster.Region.OnBeginSpellCast(Caster, this))
                {
                    State        = SpellState.Casting;
                    Caster.Spell = this;

                    if (RevealOnCast)
                    {
                        Caster.RevealingAction();
                    }

                    SayMantra();

                    TimeSpan castDelay = this.GetCastDelay();

                    /*
                     * OSI cast delay is computed with a global timer based on ticks. There is
                     * one tick per 0.25 seconds, so every tick the timer computes all the
                     * spells ready to cast. This introduces a random additional delay of 0-0.25
                     * seconds due to fact that the first tick is always incomplete. We add this
                     * manually here to enhance the gameplay to get the real OSI feeling.
                     */
                    castDelay += TimeSpan.FromSeconds(0.25 * Utility.RandomDouble());

                    if (ShowHandMovement && Caster.Body.IsHuman && !(Scroll is SpellStone))
                    {
                        int count = (int)Math.Ceiling(castDelay.TotalSeconds / AnimateDelay.TotalSeconds);

                        if (count != 0)
                        {
                            m_AnimTimer = new AnimTimer(this, count);
                            m_AnimTimer.Start();
                        }

                        if (Info.LeftHandEffect > 0)
                        {
                            Caster.FixedParticles(0, 10, 5, Info.LeftHandEffect, EffectLayer.LeftHand);
                        }

                        if (Info.RightHandEffect > 0)
                        {
                            Caster.FixedParticles(0, 10, 5, Info.RightHandEffect, EffectLayer.RightHand);
                        }
                    }

                    if (ClearHandsOnCast)
                    {
                        Caster.ClearHands();
                    }

                    m_CastTimer = new CastTimer(this, castDelay);
                    m_CastTimer.Start();

                    SpecialMove.ClearCurrentMove(Caster);
                    WeaponAbility.ClearCurrentAbility(Caster);

                    OnBeginCast();

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                Caster.LocalOverheadMessage(MessageType.Regular, 0x22, 502625);                   // Insufficient mana
            }

            return(false);
        }
Beispiel #23
0
        public bool DirectCast() //Mobile cast
        {
            m_StartCastTime = DateTime.Now;

            if (Core.AOS && m_Caster.Spell is Spell && ((Spell)m_Caster.Spell).State == SpellState.Sequencing)
                ((Spell)m_Caster.Spell).Disturb(DisturbType.NewCast);

            if (!m_Caster.CheckAlive())
            {
                return false;
            }
            if (m_Caster.Spell != null && m_Caster.Spell.IsCasting)
            {
                m_Caster.SendLocalizedMessage(502642); // You are already casting a spell.
            }
            else if (BlockedByHorrificBeast && TransformationSpellHelper.UnderTransformation(m_Caster, typeof(HorrificBeastSpell)) || (BlockedByAnimalForm && AnimalForm.UnderTransformation(m_Caster)))
            {
                m_Caster.SendLocalizedMessage(1061091); // You cannot cast that spell in this form.
            }
            else if (m_Caster.Frozen)
            {
                m_Caster.SendLocalizedMessage(502643); // You can not cast a spell while frozen.
            }
            else if (CheckNextSpellTime && DateTime.Now < m_Caster.NextSpellTime)
            {
                m_Caster.SendLocalizedMessage(502644); // You have not yet recovered from casting a spell.
            }
            else if (m_Caster is PlayerMobile && ((PlayerMobile)m_Caster).PeacedUntil > DateTime.Now)
            {
                m_Caster.SendLocalizedMessage(1072060); // You cannot cast a spell while calmed.
            }
            //Taran: Tacky fix for checking range and LoS for NPC's, I don't know where the NPC spell targeting method is so I'm using Combatant instead.
            else if (m_Caster is BaseCreature && m_Caster.Combatant != null && (!m_Caster.InLOS(m_Caster.Combatant) || !m_Caster.InRange(m_Caster.Combatant, 12) || !m_Caster.CanSee(m_Caster.Combatant)))
            {
                m_Caster.SendAsciiMessage("You cannot see your target");
            }
            else if (m_Caster.Mana >= ScaleMana(GetMana()))
            {
                if (m_Caster.Spell == null && m_Caster.CheckSpellCast(this) && CheckCast() && m_Caster.Region.OnBeginSpellCast(m_Caster, this))
                {
                    m_State = SpellState.Casting;
                    m_Caster.Spell = this;

                    if (RevealOnCast)
                    {
                        if (m_Caster is PlayerMobile)
                        {
                            if (!((PlayerMobile)m_Caster).HiddenWithSpell)
                                m_Caster.RevealingAction();
                        }
                        else
                            m_Caster.RevealingAction();
                    }

                    SayMantra();

                    var castDelay = GetCastDelay();

                    if (ShowHandMovement && m_Caster.Body.IsHuman)
                    {
                        var count = (int)Math.Ceiling(castDelay.TotalSeconds / AnimateDelay.TotalSeconds);

                        if (count != 0)
                        {
                            m_AnimTimer = new AnimTimer(this, 1);
                            m_AnimTimer.Start();
                        }

                        if (m_Info.LeftHandEffect > 0)
                            Caster.FixedParticles(0, 10, 5, m_Info.LeftHandEffect, EffectLayer.LeftHand);

                        if (m_Info.RightHandEffect > 0)
                            Caster.FixedParticles(0, 10, 5, m_Info.RightHandEffect, EffectLayer.RightHand);
                    }

                    if (m_Caster is PlayerMobile && ClearHandsOnCast) //Mobiles don't need to disarm
                        m_Caster.ClearHands();

                    m_CastTimer = new CastTimer(this, castDelay);
                    m_CastTimer.Start();

                    OnBeginCast();

                    return true;
                }
                return false;
            }
            else
            {
                m_Caster.LocalOverheadMessage(MessageType.Regular, 0x22, 502625); // Insufficient mana
            }

            return false;
        }
        public bool Cast()
        {
            m_StartCastTime = DateTime.Now;

            if (Core.AOS && m_Caster.Spell is Spell && ((Spell)m_Caster.Spell).State == SpellState.Sequencing)
            {
                ((Spell)m_Caster.Spell).Disturb(DisturbType.NewCast);
            }

            if (!m_Caster.CheckAlive())
            {
                return(false);
            }
            else if (m_Caster.Spell != null && m_Caster.Spell.IsCasting)
            {
                m_Caster.SendLocalizedMessage(502642);                   // You are already casting a spell.
            }
            else if (BlockedByHorrificBeast && TransformationSpell.UnderTransformation(m_Caster, typeof(HorrificBeastSpell)))
            {
                m_Caster.SendLocalizedMessage(1061091);                   // You cannot cast that spell in this form.
            }
            else if (!(this is Shadowjump || this is MirrorImage || this is AnimalForm) && AnimalForm.UnderEffect(m_Caster))
            {
                // TODO: Revealing action and mantra should be before this ( at least for palading spell)
                if (this is PaladinSpell)
                {
                    m_Caster.SendLocalizedMessage(1063218);                       // You cannot use that ability in this form.
                }
                else if (this is SamuraiSpell)
                {
                    if (this is MomentumStrike || this is LightningStrike || this is HonorableExecution)
                    {
                        m_Caster.SendLocalizedMessage(1063024);                           // You cannot perform this special move right now.
                    }
                    else
                    {
                        m_Caster.SendLocalizedMessage(1063218);                           // You cannot use that ability in this form.
                    }
                }
                else if (this is NinjaSpell)
                {
                    m_Caster.SendLocalizedMessage(1063024);                       // You cannot perform this special move right now.
                }
                else
                {
                    m_Caster.SendLocalizedMessage(1061091);                       // You cannot cast that spell in this form.
                }
            }
            else if (!(m_Scroll is BaseWand) && (m_Caster.Paralyzed || m_Caster.Frozen))
            {
                m_Caster.SendLocalizedMessage(502643);                   // You can not cast a spell while frozen.
            }
            else if (CheckNextSpellTime && DateTime.Now < m_Caster.NextSpellTime)
            {
                m_Caster.SendLocalizedMessage(502644);                   // You must wait for that spell to have an effect.
            }
            else if (m_Caster.Mana >= ScaleMana(GetMana()))
            {
                if (m_Caster.Spell == null && m_Caster.CheckSpellCast(this) && CheckCast() && m_Caster.Region.OnBeginSpellCast(m_Caster, this))
                {
                    m_State        = SpellState.Casting;
                    m_Caster.Spell = this;

                    if (RevealOnCast)
                    {
                        m_Caster.RevealingAction();
                    }

                    SayMantra();

                    TimeSpan castDelay = this.GetCastDelay();

                    if (m_Caster.Body.IsHuman)
                    {
                        int count = (int)Math.Ceiling(castDelay.TotalSeconds / AnimateDelay.TotalSeconds);

                        if (count != 0)
                        {
                            m_AnimTimer = new AnimTimer(this, count);
                            m_AnimTimer.Start();
                        }

                        if (m_Info.LeftHandEffect > 0)
                        {
                            Caster.FixedParticles(0, 10, 5, m_Info.LeftHandEffect, EffectLayer.LeftHand);
                        }

                        if (m_Info.RightHandEffect > 0)
                        {
                            Caster.FixedParticles(0, 10, 5, m_Info.RightHandEffect, EffectLayer.RightHand);
                        }
                    }

                    if (ClearHandsOnCast)
                    {
                        m_Caster.ClearHands();
                    }

                    m_CastTimer = new CastTimer(this, castDelay);
                    m_CastTimer.Start();

                    OnBeginCast();

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                m_Caster.LocalOverheadMessage(MessageType.Regular, 0x22, 502625);                   // Insufficient mana
            }

            return(false);
        }
Beispiel #25
0
		public bool Cast()
		{
			m_StartCastTime = DateTime.Now;

			if ( Core.AOS && m_Caster.Spell is Spell && ((Spell)m_Caster.Spell).State == SpellState.Sequencing )
				((Spell)m_Caster.Spell).Disturb( DisturbType.NewCast );

			if ( !m_Caster.CheckAlive() )
			{
				return false;
			}
			#region Mondain's Legacy
			else if ( m_Caster is PlayerMobile  && ((PlayerMobile) m_Caster).Peaced )
			{
				m_Caster.SendLocalizedMessage( 1072060 ); // You cannot cast a spell while calmed.
			}
			#endregion
			else if ( m_Caster.Spell != null && m_Caster.Spell.IsCasting )
			{
				m_Caster.SendLocalizedMessage( 502642 ); // You are already casting a spell.
			}
			else if ( BlockedByHorrificBeast && TransformationSpellHelper.UnderTransformation( m_Caster, typeof( HorrificBeastSpell ) ) || ( BlockedByAnimalForm && AnimalForm.UnderTransformation( m_Caster ) ))
			{
				m_Caster.SendLocalizedMessage( 1061091 ); // You cannot cast that spell in this form.
			}
			else if ( !(m_Scroll is BaseWand) && (m_Caster.Paralyzed || m_Caster.Frozen) )
			{
				m_Caster.SendLocalizedMessage( 502643 ); // You can not cast a spell while frozen.
			}
			else if ( CheckNextSpellTime && DateTime.Now < m_Caster.NextSpellTime )
			{
				m_Caster.SendLocalizedMessage( 502644 ); // You have not yet recovered from casting a spell.
			}
			else if ( m_Caster.Mana >= ScaleMana( GetMana() ) )
			{
				if ( m_Caster.Spell == null && m_Caster.CheckSpellCast( this ) && CheckCast() && m_Caster.Region.OnBeginSpellCast( m_Caster, this ) )
				{
					m_State = SpellState.Casting;
					m_Caster.Spell = this;

					if ( RevealOnCast )
						m_Caster.RevealingAction();

					SayMantra();

					TimeSpan castDelay = this.GetCastDelay();

					if ( ShowHandMovement && m_Caster.Body.IsHuman )
					{
						int count = (int)Math.Ceiling( castDelay.TotalSeconds / AnimateDelay.TotalSeconds );

						if ( count != 0 )
						{
							m_AnimTimer = new AnimTimer( this, count );
							m_AnimTimer.Start();
						}

						if ( m_Info.LeftHandEffect > 0 )
							Caster.FixedParticles( 0, 10, 5, m_Info.LeftHandEffect, EffectLayer.LeftHand );

						if ( m_Info.RightHandEffect > 0 )
							Caster.FixedParticles( 0, 10, 5, m_Info.RightHandEffect, EffectLayer.RightHand );
					}

					if ( ClearHandsOnCast )
						m_Caster.ClearHands();

					m_CastTimer = new CastTimer( this, castDelay );
					m_CastTimer.Start();

					OnBeginCast();

					return true;
				}
				else
				{
					return false;
				}
			}
			else
			{
				m_Caster.LocalOverheadMessage( MessageType.Regular, 0x22, 502625 ); // Insufficient mana
			}

			return false;
		}
Beispiel #26
0
		public bool Cast()
		{
			m_StartCastTime = DateTime.UtcNow;

			if (!m_Caster.CheckAlive())
			{
				return false;
			}
			else if (m_Caster.Spell != null && m_Caster.Spell.IsCasting)
			{
				m_Caster.SendLocalizedMessage(502642); // You are already casting a spell.
			}
			else if (!(m_Scroll is BaseWand || m_Scroll is GnarledStaff) && (m_Caster.Paralyzed || m_Caster.Frozen))
			{
				m_Caster.SendLocalizedMessage(502643); // You can not cast a spell while frozen.
			}
			else if (CheckNextSpellTime && DateTime.UtcNow < m_Caster.NextSpellTime)
			{
				m_Caster.SendLocalizedMessage(502644); // You have not yet recovered from casting a spell.
			}
			else if (m_Caster is PlayerMobile && ((PlayerMobile)m_Caster).PeacedUntil > DateTime.UtcNow)
			{
				m_Caster.SendLocalizedMessage(1072060); // You cannot cast a spell while calmed.
			}
				#region Dueling
			else if (m_Caster is PlayerMobile && ((PlayerMobile)m_Caster).DuelContext != null &&
					 !((PlayerMobile)m_Caster).DuelContext.AllowSpellCast(m_Caster, this))
			{ }
				#endregion

			else if (m_Caster.Mana >= ScaleMana(GetMana()))
			{
				if (m_Caster.Spell == null && m_Caster.CheckSpellCast(this) && CheckCast())
				{
					if (XmlScript.HasTrigger(m_Caster, TriggerName.onBeginCast) &&
						UberScriptTriggers.Trigger(m_Caster, m_Caster, TriggerName.onBeginCast, null, null, this))
					{
						return false;
					}
					else if (m_Caster.Region.OnBeginSpellCast(m_Caster, this))
					{
						m_State = SpellState.Casting;
						m_Caster.Spell = this;

						if (!(m_Scroll is BaseWand || m_Scroll is GnarledStaff) && RevealOnCast)
						{
							m_Caster.RevealingAction();
						}

						SayMantra();

						TimeSpan castDelay = GetCastDelay();
						var count = (int)Math.Ceiling(castDelay.TotalSeconds / AnimateDelay.TotalSeconds);
						if (ShowHandMovement && (m_Caster.Body.IsHuman || (m_Caster.Player && m_Caster.Body.IsMonster)))
						{
							if (count != 0)
							{
								m_AnimTimer = new AnimTimer(this, count);
								m_AnimTimer.Start();
							}

							if (m_Info.LeftHandEffect > 0)
							{
								Caster.FixedParticles(0, 10, 5, m_Info.LeftHandEffect, EffectLayer.LeftHand);
							}

							if (m_Info.RightHandEffect > 0)
							{
								Caster.FixedParticles(0, 10, 5, m_Info.RightHandEffect, EffectLayer.RightHand);
							}
						}
							//BaseCreature Animations For Casting
						else if (m_Caster is BaseCreature)
						{
							if (count != 0 && Utility.Random(3) == 0 || (!m_Caster.Deleted && m_Caster.NetState != null))
								// 1 in 3 chance that they do the animation
							{
								m_AnimTimer = new AnimTimer(this, count);
								m_AnimTimer.Start();
							}
						}

						if (ClearHandsOnCast)
						{
							m_Caster.ClearHands();
						}

						if (m_Caster.EraML)
						{
							WeaponAbility.ClearCurrentAbility(m_Caster);
						}

						m_CastTimer = new CastTimer(this, castDelay);
						m_CastTimer.Start();

						OnBeginCast();

						return true;
					}
				}
				return false;
			}
			else
			{
				m_Caster.LocalOverheadMessage(MessageType.Regular, 0x22, 502625); // Insufficient mana
			}

			return false;
		}
Beispiel #27
0
        public bool Cast()
        {
            m_StartCastTime = DateTime.UtcNow;

            if (!m_Caster.CheckAlive())
            {
                return(false);
            }
            else if (m_Caster.Spell != null && m_Caster.Spell.IsCasting)
            {
                m_Caster.SendLocalizedMessage(502642);                 // You are already casting a spell.
            }
            else if (!(m_Scroll is BaseWand || m_Scroll is GnarledStaff) && (m_Caster.Paralyzed || m_Caster.Frozen))
            {
                m_Caster.SendLocalizedMessage(502643);                 // You can not cast a spell while frozen.
            }
            else if (CheckNextSpellTime && DateTime.UtcNow < m_Caster.NextSpellTime)
            {
                m_Caster.SendLocalizedMessage(502644);                 // You have not yet recovered from casting a spell.
            }
            else if (m_Caster is PlayerMobile && ((PlayerMobile)m_Caster).PeacedUntil > DateTime.UtcNow)
            {
                m_Caster.SendLocalizedMessage(1072060);                 // You cannot cast a spell while calmed.
            }
            #region Dueling
            else if (m_Caster is PlayerMobile && ((PlayerMobile)m_Caster).DuelContext != null &&
                     !((PlayerMobile)m_Caster).DuelContext.AllowSpellCast(m_Caster, this))
            {
            }
            #endregion

            else if (m_Caster.Mana >= ScaleMana(GetMana()))
            {
                if (m_Caster.Spell == null && m_Caster.CheckSpellCast(this) && CheckCast())
                {
                    if (XmlScript.HasTrigger(m_Caster, TriggerName.onBeginCast) &&
                        UberScriptTriggers.Trigger(m_Caster, m_Caster, TriggerName.onBeginCast, null, null, this))
                    {
                        return(false);
                    }
                    else if (m_Caster.Region.OnBeginSpellCast(m_Caster, this))
                    {
                        m_State        = SpellState.Casting;
                        m_Caster.Spell = this;

                        if (!(m_Scroll is BaseWand || m_Scroll is GnarledStaff) && RevealOnCast)
                        {
                            m_Caster.RevealingAction();
                        }

                        SayMantra();

                        TimeSpan castDelay = GetCastDelay();
                        var      count     = (int)Math.Ceiling(castDelay.TotalSeconds / AnimateDelay.TotalSeconds);
                        if (ShowHandMovement && (m_Caster.Body.IsHuman || (m_Caster.Player && m_Caster.Body.IsMonster)))
                        {
                            if (count != 0)
                            {
                                m_AnimTimer = new AnimTimer(this, count);
                                m_AnimTimer.Start();
                            }

                            if (m_Info.LeftHandEffect > 0)
                            {
                                Caster.FixedParticles(0, 10, 5, m_Info.LeftHandEffect, EffectLayer.LeftHand);
                            }

                            if (m_Info.RightHandEffect > 0)
                            {
                                Caster.FixedParticles(0, 10, 5, m_Info.RightHandEffect, EffectLayer.RightHand);
                            }
                        }
                        //BaseCreature Animations For Casting
                        else if (m_Caster is BaseCreature)
                        {
                            if (count != 0 && Utility.Random(3) == 0 || (!m_Caster.Deleted && m_Caster.NetState != null))
                            // 1 in 3 chance that they do the animation
                            {
                                m_AnimTimer = new AnimTimer(this, count);
                                m_AnimTimer.Start();
                            }
                        }

                        if (ClearHandsOnCast)
                        {
                            m_Caster.ClearHands();
                        }

                        if (m_Caster.EraML)
                        {
                            WeaponAbility.ClearCurrentAbility(m_Caster);
                        }

                        m_CastTimer = new CastTimer(this, castDelay);
                        m_CastTimer.Start();

                        OnBeginCast();

                        return(true);
                    }
                }
                return(false);
            }
            else
            {
                m_Caster.LocalOverheadMessage(MessageType.Regular, 0x22, 502625);                 // Insufficient mana
            }

            return(false);
        }
Beispiel #28
0
        public bool Cast()
        {
            m_StartCastTime = DateTime.Now;

            if (Core.AOS && m_Caster.Spell is Spell && ((Spell)m_Caster.Spell).State == SpellState.Sequencing)
            {
                ((Spell)m_Caster.Spell).Disturb(DisturbType.NewCast);
            }

            if (!m_Caster.CheckAlive())
            {
                return(false);
            }
            #region Mondain's Legacy
            else if (m_Caster is PlayerMobile && ((PlayerMobile)m_Caster).Peaced)
            {
                m_Caster.SendLocalizedMessage(1072060);                   // You cannot cast a spell while calmed.
            }
            #endregion
            else if (m_Caster.Spell != null && m_Caster.Spell.IsCasting)
            {
                m_Caster.SendLocalizedMessage(502642);                   // You are already casting a spell.
            }
            else if (BlockedByHorrificBeast && TransformationSpellHelper.UnderTransformation(m_Caster, typeof(HorrificBeastSpell)) || (BlockedByAnimalForm && AnimalForm.UnderTransformation(m_Caster)))
            {
                m_Caster.SendLocalizedMessage(1061091);                   // You cannot cast that spell in this form.
            }
            else if (!(m_Scroll is BaseWand) && (m_Caster.Paralyzed || m_Caster.Frozen))
            {
                m_Caster.SendLocalizedMessage(502643);                   // You can not cast a spell while frozen.
            }
            else if (m_Caster.Sleep)
            {
                m_Caster.SendLocalizedMessage(1080138);                   // You cannot cast a spell while sleeping.
            }
            else if (CheckNextSpellTime && DateTime.Now < m_Caster.NextSpellTime)
            {
                m_Caster.SendLocalizedMessage(502644);                   // You have not yet recovered from casting a spell.
            }
            else if (m_Caster.Mana >= ScaleMana(GetMana()))
            {
                #region SA
                if (m_Caster.Race == Race.Gargoyle && m_Caster.Flying)
                {
                    StaticTile[] tiles = Caster.Map.Tiles.GetStaticTiles(Caster.X, Caster.Y, true);
                    ItemData     itemData;
                    bool         cancast = true;

                    for (int i = 0; i < tiles.Length && cancast; ++i)
                    {
                        itemData = TileData.ItemTable[tiles[i].ID & TileData.MaxItemValue];
                        cancast  = !(itemData.Name == "hover over");
                    }

                    if (!cancast)
                    {
                        if (m_Caster.AccessLevel == AccessLevel.Player)
                        {
                            m_Caster.SendLocalizedMessage(1113750);                               // You may not cast spells while flying over such precarious terrain.
                            return(false);
                        }
                        else
                        {
                            m_Caster.SendMessage("Your staff level allows you to cast while flying over precarious terrain.");
                        }
                    }
                }
                #endregion

                if (m_Caster.Spell == null && m_Caster.CheckSpellCast(this) && CheckCast() && m_Caster.Region.OnBeginSpellCast(m_Caster, this))
                {
                    m_State        = SpellState.Casting;
                    m_Caster.Spell = this;

                    if (RevealOnCast)
                    {
                        m_Caster.RevealingAction();
                    }

                    SayMantra();

                    TimeSpan castDelay = this.GetCastDelay();

                    if (ShowHandMovement && m_Caster.Body.IsHuman)
                    {
                        int count = (int)Math.Ceiling(castDelay.TotalSeconds / AnimateDelay.TotalSeconds);

                        if (count != 0)
                        {
                            m_AnimTimer = new AnimTimer(this, count);
                            m_AnimTimer.Start();
                        }

                        if (m_Info.LeftHandEffect > 0)
                        {
                            Caster.FixedParticles(0, 10, 5, m_Info.LeftHandEffect, EffectLayer.LeftHand);
                        }

                        if (m_Info.RightHandEffect > 0)
                        {
                            Caster.FixedParticles(0, 10, 5, m_Info.RightHandEffect, EffectLayer.RightHand);
                        }
                    }

                    if (ClearHandsOnCast)
                    {
                        m_Caster.ClearHands();
                    }

                    if (Core.ML)
                    {
                        WeaponAbility.ClearCurrentAbility(m_Caster);
                    }

                    m_CastTimer = new CastTimer(this, castDelay);
                    m_CastTimer.Start();

                    OnBeginCast();

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                m_Caster.LocalOverheadMessage(MessageType.Regular, 0x22, 502625);                   // Insufficient mana
            }

            return(false);
        }
Beispiel #29
0
        public virtual bool Cast()
        {
            m_StartCastTime = Core.TickCount;

            if (Core.AOS && m_Caster.Spell is Spell && ((Spell)m_Caster.Spell).State == SpellState.Sequencing)
            {
                ((Spell)m_Caster.Spell).Disturb(DisturbType.NewCast);
            }

            if (!m_Caster.CheckAlive())
            {
                return(false);
            }
            else if (m_Caster is PlayerMobile && ((PlayerMobile)m_Caster).Peaced)
            {
                m_Caster.SendLocalizedMessage(1072060);                 // You cannot cast a spell while calmed.
            }
            else if (m_Scroll is BaseWand && m_Caster.Spell != null && m_Caster.Spell.IsCasting)
            {
                m_Caster.SendLocalizedMessage(502643);                 // You can not cast a spell while frozen.
            }
            else if (SkillHandlers.SpiritSpeak.IsInSpiritSpeak(m_Caster) || (m_Caster.Spell != null && m_Caster.Spell.IsCasting))
            {
                m_Caster.SendLocalizedMessage(502642);                 // You are already casting a spell.
            }
            else if (BlockedByHorrificBeast && TransformationSpellHelper.UnderTransformation(m_Caster, typeof(HorrificBeastSpell)) ||
                     (BlockedByAnimalForm && AnimalForm.UnderTransformation(m_Caster)))
            {
                m_Caster.SendLocalizedMessage(1061091);                 // You cannot cast that spell in this form.
            }
            else if (!(m_Scroll is BaseWand) && (m_Caster.Paralyzed || m_Caster.Frozen))
            {
                m_Caster.SendLocalizedMessage(502643);                 // You can not cast a spell while frozen.
            }
            else if (CheckNextSpellTime && Core.TickCount - m_Caster.NextSpellTime < 0)
            {
                m_Caster.SendLocalizedMessage(502644);                 // You have not yet recovered from casting a spell.
            }
            else if (m_Caster is PlayerMobile && ((PlayerMobile)m_Caster).PeacedUntil > DateTime.UtcNow)
            {
                m_Caster.SendLocalizedMessage(1072060);                 // You cannot cast a spell while calmed.
            }
            else if (m_Caster.Mana >= ScaleMana(GetMana()))
            {
                #region Stygian Abyss
                if (m_Caster.Race == Race.Gargoyle && m_Caster.Flying)
                {
                    if (BaseMount.OnFlightPath(m_Caster))
                    {
                        if (m_Caster.IsPlayer())
                        {
                            m_Caster.SendLocalizedMessage(1113750);                             // You may not cast spells while flying over such precarious terrain.
                            return(false);
                        }
                        else
                        {
                            m_Caster.SendMessage("Your staff level allows you to cast while flying over precarious terrain.");
                        }
                    }
                }
                #endregion

                if (m_Caster.Spell == null && m_Caster.CheckSpellCast(this) && CheckCast() &&
                    m_Caster.Region.OnBeginSpellCast(m_Caster, this))
                {
                    m_State        = SpellState.Casting;
                    m_Caster.Spell = this;

                    Caster.Delta(MobileDelta.Flags);

                    if (!(m_Scroll is BaseWand) && RevealOnCast)
                    {
                        m_Caster.RevealingAction();
                    }

                    SayMantra();

                    TimeSpan castDelay = GetCastDelay();

                    if (ShowHandMovement && !(m_Scroll is SpellStone) && (m_Caster.Body.IsHuman || (m_Caster.Player && m_Caster.Body.IsMonster)))
                    {
                        int count = (int)Math.Ceiling(castDelay.TotalSeconds / AnimateDelay.TotalSeconds);

                        if (count != 0)
                        {
                            m_AnimTimer = new AnimTimer(this, count);
                            m_AnimTimer.Start();
                        }

                        if (m_Info.LeftHandEffect > 0)
                        {
                            Caster.FixedParticles(0, 10, 5, m_Info.LeftHandEffect, EffectLayer.LeftHand);
                        }

                        if (m_Info.RightHandEffect > 0)
                        {
                            Caster.FixedParticles(0, 10, 5, m_Info.RightHandEffect, EffectLayer.RightHand);
                        }
                    }

                    if (ClearHandsOnCast)
                    {
                        m_Caster.ClearHands();
                    }

                    if (Core.ML)
                    {
                        WeaponAbility.ClearCurrentAbility(m_Caster);
                    }

                    m_CastTimer = new CastTimer(this, castDelay);
                    //m_CastTimer.Start();

                    OnBeginCast();

                    if (castDelay > TimeSpan.Zero)
                    {
                        m_CastTimer.Start();
                    }
                    else
                    {
                        m_CastTimer.Tick();
                    }

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                m_Caster.LocalOverheadMessage(MessageType.Regular, 0x22, 502625);                 // Insufficient mana
            }

            return(false);
        }
Beispiel #30
0
		public bool Cast()
		{
			m_StartCastTime = DateTime.Now;

			if ( Core.AOS && m_Caster.Spell is Spell && ((Spell)m_Caster.Spell).State == SpellState.Sequencing )
				((Spell)m_Caster.Spell).Disturb( DisturbType.NewCast );

			if ( !m_Caster.CheckAlive() )
			{
				return false;
			}
			else if ( m_Caster.Spell != null && m_Caster.Spell.IsCasting )
			{
				m_Caster.SendLocalizedMessage( 502642 ); // You are already casting a spell.
			}
			//else if ( BlockedByHorrificBeast && TransformationSpell.UnderTransformation( m_Caster, typeof( HorrificBeastSpell ) ) )
			//{
			//	m_Caster.SendLocalizedMessage( 1061091 ); // You cannot cast that spell in this form.
			//}
			else if ( !(m_Scroll is BaseWand) && (m_Caster.Paralyzed || m_Caster.Frozen) )
			{
				m_Caster.SendLocalizedMessage( 502643 ); // You can not cast a spell while frozen.
			}
			//else if ( CheckNextSpellTime && DateTime.Now < m_Caster.NextSpellTime )
			else if ( DateTime.Now < m_Caster.NextSpellTime )
			{
				m_Caster.SendLocalizedMessage( 502644 ); // You must wait for that spell to have an effect.
			}
			else if ( m_Caster.Mana >= ScaleMana( GetMana() ) )
			{
				if ( m_Caster.Spell == null && m_Caster.CheckSpellCast( this ) && CheckCast() && m_Caster.Region.OnBeginSpellCast( m_Caster, this ) )
				{
					m_State = SpellState.Casting;
					m_Caster.Spell = this;

					if ( RevealOnCast )
						m_Caster.RevealingAction();

					SayMantra();

					TimeSpan castDelay = this.GetCastDelay();

// ---- Individual spell timing alterations ----

// For FC ----
					if ( m_Info.Name == "Mind Blast" )
						castDelay = this.GetCastDelay() + TimeSpan.FromSeconds( 0.45 );
					else if ( m_Info.Name == "Cure" )
						castDelay = this.GetCastDelay() + TimeSpan.FromSeconds( 0.02 );

// For FCR ----
					if ( m_Info.Name == "Heal" )
						NextSpellDelay = TimeSpan.FromSeconds( 0.95 );
					else
						NextSpellDelay = TimeSpan.FromSeconds( 0.80 );
// ----

					if ( m_Caster.Body.IsHuman )
					{
						int count = (int)Math.Ceiling( castDelay.TotalSeconds / AnimateDelay.TotalSeconds );

						if ( count != 0 )
						{
							m_AnimTimer = new AnimTimer( this, count );
							m_AnimTimer.Start();
						}

						if ( m_Info.LeftHandEffect > 0 )
							Caster.FixedParticles( 0, 10, 5, m_Info.LeftHandEffect, EffectLayer.LeftHand );

						if ( m_Info.RightHandEffect > 0 )
							Caster.FixedParticles( 0, 10, 5, m_Info.RightHandEffect, EffectLayer.RightHand );
					}

					if ( ClearHandsOnCast )
						m_Caster.ClearHands();

					m_CastTimer = new CastTimer( this, castDelay );
					m_CastTimer.Start();

					OnBeginCast();

					// If the caster is a staffmember, log the spellcasting.
					if ( m_Caster.AccessLevel > AccessLevel.Player )
						Server.Scripts.Commands.CommandLogging.LogCastSpell( m_Caster, this.Name );

					return true;
				}
				else
				{
					return false;
				}
			}
			else
			{
				m_Caster.LocalOverheadMessage( MessageType.Regular, 0x22, 502625 ); // Insufficient mana
			}

			return false;
		}