Пример #1
0
        private static void CSSCast_OnCommand(CommandEventArgs e)
        {
            if (e.Length == 1)
            {
                if (!CentralMemory.Running || !CSS.Running)
                {
                    e.Mobile.SendMessage("The Central Memory is not running.  This command is disabled.");
                    return;
                }

                if (!Multis.DesignContext.Check(e.Mobile))
                {
                    e.Mobile.SendMessage("You cannot cast while customizing!");
                    return;
                }

                CastCommandsModule module = (CastCommandsModule)CentralMemory.GetModule(e.Mobile.Serial, typeof(CastCommandsModule));
                if (module == null)
                {
                    e.Mobile.SendMessage("You do not have any commands to cast stored.");
                    return;
                }

                CastInfo info = module.Get(e.GetString(0));
                if (info == null)
                {
                    e.Mobile.SendMessage("You have not assigned that command to any spells.");
                    return;
                }

                if (SpellRestrictions.UseRestrictions && !SpellRestrictions.CheckRestrictions(e.Mobile, info.SpellType))
                {
                    e.Mobile.SendMessage("You are not allowed to cast this spell.");
                    return;
                }

                if (!CSpellbook.MobileHasSpell(e.Mobile, info.School, info.SpellType))
                {
                    e.Mobile.SendMessage("You do not have this spell.");
                    return;
                }

                Spell spell = SpellInfoRegistry.NewSpell(info.SpellType, info.School, e.Mobile, null);
                if (spell != null)
                {
                    spell.Cast();
                }
                else
                {
                    e.Mobile.SendMessage("This spell has been disabled.");
                }
            }
            else
            {
                e.Mobile.SendMessage("Format: Cast <text>");
            }
        }