Esempio n. 1
0
  private boolean solved() {
    if (index == -1) {
      return false;
    }
    RSInterface solver = interfaces.get(CHEST_INTERFACE_PARENT);
    if (solver != null && solver.isValid()) {
      RSComponent container = solver.getComponent(CHEST_INTERFACE_CENTER);

      Point p1 = solver.getComponent(INTERFACE_SOLVE_IDS[index][0]).getCenter();
      p1.setLocation(p1.x + 15, p1.y);
      Point p2 = solver.getComponent(INTERFACE_SOLVE_IDS[index][1]).getCenter();
      p2.setLocation(p2.x + 15, p1.y);
      Point p3 = solver.getComponent(INTERFACE_SOLVE_IDS[index][2]).getCenter();
      p3.setLocation(p3.x + 15, p1.y);
      return (container.getArea().contains(p1)
          && container.getArea().contains(p2)
          && container.getArea().contains(p3));
    }
    return false;
  }
 RSComponentListener(final RSComponent child) {
   a = child;
   type = child.getType();
   specialtype = child.getSpecialType();
   bounds = child.getBoundsArrayIndex();
   model = child.getModelID();
   color = child.getBackgroundColor();
   getID = child.getParentID();
   getText = child.getText();
   tooltip = child.getTooltip();
   selectionname = child.getSelectedActionName();
   compID = child.getComponentID();
   compStackSize = child.getComponentStackSize();
   relativeloc = new Point(child.getRelativeX(), child.getRelativeY());
   absoluteloc = new Point(child.getAbsoluteX(), child.getAbsoluteY());
   area = child.getArea();
   xRot = child.getXRotation();
   yRot = child.getYRotation();
   zRot = child.getZRotation();
 }
Esempio n. 3
0
  @Override
  public int loop() {
    if (bank.isDepositOpen() || bank.isOpen()) {
      bank.close();
    }

    if (!activateCondition()) {
      return -1;
    }

    if (getMyPlayer().isMoving()) {
      return random(1000, 2000);
    }

    switch (getState()) {
      case EXIT:
        RSObject portal = objects.getNearest(EXIT_PORTAL);
        if (portal != null) {
          if (!portal.isOnScreen()) {
            camera.turnTo(portal);
          }
          if (portal.doAction("Enter")) {
            return random(1000, 1300);
          }
        }
        break;

      case OPEN_CHEST:
        RSObject chest = objects.getNearest(ARNAV_CHEST);
        if (chest != null) {
          if (chest.doClick()) {
            return random(1000, 1300);
          }
        }
        break;

      case TALK:
        if (interfaces.canContinue()) {
          interfaces.clickContinue();
          return random(1500, 2000);
        }
        RSComponent okay = interfaces.getComponent(TALK_INTERFACE, 3);
        if (okay != null && okay.isValid()) {
          okay.doClick();
        }
        return random(1500, 2000);

      case SOLVE:
        RSInterface solver = interfaces.get(CHEST_INTERFACE_PARENT);
        if (solver != null && solver.isValid()) {

          String s = solver.getComponent(32).getText();
          if (s.contains("Bowl")) {
            index = 0;
          } else if (s.contains("Ring")) {
            index = 1;
          } else if (s.contains("Coin")) {
            index = 2;
          } else if (s.contains("Bar")) {
            index = 3;
          }

          if (solved()) {
            solver.getComponent(CHEST_INTERFACE_UNLOCK).doClick();
            return random(600, 900);
          }

          RSComponent container = solver.getComponent(CHEST_INTERFACE_CENTER);
          for (int i = 0; i < 3; i++) {
            int rand = random(0, 100);
            if (rand < 50) {
              rand = 0;
            } else if (rand >= 50) {
              rand = 1;
            }
            RSComponent target = solver.getComponent(INTERFACE_SOLVE_IDS[index][i]);
            RSComponent arrow = solver.getComponent(ARROWS[i][rand]);
            while (container.isValid()
                && target.isValid()
                && !container
                    .getArea()
                    .contains(new Point(target.getCenter().x + 15, target.getCenter().y))
                && arrow.isValid()
                && new Timer(10000).isRunning()) {
              arrow.doClick();
              sleep(random(1000, 1200));
            }
          }
        }
    }
    return random(500, 800);
  }