public void OnTarget(Mobile from, object targeted, BaseCommand command, string[] args)
        {
            if (!BaseCommand.IsAccessible(from, targeted))
            {
                from.SendLocalizedMessage(500447); // That is not accessible.
                from.BeginTarget(-1, command.ObjectTypes == ObjectTypes.All, TargetFlags.None,
                                 (m, t) => OnTarget(m, t, command, args));
                return;
            }

            switch (command.ObjectTypes)
            {
            case ObjectTypes.Both:
            {
                if (!(targeted is Item || targeted is Mobile))
                {
                    from.SendMessage("This command does not work on that.");
                    return;
                }

                break;
            }

            case ObjectTypes.Items:
            {
                if (!(targeted is Item))
                {
                    from.SendMessage("This command only works on items.");
                    return;
                }

                break;
            }

            case ObjectTypes.Mobiles:
            {
                if (!(targeted is Mobile))
                {
                    from.SendMessage("This command only works on mobiles.");
                    return;
                }

                break;
            }
            }

            RunCommand(from, targeted, command, args);

            from.BeginTarget(-1, command.ObjectTypes == ObjectTypes.All, TargetFlags.None,
                             (m, t) => OnTarget(m, t, command, args));
        }
예제 #2
0
        public void OnTarget(Mobile from, object targeted, object state)
        {
            if (!BaseCommand.IsAccessible(from, targeted))
            {
                from.SendMessage("That is not accessible.");
                return;
            }

            object[]    states  = (object[])state;
            BaseCommand command = (BaseCommand)states[0];

            string[] args = (string[])states[1];

            switch (command.ObjectTypes)
            {
            case ObjectTypes.Both:
            {
                if (!(targeted is Item) && !(targeted is Mobile))
                {
                    from.SendMessage("This command does not work on that.");
                    return;
                }

                break;
            }

            case ObjectTypes.Items:
            {
                if (!(targeted is Item))
                {
                    from.SendMessage("This command only works on items.");
                    return;
                }

                break;
            }

            case ObjectTypes.Mobiles:
            {
                if (!(targeted is Mobile))
                {
                    from.SendMessage("This command only works on mobiles.");
                    return;
                }

                break;
            }
            }

            this.RunCommand(from, targeted, command, args);
        }
        public override void Compile(Mobile from, BaseCommand command, ref string[] args, ref object obj)
        {
            try
            {
                var ext = Extensions.Parse(from, ref args);

                if (!CheckObjectTypes(from, command, ext, out var _, out var mobiles))
                {
                    return;
                }

                if (!mobiles) // sanity check
                {
                    command.LogFailure("This command does not support items.");
                    return;
                }

                var list = new List <object>();

                var states = TcpServer.Instances;

                for (var i = 0; i < states.Count; ++i)
                {
                    var ns  = states[i];
                    var mob = ns.Mobile;

                    if (mob == null)
                    {
                        continue;
                    }

                    if (!BaseCommand.IsAccessible(from, mob))
                    {
                        continue;
                    }

                    if (ext.IsValid(mob))
                    {
                        list.Add(mob);
                    }
                }

                ext.Filter(list);

                obj = list;
            }
            catch (Exception ex)
            {
                from.SendMessage(ex.Message);
            }
        }
예제 #4
0
        public override void Compile(Mobile from, BaseCommand command, ref string[] args, ref object obj)
        {
            try
            {
                Extensions ext = Extensions.Parse(from, ref args);

                bool items, mobiles;

                if (!CheckObjectTypes(from, command, ext, out items, out mobiles))
                {
                    return;
                }

                Region reg = from.Region;

                ArrayList list = new ArrayList();

                if (mobiles)
                {
                    foreach (Mobile mob in reg.GetMobiles())
                    {
                        if (!BaseCommand.IsAccessible(from, mob))
                        {
                            continue;
                        }

                        if (ext.IsValid(mob))
                        {
                            list.Add(mob);
                        }
                    }
                }
                else
                {
                    command.LogFailure("This command does not support items.");
                    return;
                }

                ext.Filter(list);

                obj = list;
            }
            catch (Exception ex)
            {
                from.SendMessage(ex.Message);
                Server.Diagnostics.ExceptionLogging.LogException(ex);
            }
        }
예제 #5
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            switch (info.ButtonID)
            {
            case 1:
            {
                if (m_Page > 0)
                {
                    m_From.SendGump(new InterfaceGump(m_From, m_Columns, m_List, m_Page - 1, m_Select));
                }

                break;
            }

            case 2:
            {
                if ((m_Page + 1) * EntriesPerPage < m_List.Count)
                {
                    m_From.SendGump(new InterfaceGump(m_From, m_Columns, m_List, m_Page + 1, m_Select));
                }

                break;
            }

            default:
            {
                var v = info.ButtonID - 3;

                if (v >= 0 && v < m_List.Count)
                {
                    var obj = m_List[v];

                    if (!BaseCommand.IsAccessible(m_From, obj))
                    {
                        m_From.SendLocalizedMessage(500447);         // That is not accessible.
                        m_From.SendGump(new InterfaceGump(m_From, m_Columns, m_List, m_Page, m_Select));
                        break;
                    }

                    if (obj is Item item && !item.Deleted)
                    {
                        m_From.SendGump(new InterfaceItemGump(m_From, m_Columns, m_List, m_Page, item));
                    }
                    else if (obj is Mobile mobile && !mobile.Deleted)
                    {
                        m_From.SendGump(new InterfaceMobileGump(m_From, m_Columns, m_List, m_Page, mobile));
                    }
예제 #6
0
        public override void Compile(Mobile from, BaseCommand command, ref string[] args, ref object obj)
        {
            try
            {
                var ext = Extensions.Parse(from, ref args);

                if (!CheckObjectTypes(from, command, ext, out var items, out var mobiles))
                {
                    return;
                }

                var reg = from.Region;

                var list = new List <object>();

                if (mobiles)
                {
                    foreach (var mob in reg.GetMobiles())
                    {
                        if (BaseCommand.IsAccessible(from, mob) && ext.IsValid(mob))
                        {
                            list.Add(mob);
                        }
                    }
                }

                if (items)
                {
                    foreach (var item in reg.GetItems())
                    {
                        if (BaseCommand.IsAccessible(from, item) && ext.IsValid(item))
                        {
                            list.Add(item);
                        }
                    }
                }

                ext.Filter(list);

                obj = list;
            }
            catch (Exception ex)
            {
                from.SendMessage(ex.Message);
            }
        }
예제 #7
0
        public void OnTarget(Mobile from, object targeted, BaseCommand command, string[] args)
        {
            if (!BaseCommand.IsAccessible(from, targeted))
            {
                from.SendLocalizedMessage(500447); // That is not accessible.
                return;
            }

            switch (command.ObjectTypes)
            {
            case ObjectTypes.Both:
            {
                if (targeted is not Item && targeted is not Mobile)
                {
                    from.SendMessage("This command does not work on that.");
                    return;
                }

                break;
            }

            case ObjectTypes.Items:
            {
                if (targeted is not Item)
                {
                    from.SendMessage("This command only works on items.");
                    return;
                }

                break;
            }

            case ObjectTypes.Mobiles:
            {
                if (targeted is not Mobile)
                {
                    from.SendMessage("This command only works on mobiles.");
                    return;
                }

                break;
            }
            }

            RunCommand(from, targeted, command, args);
        }
예제 #8
0
        public override void Compile(Mobile from, BaseCommand command, ref string[] args, ref object obj)
        {
            try
            {
                var ext = Extensions.Parse(from, ref args);

                if (!CheckObjectTypes(from, command, ext, out var _, out var mobiles))
                {
                    return;
                }

                var reg = from.Region;

                var list = new List <object>();

                if (mobiles)
                {
                    foreach (var mob in reg.GetMobiles())
                    {
                        if (!BaseCommand.IsAccessible(from, mob))
                        {
                            continue;
                        }

                        if (ext.IsValid(mob))
                        {
                            list.Add(mob);
                        }
                    }
                }
                else
                {
                    command.LogFailure("This command does not support items.");
                    return;
                }

                ext.Filter(list);

                obj = list;
            }
            catch (Exception ex)
            {
                from.SendMessage(ex.Message);
            }
        }
예제 #9
0
        public void OnTarget(Mobile from, Map map, Point3D start, Point3D end, BaseCommand command, string[] args)
        {
            try
            {
                var rect = new Rectangle2D(start.X, start.Y, end.X - start.X + 1, end.Y - start.Y + 1);

                var ext = Extensions.Parse(from, ref args);

                if (!CheckObjectTypes(from, command, ext, out var items, out var mobiles))
                {
                    return;
                }

                if (!(items || mobiles))
                {
                    return;
                }

                var eable = map.GetObjectsInBounds(rect);

                var objs = new List <object>();

                foreach (var obj in eable)
                {
                    if (!mobiles && obj is Mobile || !items && obj is Item)
                    {
                        continue;
                    }

                    if (BaseCommand.IsAccessible(from, obj) && ext.IsValid(obj))
                    {
                        objs.Add(obj);
                    }
                }

                eable.Free();
                ext.Filter(objs);

                RunCommand(from, objs, command, args);
            }
            catch (Exception ex)
            {
                from.SendMessage(ex.Message);
            }
        }
        public void OnTarget(Mobile from, Map map, Point3D start, Point3D end, BaseCommand command, string[] args)
        {
            try
            {
                Rectangle2D rect = new Rectangle2D(start.X, start.Y, end.X - start.X + 1, end.Y - start.Y + 1);

                Extensions ext = Extensions.Parse(from, ref args);

                if (!CheckObjectTypes(from, command, ext, out bool items, out bool mobiles))
                {
                    return;
                }

                if (!(items || mobiles))
                {
                    return;
                }

                IPooledEnumerable <IEntity> eable = map.GetObjectsInBounds(rect, items, mobiles);

                List <object> objs = new List <object>();

                foreach (IEntity obj in eable)
                {
                    if ((!mobiles || obj is Mobile) && BaseCommand.IsAccessible(from, obj) && ext.IsValid(obj))
                    {
                        objs.Add(obj);
                    }
                }


                eable.Free();
                ext.Filter(objs);

                RunCommand(from, objs, command, args);
            }
            catch (Exception ex)
            {
                from.SendMessage(ex.Message);
            }
        }
예제 #11
0
        public void OnTarget(Mobile from, Map map, Point3D start, Point3D end, object state)
        {
            try
            {
                object[]    states  = (object[])state;
                BaseCommand command = (BaseCommand)states[0];
                string[]    args    = (string[])states[1];

                Rectangle2D rect = new Rectangle2D(start.X, start.Y, end.X - start.X + 1, end.Y - start.Y + 1);

                Extensions ext = Extensions.Parse(from, ref args);

                bool items, mobiles;

                if (!CheckObjectTypes(from, command, ext, out items, out mobiles))
                {
                    return;
                }

                IPooledEnumerable eable;

                if (items && mobiles)
                {
                    eable = map.GetObjectsInBounds(rect);
                }
                else if (items)
                {
                    eable = map.GetItemsInBounds(rect);
                }
                else if (mobiles)
                {
                    eable = map.GetMobilesInBounds(rect);
                }
                else
                {
                    return;
                }

                ArrayList objs = new ArrayList();

                foreach (object obj in eable)
                {
                    if (mobiles && obj is Mobile && !BaseCommand.IsAccessible(from, obj))
                    {
                        continue;
                    }

                    if (ext.IsValid(obj))
                    {
                        objs.Add(obj);
                    }
                }

                eable.Free();

                ext.Filter(objs);

                RunCommand(from, objs, command, args);
            }
            catch (Exception ex)
            {
                from.SendMessage(ex.Message);
                Diagnostics.ExceptionLogging.LogException(ex);
            }
        }
예제 #12
0
        public override void Compile(Mobile from, BaseCommand command, ref string[] args, ref object obj)
        {
            try
            {
                Extensions ext = Extensions.Parse(from, ref args);

                bool items, mobiles;

                if (!CheckObjectTypes(from, command, ext, out items, out mobiles))
                {
                    return;
                }

                Region reg = from.Region;

                ArrayList list = new ArrayList();

                if (mobiles)
                {
                    foreach (Mobile mob in reg.GetMobiles())
                    {
                        if (!BaseCommand.IsAccessible(from, mob))
                        {
                            continue;
                        }

                        if (ext.IsValid(mob))
                        {
                            list.Add(mob);
                        }
                    }
                }

                else if (items)
                {
                    foreach (Item item in reg.GetItems())
                    {
                        if (!BaseCommand.IsAccessible(from, item))
                        {
                            continue;
                        }

                        if (ext.IsValid(item))
                        {
                            list.Add(item);
                        }
                    }
                }


                else
                {
                    command.LogFailure("Could not find item or mobile with property in region.");
                    return;
                }

                ext.Filter(list);

                obj = list;
            }
            catch (Exception ex)
            {
                from.SendMessage(ex.Message);
            }
        }
예제 #13
0
        public void OnTarget(Mobile from, object targeted, object state)
        {
            if (!BaseCommand.IsAccessible(from, targeted))
            {
                from.SendMessage("That is not accessible.");
                return;
            }

            object[]    states  = (object[])state;
            BaseCommand command = (BaseCommand)states[0];

            string[] args = (string[])states[1];

            if (command.ObjectTypes == ObjectTypes.Mobiles)
            {
                return; // sanity check
            }
            if (!(targeted is Container))
            {
                from.SendMessage("That is not a container.");
            }
            else
            {
                try
                {
                    Extensions ext = Extensions.Parse(from, ref args);

                    bool items, mobiles;

                    if (!CheckObjectTypes(from, command, ext, out items, out mobiles))
                    {
                        return;
                    }

                    if (!items)
                    {
                        from.SendMessage("This command only works on items.");
                        return;
                    }

                    Container cont = (Container)targeted;

                    Item[] found = cont.FindItemsByType(typeof(Item), true);

                    ArrayList list = new ArrayList();

                    for (int i = 0; i < found.Length; ++i)
                    {
                        if (ext.IsValid(found[i]))
                        {
                            list.Add(found[i]);
                        }
                    }

                    ext.Filter(list);

                    RunCommand(from, list, command, args);
                }
                catch (Exception e)
                {
                    from.SendMessage(e.Message);
                }
            }
        }
예제 #14
0
파일: Interface.cs 프로젝트: ygtkms/ServUO
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (m_Mobile.Deleted)
            {
                m_From.SendGump(new InterfaceGump(m_From, m_Columns, m_List, m_Page, m_Mobile));
                return;
            }
            else if (!BaseCommand.IsAccessible(m_From, m_Mobile))
            {
                m_From.SendMessage("That is no longer accessible.");
                m_From.SendGump(new InterfaceGump(m_From, m_Columns, m_List, m_Page, m_Mobile));
                return;
            }

            switch (info.ButtonID)
            {
            case 0:
            case 1:
            {
                m_From.SendGump(new InterfaceGump(m_From, m_Columns, m_List, m_Page, m_Mobile));
                break;
            }

            case 2:     // Properties
            {
                m_From.SendGump(new InterfaceMobileGump(m_From, m_Columns, m_List, m_Page, m_Mobile));
                m_From.SendGump(new PropertiesGump(m_From, m_Mobile));
                break;
            }

            case 3:     // Delete
            {
                if (!m_Mobile.Player)
                {
                    CommandLogging.WriteLine(m_From, "{0} {1} deleting {2}", m_From.AccessLevel, CommandLogging.Format(m_From), CommandLogging.Format(m_Mobile));
                    m_Mobile.Delete();
                    m_From.SendGump(new InterfaceGump(m_From, m_Columns, m_List, m_Page, m_Mobile));
                }

                break;
            }

            case 4:     // Go there
            {
                m_From.SendGump(new InterfaceMobileGump(m_From, m_Columns, m_List, m_Page, m_Mobile));
                InvokeCommand(String.Format("Go {0}", m_Mobile.Serial.Value));
                break;
            }

            case 5:     // Bring them here
            {
                if (m_From.Map == null || m_From.Map == Map.Internal)
                {
                    m_From.SendMessage("You cannot bring that person here.");
                }
                else
                {
                    m_From.SendGump(new InterfaceMobileGump(m_From, m_Columns, m_List, m_Page, m_Mobile));
                    m_Mobile.MoveToWorld(m_From.Location, m_From.Map);
                }

                break;
            }

            case 6:     // Move to target
            {
                m_From.SendGump(new InterfaceMobileGump(m_From, m_Columns, m_List, m_Page, m_Mobile));
                m_From.Target = new MoveTarget(m_Mobile);
                break;
            }

            case 7:     // Kill
            {
                if (m_From == m_Mobile || m_From.AccessLevel > m_Mobile.AccessLevel)
                {
                    m_Mobile.Kill();
                }

                m_From.SendGump(new InterfaceMobileGump(m_From, m_Columns, m_List, m_Page, m_Mobile));

                break;
            }

            case 8:     // Res
            {
                if (m_From == m_Mobile || m_From.AccessLevel > m_Mobile.AccessLevel)
                {
                    m_Mobile.PlaySound(0x214);
                    m_Mobile.FixedEffect(0x376A, 10, 16);

                    m_Mobile.Resurrect();
                }

                m_From.SendGump(new InterfaceMobileGump(m_From, m_Columns, m_List, m_Page, m_Mobile));

                break;
            }

            case 9:     // Client
            {
                m_From.SendGump(new InterfaceMobileGump(m_From, m_Columns, m_List, m_Page, m_Mobile));

                if (m_Mobile.NetState != null)
                {
                    m_From.SendGump(new ClientGump(m_From, m_Mobile.NetState));
                }

                break;
            }
            }
        }
예제 #15
0
파일: Interface.cs 프로젝트: ygtkms/ServUO
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (m_Item.Deleted)
            {
                m_From.SendGump(new InterfaceGump(m_From, m_Columns, m_List, m_Page, m_Item));
                return;
            }
            else if (!BaseCommand.IsAccessible(m_From, m_Item))
            {
                m_From.SendMessage("That is no longer accessible.");
                m_From.SendGump(new InterfaceGump(m_From, m_Columns, m_List, m_Page, m_Item));
                return;
            }

            switch (info.ButtonID)
            {
            case 0:
            case 1:
            {
                m_From.SendGump(new InterfaceGump(m_From, m_Columns, m_List, m_Page, m_Item));
                break;
            }

            case 2:     // Properties
            {
                m_From.SendGump(new InterfaceItemGump(m_From, m_Columns, m_List, m_Page, m_Item));
                m_From.SendGump(new PropertiesGump(m_From, m_Item));
                break;
            }

            case 3:     // Delete
            {
                CommandLogging.WriteLine(m_From, "{0} {1} deleting {2}", m_From.AccessLevel, CommandLogging.Format(m_From), CommandLogging.Format(m_Item));
                m_Item.Delete();
                m_From.SendGump(new InterfaceGump(m_From, m_Columns, m_List, m_Page, m_Item));
                break;
            }

            case 4:     // Go there
            {
                m_From.SendGump(new InterfaceItemGump(m_From, m_Columns, m_List, m_Page, m_Item));
                InvokeCommand(String.Format("Go {0}", m_Item.Serial.Value));
                break;
            }

            case 5:     // Move to target
            {
                m_From.SendGump(new InterfaceItemGump(m_From, m_Columns, m_List, m_Page, m_Item));
                m_From.Target = new MoveTarget(m_Item);
                break;
            }

            case 6:     // Bring to pack
            {
                Mobile owner = m_Item.RootParent as Mobile;

                if (owner != null && (owner.Map != null && owner.Map != Map.Internal) && !BaseCommand.IsAccessible(m_From, owner) /* !m_From.CanSee( owner )*/)
                {
                    m_From.SendMessage("You can not get what you can not see.");
                }
                else if (owner != null && (owner.Map == null || owner.Map == Map.Internal) && owner.Hidden && owner.AccessLevel >= m_From.AccessLevel)
                {
                    m_From.SendMessage("You can not get what you can not see.");
                }
                else
                {
                    m_From.SendGump(new InterfaceItemGump(m_From, m_Columns, m_List, m_Page, m_Item));
                    m_From.AddToBackpack(m_Item);
                }

                break;
            }
            }
        }