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; }
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); } } }
private boolean inControlInterface() { final RSInterface i = interfaces.get(Molly.CONTROL_INTERFACEGROUP); return (i != null) && i.isValid(); }
@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); }