Ejemplo n.º 1
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.º 2
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);
  }