public void update(final String search) {
   interfaceWraps.clear();
   HighLightWraps.clear();
   for (final RSInterface iface : interfaces.getAll()) {
     toBreak:
     for (final RSComponent child : iface.getComponents()) {
       if (searchMatches(child, search)) {
         interfaceWraps.add(new RSInterfaceWrap(iface));
         if (window.isVisible()
             && !listenerButton.isSelected()
             && !searchBox.getText().equals("")) {
           HighLightWraps.add(new HighLightInterface(iface, child, null, -1));
         }
         break;
       }
       for (final RSComponent component : child.getComponents()) {
         if (searchMatches(component, search)) {
           interfaceWraps.add(new RSInterfaceWrap(iface));
           if (window.isVisible()
               && !listenerButton.isSelected()
               && !searchBox.getText().equals("")) {
             HighLightWraps.add(new HighLightInterface(iface, child, component, -1));
           }
           break toBreak;
         }
       }
     }
   }
   fireTreeStructureChanged(root);
 }
 private void antiban() {
   if (System.currentTimeMillis() - antiban > random(120000, 420000)) {
     if (random(0, 2) == 1) {
       camera.setRotation(random(1, 360));
     } else {
       final int tab = tabConstants[random(0, tabConstants.length)];
       if (tab == TAB_STATS) {
         game.openTab(tab);
         wait(random(600, 700));
         final RSInterface statInterface = iface.get(320);
         if (statInterface != null) {
           try {
             final RSInterfaceChild stat =
                 statInterface.getChild(statConstants[random(0, statConstants.length)]);
             if (stat != null) {
               mouse.move(
                   stat.getAbsoluteX(), stat.getAbsoluteY(), stat.getWidth(), stat.getHeight());
               waitSafely(random(1100, 1600));
             }
           } catch (Exception e) {
           }
         }
       } else {
         game.openTab(tab);
         waitSafely(random(1100, 1600));
       }
     }
     antiban = System.currentTimeMillis();
   }
 }
示例#3
0
文件: Exam.java 项目: HKbotz/RSBot
  public RSComponent searchInterfacesText(final String string) {
    final RSInterface[] inters = interfaces.getAll();
    for (final RSInterface inter : inters) {
      for (final RSComponent interfaceChild : inter.getComponents()) {
        if (interfaceChild.getText().toLowerCase().contains(string.toLowerCase())) {
          return interfaceChild;
        }
      }
    }

    return null;
  }
 private void addOldComponent() {
   OldInterfaces.clear();
   for (final RSInterface iface : interfaces.getAll()) {
     for (final RSComponent child : iface.getComponents()) {
       OldInterfaces.add(new RSComponentListener(child));
       if (child.getComponentStackSize() != 0) {
         for (final RSComponent component : child.getComponents()) {
           OldInterfaces.add(new RSComponentListener(component));
         }
       }
     }
   }
 }
示例#5
0
文件: Molly.java 项目: HKbotz/RSBot
 private void navigateClaw() {
   if (!inControlInterface() || (mollyID < 1)) {
     return;
   }
   RSObject claw;
   RSNPC suspect;
   while ((claw = objects.getNearest(Molly.CLAW_ID)) != null
       && (suspect = npcs.getNearest(mollyID - 40)) != null) {
     final RSTile clawLoc = claw.getLocation();
     final RSTile susLoc = suspect.getLocation();
     final ArrayList<Integer> options = new ArrayList<Integer>();
     if (susLoc.getX() > clawLoc.getX()) {
       options.add(Molly.CONTROLS_LEFT);
     }
     if (susLoc.getX() < clawLoc.getX()) {
       options.add(Molly.CONTROLS_RIGHT);
     }
     if (susLoc.getY() > clawLoc.getY()) {
       options.add(Molly.CONTROLS_DOWN);
     }
     if (susLoc.getY() < clawLoc.getY()) {
       options.add(Molly.CONTROLS_UP);
     }
     if (options.isEmpty()) {
       options.add(Molly.CONTROLS_GRAB);
     }
     final RSInterface i = interfaces.get(Molly.CONTROL_INTERFACEGROUP);
     if ((i != null) && i.isValid()) {
       i.getComponent(options.get(random(0, options.size()))).doClick();
     }
     delayTime = System.currentTimeMillis();
     while (!hasClawMoved(clawLoc) && (System.currentTimeMillis() - delayTime < 3500)) {
       sleep(10);
     }
   }
 }
示例#6
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;
  }
示例#7
0
文件: Molly.java 项目: HKbotz/RSBot
 private boolean inControlInterface() {
   final RSInterface i = interfaces.get(Molly.CONTROL_INTERFACEGROUP);
   return (i != null) && i.isValid();
 }
 @Override
 public String toString() {
   return "Interface " + wrapped.getIndex();
 }
示例#9
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);
  }