private void antiban() {
   if (System.currentTimeMillis() - antiban > random(120000, 420000)) {
     if (random(0, 2) == 1) {
       camera.setRotation(random(1, 360));
     } else {
       final int tab = tabConstants[random(0, tabConstants.length)];
       if (tab == TAB_STATS) {
         game.openTab(tab);
         wait(random(600, 700));
         final RSInterface statInterface = iface.get(320);
         if (statInterface != null) {
           try {
             final RSInterfaceChild stat =
                 statInterface.getChild(statConstants[random(0, statConstants.length)]);
             if (stat != null) {
               mouse.move(
                   stat.getAbsoluteX(), stat.getAbsoluteY(), stat.getWidth(), stat.getHeight());
               waitSafely(random(1100, 1600));
             }
           } catch (Exception e) {
           }
         }
       } else {
         game.openTab(tab);
         waitSafely(random(1100, 1600));
       }
     }
     antiban = System.currentTimeMillis();
   }
 }
Ejemplo n.º 2
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);
  }