Example #1
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;
        }
Example #2
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;
        }
Example #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;
		}
Example #4
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;
		}
Example #5
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;
        }
Example #6
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;
		}
Example #7
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;
        }
Example #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;
        }
Example #9
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;
        }
Example #10
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;
        }
Example #11
0
      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;
      }
Example #12
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;
		}
Example #13
0
        public bool Cast()
        {
            m_StartCastTime = Core.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 && Core.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);
        }
Example #14
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);
        }
Example #15
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);
        }
Example #16
0
        public virtual bool Cast()
        {
            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 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 (!CheckManaBeforeCast || 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();
                    }

                    WeaponAbility.ClearCurrentAbility(m_Caster);
                    m_CastTime = Core.TickCount + (long)castDelay.TotalMilliseconds;

                    CastTimer.AddTimer(this);
                    OnBeginCast();

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                m_Caster.LocalOverheadMessage(MessageType.Regular, 0x22, 502625, ScaleMana(GetMana()).ToString()); // Insufficient mana. You must have at least ~1_MANA_REQUIREMENT~ Mana to use this spell.
            }

            return(false);
        }