コード例 #1
0
                public override void OnResponse(Server.Network.NetState state, int index)
                {
                    if (this.Answers[index] == "Next")
                    {
                        WandMenu menu = null;

                        if (m_SpellCircle == SpellCircle.First)
                        {
                            menu = new WandMenu(m_Wand, (string[])Spells2.ToArray(typeof(string)), SpellCircle.Second);
                        }
                        else if (m_SpellCircle == SpellCircle.Second)
                        {
                            menu = new WandMenu(m_Wand, (string[])Spells3.ToArray(typeof(string)), SpellCircle.Third);
                        }
                        else if (m_SpellCircle == SpellCircle.Third)
                        {
                            menu = new WandMenu(m_Wand, (string[])Spells4.ToArray(typeof(string)), SpellCircle.Fourth);
                        }
                        else if (m_SpellCircle == SpellCircle.Fourth)
                        {
                            menu = new WandMenu(m_Wand, (string[])Spells5.ToArray(typeof(string)), SpellCircle.Fifth);
                        }
                        else if (m_SpellCircle == SpellCircle.Fifth)
                        {
                            menu = new WandMenu(m_Wand, (string[])Spells6.ToArray(typeof(string)), SpellCircle.Sixth);
                        }
                        else if (m_SpellCircle == SpellCircle.Sixth)
                        {
                            menu = new WandMenu(m_Wand, (string[])Spells7.ToArray(typeof(string)), SpellCircle.Seventh);
                        }
                        else if (m_SpellCircle == SpellCircle.Seventh)
                        {
                            menu = new WandMenu(m_Wand, (string[])Spells8.ToArray(typeof(string)), SpellCircle.Eighth);
                        }
                        else if (m_SpellCircle == SpellCircle.Eighth)
                        {
                            menu = new WandMenu(m_Wand, (string[])Spells1.ToArray(typeof(string)), SpellCircle.First);
                        }

                        state.Mobile.CloseAllGumps();
                        menu.SendTo(state);

                        return;
                    }

                    TeiravonMobile m_Player = (TeiravonMobile)state.Mobile;

                    if (m_Player.CanCast(this.Answers[index]))
                    {
                        m_Player.Mana = 0;
                        m_Wand.Spell  = this.Answers[index];

                        m_Player.SendMessage("You charge the wand!");
                    }
                    else
                    {
                        m_Player.SendMessage("You can't cast this spell!");
                    }
                }
コード例 #2
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);
        }