Exemple #1
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);
  }
Exemple #2
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);
 }