Example #1
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;
 }
Example #2
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;
 }
Example #3
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;
  }
Example #4
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);
  }