Beispiel #1
0
 /**
  * Turns the camera towards the RSObject.
  *
  * @author LastCoder
  * @return <tt>true</tt> If RSObject is on screen after attempted to move camera angle.
  */
 public boolean turnTo() {
   final RSObject o = methods.objects.getNearest(getID());
   if (o != null) {
     if (!o.isOnScreen()) {
       methods.camera.turnTo(o);
       return o.isOnScreen();
     }
   }
   return false;
 }
Beispiel #2
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;
  }
Beispiel #3
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);
  }
Beispiel #4
0
 /**
  * Returns the name of the object.
  *
  * @param object The object to look up.
  * @return The object name if the definition is available; otherwise "".
  */
 public String getName(final RSObject object) {
   return object.getName();
 }