Ejemplo n.º 1
0
        public void MoveItemWillSendDragPacket()
        {
            AutoResetEvent are = new AutoResetEvent(false);

            void OnInternalPacketSentEvent(byte[] data, int length)
            {
                if (data[0] != 0x07)
                {
                    return;
                }

                int serial = (data[1] << 24) | (data[2] << 16) | (data[3] << 8) | data[4];

                Assert.AreEqual(0x00aabbcc, serial);

                are.Set();
            }

            Engine.InternalPacketSentEvent += OnInternalPacketSentEvent;

            Engine.Items.Add(new Item(0x00aabbcc)
            {
                Count = 50
            });

            ObjectCommands.MoveItem(0x00aabbcc, 0xaabbdd);

            bool result = are.WaitOne(5000);

            Assert.IsTrue(result);

            Engine.InternalPacketSentEvent -= OnInternalPacketSentEvent;
        }
Ejemplo n.º 2
0
        public void WillFindTypeAnyGraphic()
        {
            Item container = new Item(0x40000000)
            {
                Container = new ItemCollection(0x40000000)
            };

            for (int i = 1; i < 11; i++)
            {
                container.Container.Add(new Item(0x40000000 + i, 0x40000000)
                {
                    ID = i
                });
            }

            Engine.Items.Add(container);
            ObjectCommands.ClearIgnoreList();

            int count = 0;

            while (ObjectCommands.FindType(-1, -1, 0x40000000))
            {
                ObjectCommands.IgnoreObject(AliasCommands.GetAlias("found"));
                count++;
            }

            Assert.AreEqual(10, count);

            Engine.Items.Remove(container);
            ObjectCommands.ClearIgnoreList();
        }
Ejemplo n.º 3
0
        public void WillFindObjectInContainer()
        {
            Item container = new Item(0x55)
            {
                Container = new ItemCollection(0x55)
            };

            Engine.Items.Add(container);

            container.Container.Add(new Item(0x56)
            {
                Owner = 0x55
            });

            bool result = ObjectCommands.FindObject(0x56, -1, 0x55);

            Assert.IsTrue(result);

            Item subContainer = new Item(0x57)
            {
                Container = new ItemCollection(0x57), Owner = 0x55
            };

            container.Container.Add(subContainer);
            subContainer.Container.Add(new Item(0x58)
            {
                Owner = 0x57
            });

            result = ObjectCommands.FindObject(0x57, -1, 0x55);

            Assert.IsTrue(result);

            Engine.Items.Remove(container);
        }
Ejemplo n.º 4
0
        public void WillFindObjectGround()
        {
            Engine.Player = new PlayerMobile(0x01)
            {
                X = 0, Y = 0
            };

            Item item1 = new Item(0x40000001);
            Item item2 = new Item(0x40000002)
            {
                X = 100, Y = 100
            };

            Engine.Items.Add(item1);
            Engine.Items.Add(item2);

            Assert.IsTrue(ObjectCommands.FindObject(item1.Serial));
            Assert.IsTrue(ObjectCommands.FindObject(item2.Serial));
            Assert.IsFalse(ObjectCommands.FindObject(item2.Serial, 5));

            Engine.Items.Remove(item2);
            Engine.Items.Remove(item1);

            Engine.Player = null;
        }
Ejemplo n.º 5
0
        public void WillCountType()
        {
            PlayerMobile player   = new PlayerMobile(1);
            Item         backpack =
                new Item(0x40000001)
            {
                ID = 0xff, Owner = 0x01, Container = new ItemCollection(0x40000001)
            };

            Engine.Player = player;
            Engine.Items.Add(backpack);

            player.SetLayer(Layer.Backpack, 0x40000001);

            backpack.Container.Add(new Item(0x40000002)
            {
                ID = 0xFE, Owner = 0x40000001
            });

            int count = ObjectCommands.CountType(0xfe, 0x40000001);

            Assert.AreEqual(1, count);

            Engine.Items.Clear();
            Engine.Player = null;
        }
Ejemplo n.º 6
0
        public void WillSendUseObjectPacket()
        {
            AutoResetEvent are = new AutoResetEvent(false);

            void InternalPacketSentEvent(byte[] data, int length)
            {
                if (data[0] != 0x06)
                {
                    Assert.Fail();
                }

                int serial = (data[1] << 24) | (data[2] << 16) | (data[3] << 8) | data[4];

                Assert.AreEqual(0x40000001, serial);

                are.Set();
            }

            Engine.InternalPacketSentEvent += InternalPacketSentEvent;

            Engine.Items.Add(new Item(0x40000001));

            AliasCommands.SetAlias("item", 0x40000001);

            ObjectCommands.UseObject("item");

            bool result = are.WaitOne(5000);

            Assert.IsTrue(result);

            Engine.InternalPacketSentEvent -= InternalPacketSentEvent;
            Engine.Items.Clear();
            AliasCommands.UnsetAlias("item");
        }
Ejemplo n.º 7
0
        public void WillUseIgnoreListIfEnabledGetNextFriend()
        {
            Options.CurrentOptions.GetFriendEnemyUsesIgnoreList = true;

            Engine.Player = new PlayerMobile(0x01);
            Mobile mobile = new Mobile(0x02)
            {
                Notoriety = Notoriety.Murderer
            };

            Engine.Mobiles.Add(mobile);

            bool result = TargetCommands.GetFriend(new[] { Notoriety.Murderer.ToString() });

            Assert.IsTrue(result);
            Assert.AreEqual(mobile.Serial, AliasCommands.GetAlias("friend"));

            AliasCommands.UnsetAlias("enemy");
            ObjectCommands.IgnoreObject(mobile.Serial);

            result = TargetCommands.GetFriend(new[] { Notoriety.Murderer.ToString() });

            Assert.IsFalse(result);

            ObjectCommands.ClearIgnoreList();
            Engine.Mobiles.Clear();
            Engine.Player = null;
            AliasCommands.SetAlias("friend", -1);
        }
Ejemplo n.º 8
0
        public override void Execute()
        {
            PlayerMobile player = Engine.Player;

            if (player == null)
            {
                UOC.SystemMessage(Strings.Error__No_Player);
                return;
            }

            Item backpack = player.Backpack;

            if (backpack == null)
            {
                UOC.SystemMessage(Strings.Error__Cannot_find_player_backpack);
                return;
            }

            Item bandage = backpack.Container?.SelectEntity(i => _bandageTypes.Contains(i.ID));

            if (bandage == null)
            {
                UOC.SystemMessage(Strings.Error__Cannot_find_type);
                return;
            }

            ObjectCommands.UseObject(bandage.Serial);
            bool result = UOC.WaitForTarget(TIMEOUT);

            if (result)
            {
                Engine.SendPacketToServer(new Target(-1, player, true));
            }
        }
Ejemplo n.º 9
0
        public void WontGetInvalidBodyGetFriendListOnlyTransformation()
        {
            Engine.Player = new PlayerMobile(0x01);
            Mobile mobile = new Mobile(0x02)
            {
                Notoriety = Notoriety.Murderer, ID = 0x190
            };

            Engine.Mobiles.Add(mobile);
            Options.CurrentOptions.Friends.Add(new FriendEntry {
                Name = "Friend", Serial = mobile.Serial
            });

            bool result = TargetCommands.GetFriendListOnly("Closest", "Any", "Humanoid");

            Assert.IsTrue(result);
            Assert.AreEqual(mobile.Serial, AliasCommands.GetAlias("friend"));

            result = TargetCommands.GetFriendListOnly("Closest", "Any", "Transformation");

            Assert.IsFalse(result);

            result = TargetCommands.GetFriendListOnly("Next");

            Assert.IsTrue(result);
            Assert.AreEqual(mobile.Serial, AliasCommands.GetAlias("friend"));

            Options.CurrentOptions.Friends.Clear();
            ObjectCommands.ClearIgnoreList();
            Engine.Mobiles.Clear();
            Engine.Player = null;
            AliasCommands.SetAlias("friend", -1);
        }
Ejemplo n.º 10
0
        public void WillFindTypeSubcontainer()
        {
            Item container = new Item(1)
            {
                Container = new ItemCollection(1)
                {
                    new Item(0x02)
                    {
                        ID = 0xdda, Owner = 1
                    }
                }
            };

            Engine.Items.Add(container);

            AliasCommands.SetAlias("cont", 1);

            bool result = ObjectCommands.FindType(0xdda, -1, "cont");

            Assert.IsTrue(result);

            int val = AliasCommands.GetAlias("found");

            Assert.AreEqual(0x02, val);

            Engine.Items.Clear();
        }
Ejemplo n.º 11
0
        public override void Execute()
        {
            int serial = Engine.Player?.LastObjectSerial ?? 0;

            if (serial != 0)
            {
                ObjectCommands.UseObject(serial);
            }
        }
Ejemplo n.º 12
0
        public void WontFindTypeOutsideSearchRange()
        {
            Engine.Player = new PlayerMobile(1);
            Item backpack = new Item(0x40000000)
            {
                Container = new ItemCollection(0x40000000)
            };
            Item subContainer = new Item(0x40000001, 0x40000000)
            {
                Container = new ItemCollection(0x40000001)
            };

            backpack.Container.Add(subContainer);
            AliasCommands.SetAlias("backpack", backpack.Serial);

            backpack.Container.Add(new Item(0x40000002, 0x40000000)
            {
                ID = 0xabcd
            });
            subContainer.Container.Add(new Item(0x40000003, 0x40000001)
            {
                ID = 0xabcd
            });

            Engine.Items.Add(backpack);

            int count = 0;

            while (ObjectCommands.FindType(0xabcd, 0, "backpack"))
            {
                Assert.AreNotEqual(AliasCommands.GetAlias("found"), 0x40000003);
                ObjectCommands.IgnoreObject(AliasCommands.GetAlias("found"));
                count++;
            }

            Assert.AreEqual(1, count);

            ObjectCommands.ClearIgnoreList();

            count = 0;

            while (ObjectCommands.FindType(0xabcd, 1, "backpack"))
            {
                ObjectCommands.IgnoreObject(AliasCommands.GetAlias("found"));
                count++;
            }

            Assert.AreEqual(2, count);

            ObjectCommands.ClearIgnoreList();
            Engine.Player = null;
            Engine.Items.Clear();
        }
Ejemplo n.º 13
0
        public void WillFindTypeStackAmount()
        {
            Item stack = new Item(0x40000001)
            {
                ID = 0xabcd, Count = 100
            };

            Engine.Items.Add(stack);

            bool found = ObjectCommands.FindType(0xabcd, -1, null, -1, 50);

            Assert.IsTrue(found);

            Engine.Items.Clear();
        }
Ejemplo n.º 14
0
        public void WillFindTypeStackAmountIgnoreIfMobile()
        {
            Mobile mobile = new Mobile(0x01)
            {
                ID = 0x190
            };

            Engine.Mobiles.Add(mobile);

            bool found = ObjectCommands.FindType(0x190, -1, null, -1, 50);

            Assert.IsTrue(found);

            Engine.Mobiles.Clear();
        }
Ejemplo n.º 15
0
        public void WillFindTypeInRange()
        {
            Engine.Player = new PlayerMobile(1);
            Engine.Mobiles.Add(new Mobile(0x02)
            {
                ID = 0x190, X = 5, Y = 5
            });

            bool result = ObjectCommands.FindType(0x190, 8);

            Assert.IsTrue(result);

            Engine.Mobiles.Clear();
            Engine.Player = null;
        }
Ejemplo n.º 16
0
        public void WontFindTypeOutOfRange()
        {
            Engine.Player = new PlayerMobile(1);
            Engine.Mobiles.Add(new Mobile(0x02)
            {
                ID = 0x190, X = 5, Y = 5
            });

            bool result = ObjectCommands.FindType(0x190, 1);

            Assert.IsFalse(result);

            Engine.Mobiles.Clear();
            Engine.Player = null;
        }
Ejemplo n.º 17
0
        public void WillFindTypeGroundMobile()
        {
            Engine.Mobiles.Add(new Mobile(0x02)
            {
                ID = 0x190
            });

            bool result = ObjectCommands.FindType(0x190);

            Assert.IsTrue(result);

            int val = AliasCommands.GetAlias("found");

            Assert.AreEqual(0x02, val);

            Engine.Mobiles.Clear();
        }
Ejemplo n.º 18
0
        public void WillFindTypeGround()
        {
            Engine.Items.Add(new Item(0x40000001)
            {
                ID = 0xdda
            });

            bool result = ObjectCommands.FindType(0xdda);

            Assert.IsTrue(result);

            int val = AliasCommands.GetAlias("found");

            Assert.AreEqual(0x40000001, val);

            Engine.Items.Clear();
        }
Ejemplo n.º 19
0
        public static void UseHand(Layer layer)
        {
            PlayerMobile player = Engine.Player;

            if (player == null)
            {
                return;
            }

            int serial = player.GetLayer(layer);

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

            ObjectCommands.UseObject(serial);
        }
Ejemplo n.º 20
0
        public void WillIgnoreObject()
        {
            Engine.Mobiles.Add(new Mobile(0x02)
            {
                ID = 0x190, X = 5, Y = 5
            });

            bool result = ObjectCommands.FindType(0x190);

            Assert.IsTrue(result);

            ObjectCommands.IgnoreObject("found");

            result = ObjectCommands.FindType(0x190);

            Assert.IsFalse(result);

            Engine.Mobiles.Clear();
            ObjectCommands.ClearIgnoreList();
        }
Ejemplo n.º 21
0
        public void WillCountMobileGround()
        {
            Engine.Player = new PlayerMobile(0x01);

            Mobile mobile = new Mobile(0x02)
            {
                ID = 0x190
            };
            Mobile mobile2 = new Mobile(0x03)
            {
                ID = 0x191
            };

            Engine.Mobiles.Add(mobile);
            Engine.Mobiles.Add(mobile2);

            int count = ObjectCommands.CountTypeGround(0x190, -1, 5);

            Assert.AreEqual(1, count);

            Engine.Mobiles.Clear();
            Engine.Player = null;
        }
Ejemplo n.º 22
0
 public override void Execute()
 {
     ObjectCommands.UseType(0xf06, 1161, "backpack");
 }
Ejemplo n.º 23
0
 public override void Execute()
 {
     ObjectCommands.UseType(0x2808, 0, "backpack");
 }
Ejemplo n.º 24
0
 public override void Execute()
 {
     ObjectCommands.UseType(0x2fd7, 1154, "backpack");
 }
Ejemplo n.º 25
0
 public override void Execute()
 {
     ObjectCommands.UseType(0x2fd7, 1154, Engine.Player.GetLayer(Layer.Backpack));
 }
Ejemplo n.º 26
0
 public override void Execute()
 {
     ObjectCommands.UseType(0x1021, 43, "backpack");
 }