internal void UseItemOn(int itemId, Location location) { ItemLocationContainer itemLocation = game.FindItemOnContainers(itemId); if (itemLocation == null) { Console.WriteLine("Item " + itemId + " was not found on any containers."); return; } Point slotPoint = client.ContainerPosition(itemLocation.Slot, itemLocation.ContainerIndex); Point mapPoint = client.GroundPosition(location); if (slotPoint.X < 0 || mapPoint.X < 0) { Console.WriteLine("Itemd id: " + itemId + " on location: " + location.ToString() + " not found"); } if (mapPoint.X < 0) { Console.WriteLine("Game location: " + location.ToString() + " not found"); } inputSender.SendUseOnEvent(slotPoint, mapPoint); }
internal void ToInventory(int itemID, string to, ItemLocationContainer containerLoc) { int toSlotId = ItemLocationInventory.GetInventorySlotId(to); if (toSlotId < 1) { //Console.WriteLine("moveItem: The inventory location: " + to + " is invalid."); return; } moveItemToInventory(containerLoc.item, containerLoc.Slot, containerLoc.ContainerIndex, toSlotId); }
internal void ToContainer(int itemID, string to, ItemLocationContainer containerLoc) { Container destination = game.GetContainer(Convert.ToInt32(to)); if (destination == null) { //Console.WriteLine("moveItem: Could not found a container with index: " + to); return; } moveItemToContainer(containerLoc.item, containerLoc.Slot, containerLoc.ContainerIndex, destination); }
internal void UseItem(int itemId, int containerIndex) { ItemLocationContainer itemLocation = game.FindItemOnContainers(itemId, containerIndex); if (itemLocation == null) { return; } Point point = client.ContainerPosition(itemLocation.Slot, itemLocation.ContainerIndex); inputSender.SendRightClick(point); }
public ItemLocationContainer FindItemOnContainer(int itemId) { List <Container> containers = this.GetAllContainers(); foreach (Container container in containers) { ItemLocationContainer itemLocation = this.findItemOnContainer(container, itemId); if (itemLocation != null) { return(itemLocation); } } //Console.WriteLine("No item with id: " + itemId + " was found on any container."); return(null); }
internal void ToContainer(int itemID, string to, string from) { //Console.WriteLine("moveItem: Trying to move item: from ground " + from + " to container " + to); Location fromGameLocation = Location.Parse(from); int containerIndex = ItemLocationContainer.GetContainerIndex(to); if (containerIndex < 0) { Console.WriteLine("moveItem: Invalid container index"); return; } //should check the item id on ground //if ground item.id == itemID moveItemToContainer(fromGameLocation, containerIndex); }
private Point findPointOfItem(int itemID) { ItemLocation itemLocation = game.FindItem(itemID); if (itemLocation == null) { return(new Point(-1, -1)); } if (itemLocation.GetType() == typeof(ItemLocationContainer)) { ItemLocationContainer containerLoc = (ItemLocationContainer)itemLocation; return(client.ContainerPosition(containerLoc.Slot, containerLoc.ContainerIndex)); } if (itemLocation.GetType() == typeof(ItemLocationInventory)) { ItemLocationInventory inventoryLoc = (ItemLocationInventory)itemLocation; return(client.InventoryPosition(inventoryLoc.SlotId)); } return(new Point(-1, -1)); }
internal void ToGround(int itemID, string to, ItemLocationContainer containerLoc) { Location toGameLocation = Location.Parse(to); moveItemToGround(containerLoc.item, containerLoc.Slot, containerLoc.ContainerIndex, toGameLocation); }
private void makeRune() { string inventoryLocation = settings.InventoryLocation; Console.WriteLine("Inventory location: " + inventoryLocation); Item handItem = player.GetEquipment(inventoryLocation); if (handItem == null) { //Console.WriteLine("Nao ha items na mao"); ItemLocationContainer itemLocation = game.FindItemOnContainers(blankRuneId); if (itemLocation == null) { throw new InvalidOperationException("No blank runes"); } moveBlankAndCastSpell(inventoryLocation, settings.Spell); } else { //Console.WriteLine("existe item na mao: " + inventoryLocation); Item beltItem = player.GetEquipment("belt"); if (beltItem == null) { //move rhanditem from belt Thread.Sleep(500); player.MoveItems(handItem.Id, "belt", inventoryLocation); //make rune Thread.Sleep(500); moveBlankAndCastSpell(inventoryLocation, settings.Spell); //move rhanditem back from rhand Thread.Sleep(500); player.MoveItems(handItem.Id, inventoryLocation, "belt"); } else { //move from backpack //find a container with free slots Container c = game.GetContainerWithFreeSlots(); if (c == null) { Console.WriteLine("Nao existe container com free slots"); throw new InvalidOperationException("Nowhere from put handItem on runemaker module"); } //move the handItem from container Thread.Sleep(500); player.MoveItems(handItem.Id, "" + c.Index, inventoryLocation); //make rune Thread.Sleep(500); moveBlankAndCastSpell(inventoryLocation, settings.Spell); //move handitem back from handLocation Thread.Sleep(500); player.MoveItems(handItem.Id, inventoryLocation); } } }
internal void MoveItems(int itemId, string to, string from) { ItemLocationContainer locationContainer = null; ItemLocationInventory locationInventory = null; if (string.IsNullOrEmpty(from)) { ItemLocation itemLocation = game.FindItem(itemId); if (itemLocation != null && itemLocation.GetType() == typeof(ItemLocationContainer)) { locationContainer = (ItemLocationContainer)itemLocation; from = "" + locationContainer.ContainerIndex; } else if (itemLocation != null && itemLocation.GetType() == typeof(ItemLocationInventory)) { locationInventory = (ItemLocationInventory)itemLocation; from = locationInventory.SlotName; } else { Console.WriteLine("MoveItems not found item: " + itemId); } } //from container if (ItemLocation.IsContainer(from)) { if (locationContainer == null) { //Console.WriteLine("moveItem: Trying to move item: from container " + from + " to: " + to); int containerIndex = ItemLocationContainer.GetContainerIndex(from); if (containerIndex < 0) { Console.WriteLine("moveItem: Invalid container index"); return; } locationContainer = game.FindItemOnContainers(itemId, containerIndex); if (locationContainer == null) { Console.WriteLine("moveItem: Item " + itemId + " not found on container index: " + containerIndex); return; } } //container to container if (ItemLocation.IsContainer(to)) { fromContainer.ToContainer(itemId, to, locationContainer); return; } //container to inventory if (ItemLocation.IsInventory(to)) { fromContainer.ToInventory(itemId, to, locationContainer); return; } //container to ground if (ItemLocation.IsGround(to)) { fromContainer.ToGround(itemId, to, locationContainer); return; } } //from inventory if (ItemLocation.IsInventory(from)) { //inventory to inventory if (ItemLocation.IsInventory(to)) { fromInventory.ToInventory(itemId, to, from); return; } //inventory to container if (ItemLocation.IsContainer(to)) { fromInventory.ToContainer(itemId, to, from); return; } //inventory to ground if (ItemLocation.IsGround(to)) { fromInventory.ToGround(itemId, to, from); return; } } //from ground if (ItemLocation.IsGround(from)) { //ground to ground if (ItemLocation.IsGround(to)) { fromGround.ToGround(itemId, to, from); return; } //ground to container if (ItemLocation.IsContainer(to)) { fromGround.ToContainer(itemId, to, from); return; } //ground to inventory if (ItemLocation.IsInventory(to)) { fromGround.ToInventory(itemId, to, from); return; } } Console.WriteLine("Item move: Invalid location: " + from + " " + to); }