Beispiel #1
0
 /**
  * @param id ID of the item you want to withdraw.
  * @param amount Amount of the item you want to withdraw.
  * @param type Withdraw type: WITHDRAW_
  */
 private void withdraw(int id, int amount, int type) {
   boolean doAction = false;
   Item item = getItem(id);
   if (isOpen() && contains(id) && item != null) {
     doAction = scrollToItem(item);
   }
   if (doAction) {
     String action = "Withdraw-" + amount;
     if (type == WITHDRAW_ALL) {
       action = "Withdraw-All";
     } else if (type == WITHDRAW_ALL_BUT_ONE) {
       action = "Withdraw-All but one";
     }
     if (item.hasAction(action)) {
       item.doAction(action);
     } else { // withdraw X
       if (item.doAction("Withdraw-X")) {
         for (int i = 0; i < random(2000, 3000); i += 50) {
           IComponent c = botEnv.interfaces.getComponent(752, 5);
           if (c != null && c.isValid() && c.isVisible()) {
             sleep(500, 1000);
             botEnv.keyboard.writeText(Integer.toString(amount), true);
             break;
           }
           sleep(50);
         }
       }
     }
   }
 }
Beispiel #2
0
  /**
   * Sets withdraw mode - true for noted items, false for un-noted
   *
   * @param which
   */
  private void withdrawNote(boolean which) {
    if (!isOpen()) return;

    IComponent n = botEnv.interfaces.getComponent(BANK_INTERFACE_ID, BANK_BUTTON_NOTE);
    if (n == null) return;
    if (which) {
      // Set to withdraw-notes
      if (n.getTextureID() != 1433) n.doClick();
    } else {
      if (n.getTextureID() != 1431) n.doClick();
    }
  }
Beispiel #3
0
  /**
   * @param depositType Inventory, equipment, or familiar.
   * @return
   */
  private boolean depositByButton(int depositType) {
    if (!isOpen()) return false;

    IComponent depButton = botEnv.interfaces.getComponent(Bank.BANK_INTERFACE_ID, depositType);
    if (depButton != null && depButton.isVisible()) {
      if (depButton.doClick()) {
        sleep(300, 500);
        return true;
      }
    }

    return false;
  }
Beispiel #4
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()]);
 }
Beispiel #5
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());
 }
Beispiel #6
0
 /** Closes the bank interface. */
 public void close() {
   IComponent close = botEnv.interfaces.getComponent(762, BANK_BUTTON_CLOSE);
   if (close != null && isOpen()) {
     close.doClick();
   }
 }
Beispiel #7
0
 /**
  * Checks if the bank is open.
  *
  * @return Whether or not the bank interface is up.
  */
 public boolean isOpen() {
   IComponent iComponent = botEnv.interfaces.getComponent(BANK_INTERFACE_ID, BANK_ITEM_PANE_ID);
   return iComponent != null && iComponent.isVisible();
 }