コード例 #1
0
        public override void Execute()
        {
            int serial = UO.Commands.GetTargeSerialAsync(Strings.Target_object___).Result;

            if (serial <= 0)
            {
                return;
            }

            Entity entity = UOMath.IsMobile(serial)
                ? (Entity)Engine.Mobiles.GetMobile(serial)
                : Engine.Items.GetItem(serial);

            if (entity == null)
            {
                return;
            }

            Thread t = new Thread(() =>
            {
                ObjectInspectorWindow window =
                    new ObjectInspectorWindow {
                    DataContext = new ObjectInspectorViewModel(entity)
                };

                window.ShowDialog();
            })
            {
                IsBackground = true
            };

            t.SetApartmentState(ApartmentState.STA);
            t.Start();
        }
コード例 #2
0
        public static int Graphic(object obj = null)
        {
            int serial = AliasCommands.ResolveSerial(obj);

            if (serial == 0)
            {
                UOC.SystemMessage(Strings.Invalid_or_unknown_object_id);
                return(0);
            }

            Entity entity = UOMath.IsMobile(serial)
                ? Engine.Mobiles.GetMobile(serial)
                : Engine.Items.GetItem(serial) as Entity;

            if (entity != null)
            {
                return(entity.ID);
            }

            if (!MacroManager.QuietMode)
            {
                UOC.SystemMessage(Strings.Entity_not_found___);
            }

            return(0);
        }
コード例 #3
0
        public Entity PromptTarget()
        {
            int serial = UOC.GetTargetSerialAsync(Strings.Target_object___).Result;

            if (serial == 0)
            {
                UOC.SystemMessage(Strings.Invalid_or_unknown_object_id);
                return(null);
            }

            Entity entity = UOMath.IsMobile(serial)
                ? (Entity)Engine.Mobiles.GetMobile(serial)
                : Engine.Items.GetItem(serial);

            if (entity != null)
            {
                return(entity);
            }

            if (!MacroManager.QuietMode)
            {
                UOC.SystemMessage(
                    UOMath.IsMobile(serial) ? Strings.Mobile_not_found___ : Strings.Cannot_find_item___);
            }

            return(null);
        }
コード例 #4
0
        private static void OnItemDeleted(PacketReader reader)
        {
            int serial = reader.ReadInt32();

            Mobile mobile = Engine.Mobiles
                            .FirstOrDefault(m => m.GetEquippedItems().Any(i => i.Serial == serial));

            if (mobile != null)
            {
                Item item = Engine.Items.GetItem(serial);

                if (item != null)
                {
                    mobile.SetLayer(item.Layer, 0);
                }
            }

            if (UOMath.IsMobile(serial))
            {
                Engine.Mobiles.Remove(serial);
                Engine.Items.RemoveByOwner(serial);
            }
            else
            {
                Engine.Items.Remove(serial);
            }
        }
コード例 #5
0
        public static void UpdateLabel(int index, int serial, string name, string text)
        {
            ClientInfo ci;

            if (!GetClient(index, out ci))
            {
                return;
            }

            if (UOMath.IsMobile(serial))
            {
                Mobile m;
                if (ci.Mobiles.GetMobile(serial, out m))
                {
                    m.Name  = name;
                    m.Label = text;
                }
            }
            else
            {
                Item i;
                if (ci.Items.GetItem(serial, out i))
                {
                    i.Name  = UOMachine.Data.Cliloc.GetLocalString(name);
                    i.Label = text;
                }
            }
        }
コード例 #6
0
        public static bool FindLayer(object layer, object obj = null)
        {
            if (obj == null)
            {
                obj = "self";
            }

            int serial = AliasCommands.ResolveSerial(obj);

            if (serial == 0)
            {
                UOC.SystemMessage(Strings.Invalid_or_unknown_object_id, true);
                return(false);
            }

            Layer layerValue = Layer.Invalid;

            switch (layer)
            {
            case string s:
                layerValue = Utility.GetEnumValueByName <Layer>(s);
                break;

            case int i:
                layerValue = (Layer)i;
                break;

            case Layer l:
                layerValue = l;
                break;
            }

            if (layerValue == Layer.Invalid)
            {
                UOC.SystemMessage(Strings.Invalid_layer_value___);
                return(false);
            }

            if (!UOMath.IsMobile(serial))
            {
                UOC.SystemMessage(Strings.Cannot_find_item___);
                return(false);
            }

            Mobile mobile = Engine.Mobiles.GetMobile(serial);

            int layerSerial = mobile?.GetLayer(layerValue) ?? 0;

            if (layerSerial == 0)
            {
                AliasCommands.UnsetAlias("found");
                return(false);
            }

            AliasCommands.SetMacroAlias("found", layerSerial);

            UOC.SystemMessage(string.Format(Strings.Object___0___updated___, "found"), true);

            return(true);
        }
コード例 #7
0
        private static void OnProperties(PacketReader reader)
        {
            reader.Seek(2, SeekOrigin.Current);   // word 1

            int serial = reader.ReadInt32();

            reader.Seek(2, SeekOrigin.Current);   // word 0

            int hash = reader.ReadInt32();

            List <Property> list = new List <Property>();

            int    cliloc;
            bool   first = true;
            string name  = "";

            while ((cliloc = reader.ReadInt32()) != 0)
            {
                Property property = new Property {
                    Cliloc = cliloc
                };

                int length = reader.ReadInt16();

                property.Arguments = reader.ReadUnicodeString(length)
                                     .Split(new[] { '\t' }, StringSplitOptions.RemoveEmptyEntries);

                property.Text = Cliloc.GetLocalString(cliloc, property.Arguments);

                if (first)
                {
                    name  = property.Text;
                    first = false;
                }

                list.Add(property);
            }

            if (Engine.Player?.Serial == serial)
            {
                Engine.Player.Name       = name;
                Engine.Player.Properties = list.ToArray();
                Engine.UpdateWindowTitle();
            }
            else if (UOMath.IsMobile(serial))
            {
                Mobile mobile = Engine.GetOrCreateMobile(serial);

                mobile.Name       = name;
                mobile.Properties = list.ToArray();
            }
            else
            {
                Item item = Engine.GetOrCreateItem(serial);

                item.Name       = name;
                item.Properties = list.ToArray();
            }
        }
コード例 #8
0
        public static void Target(object obj, bool checkRange = false, bool useQueue = false)
        {
            int serial = AliasCommands.ResolveSerial(obj);

            if (serial == 0)
            {
                return;
            }

            if (checkRange && UOMath.IsMobile(serial) && Engine.TargetExists)
            {
                Mobile mobile = Engine.Mobiles.GetMobile(serial);

                if (mobile != null)
                {
                    if (mobile.Distance > Options.CurrentOptions.RangeCheckLastTargetAmount)
                    {
                        UOC.SystemMessage(Strings.Target_out_of_range__try_again___);
                        UOC.ResendTargetToClient();
                        return;
                    }
                }
                else
                {
                    UOC.SystemMessage(Strings.Target_out_of_range__try_again___);
                    UOC.ResendTargetToClient();
                    return;
                }
            }

            if (Options.CurrentOptions.PreventTargetingInnocentsInGuardzone && Engine.TargetExists)
            {
                Mobile mobile = Engine.Mobiles.GetMobile(serial);

                if (mobile != null && mobile.Notoriety == Notoriety.Innocent &&
                    mobile.Serial != Engine.Player?.Serial && Engine.TargetFlags == TargetFlags.Harmful &&
                    mobile.GetRegion().Attributes.HasFlag(RegionAttributes.Guarded))
                {
                    UOC.SystemMessage(Strings.Target_blocked____try_again___);
                    UOC.ResendTargetToClient();

                    return;
                }
            }

            if (useQueue && !Engine.TargetExists)
            {
                MsgCommands.HeadMsg(Strings.Target_Queued, Engine.Player?.Serial);
                Engine.LastTargetQueue.Enqueue(new TargetQueueObject {
                    Object = obj
                });
                return;
            }

            Engine.SendPacketToServer(new Target(TargetTypeEnum.Object, -1, TargetFlags.None, serial, -1, -1, -1, 0,
                                                 true));
            Engine.TargetExists = false;
        }
コード例 #9
0
        public void SetLastTarget(Entity m)
        {
            Engine.Player.LastTargetSerial = m.Serial;

            if (!UOMath.IsMobile(m.Serial))
            {
                return;
            }

            MsgCommands.HeadMsg("[Target]", m.Serial);
            MsgCommands.HeadMsg($"Target: {m.Name?.Trim() ?? "Unknown"}");
            Engine.SendPacketToClient(new ChangeCombatant(m.Serial));
        }
コード例 #10
0
        public static bool UseLayer(object layer, object obj = null)
        {
            int serial = AliasCommands.ResolveSerial(obj);

            if (serial == 0 || !UOMath.IsMobile(serial))
            {
                UOC.SystemMessage(Strings.Cannot_find_item___);
                return(false);
            }

            Layer layerValue = Layer.Invalid;

            switch (layer)
            {
            case string s:
                layerValue = Utility.GetEnumValueByName <Layer>(s);
                break;

            case int i:
                layerValue = (Layer)i;
                break;

            case Layer l:
                layerValue = l;
                break;
            }

            Mobile mobile = Engine.Mobiles.GetMobile(serial);

            if (mobile == null)
            {
                if (!MacroManager.QuietMode)
                {
                    UOC.SystemMessage(Strings.Mobile_not_found___);
                }

                return(false);
            }

            int layerSerial = mobile.GetLayer(layerValue);

            if (layerSerial == 0)
            {
                UOC.SystemMessage(Strings.Cannot_find_item___);
                return(false);
            }

            UseObject(layerSerial);

            return(true);
        }
コード例 #11
0
        public static string Direction(object obj = null)
        {
            int serial = AliasCommands.ResolveSerial(obj);

            Entity entity = UOMath.IsMobile(serial)
                ? Engine.Mobiles.GetMobile(serial)
                : Engine.Items.GetItem(serial) as Entity;

            if (serial == 0 || entity == null)
            {
                UOC.SystemMessage(Strings.Invalid_or_unknown_object_id);
                return(UO.Data.Direction.Invalid.ToString());
            }

            return(entity.Direction.ToString());
        }
コード例 #12
0
        public static bool FindAlias(string aliasName)
        {
            int serial;

            if ((serial = GetAlias(aliasName)) == -1)
            {
                return(false);
            }

            if (UOMath.IsMobile(serial))
            {
                return(Engine.Mobiles.GetMobile(serial) != null);
            }

            return(Engine.Items.GetItem(serial) != null);
        }
コード例 #13
0
            private static void OutgoingPackets_UseItemRequestedEvent(int client, int serial)
            {
                ClientInfo ci;

                if (!ClientInfoCollection.GetClient(client, out ci))
                {
                    return;
                }

                if ((serial & ~0x7FFFFFFF) != 0)
                {
                    serial ^= ~0x7FFFFFFF;
                    if (ci.Player.Serial == serial)
                    {
                        TreeViewUpdater.UpdateLastObject(ci.ProcessID, (WorldItem)ci.Player);
                        return;
                    }
                }
                if (UOMath.IsMobile(serial))
                {
                    Mobile m;
                    if (ClientInfoCollection.GetMobile(client, serial, out m))
                    {
                        TreeViewUpdater.UpdateLastObject(ci.ProcessID, (WorldItem)m);
                    }
                    else
                    {
                        Mobile newMobile = new Mobile(serial, client);
                        newMobile.myName = "This mobile not found!";
                        TreeViewUpdater.UpdateLastObject(ci.ProcessID, (WorldItem)newMobile);
                    }
                }
                else
                {
                    Item i;
                    if (ClientInfoCollection.GetItem(client, serial, out i))
                    {
                        TreeViewUpdater.UpdateLastObject(ci.ProcessID, (WorldItem)i);
                    }
                    else
                    {
                        Item newItem = new Item(serial);
                        newItem.Name = "This item not found!";
                        TreeViewUpdater.UpdateLastObject(ci.ProcessID, (WorldItem)newItem);
                    }
                }
            }
コード例 #14
0
        public static void Info(object obj = null)
        {
            int serial = 0;

            if (obj == null)
            {
                serial = UOC.GetTargeSerialAsync(Strings.Target_object___).Result;

                if (serial == 0)
                {
                    return;
                }
            }

            serial = AliasCommands.ResolveSerial(serial != 0 ? serial : obj);

            if (serial == 0)
            {
                return;
            }

            Entity entity = UOMath.IsMobile(serial)
                ? Engine.Mobiles.GetMobile(serial)
                : (Entity)Engine.Items.GetItem(serial);

            if (entity == null)
            {
                UOC.SystemMessage(Strings.Cannot_find_item___);
                return;
            }

            Thread t = new Thread(() =>
            {
                ObjectInspectorWindow window =
                    new ObjectInspectorWindow {
                    DataContext = new ObjectInspectorViewModel(entity)
                };

                window.ShowDialog();
            })
            {
                IsBackground = true
            };

            t.SetApartmentState(ApartmentState.STA);
            t.Start();
        }
コード例 #15
0
        public void SetLastTarget(Entity m)
        {
            Engine.Player.LastTargetSerial = m.Serial;

            if (!UOMath.IsMobile(m.Serial))
            {
                return;
            }

            if (!MacroManager.QuietMode)
            {
                MsgCommands.HeadMsg(Options.CurrentOptions.LastTargetMessage, m.Serial);
            }

            MsgCommands.HeadMsg($"Target: {m.Name?.Trim() ?? "Unknown"}");
            Engine.SendPacketToClient(new ChangeCombatant(m.Serial));
        }
コード例 #16
0
            private static void IncomingPackets_ItemDeletedEvent(int client, int serial)
            {
                ClientInfo ci;

                if (ClientInfoCollection.GetClient(client, out ci))
                {
                    if (UOMath.IsMobile(serial))
                    {
                        ci.Mobiles.Remove(serial);
                        ci.Items.RemoveByOwner(serial);
                    }
                    else
                    {
                        ci.Items.Remove(serial);
                    }
                }
            }
コード例 #17
0
            public override void Execute()
            {
                TargetManager manager = TargetManager.GetInstance();

                Entity entity = manager.PromptTarget();

                if (entity == null)
                {
                    return;
                }

                manager.SetLastTarget(entity);

                if (UOMath.IsMobile(entity.Serial))
                {
                    Engine.SendPacketToServer(new LookRequest(entity.Serial));
                }
            }
コード例 #18
0
ファイル: RehueList.cs プロジェクト: solracCH/ClassicAssist
        public void CheckItem(Item item)
        {
            if (!_rehueList.TryGetValue(item.Serial, out int hueOverride))
            {
                return;
            }

            if (item.Owner != 0 && !UOMath.IsMobile(item.Serial))
            {
                Engine.SendPacketToClient(new ContainerContentUpdate(item.Serial, item.ID, item.Direction, item.Count,
                                                                     item.X, item.Y, item.Grid, item.Owner, hueOverride));
            }
            else
            {
                // TODO
                Commands.Resync();
            }
        }
コード例 #19
0
        public static void Rehue(object obj, int hue)
        {
            int serial = AliasCommands.ResolveSerial(obj);

            if (serial > 0)
            {
                if (hue > 0)
                {
                    Engine.RehueList.Add(serial, hue);
                }
                else
                {
                    Engine.RehueList.Remove(serial);
                }

                if (UOMath.IsMobile(serial))
                {
                    Mobile m = Engine.Mobiles.GetMobile(serial);

                    if (m == null)
                    {
                        return;
                    }

                    Engine.SendPacketToClient(new MobileIncoming(m, m.Equipment, hue));
                }
                else
                {
                    Item i = Engine.Items.GetItem(serial);

                    if (i == null)
                    {
                        return;
                    }

                    Engine.RehueList.CheckItem(i);
                }

                return;
            }

            UOC.SystemMessage(Strings.Invalid_or_unknown_object_id);
        }
コード例 #20
0
        public static string DirectionTo(object obj)
        {
            int serial = AliasCommands.ResolveSerial(obj);

            if (serial == 0)
            {
                return(Direction.Invalid.ToString());
            }

            Entity entity = UOMath.IsMobile(serial)
                ? Engine.Mobiles.GetMobile(serial)
                : Engine.Items.GetItem(serial) as Entity;

            if (entity == null)
            {
                return(Direction.Invalid.ToString());
            }

            return(UOMath.MapDirection(Engine.Player.X, Engine.Player.Y, entity.X, entity.Y).ToString());
        }
コード例 #21
0
        public static void Target(object obj, bool checkRange = false, bool useQueue = false)
        {
            int serial = AliasCommands.ResolveSerial(obj);

            if (serial == 0)
            {
                return;
            }

            if (checkRange && UOMath.IsMobile(serial))
            {
                Mobile mobile = Engine.Mobiles.GetMobile(serial);

                if (mobile != null)
                {
                    if (mobile.Distance > Options.CurrentOptions.RangeCheckLastTargetAmount)
                    {
                        UOC.SystemMessage(Strings.Target_out_of_range__try_again___);
                        UOC.ResendTargetToClient();
                        return;
                    }
                }
                else
                {
                    UOC.SystemMessage(Strings.Target_out_of_range__try_again___);
                    UOC.ResendTargetToClient();
                    return;
                }
            }

            if (useQueue && !Engine.TargetExists)
            {
                MsgCommands.HeadMsg(Strings.Target_Queued, Engine.Player?.Serial);
                Engine.LastTargetQueue.Enqueue(serial);
            }
            else
            {
                Engine.SendPacketToServer(new Target(TargetType.Object, -1, TargetFlags.None, serial, -1, -1, -1, 0,
                                                     true));
            }
        }
コード例 #22
0
        public static void Pathfind(object obj)
        {
            int serial = AliasCommands.ResolveSerial(obj);

            if (serial == 0)
            {
                UOC.SystemMessage(Strings.Entity_not_found___);
                return;
            }

            Entity entity = UOMath.IsMobile(serial)
                ? (Entity)Engine.Mobiles.GetMobile(serial)
                : Engine.Items.GetItem(serial);

            if (entity == null)
            {
                UOC.SystemMessage(Strings.Entity_not_found___);
                return;
            }

            Pathfind(entity.X, entity.Y, entity.Z);
        }
コード例 #23
0
        public static void UpdateProperties(int index, int serial, string name, Property[] properties, string propertyText)
        {
            ClientInfo ci;

            if (GetClient(index, out ci))
            {
                if (UOMath.IsMobile(serial))
                {
                    if (ci.Player.Serial == serial)
                    {
                        ci.Player.Name         = name;
                        ci.Player.Properties   = properties;
                        ci.Player.PropertyText = propertyText;
                        TreeViewUpdater.EditPlayerNode(index, ClientList[index].Player);
                    }
                    else
                    {
                        Mobile m;
                        if (ci.Mobiles.GetMobile(serial, out m))
                        {
                            m.Name         = name;
                            m.Properties   = properties;
                            m.PropertyText = propertyText;
                        }
                    }
                }
                else
                {
                    Item i;
                    if (ci.Items.GetItem(serial, out i))
                    {
                        i.Name         = Cliloc.GetLocalString(name);
                        i.Properties   = properties;
                        i.PropertyText = propertyText;
                    }
                }
            }
        }
コード例 #24
0
        public static int Hue(object obj = null)
        {
            int serial = AliasCommands.ResolveSerial(obj);

            if (serial == 0)
            {
                UOC.SystemMessage(Strings.Invalid_or_unknown_object_id, true);
                return(0);
            }

            Entity entity = UOMath.IsMobile(serial)
                ? Engine.Mobiles.GetMobile(serial)
                : Engine.Items.GetItem(serial) as Entity;

            if (entity != null)
            {
                return(entity.Hue);
            }

            UOC.SystemMessage(Strings.Entity_not_found___, true);

            return(0);
        }
コード例 #25
0
        private static void OnItemAddedToContainer(PacketReader reader)
        {
            int serial = reader.ReadInt32();
            int id     = reader.ReadUInt16();

            reader.ReadByte(); // offset
            int count           = reader.ReadUInt16();
            int x               = reader.ReadInt16();
            int y               = reader.ReadInt16();
            int grid            = reader.ReadByte();
            int containerSerial = reader.ReadInt32();
            int hue             = reader.ReadUInt16();

            Item item = Engine.GetOrCreateItem(serial, containerSerial);

            item.ID    = id;
            item.Count = count;
            item.X     = x;
            item.Y     = y;
            item.Grid  = grid;
            item.Owner = containerSerial;
            item.Hue   = hue;

            // Check mobile layer items if container is not a mobile
            if (!UOMath.IsMobile(containerSerial))
            {
                Layer layer = Engine.Player?.GetAllLayers().Select((s, i) => new { i, s })
                              .Where(t => t.s == serial)
                              .Select(t => (Layer)t.i).FirstOrDefault() ?? Layer.Invalid;

                if (layer != Layer.Invalid)
                {
                    Engine.Player?.SetLayer(layer, 0);
                }
                else
                {
                    Mobile mobile = Engine.Mobiles.SelectEntity(m => m.GetAllLayers().Contains(serial));

                    layer = mobile?.GetAllLayers().Select((s, i) => new { i, s })
                            .Where(t => t.s == serial)
                            .Select(t => (Layer)t.i).FirstOrDefault() ?? Layer.Invalid;

                    if (layer != Layer.Invalid)
                    {
                        mobile?.SetLayer(layer, 0);
                    }
                }
            }

            if (UOMath.IsMobile(containerSerial))
            {
                item.Owner = containerSerial;
                Engine.Items.Add(item);
            }
            else
            {
                Item container = Engine.GetOrCreateItem(containerSerial);

                item.Owner = container.Serial;

                if (container.Container == null)
                {
                    container.Container = new ItemCollection(containerSerial);
                }

                container.Container.Add(item);
            }

            //rehueList

            int backpack = Engine.Player?.Backpack?.Serial ?? 0;

            if (item.IsDescendantOf(backpack))
            {
                Engine.RehueList.CheckRehue(item);
            }

            //rehueList
        }