Example #1
0
 public override bool CheckCast()
 {
     if (SpellRestrictions.UseRestrictions)
     {
         return(SpellRestrictions.CheckRestrictions(Caster, this.GetType()));
     }
     return(true);
 }
Example #2
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>");
            }
        }
        public override void OnResponse(NetState state, RelayInfo info)
        {
            if (!CSS.Running || !CentralMemory.Running)
            {
                return;
            }

            switch (info.ButtonID)
            {
            case 1:
            {
                IconsModule mod = new IconsModule(state.Mobile.Serial, m_Info);
                CentralMemory.AppendModule(state.Mobile.Serial, (Module)mod, true);
                state.Mobile.SendMessage("That icon has been removed and will not open again.");
                break;
            }

            case 2:
            {
                if (!Multis.DesignContext.Check(state.Mobile))
                {
                    state.Mobile.SendMessage("You cannot cast while customizing!");
                    state.Mobile.SendGump(new SpellIconGump(m_Info));
                    return;
                }
                if (SpellRestrictions.UseRestrictions && !SpellRestrictions.CheckRestrictions(state.Mobile, m_Info.SpellType))
                {
                    state.Mobile.SendMessage("You are not allowed to cast this spell.");
                    return;
                }

                if (!CSpellbook.MobileHasSpell(state.Mobile, m_Info.School, m_Info.SpellType))
                {
                    state.Mobile.SendMessage("You do not have this spell.");
                    goto case 1;
                }

                Spell spell = SpellInfoRegistry.NewSpell(m_Info.SpellType, m_Info.School, state.Mobile, null);
                if (spell != null)
                {
                    spell.Cast();
                }
                else
                {
                    state.Mobile.SendMessage("This spell has been disabled.");
                    goto case 1;
                }

                state.Mobile.SendGump(new SpellIconGump(m_Info));
                break;
            }
            }
        }
Example #4
0
        public static Spell NewSpell(Type type, School school, Mobile caster, Item scroll)
        {
            if (!CSS.Running)
            {
                return(null);
            }
            else if (school == School.Invalid && scroll == null && !CheckBooksForSchool(caster, type))
            {
                return(null);
            }
            else if (!CheckRegistry(school, type))
            {
                return(null);
            }
            else if (!SpellRestrictions.UseRestrictions && SpellRestrictions.CheckRestrictions(caster, type))
            {
                return(null);
            }

            m_Params[0] = caster;
            m_Params[1] = scroll;

            return((Spell)Activator.CreateInstance(type, m_Params));;
        }
Example #5
0
        public override void OnResponse(NetState state, RelayInfo info)
        {
            if (info.ButtonID == 0 || !CSS.Running)
            {
                return;
            }

            else if (info.ButtonID >= 1000 && info.ButtonID < (1000 + m_Spells.Count))
            {
                if (SpellRestrictions.UseRestrictions && !SpellRestrictions.CheckRestrictions(state.Mobile, m_Book.School))
                {
                    state.Mobile.SendMessage("You are not allowed to cast this spell.");
                    return;
                }

                CSpellInfo si = SpellInfoRegistry.GetInfo(m_Book.School, (Type)m_Spells[info.ButtonID - 1000]);
                if (si == null)
                {
                    state.Mobile.SendMessage("That spell is disabled.");
                    return;
                }
                state.Mobile.CloseGump(typeof(ScrollGump));
                state.Mobile.SendGump(new ScrollGump(m_Book, si, TextHue, state.Mobile));
                //				m_Book.Mark = (info.ButtonID-1000)/16;
                //				state.Mobile.SendMessage( "{0}", m_Book.Mark );
            }

            else if (info.ButtonID >= 2000 && info.ButtonID < (2000 + m_Spells.Count))
            {
                if (SpellRestrictions.UseRestrictions && !SpellRestrictions.CheckRestrictions(state.Mobile, m_Book.School))
                {
                    state.Mobile.SendMessage("You are not allowed to cast this spell.");
                    return;
                }

                if (!CSpellbook.MobileHasSpell(state.Mobile, m_Book.School, (Type)m_Spells[info.ButtonID - 2000]))
                {
                    state.Mobile.SendMessage("You do not have this spell.");
                    return;
                }

                Spell spell = SpellInfoRegistry.NewSpell((Type)m_Spells[info.ButtonID - 2000], m_Book.School, state.Mobile, null);
                if (spell == null)
                {
                    state.Mobile.SendMessage("That spell is disabled.");
                }
                else
                {
                    spell.Cast();
                }
                //				m_Book.Mark = (info.ButtonID-2000)/16;
                //				state.Mobile.SendMessage( "{0}", m_Book.Mark );
            }

            object[] Params = new object[1] {
                m_Book
            };
            CSpellbookGump gump = Activator.CreateInstance(GumpType, Params) as CSpellbookGump;

            if (gump != null)
            {
                state.Mobile.SendGump(gump);
            }

            //GumpUpTimer
        }
Example #6
0
        public override void OnResponse(NetState state, RelayInfo info)
        {
            if (info.ButtonID == 0 || !CSS.Running)
            {
                return;
            }

            else if (info.ButtonID == 1)
            {
                if (SpellRestrictions.UseRestrictions && !SpellRestrictions.CheckRestrictions(state.Mobile, m_Info.School))
                {
                    state.Mobile.SendMessage("You are not allowed to cast this spell.");
                    return;
                }

                if (!CSpellbook.MobileHasSpell(state.Mobile, m_Info.School, m_Info.Type))
                {
                    state.Mobile.SendMessage("You do not have this spell.");
                    return;
                }

                Spell spell = SpellInfoRegistry.NewSpell(m_Info.Type, m_Info.School, state.Mobile, null);
                if (spell == null)
                {
                    state.Mobile.SendMessage("That spell is disabled.");
                }
                else
                {
                    spell.Cast();
                }
            }

            else if (info.ButtonID == 2)
            {
                //Scribe
            }

            else if (info.ButtonID == 3)
            {
                if (!CentralMemory.Running)
                {
                    return;
                }

                if (SpellRestrictions.UseRestrictions && !SpellRestrictions.CheckRestrictions(state.Mobile, m_Info.School))
                {
                    return;
                }

                state.Mobile.SendGump(new IconPlacementGump(m_Book, state.Mobile, 100, 100, 10, m_Info.Icon, m_Info.Type, m_Info.Back, m_Book.School));
            }

            else if (info.ButtonID == 4)
            {
                if (!CentralMemory.Running)
                {
                    return;
                }

                string command = info.GetTextEntry(5).Text;

                if (command == null || command.Length == 0)
                {
                    if (m_CastCommandModule == null)
                    {
                        state.Mobile.SendGump(new ScrollGump(m_Book, m_Info, m_TextHue, state.Mobile));
                        return;
                    }

                    m_CastCommandModule.RemoveCommandByInfo(m_CastInfo);
                    state.Mobile.SendGump(new ScrollGump(m_Book, m_Info, m_TextHue, state.Mobile));
                }
                else
                {
                    if (m_CastCommandModule == null)
                    {
                        CentralMemory.AddModule(new CastCommandsModule(state.Mobile.Serial, command, m_CastInfo));
                        state.Mobile.SendGump(new ScrollGump(m_Book, m_Info, m_TextHue, state.Mobile));
                        return;
                    }

                    m_CastCommandModule.Add(command, m_CastInfo);
                    state.Mobile.SendGump(new ScrollGump(m_Book, m_Info, m_TextHue, state.Mobile));
                }
            }
        }