Exemplo n.º 1
0
        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;
            }
            }
        }
Exemplo n.º 2
0
        private static void EventSink_Login(LoginEventArgs args)
        {
            if (!CentralMemory.Running || !CSS.Running)
            {
                return;
            }

            Mobile m = args.Mobile;

            IconsModule im = (IconsModule)CentralMemory.GetModule(m.Serial, typeof(IconsModule));

            if (im == null)
            {
                return;
            }

            IconsModule imRemove = new IconsModule(m.Serial);

            foreach (KeyValuePair <Type, IconInfo> kvp in im.Icons)
            {
                IconInfo ii = kvp.Value;
                if (ii == null)
                {
                    imRemove.Add(ii);
                    continue;
                }

                if (ii.SpellType == null || ii.School == School.Invalid)
                {
                    imRemove.Add(ii);
                    continue;
                }

                if (SpellRestrictions.UseRestrictions && !SpellRestrictions.CheckRestrictions(m, ii.School))
                {
                    imRemove.Add(ii);
                    continue;
                }

                m.SendGump(new SpellIconGump(ii));
            }

            if (im.Icons.Count > 0)
            {
                CentralMemory.AppendModule(m.Serial, (Module)imRemove, true);
            }
        }
Exemplo n.º 3
0
        public override Item CreateBulkOrder(Mobile from, bool fromContextMenu)
        {
            PlayerMobile pm      = from as PlayerMobile;
            BODModule    bod_mod = (BODModule)CentralMemory.GetModule(from.Serial, typeof(BODModule));

            if (bod_mod == null && from == null)
            {
                return(null);
            }

            if (bod_mod != null && bod_mod.NextCarpenterBulkOrder == TimeSpan.Zero && (fromContextMenu || 0.2 > Utility.RandomDouble()))
            {
                double theirSkill = pm.Skills[SkillName.Carpentry].Base;

                if (theirSkill >= 70.1)
                {
                    bod_mod.NextCarpenterBulkOrder = TimeSpan.FromHours(3.0);
                }
                else if (theirSkill >= 50.1)
                {
                    bod_mod.NextCarpenterBulkOrder = TimeSpan.FromHours(2.0);
                }
                else
                {
                    bod_mod.NextCarpenterBulkOrder = TimeSpan.FromHours(1.0);
                }

                if (theirSkill >= 70.1 && ((theirSkill - 40.0) / 300.0) > Utility.RandomDouble())
                {
                    return(new LargeCarpenterBOD());
                }

                return(SmallCarpenterBOD.CreateRandomFor(from));
            }
            else
            {
                CentralMemory.AppendModule(from.Serial, new BODModule(from.Serial), true);
                from.SendMessage("Please try again");
            }

            return(null);
        }
        public override void OnResponse(NetState state, RelayInfo info)
        {
            Mobile from = state.Mobile;

            switch (info.ButtonID)
            {
            //Apply
            case 1:
            {
                if (!CentralMemory.Running)
                {
                    from.SendMessage("There is no Central Memory!  Please page an Admin to assist.");
                    return;
                }

                IconInfo ii = new IconInfo(m_Spell, m_Icon, m_X, m_Y, m_Background, m_School);

                if (!CentralMemory.ContainsModule(from.Serial, typeof(IconsModule)))
                {
                    CentralMemory.AddModule(from.Serial, typeof(IconsModule));
                }

                IconsModule im = new IconsModule(from.Serial);
                im.Add(ii);

                CentralMemory.AppendModule(from.Serial, (Module)im, false);

                from.SendGump(new SpellIconGump(ii));
                break;
            }

            //Move
            case 2:
            {
                TextRelay xrelay  = info.GetTextEntry(7);
                TextRelay yrelay  = info.GetTextEntry(8);
                string    xstring = (xrelay == null ? null : xrelay.Text.Trim());
                string    ystring = (yrelay == null ? null : yrelay.Text.Trim());
                if (xstring == null || xstring.Length == 0 || ystring == null || ystring.Length == 0)
                {
                    from.SendMessage("Please enter a X coordinate in the top box and a Y coordinate in the bottom box");
                }
                else
                {
                    int x = m_X;
                    int y = m_Y;
                    try
                    {
                        x   = Int32.Parse(xstring);
                        y   = Int32.Parse(ystring);
                        m_X = x;
                        m_Y = y;
                    }
                    catch
                    {
                        from.SendMessage("Please enter a X coordinate in the top box and a Y coordinate in the bottom box");
                    }
                }
                if (m_X < 0)
                {
                    m_X = 0;
                    from.SendMessage("You cannot go any farther left");
                }
                if (m_Y < 0)
                {
                    m_Y = 0;
                    from.SendMessage("You cannot go any farther up");
                }

                from.CloseGump(typeof(IconPlacementGump));
                from.SendGump(new IconPlacementGump(m_Book, from, m_X, m_Y, m_I, m_Icon, m_Spell, m_Background, m_School));
                break;
            }

            //Up
            case 3:
            {
                MakeI(info);
                from.CloseGump(typeof(IconPlacementGump));
                if ((m_Y - m_I) < 0)
                {
                    m_Y = 0;
                    from.SendMessage("You cannot go any farther up");
                    from.SendGump(new IconPlacementGump(m_Book, from, m_X, m_Y, m_I, m_Icon, m_Spell, m_Background, m_School));
                }
                else
                {
                    from.SendGump(new IconPlacementGump(m_Book, from, m_X, (m_Y - m_I), m_I, m_Icon, m_Spell, m_Background, m_School));
                }
                break;
            }

            //Right
            case 4:
            {
                MakeI(info);
                from.CloseGump(typeof(IconPlacementGump));
                from.SendGump(new IconPlacementGump(m_Book, from, (m_X + m_I), m_Y, m_I, m_Icon, m_Spell, m_Background, m_School));
                break;
            }

            //Down
            case 5:
            {
                MakeI(info);
                from.CloseGump(typeof(IconPlacementGump));
                from.SendGump(new IconPlacementGump(m_Book, from, m_X, (m_Y + m_I), m_I, m_Icon, m_Spell, m_Background, m_School));
                break;
            }

            //Left
            case 6:
            {
                MakeI(info);
                from.CloseGump(typeof(IconPlacementGump));
                if ((m_X - m_I) < 0)
                {
                    m_X = 0;
                    from.SendMessage("You cannot go any farther left");
                    from.SendGump(new IconPlacementGump(m_Book, from, m_X, m_Y, m_I, m_Icon, m_Spell, m_Background, m_School));
                }
                else
                {
                    from.SendGump(new IconPlacementGump(m_Book, from, (m_X - m_I), m_Y, m_I, m_Icon, m_Spell, m_Background, m_School));
                }
                break;
            }
            }
        }