Пример #1
0
        private static void LiftReject(PacketReader p, PacketHandlerEventArgs args)
        {
            Item item = World.FindItem(DragDropManager.m_Holding);

            if (DragDropManager.LiftReject() || item == null)
            {
                return;
            }
            DragDropInfo info = items.Find(i => i.Drag == item.Serial);

            if (info == null)
            {
                return;
            }
            args.Block = true;
            if (World.FindItem(info.Drop) == item.Container)
            {
                return;
            }

            if (info.Layer != Layer.Invalid)
            {
                DragDropManager.DragDrop(item, World.Player, info.Layer);
            }
            else if (info.Position != Point3D.Zero)
            {
                DragDropManager.Drag(item, item.Amount);
                DragDropManager.Drop(item, info.Drop, info.Position);
            }
            else
            {
                DragDropManager.DragDrop(item, info.Drop);
            }
        }
Пример #2
0
        private static bool DropItem(string command, Variable[] vars, bool quiet, bool force)
        {
            if (vars.Length < 1)
            {
                throw new RunTimeError("Usage: drop (serial) (x y z/layername)");
            }

            Serial serial = vars[0].AsString().IndexOf("ground", StringComparison.OrdinalIgnoreCase) > 0
                ? uint.MaxValue
                : vars[0].AsSerial();

            Point3D to    = new Point3D(0, 0, 0);
            Layer   layer = Layer.Invalid;

            switch (vars.Length)
            {
            case 1:     // drop at feet if only serial is provided
                to = new Point3D(World.Player.Position.X, World.Player.Position.Y, World.Player.Position.Z);
                break;

            case 2:     // dropping on a layer
                layer = (Layer)Enum.Parse(typeof(Layer), vars[1].AsString(), true);
                break;

            case 3:     // x y
                to = new Point3D(Utility.ToInt32(vars[1].AsString(), 0), Utility.ToInt32(vars[2].AsString(), 0), 0);
                break;

            case 4:     // x y z
                to = new Point3D(Utility.ToInt32(vars[1].AsString(), 0), Utility.ToInt32(vars[2].AsString(), 0),
                                 Utility.ToInt32(vars[3].AsString(), 0));
                break;
            }

            if (DragDropManager.Holding != null)
            {
                if (layer > Layer.Invalid && layer <= Layer.LastUserValid)
                {
                    Mobile m = World.FindMobile(serial);
                    if (m != null)
                    {
                        DragDropManager.Drop(DragDropManager.Holding, m, layer);
                    }
                }
                else
                {
                    DragDropManager.Drop(DragDropManager.Holding, serial, to);
                }
            }
            else
            {
                CommandHelper.SendWarning(command, "Not holding anything", quiet);
            }

            return(true);
        }
Пример #3
0
        private static bool DropItem(string command, Argument[] args, bool quiet, bool force)
        {
            if (args.Length < 1)
            {
                throw new RunTimeError(null, "Usage: drop (serial) (x y z/layername)");
            }

            Serial serial = args[0].AsString().IndexOf("ground", StringComparison.InvariantCultureIgnoreCase) > 0
                ? uint.MaxValue
                : args[0].AsSerial();

            Point3D to    = new Point3D(0, 0, 0);
            Layer   layer = Layer.Invalid;

            switch (args.Length)
            {
            case 1:     // drop at feet if only serial is provided
                to = new Point3D(World.Player.Position.X, World.Player.Position.Y, World.Player.Position.Z);
                break;

            case 2:     // dropping on a layer
                layer = (Layer)Enum.Parse(typeof(Layer), args[1].AsString(), true);
                break;

            case 3:     // x y
                to = new Point3D(Utility.ToInt32(args[1].AsString(), 0), Utility.ToInt32(args[2].AsString(), 0), 0);
                break;

            case 4:     // x y z
                to = new Point3D(Utility.ToInt32(args[1].AsString(), 0), Utility.ToInt32(args[2].AsString(), 0),
                                 Utility.ToInt32(args[3].AsString(), 0));
                break;
            }

            if (DragDropManager.Holding != null)
            {
                if (layer > Layer.Invalid && layer <= Layer.LastUserValid)
                {
                    Mobile m = World.FindMobile(serial);
                    if (m != null)
                    {
                        DragDropManager.Drop(DragDropManager.Holding, m, layer);
                    }
                }
                else
                {
                    DragDropManager.Drop(DragDropManager.Holding, serial, to);
                }
            }
            else
            {
                World.Player.SendMessage(MsgLevel.Warning, LocString.MacroNoHold);
            }

            return(true);
        }
Пример #4
0
 public static void Move(Item item, Item to, Point3D position)
 {
     if (item == null || to == null)
     {
         return;
     }
     items.Add(new DragDropInfo(item.Serial, to.Serial, position));
     DragDropManager.Drag(item, item.Amount);
     DragDropManager.Drop(item, to, position);
 }
Пример #5
0
        private static bool DropItem(string command, Argument[] args, bool quiet, bool force)
        {
            if (args.Length < 2)
            {
                ScriptManager.Error("Usage: drop (serial) (x y z/layername)");
                return(true);
            }

            Serial  serial = args[0].AsSerial();
            Point3D to     = new Point3D(0, 0, 0);
            Layer   layer  = Layer.Invalid;

            switch (args.Length)
            {
            case 1:     // drop at feet
                to = new Point3D(World.Player.Position.X, World.Player.Position.Y, World.Player.Position.Z);
                break;

            case 2:     // dropping on a layer
                layer = (Layer)Enum.Parse(typeof(Layer), args[1].AsString(), true);
                break;

            default:     // dropping at x/y/z
                to = new Point3D(Utility.ToInt32(args[1].AsString(), 0), Utility.ToInt32(args[2].AsString(), 0),
                                 Utility.ToInt32(args[3].AsString(), 0));
                break;
            }

            if (DragDropManager.Holding != null)
            {
                if (layer > Layer.Invalid && layer <= Layer.LastUserValid)
                {
                    Mobile m = World.FindMobile(serial);
                    if (m != null)
                    {
                        DragDropManager.Drop(DragDropManager.Holding, m, layer);
                    }
                }
                else
                {
                    DragDropManager.Drop(DragDropManager.Holding, serial, to);
                }
            }
            else
            {
                World.Player.SendMessage(MsgLevel.Warning, LocString.MacroNoHold);
            }

            return(true);
        }
Пример #6
0
        private static bool DropRelLoc(string command, Variable[] vars, bool quiet, bool force)
        {
            if (vars.Length < 2)
            {
                throw new RunTimeError("Usage: droprelloc (x) (y)");
            }

            int x = vars[0].AsInt();
            int y = vars[1].AsInt();

            if (DragDropManager.Holding != null)
            {
                DragDropManager.Drop(DragDropManager.Holding, null,
                                     new Point3D((ushort)(World.Player.Position.X + x),
                                                 (ushort)(World.Player.Position.Y + y), World.Player.Position.Z));
            }
            else
            {
                CommandHelper.SendWarning(command, "Not holding anything", quiet);
            }

            return(true);
        }
Пример #7
0
        private static bool DropRelLoc(string command, Argument[] args, bool quiet, bool force)
        {
            if (args.Length < 3)
            {
                throw new RunTimeError(null, "Usage: droprelloc (x) (y)");
            }

            int x = args[0].AsInt();
            int y = args[1].AsInt();

            if (DragDropManager.Holding != null)
            {
                DragDropManager.Drop(DragDropManager.Holding, null,
                                     new Point3D((ushort)(World.Player.Position.X + x),
                                                 (ushort)(World.Player.Position.Y + y), World.Player.Position.Z));
            }
            else
            {
                World.Player.SendMessage(LocString.MacroNoHold);
            }

            return(true);
        }