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; }
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(); }
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); }
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; }
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; }
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"); }
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); }
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)); } }
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); }
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(); }
public override void Execute() { int serial = Engine.Player?.LastObjectSerial ?? 0; if (serial != 0) { ObjectCommands.UseObject(serial); } }
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(); }
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(); }
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(); }
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; }
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; }
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(); }
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(); }
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); }
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(); }
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; }
public override void Execute() { ObjectCommands.UseType(0xf06, 1161, "backpack"); }
public override void Execute() { ObjectCommands.UseType(0x2808, 0, "backpack"); }
public override void Execute() { ObjectCommands.UseType(0x2fd7, 1154, "backpack"); }
public override void Execute() { ObjectCommands.UseType(0x2fd7, 1154, Engine.Player.GetLayer(Layer.Backpack)); }
public override void Execute() { ObjectCommands.UseType(0x1021, 43, "backpack"); }