private void TakeItem(Item i, KonjoBot.Objects.Bot.LootItem lot) { if (lot.Cap <= Core.client.Player.Capacity) { if (lot.Cap * i.Count > Core.client.Player.Capacity) { i.Count = 1; } switch (lot.Destination) { case Constants.LootDestination.Arrow: i.Move(ItemLocation.FromSlot(Constants.SlotNumber.Ammo)); break; case Constants.LootDestination.Container: if (lot.ContainerDestionation == 16) // any { i.Move(LootTo(i)); } else { i.Move(LootToIndex(i, lot.ContainerDestionation)); } break; case Constants.LootDestination.Ground: i.Move(ItemLocation.FromLocation(Core.client.PlayerLocation)); break; case Constants.LootDestination.LeftHand: i.Move(ItemLocation.FromSlot(Constants.SlotNumber.Left)); break; case Constants.LootDestination.RightHand: i.Move(ItemLocation.FromSlot(Constants.SlotNumber.Right)); break; } } }
private void MakeRune() { // If we move an item from the ammo slot, store it here. Item itemMovedToAmmo = null; // Make sure the player has enough mana if (player.Mana >= rune.Spell.ManaPoints) { // Find the first original Item original = client.Inventory.GetItems().FirstOrDefault(i => i.Id == rune.OriginalItem.Id); // Make sure an original was found if (original != null) { // Save the current location of the original ItemLocation oldLocation = original.Location; // The location where the item will be made ItemLocation newLocation = null; // Determine the location to make the item if (client.Inventory.GetItemInSlot( Tibia.Constants.SlotNumber.Right) != null) { newLocation = ItemLocation.FromSlot(Tibia.Constants.SlotNumber.Right); } else if (client.Inventory.GetItemInSlot( Tibia.Constants.SlotNumber.Left) != null) { newLocation = ItemLocation.FromSlot(Tibia.Constants.SlotNumber.Left); } if (newLocation == null && client.Inventory.GetItemInSlot( Tibia.Constants.SlotNumber.Ammo) != null) { // If no hands are free, but the ammo slot is, // move the right hand item to clear the ammo slot newLocation = ItemLocation.FromSlot(Tibia.Constants.SlotNumber.Right); itemMovedToAmmo = client.Inventory.GetItemInSlot(Tibia.Constants.SlotNumber.Right); itemMovedToAmmo.Move(ItemLocation.FromSlot(Tibia.Constants.SlotNumber.Ammo)); } // Move the original and say the magic words, make sure everything went well Thread.Sleep(200); original.Move(newLocation); Thread.Sleep(200); client.Console.Say(rune.Spell.Words); Thread.Sleep(200); // Build an item object for the newly created item // We don't use getSlot because it could execute too fast, returning a blank // rune or nothing at all. If we just send a packet, the server will catch up. Item newItem = new Item(client, rune.Id, 0, "", newLocation); // Move the rune back to it's original location Thread.Sleep(300); newItem.Move(oldLocation); // Check if we moved an item to the ammo slot // If we did, move it back Thread.Sleep(200); if (itemMovedToAmmo != null) { itemMovedToAmmo.Location = ItemLocation.FromSlot(Tibia.Constants.SlotNumber.Ammo); itemMovedToAmmo.Move(ItemLocation.FromSlot(Tibia.Constants.SlotNumber.Right)); } } } }