Пример #1
0
        public static bool MoveTypeOffset(int id, object findLocation, int xOffset, int yOffset, int zOffset,
                                          int amount = -1)
        {
            if (findLocation == null ||
                ((string)findLocation).Equals("ground", StringComparison.InvariantCultureIgnoreCase))
            {
                UOC.SystemMessage(Strings.Invalid_container___);
                return(false);
            }

            int owner = AliasCommands.ResolveSerial(findLocation);

            bool Predicate(Item i)
            {
                return(i.ID == id && i.IsDescendantOf(owner));
            }

            Item entity = Engine.Items.SelectEntities(Predicate)?.FirstOrDefault();

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

            PlayerMobile player = Engine.Player;

            if (player == null)
            {
                return(false);
            }

            int x = player.X + xOffset;
            int y = player.Y + yOffset;
            int z = player.Z + zOffset;

            ActionPacketQueue.EnqueueDragDropGround(entity.Serial, amount, x, y, z);

            return(true);
        }
Пример #2
0
        public static void MoveItemOffset(object obj, int xOffset, int yOffset, int zOffset, int amount = -1)
        {
            int serial = AliasCommands.ResolveSerial(obj);

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

                return;
            }

            PlayerMobile player = Engine.Player;

            if (player == null)
            {
                return;
            }

            int x = player.X + xOffset;
            int y = player.Y + yOffset;
            int z = player.Z + zOffset;

            ActionPacketQueue.EnqueueDragDropGround(serial, amount, x, y, z);
        }
Пример #3
0
        public static void MoveType(int id, object sourceContainer, object destinationContainer, int x = -1,
                                    int y = -1, int z = 0, int hue = -1, int amount = -1)
        {
            int sourceSerial = AliasCommands.ResolveSerial(sourceContainer);

            if (sourceSerial == -1)
            {
                UOC.SystemMessage(Strings.Invalid_source_container___);
                return;
            }

            int destinationSerial;

            if (destinationContainer is int destSerial)
            {
                destinationSerial = destSerial;
            }
            else
            {
                destinationSerial = AliasCommands.ResolveSerial(destinationContainer);
            }

            Item sourceItem = Engine.Items.GetItem(sourceSerial);

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

            if (sourceItem.Container == null)
            {
                UOC.SystemMessage(Strings.Invalid_container___);
                return;
            }

            Item entity = sourceItem.Container.SelectEntities(i => i.ID == id && (hue == -1 || i.Hue == hue))
                          .FirstOrDefault();

            if (entity == null)
            {
                return;
            }

            if (amount == -1)
            {
                amount = entity.Count;
            }

            if (amount > entity.Count)
            {
                amount = entity.Count;
            }

            if (destinationSerial == -1)
            {
                ActionPacketQueue.EnqueueDragDropGround(entity.Serial, amount, x, y, z);
            }
            else
            {
                ActionPacketQueue.EnqueueDragDrop(entity.Serial, amount, destinationSerial);
            }
        }