Ejemplo n.º 1
0
 private void noteHerbs() {
   if (inventory.containsOneOf(grimyID)) {
     status = "Noting herbs";
     RSNPC leprechaun = npcs.getNearest(leprechaunID);
     if (!leprechaun.isOnScreen() || calc.distanceTo(leprechaun) > 4) {
       walking.walkTileMM(leprechaun.getLocation(), 1, 1);
       sleep(random(3000, 4000));
     }
     int tmp = inventory.getCount(grimyID);
     for (int i = 0; i < 5; i++) {
       if (tmp == inventory.getCount(grimyID)) {
         inventory.getItem(grimyID).doAction("Use");
         sleep(200, 300);
         if (inventory.isItemSelected()) {
           leprechaun.doAction("Use");
           sleep(3000, 4000);
         }
       } else break;
     }
     RSObject plot = objects.getNearest(herbPlot);
     if (plot != null) {
       if (!plot.isOnScreen()) {
         walking.walkTileMM(plot.getLocation(), 1, 1);
         sleep(random(3000, 4000));
       }
     }
   }
 }
Ejemplo n.º 2
0
 private boolean hasClawMoved(RSTile prevClawLoc) {
   RSObject claw = objects.getNearest(Molly.CLAW_ID);
   if (claw == null) {
     return false;
   }
   RSTile currentClawLoc = claw.getLocation();
   return (currentClawLoc.getX() - prevClawLoc.getX() != 0)
       || (currentClawLoc.getY() - prevClawLoc.getY() != 0);
 }
Ejemplo n.º 3
0
 private void checkCrops() {
   status = "Checking crops";
   RSObject plot = objects.getNearest(herbPlot);
   if (plot != null) {
     if (!plot.isOnScreen() || calc.distanceTo(plot) > 3) {
       walking.walkTileMM(plot.getLocation(), 1, 1);
       sleep(random(3000, 4000));
     }
     plot.doAction(inspect);
   }
 }
Ejemplo n.º 4
0
 private boolean openDoor() {
   final RSObject door = objects.getNearest(Molly.DOOR_ID);
   if (door == null) {
     return false;
   }
   if (!calc.tileOnScreen(door.getLocation())) {
     walking.walkTileOnScreen(door.getLocation());
     sleep(1000, 2000);
     return false;
   }
   door.doAction("Open");
   return false;
 }
Ejemplo n.º 5
0
 private void rakePatch() {
   status = "Raking the patch";
   RSObject plot = objects.getNearest(herbPlot);
   if (plot != null) {
     plot.doAction(rake);
     sleep(random(1250, 2000));
     Timer idleTimer = new Timer(random(1250, 2000));
     while (idleTimer.isRunning()) {
       if (players.getMyPlayer().getAnimation() != -1) idleTimer.reset();
       sleep(random(50, 200));
     }
   }
   currentState = State.CHECK_CROPS;
 }
Ejemplo n.º 6
0
 private void plantSeed() {
   status = "Planting seed";
   RSObject plot = objects.getNearest(herbPlot);
   if (plot != null && inventory.contains(seedID)) {
     int tmp = inventory.getItem(seedID).getStackSize();
     for (int i = 0; i < 5; i++) {
       if (tmp == inventory.getItem(seedID).getStackSize() && currentState == State.PLANT) {
         if (i > 0) camera.setAngle(random(0, 360));
         inventory.getItem(seedID).doClick(true);
         plot.doClick();
         sleep(random(2000, 3000));
       } else {
         if (currentState == State.PLANT) numSeedsPlanted++;
         break;
       }
     }
   }
   currentState = State.CHECK_CROPS;
 }
Ejemplo n.º 7
0
 private void cureHerbs() {
   status = "Curing diseased herbs";
   RSObject plot = objects.getNearest(herbPlot);
   if (plot != null) {
     if (inventory.contains(plantCureID)) {
       int tmp = inventory.getCount(plantCureID);
       for (int i = 0; i < 5; i++) {
         if (tmp == inventory.getCount(plantCureID) && currentState == State.CURE) {
           if (i > 0) camera.setAngle(random(0, 360));
           inventory.getItem(plantCureID).doClick(true);
           plot.doClick();
           sleep(random(3000, 4000));
         } else break;
       }
     }
     sleep(random(200, 300));
   }
   currentState = State.CHECK_CROPS;
 }
 private void clickObject(final int id, final String action) {
   final RSObject obj = objects.getNearestByID(id);
   if (obj != null) {
     try {
       if (tile.onScreen(obj.getLocation())) {
         if (obj.action(action)) {
           wait(random(2500, 3000));
           waitToStop();
         } else {
           rotateCameraRandomly();
         }
       } else {
         camera.turnTo(obj, random(20, 60));
         if (!tile.onScreen(obj.getLocation())) {
           walk.to(obj.getLocation());
         }
       }
     } catch (final Exception e) {
     }
   }
 }
  public void clickDoor(RSTile location, char direction) {
    if (Bot.getClient().getCameraPitch() != 3072) {
      camera.setAltitude(true);
    }

    if (location.isOnScreen()) {
      RSObject door = objects.getTopAt(location);
      if (!door.action("Open")) {
        rotateCameraRandomly();
      } else {
        if (door.distanceTo() > 0) {
          player.waitToMove(3000);
        }

        player.waitForAnim(random(2500, 3000));
        waitToStop();
      }
    } else {
      walk.to(location);
    }
  }
Ejemplo n.º 10
0
  private void compostPatch() {
    status = "Adding supercompost";
    RSObject plot = objects.getNearest(herbPlot);
    if (plot != null) {
      if (!inventory.contains(compostID)) {
        RSNPC leprechaun = npcs.getNearest(leprechaunID);
        if (!leprechaun.isOnScreen() || calc.distanceTo(leprechaun) > 4) {
          walking.walkTileMM(leprechaun.getLocation(), 1, 1);
          sleep(random(3000, 4000));
        }

        leprechaun.doAction("Exchange");
        sleep(random(1500, 2000));
        mouse.click(359, 265, 10, 10, true);
        sleep(random(300, 900));
        interfaces.getComponent(leprechaunInterface, closeInterface).doClick();
        sleep(random(200, 300));
        if (!plot.isOnScreen() || calc.distanceTo(plot) > 4) {
          walking.walkTileMM(plot.getLocation(), 1, 1);
          sleep(random(3000, 4000));
        }
      }
      if (inventory.contains(compostID)) {
        int tmp = inventory.getCount(compostID);
        for (int i = 0; i < 5; i++) {
          if (tmp == inventory.getCount(compostID) && currentState == State.COMPOST) {
            if (i > 0) camera.setAngle(random(0, 360));
            if (inventory.contains(compostID)) {
              inventory.getItem(compostID).doClick(true);
              plot.doClick();
            }
            sleep(random(4000, 5000));
          } else break;
        }
      }
    }
    currentState = State.CHECK_CROPS;
  }
Ejemplo n.º 11
0
  // My clickObject, like clickCharacter, and faster than atObject.
  public boolean clickObject(final RSObject c, final String action) {
    try {
      Point screenLoc;
      int X = (int) calc.tileToScreen(c.getLocation()).getX();
      int Y = (int) calc.tileToScreen(c.getLocation()).getY();

      screenLoc = new Point(X, Y);

      if ((c == null) || !calc.pointOnScreen(screenLoc)) {
        log("Not on screen " + action);
        return false;
      }

      mouse.move(screenLoc);

      X = (int) calc.tileToScreen(c.getLocation()).getX();
      Y = (int) calc.tileToScreen(c.getLocation()).getY();
      screenLoc = new Point(X, Y);
      if (!mouse.getLocation().equals(screenLoc)) {
        return false;
      }

      final String[] items = menu.getItems();
      if (items.length <= 1) {
        return false;
      }
      if (items[0].toLowerCase().contains(action.toLowerCase())) {
        mouse.click(screenLoc, true);
        return true;
      } else {
        mouse.click(screenLoc, false);
        return menu.doAction(action);
      }
    } catch (final NullPointerException ignored) {
    }
    return true;
  }
Ejemplo n.º 12
0
 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);
     }
   }
 }
Ejemplo n.º 13
0
 @Override
 public int loop() {
   if (!activateCondition()) {
     log("Molly random finished!");
     sleep(500);
     if (!activateCondition()) {
       return -1;
     }
   }
   controlPanel = objects.getNearest(Molly.CONTROL_PANEL_ID);
   while (getMyPlayer().isMoving() || (getMyPlayer().getAnimation() != -1)) {
     return (random(800, 1300));
   }
   if (interfaces.canContinue()) {
     interfaces.clickContinue();
     return random(250, 750);
   }
   if (mollyID == -1) {
     mollyID = molly.getID();
     log("Molly ID: " + Integer.toString(mollyID));
     log("Evil Twin ID:" + Integer.toString(mollyID - 40));
   }
   if (interfaces.canContinue()) {
     setCamera();
     interfaces.clickContinue();
     return random(500, 800);
   }
   final RSComponent skipInterface =
       interfaces.get(Molly.MOLLY_CHATBOX_INTERFACEGROUP).getComponent(Molly.MOLLY_CHATBOX_SKIP);
   if ((skipInterface != null)
       && skipInterface.isValid()
       && skipInterface.getAbsoluteY() > 5
       && skipInterface.containsText("Yes, I")) {
     skipInterface.doClick();
     return random(600, 1000);
   }
   final RSComponent noThanksInterface =
       interfaces
           .get(Molly.MOLLY_CHATBOX_INTERFACEGROUP)
           .getComponent(Molly.MOLLY_CHATBOX_NOTHANKS);
   if ((noThanksInterface != null)
       && noThanksInterface.isValid()
       && noThanksInterface.getAbsoluteY() > 5) {
     setCamera();
     sleep(random(800, 1200));
     noThanksInterface.doClick();
     talkedToMolly = true;
     return random(600, 1000);
   }
   if (!cameraSet) {
     camera.setPitch(true);
     cameraSet = true;
     return (random(300, 500));
   }
   if (finished && !inControlRoom()) {
     if (!calc.tileOnScreen(molly.getLocation())) {
       walking.walkTileOnScreen(molly.getLocation());
       return random(1000, 2000);
     }
     molly.doAction("Talk");
     return (random(1000, 1200));
   }
   if (finished && inControlRoom()) {
     if (!openDoor()) {
       return (random(1000, 1500));
     }
     return (random(400, 600));
   }
   if (!inControlRoom()) {
     if (talkedToMolly
         && !finished
         && (interfaces.get(Molly.MOLLY_CHATBOX_INTERFACEGROUP) == null
             || interfaces.get(Molly.MOLLY_CHATBOX_INTERFACEGROUP).getComponent(0).getAbsoluteY()
                 < 2)
         && (interfaces.get(Molly.MOLLY_CHATBOX_NOTHANKS) == null
             || interfaces.get(Molly.MOLLY_CHATBOX_NOTHANKS).getComponent(0).getAbsoluteY() < 2)) {
       openDoor();
       sleep(random(800, 1200));
     } else {
       molly.doAction("Talk");
       talkedToMolly = true;
       return (random(1000, 2000));
     }
   } else {
     if (npcs.getNearest("Molly") != null) {
       finished = true;
       sleep(random(800, 1200));
     } else {
       if (!inControlInterface()) {
         if (calc.tileOnScreen(controlPanel.getLocation())) {
           controlPanel.doAction("Use");
           sleep(random(1200, 2000));
         } else {
           walking.walkTileOnScreen(controlPanel.getLocation());
           camera.setPitch(true);
           camera.turnTo(controlPanel);
         }
       } else {
         navigateClaw();
         delayTime = System.currentTimeMillis();
         while (!interfaces.canContinue() && (System.currentTimeMillis() - delayTime < 15000)) {}
         if (interfaces.canContinue()) {
           interfaces.clickContinue();
         }
         sleep(random(300, 400));
       }
     }
   }
   return random(200, 400);
 }
Ejemplo n.º 14
0
 @Override
 public int loop() {
   if (!activateCondition()) {
     return -1;
   }
   RSObject statue1 = objects.getNearest(STATUE_IDS[0]);
   RSObject statue2 = objects.getNearest(STATUE_IDS[1]);
   RSObject statue3 = objects.getNearest(STATUE_IDS[2]);
   RSObject statue4 = objects.getNearest(STATUE_IDS[3]);
   if (getMyPlayer().isMoving() || getMyPlayer().getAnimation() != -1) {
     return random(550, 700);
   }
   if (interfaces.get(241).getComponent(4).isValid()
       && interfaces.get(241).getComponent(4).getText().contains("catnap")) {
     finished = true;
   }
   if (interfaces.get(64).getComponent(4).isValid()
       && interfaces.get(64).getComponent(4).getText().contains("fallen asleep")) {
     finished = true;
   }
   if (interfaces.get(242).getComponent(4).isValid()
       && interfaces.get(242).getComponent(4).getText().contains("Wait! Before")) {
     forceTalk = true;
   }
   if (interfaces.canContinue()) {
     if (interfaces.clickContinue()) {
       return random(500, 1000);
     }
   }
   if (forceTalk) {
     RSNPC servant = npcs.getNearest(2481);
     if (servant != null && direction == null && settings.getSetting(344) == 0) {
       if (!calc.tileOnScreen(servant.getLocation())) {
         walking.walkTileMM(walking.getClosestTileOnMap(servant.getLocation()));
         return 700;
       }
       if (servant.doAction("Talk-to")) {
         forceTalk = false;
       }
       return random(1000, 2000);
     }
     if (servant == null) {
       servant = npcs.getNearest(2481);
       if (servant == null) {
         walking.walkTileMM(walking.getClosestTileOnMap(CENTER_TILE));
         return random(1000, 2000);
       }
       return random(50, 100);
     }
   }
   if (finished) {
     RSObject portal = objects.getNearest(8987);
     if (portal != null) {
       if (!calc.tileOnScreen(portal.getLocation())) {
         walking.walkTileMM(walking.getClosestTileOnMap(portal.getLocation()));
         return random(500, 1000);
       } else {
         if (portal.doAction("Enter")) {
           return random(6000, 7000);
         }
         return random(500, 1000);
       }
     } else {
       walking.walkTileMM(walking.getClosestTileOnMap(CENTER_TILE));
     }
   }
   if (bank.isDepositOpen() && bank.getBoxCount() - bank.getBoxCount(6209, 6202, 6200) >= 27) {
     RSComponent randomItem = interfaces.get(11).getComponent(17).getComponent(random(16, 26));
     int randomID = randomItem.getComponentID();
     if (randomID < 0) {
       return random(50, 100);
     }
     log("Item with ID " + randomID + " was deposited.");
     if (interfaces.get(11).getComponent(17).getComponent(random(16, 26)).doAction("Dep")) {
       return random(500, 1000);
     }
     return random(50, 100);
   }
   if (bank.isDepositOpen() && bank.getBoxCount() - bank.getBoxCount(6209, 6202, 6200) < 27) {
     bank.close();
     return random(500, 1000);
   }
   if (inventory.getCountExcept(6209, 6202, 6200) >= 27) {
     RSObject box = objects.getNearest(32930);
     if (!calc.tileOnScreen(box.getLocation())) {
       walking.walkTileMM(walking.getClosestTileOnMap(box.getLocation()));
       return random(1000, 2000);
     } else {
       log("Depositing item(s) to make room.");
       box.doAction("Deposit");
       return random(500, 1000);
     }
   }
   if (inventory.getCount(6202) > 0) {
     final RSObject pot = objects.getNearest(8985);
     if (pot != null) {
       if (!calc.tileOnScreen(pot.getLocation())) {
         walking.walkTileMM(walking.getClosestTileOnMap(pot.getLocation()));
         return random(400, 800);
       }
       inventory.getItem(6202).doAction("Use");
       sleep(random(800, 1000));
       if (pot.doAction("Use")) {
         sleep(1000);
       }
       return random(2000, 2400);
     } else {
       walking.walkTileMM(walking.getClosestTileOnMap(CENTER_TILE));
     }
   }
   if (fishing && inventory.getCount(6209) == 0) {
     final RSGroundItem net = groundItems.getNearest(6209);
     if (net != null) {
       if (!calc.tileOnScreen(net.getLocation())) {
         walking.walkTileMM(walking.getClosestTileOnMap(net.getLocation()));
         return random(800, 1000);
       } else {
         tiles.doAction(net.getLocation(), "Take");
         return random(800, 1000);
       }
     } else {
       walking.walkTileMM(walking.getClosestTileOnMap(CENTER_TILE));
     }
   }
   if (interfaces.get(246).getComponent(5).containsText("contains")
       && settings.getSetting(334) == 1
       && direction == null) {
     sleep(2000);
     if (calc.tileOnScreen(statue1.getLocation())) {
       direction = statue1;
       fishing = true;
     }
     if (calc.tileOnScreen(statue2.getLocation())) {
       direction = statue2;
       fishing = true;
     }
     if (calc.tileOnScreen(statue3.getLocation())) {
       direction = statue3;
       fishing = true;
     }
     if (calc.tileOnScreen(statue4.getLocation())) {
       direction = statue4;
       fishing = true;
     }
     log("Checking direction");
     return random(2000, 3000);
   }
   if (direction != null && inventory.getCount(6200) < 1) {
     sleep(random(1000, 1200));
     if (!calc.tileOnScreen(direction.getLocation())) {
       walking.walkTileMM(walking.getClosestTileOnMap(direction.getLocation()));
       return random(400, 600);
     }
     final RSObject spot = objects.getNearest(8986);
     if (spot != null) {
       if (!calc.tileOnScreen(spot.getLocation())) {
         camera.turnTo(spot.getLocation());
       }
       if (!calc.tileOnScreen(spot.getLocation()) && walking.walkTileMM(spot.getLocation())) {
         sleep(random(1000, 2000));
         if (!calc.tileOnScreen(spot.getLocation())) {
           sleep(1000);
         }
       }
       tiles.doAction(spot.getLocation(), "Net");
       return random(2000, 2500);
     } else {
       walking.walkTileMM(walking.getClosestTileOnMap(CENTER_TILE));
     }
   }
   if (inventory.getCount(6200) > 0) {
     final RSNPC cat = npcs.getNearest(2479);
     if (cat != null) {
       if (!calc.tileOnScreen(cat.getLocation())) {
         walking.walkTileMM(walking.getClosestTileOnMap(cat.getLocation()));
       }
       inventory.getItem(6200).doAction("Use");
       sleep(random(500, 1000));
       cat.doAction("Use Raw fish-like thing -> Evil bob");
     } else {
       walking.walkTileMM(walking.getClosestTileOnMap(CENTER_TILE));
     }
     return random(1900, 2200);
   }
   RSNPC servant = npcs.getNearest(2481);
   if (servant != null && direction == null && settings.getSetting(344) == 0) {
     if (!calc.tileOnScreen(servant.getLocation())) {
       walking.walkTileMM(walking.getClosestTileOnMap(servant.getLocation()));
       return 700;
     }
     servant.doAction("Talk-to");
     return random(1000, 2000);
   }
   if (servant == null) {
     servant = npcs.getNearest(2481);
     if (servant == null) {
       walking.walkTileMM(walking.getClosestTileOnMap(CENTER_TILE));
       return random(1000, 2000);
     }
     return random(50, 100);
   }
   log("Setting 344: " + settings.getSetting(344));
   return random(800, 1200);
 }
Ejemplo n.º 15
0
  @Override
  public int loop() {
    final RSNPC mordaut = npcs.getNearest("Mr. Mordaut");
    if (mordaut == null) {
      return -1;
    }

    if (getMyPlayer().isMoving() || (getMyPlayer().getAnimation() != -1)) {
      return random(800, 1200);
    }

    if (door != null) {
      if (calc.distanceTo(door) > 3) {
        walking.getPath(door.getLocation()).traverse();
        sleep(random(1400, 2500));
      }
      if (!calc.tileOnScreen(door.getLocation())) {
        walking.walkTileMM(door.getLocation());
        sleep(random(1400, 2500));
      }
      if (door.getID() == 2188) {
        camera.setCompass('w');
      }
      if (door.getID() == 2193) {
        camera.setCompass('e');
      }
      if (door.getID() == 2189) {
        camera.setCompass('w');
      }
      if (door.getID() == 2192) {
        camera.setCompass('n');
      }
      clickObject(door, "Open");
      return random(500, 1000);
    }
    final RSComponent inter = searchInterfacesText("To exit,");
    if (inter != null) {
      if (inter.getText().toLowerCase().contains("red")) {
        door = objects.getNearest(2188);
      }
      if (inter.getText().toLowerCase().contains("green")) {
        door = objects.getNearest(2193);
      }
      if (inter.getText().toLowerCase().contains("blue")) {
        door = objects.getNearest(2189);
      }
      if (inter.getText().toLowerCase().contains("purple")) {
        door = objects.getNearest(2192);
      }
      return random(500, 1000);
    }
    if (!interfaces.get(nextObjectInterface).isValid()
        && !getMyPlayer().isMoving()
        && !interfaces.get(relatedCardsInterface).isValid()
        && !interfaces.canContinue()
        && door == null) {
      if (calc.distanceTo(mordaut) > 4) {
        walking.getPath(mordaut.getLocation()).traverse();
      }
      if (!calc.tileOnScreen(mordaut.getLocation())) {
        walking.walkTileMM(mordaut.getLocation());
      }
      clickCharacter(mordaut, "Talk-to");
      return (random(1500, 1700));
    }
    if (interfaces.get(nextObjectInterface).isValid()) {
      log.info("Question Type: Next Object");
      final NextObjectQuestion noq = new NextObjectQuestion();
      if (noq.getObjects()) {
        if (noq.clickAnswer()) {
          return random(800, 1200);
        } else {
          noq.guess();
          return random(800, 1200);
        }
      } else {
        log.info("Could not find get object. Making educated guess.");
        noq.guess();
        return random(800, 1200);
      }
    }

    if (interfaces.get(relatedCardsInterface).isValid()) {
      log.info("Question Type: Similar Objects");
      int z = 0;
      for (final SimilarObjectQuestion obj : simObjects) {
        if (obj.activateCondition()) {
          z = 1;
          if (obj.clickObjects()) {
            obj.accept();
          }
        }
      }
      if (z == 0) {
        log.severe("This is a new question.");
        log.severe("Please post this on the forums.");
        log.severe("The Missing Question is :");
        log(interfaces.get(nextObjectInterface).getComponent(25).getText().toLowerCase());
      }
      return random(800, 1200);
    }

    if (interfaces.clickContinue()) {
      return random(800, 3500);
    }

    return random(800, 1200);
  }
Ejemplo n.º 16
0
  @Override
  public int loop() {
    camera.setAltitude(true);
    if (!activateCondition() && readyToLeave) {
      readyToLeave = false;
      failCount = 0;
      log(ScreenLog.cerFinish);
      return -1;
    }

    if (iface.getChild(241, 4).containsText("Ahem, ")) {
      readyToLeave = false;
    }

    if (iface.getChild(241, 4).containsText("Correct.")
        || iface.getChild(241, 4).containsText("You can go now.")) {
      readyToLeave = true;
    }

    if (readyToLeave) {
      final int PORTAL_ID = 11368;
      final RSObject portal = objects.getNearestByID(PORTAL_ID);
      if (portal != null) {
        final RSTile portalLocation = portal.getLocation();
        if (portal.distanceTo() < 4) {
          objects.at(portal, "Enter");
          return random(3000, 4000);
        } else {
          walk.tileMM(
              walk.randomizeTile(
                  new RSTile(portalLocation.getX() - 1, portalLocation.getY()), 1, 1));
          return random(6000, 8000);
        }
      }
    }

    if (iface.getChild(184, 0).isValid()) {
      final int modelID = iface.getChild(184, 8).getChildren()[3].getModelID();
      String itemName = null;
      for (int i = 0; i < MODEL_IDS.length; i++) {
        if (MODEL_IDS[i] == modelID) {
          itemName = ITEM_NAMES[i];
        }
      }

      if (itemName == null) {
        log(ScreenLog.cerID + modelID);
        failCount++;
        if (failCount > 10) {
          stopScript(false);
          return -1;
        }
        return random(1000, 2000);
      }

      for (int j = 0; j < 3; j++) {
        final RSInterfaceChild ifa = iface.getChild(184, 8).getChildren()[j];
        if (ifa.containsText(itemName)) {
          ifa.click();
          return random(3000, 5000);
        }
      }
    }

    if (iface.canContinue()) {
      iface.clickContinue();
      return random(3000, 4000);
    }

    final RSNPC certer = npc.getNearestByName("Niles", "Miles", "Giles");
    if (certer != null) {
      if (certer.distanceTo() < 4) {
        npc.action(certer, "Talk-to");
        return random(4000, 5000);
      } else {
        final RSTile certerLocation = certer.getLocation();
        walk.tileMM(
            walk.randomizeTile(new RSTile(certerLocation.getX() + 2, certerLocation.getY()), 1, 1));
        return random(6000, 8000);
      }
    }

    failCount++;
    if (failCount > 10) {
      stopScript(false);
      return -1;
    }
    return random(1000, 2000);
  }
Ejemplo n.º 17
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);
  }
Ejemplo n.º 18
0
  @Override
  public int loop() {
    if (!activateCondition() && readyToLeave) {
      readyToLeave = false;
      failCount = 0;
      return -1;
    }
    if (getMyPlayer().getAnimation() != -1 || getMyPlayer().isMoving()) {
      return random(500, 1000);
    }
    if (interfaces.getComponent(241, 4).containsText("Ahem, ")) {
      readyToLeave = false;
    }

    if (interfaces.getComponent(241, 4).containsText("Correct.")
        || interfaces.getComponent(241, 4).containsText("You can go now.")) {
      readyToLeave = true;
    }

    if (readyToLeave) {
      int PORTAL_ID = 11368;
      final RSObject portal = objects.getNearest(PORTAL_ID);
      if (portal != null) {
        final RSTile portalLocation = portal.getLocation();
        if (portal.isOnScreen()) {
          portal.doAction("Enter");
          return random(3000, 4000);
        } else {
          walking.walkTileMM(
              new RSTile(portalLocation.getX() - 1, portalLocation.getY()).randomize(1, 1));
          return random(1500, 2000);
        }
      }
    }

    if (interfaces.getComponent(184, 0).isValid()) {
      final int modelID = interfaces.getComponent(184, 8).getComponents()[3].getModelID();
      String itemName = null;
      for (int i = 0; i < MODEL_IDS.length; i++) {
        if (MODEL_IDS[i] == modelID) {
          itemName = ITEM_NAMES[i];
        }
      }

      if (itemName == null) {
        log("The object couldn't be identified! ID: " + modelID);
        failCount++;
        if (failCount > 10) {
          stopScript(false);
          return -1;
        }
        return random(1000, 2000);
      }

      for (int j = 0; j < 3; j++) {
        final RSComponent iface = interfaces.getComponent(184, 8).getComponents()[j];
        if (iface.containsText(itemName)) {
          iface.doClick();
          return random(1000, 1200);
        }
      }
    }

    if (interfaces.canContinue()) {
      interfaces.clickContinue();
      return random(1000, 1200);
    }

    final RSNPC certer = npcs.getNearest("Niles", "Miles", "Giles");
    if (certer != null) {
      if (calc.distanceTo(certer) < 4) {
        certer.doAction("Talk-to");
        return random(2500, 3000);
      } else {
        final RSTile certerLocation = certer.getLocation();
        walking.walkTileMM(
            new RSTile(certerLocation.getX() + 2, certerLocation.getY()).randomize(1, 1));
        return random(3000, 3500);
      }
    }

    failCount++;
    if (failCount > 10) {
      stopScript(false);
      return -1;
    }
    return random(400, 600);
  }
Ejemplo n.º 19
0
 private boolean inControlRoom() {
   final RSObject o = objects.getNearest(DOOR_ID);
   return (o != null) && (getMyPlayer().getLocation().getX() > o.getLocation().getX());
 }