Пример #1
0
        public override bool OnBeginSpellCast(Mobile from, ISpell s)
        {
            if (@from.AccessLevel >= AccessLevel.Counselor)
            {
                return(true);
            }
            bool restricted = m_Controller.IsRestrictedSpell(s);

            if (restricted)
            {
                @from.SendMessage("Thou canst not cast thy spell here.");
                return(false);
            }

            if (m_Controller.CanMountEthereal || ((Spell)s).Info.Name != "Ethereal Mount")
            {
                return(true);
            }
            @from.SendMessage("Thou canst not mount thy ethereal here.");
            return(false);
        }
Пример #2
0
        public override bool OnBeginSpellCast(Mobile from, ISpell s)
        {
            if (from.AccessLevel == AccessLevel.Player)
            {
                bool restricted = m_Controller.IsRestrictedSpell(s, from);
                if (restricted && ((from is BaseCreature && m_Controller.RestrictCreatureMagic) || from is PlayerMobile))
                {
                    if (m_Controller.MagicMsgFailure == null)
                    {
                        from.SendMessage("You cannot cast that spell here.");
                    }
                    else
                    {
                        from.SendMessage(m_Controller.MagicMsgFailure);
                    }

                    return(false);
                }
            }

            return(base.OnBeginSpellCast(from, s));
        }
Пример #3
0
        public override bool OnBeginSpellCast(Mobile from, ISpell s)
        {
            if (from.AccessLevel == AccessLevel.Player)
            {
                bool restricted = m_Controller.IsRestrictedSpell(s);
                if (restricted)
                {
                    from.SendMessage("You cannot cast that spell here.");
                    return(false);
                }

                //if ( s is EtherealSpell && !CanMountEthereal ) Grr, EthereealSpell is private :<
                if (!m_Controller.CanMountEthereal && ((Spell)s).Info.Name == "Ethereal Mount")                  //Hafta check with a name compare of the string to see if ethy
                {
                    from.SendMessage("You cannot mount your ethereal here.");
                    return(false);
                }
            }

            //return base.OnBeginSpellCast( from, s );
            return(true);               //Let users customize spells, not rely on weather it's guarded or not.
        }
Пример #4
0
        public override bool OnBeginSpellCast(Mobile from, ISpell s)
        {
            if (IsAngelIslandRules && (s is TeleportSpell || s is RecallSpell || s is GateTravelSpell || s is MarkSpell) && from.AccessLevel == AccessLevel.Player)
            {
                from.SendMessage("You cannot cast that spell here.");
                return(false);
            }
            if (IsGreenAcresRules && (s is GateTravelSpell || s is RecallSpell || s is MarkSpell) && from.AccessLevel == AccessLevel.Player)
            {
                from.SendMessage("You cannot cast that spell here.");
                return(false);
            }
            if (IsJailRules && from.AccessLevel == AccessLevel.Player)
            {
                from.SendLocalizedMessage(502629);                 // You cannot cast spells here.
                return(false);
            }
            if (from.AccessLevel == AccessLevel.Player)
            {
                bool restricted = m_Controller.IsRestrictedSpell(s, from);
                if (restricted && ((from is BaseCreature && m_Controller.RestrictCreatureMagic) || from is PlayerMobile))
                {
                    if (m_Controller.MagicMsgFailure == null)
                    {
                        from.SendMessage("You cannot cast that spell here.");
                    }
                    else
                    {
                        from.SendMessage(m_Controller.MagicMsgFailure);
                    }

                    return(false);
                }
            }

            return(base.OnBeginSpellCast(from, s));
        }
Пример #5
0
        public virtual bool CheckSequence()
        {
            try
            {
                RegionControl regstone = null;
                CustomRegion  reg      = null;
                if (m_Caster != null)
                {
                    reg = CustomRegion.FindDRDTRegion(m_Caster);
                }
                if (reg != null)
                {
                    regstone = reg.GetRegionControler();
                }

                //if your in a region area spells will fail if disallowed, prevents the run outside of area precast
                //run back into region then release spell ability
                if (m_Caster != null && m_Caster.Spell != null && regstone != null && regstone.IsRestrictedSpell(m_Caster.Spell, m_Caster) && m_Caster.AccessLevel == AccessLevel.Player && ((m_Caster is BaseCreature && !regstone.RestrictCreatureMagic) || m_Caster is PlayerMobile))
                {
                    m_State = SpellState.None;
                    if (m_Caster.Spell == this)
                    {
                        m_Caster.Spell = null;
                    }
                    Targeting.Target.Cancel(m_Caster);
                    if (regstone.MagicMsgFailure == null)
                    {
                        m_Caster.SendMessage("You cannot cast that spell here.");
                    }
                    else
                    {
                        m_Caster.SendMessage(regstone.MagicMsgFailure);
                    }
                }
            }
            catch (NullReferenceException e)
            {
                LogHelper.LogException(e);
                Console.WriteLine("{0} Caught exception.", e);
            }
            catch (Exception ex)
            {
                LogHelper.LogException(ex);
            }


            int mana = ScaleMana(GetMana());

            if (m_Caster.Deleted || !m_Caster.Alive || m_Caster.Spell != this || m_State != SpellState.Sequencing)
            {
                DoFizzle();
            }
            else if (m_Scroll != null && !(m_Scroll is Runebook) && (m_Scroll.Amount <= 0 || m_Scroll.Deleted || m_Scroll.RootParent != m_Caster || (m_Scroll is BaseWand && (((BaseWand)m_Scroll).Charges <= 0 || m_Scroll.Parent != m_Caster))))
            {
                DoFizzle();
            }
            else if (!ConsumeReagents())
            {
                m_Caster.LocalOverheadMessage(MessageType.Regular, 0x22, 502630);                 // More reagents are needed for this spell.
            }
            else if (m_Caster.Mana < mana)
            {
                m_Caster.LocalOverheadMessage(MessageType.Regular, 0x22, 502625);                 // Insufficient mana for this spell.
            }
            else if (Core.AOS && (m_Caster.Frozen || m_Caster.Paralyzed))
            {
                m_Caster.SendLocalizedMessage(502646);                 // You cannot cast a spell while frozen.
                DoFizzle();
            }
            else if (!CheckFizzle())
            {
                m_Caster.Mana -= mana;

                if (m_Scroll is SpellScroll)
                {
                    m_Scroll.Consume();
                }
                else if (m_Scroll is BaseWand)
                {
                    ((BaseWand)m_Scroll).ConsumeCharge(m_Caster);
                }

                if (m_Scroll is BaseWand)
                {
                    bool m = m_Scroll.Movable;

                    m_Scroll.Movable = false;

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

                    m_Scroll.Movable = m;
                }
                else
                {
                    if (ClearHandsOnCast)
                    {
                        m_Caster.ClearHands();
                    }
                }

                int karma = ComputeKarmaAward();

                if (karma != 0)
                {
                    Misc.Titles.AwardKarma(Caster, karma, true);
                }

                /*
                 * if ( TransformationSpell.UnderTransformation( m_Caster, typeof( VampiricEmbraceSpell ) ) )
                 * {
                 *      bool garlic = false;
                 *
                 *      for ( int i = 0; !garlic && i < m_Info.Reagents.Length; ++i )
                 *              garlic = ( m_Info.Reagents[i] == Reagent.Garlic );
                 *
                 *      if ( garlic )
                 *      {
                 *              m_Caster.SendLocalizedMessage( 1061651 ); // The garlic burns you!
                 *              AOS.Damage( m_Caster, Utility.RandomMinMax( 17, 23 ), 100, 0, 0, 0, 0 );
                 *      }
                 * }
                 */

                return(true);
            }
            else
            {
                DoFizzle();
            }

            return(false);
        }
Пример #6
0
        public bool CheckHSequence(Mobile target)
        {
            try
            {
                RegionControl regstone = null;
                CustomRegion  reg      = null;
                if (target != null)
                {
                    reg = CustomRegion.FindDRDTRegion(target);
                }
                if (reg != null)
                {
                    regstone = reg.GetRegionControler();
                }

                //if your in a region area spells will fail if disallowed, prevents the run outside of area precast
                //run back into region then release spell ability
                if (m_Caster != null && target != null && m_Caster.Spell != null && m_Caster.Region != target.Region && regstone != null && (regstone.IsRestrictedSpell(m_Caster.Spell, m_Caster) || regstone.IsMagicIsolated) && m_Caster.AccessLevel == AccessLevel.Player && ((m_Caster is BaseCreature && !regstone.RestrictCreatureMagic) || m_Caster is PlayerMobile))
                {
                    m_State = SpellState.None;
                    if (m_Caster.Spell == this)
                    {
                        m_Caster.Spell = null;
                    }
                    Targeting.Target.Cancel(m_Caster);
                    m_Caster.SendMessage("You cannot cast your spell into that area.");
                    return(false);
                }
            }
            catch (NullReferenceException e)
            {
                LogHelper.LogException(e);
                Console.WriteLine("{0} Caught exception.", e);
            }
            catch (Exception ex)
            {
                LogHelper.LogException(ex);
            }

            if (!target.Alive)
            {
                m_Caster.SendLocalizedMessage(501857);                 // This spell won't work on that!
                return(false);
            }
            else if (Caster.CanBeHarmful(target) && CheckSequence())
            {
                Caster.DoHarmful(target);
                return(true);
            }
            else
            {
                return(false);
            }
        }