Ejemplo n.º 1
0
 public boolean scrollToItem(Item i) {
   Interface bankInterface = botEnv.interfaces.getInterface(Bank.BANK_INTERFACE_ID);
   IComponent itemContainer = bankInterface.getComponent(Bank.BANK_ITEM_PANE_ID);
   if (!i.container.isElementVisible()) {
     bankInterface.getComponent(62).doClick();
     sleep(500, 1000);
   }
   /*if (bankInterface.getComponent(61).getTextureID() != 1419 && (itemContainer.getBounds().getLocation().equals(i.getBounds().getLocation()) ||
           i.container.getRelativeX() == 0 && i.container.getRelativeY() == 0)) {
       bankInterface.getComponent(62).doClick();
       sleep(500, 1000);
   }   */
   if (itemContainer.getBounds().contains(i.getCenter())) {
     return true;
   }
   IComponent arrow;
   if (i.getCenter().getY() < itemContainer.getAbsoluteY()) {
     arrow = bankInterface.getComponent(114).getChildren()[4];
   } else {
     arrow = bankInterface.getComponent(114).getChildren()[5];
   }
   Point p = botEnv.mouse.getMousePos();
   if (!arrow.getBounds().contains(p)) {
     botEnv.mouse.moveMouse(arrow.getBounds());
   }
   EventFactory eventFactory = new EventFactory(botEnv);
   p = botEnv.mouse.getMousePos();
   MouseEvent mouseEvent = eventFactory.createMousePress(p.x, p.y, true);
   botEnv.dispatchEvent(mouseEvent);
   KTimer timeout = new KTimer(random(5000, 6000));
   while (!itemContainer.getBounds().contains(i.getCenter()) && !timeout.isDone()) {
     sleep(200, 500);
   }
   mouseEvent = eventFactory.createMouseRelease(p.x, p.y, true);
   botEnv.dispatchEvent(mouseEvent);
   mouseEvent = eventFactory.createMouseClicked(p.x, p.y, true);
   botEnv.dispatchEvent(mouseEvent);
   return itemContainer.getBounds().contains(i.getCenter());
 }
Ejemplo n.º 2
0
 /**
  * Gets an item array of all the bank items.
  *
  * @return Array of bank items.
  */
 public Item[] getItems() {
   Interfaces interfaces = botEnv.interfaces;
   Interface inventoryInterface = interfaces.getInterface(BANK_INTERFACE_ID);
   if (inventoryInterface == null) {
     return new Item[0];
   }
   IComponent inventoryPane = inventoryInterface.getComponent(BANK_ITEM_PANE_ID);
   IComponent[] children = inventoryPane.getChildren();
   if (children == null || children.length == 0) {
     return new Item[0];
   }
   List<Item> items = new ArrayList<Item>();
   for (IComponent aChildren : children) {
     if (aChildren == null) {
       continue;
     }
     Item item = new Item(botEnv, aChildren);
     if (item.getID() == -1) {
       continue;
     }
     items.add(item);
   }
   return items.toArray(new Item[items.size()]);
 }