Example #1
0
 public static boolean directionPassable(Directions d, Tile t) {
   final int[][] flags = Walking.getCollisionFlags(Game.getPlane());
   final Tile offset =
       Walking.getCollisionOffset(Game.getPlane()).derive(Game.getBaseX(), Game.getBaseY());
   int toCheckFlag = flags[t.getX() - offset.getX()][t.getY() - offset.getY()];
   return ((toCheckFlag & ~d.getBlockFlag()) == toCheckFlag);
 }
Example #2
0
 public Tile getLocation() {
   final RegionOffset localTile = getRegionOffset();
   return new Tile(
       Game.getBaseX() + localTile.getX(),
       Game.getBaseY() + localTile.getY(),
       localTile.getPlane());
 }
Example #3
0
 public Area getArea() {
   if (object instanceof RSAnimable) {
     final RSAnimable animable = (RSAnimable) object;
     final int bX = Game.getBaseX(), bY = Game.getBaseY();
     final Tile tile1 = new Tile(bX + (int) animable.getX1(), bY + (int) animable.getY1(), plane);
     final Tile tile2 = new Tile(bX + (int) animable.getX2(), bY + (int) animable.getY2(), plane);
     return new Area(tile1, tile2);
   }
   return null;
 }
Example #4
0
  @Override
  public void run() {

    if (Squeal.isLogoutNeeded()) {

      Game.logout(false);

      Time.sleep(1000);

      Squeal.setLogout(false);
    }

    clientDead = false;

    if (!Lobby.isOpen() || !Lobby.getOpenDialog().isOpen()) {

      while (!Lobby.isOpen()
          && !clientDead
          && !Game.isLoggedIn()
          && Widgets.get(596, 70).isOnScreen()) {

        getId();
        clearDetails();
        enterDetails();
        attemptLog();
      }

    } else {

      if (clientDead == false) {

        while (!Game.isLoggedIn()) {

          if (Lobby.enterGame()) {

            // Method sometimes fails for some unknown reason.

            Time.sleep(3000, 5000);
          }
        }

        if (Widgets.get(1313, 11).isOnScreen()) {

          Widgets.get(1313, 2).click(true);
        }
      }
    }
  }
  @Override
  public void onRepaint(Graphics g1) {
    Graphics2D g = (Graphics2D) g1;

    final Color color1 = new Color(213, 214, 175);
    final Color color2 = new Color(0, 0, 0);
    final Color color3 = new Color(1, 1, 1);

    final BasicStroke stroke1 = new BasicStroke(1);

    final Font font1 = new Font("Verdana", 3, 18);
    final Font font2 = new Font("Verdana", 1, 12);

    if (Game.isLoggedIn()) {
      currentWcExp = Skills.getExperience(Skills.WOODCUTTING);
      woodcuttingExpGained = currentWcExp - startWoodcuttingExp;
      int xpHour = (int) (3600000.0 / (runTime.getElapsed()) * woodcuttingExpGained);

      g.setColor(color1);
      g.fillRect(8, 394, 487, 114);
      g.setColor(color2);
      g.setStroke(stroke1);
      g.drawRect(8, 394, 487, 114);
      g.setFont(font1);
      g.setColor(color3);
      g.drawString("AnDraynorWillowChopper v0.3", 219, 421);
      g.setFont(font2);
      g.drawString("Status: " + Status, 18, 433);
      g.drawString("Run Time: " + runTime.toElapsedString(), 18, 452);
      g.drawString("Xp gained: " + woodcuttingExpGained + "(" + xpHour + ")/hr", 19, 472);
      g.drawString("WoodCutting Level: " + Skills.getLevel(Skills.WOODCUTTING), 18, 491);
    }
  }
 @Override
 public int loop() {
   final Node stateNode = script.state();
   if (Game.getClientState() != Game.INDEX_MAP_LOADED) {
     return 2000;
   }
   if (client != Bot.client()) {
     WidgetCache.purge();
     Bot.context().getEventManager().addListener(this);
     client = Bot.client();
   }
   if (stateNode != null && Game.isLoggedIn()) {
     script.set(stateNode);
     final Node setNode = script.get();
     if (setNode != null) {
       getContainer().submit(setNode);
       setNode.join();
     }
   }
   return 250;
 }
Example #7
0
  @Override
  public void onRepaint(Graphics g1) {
    Graphics2D g = (Graphics2D) g1;

    if (Game.getClientState() != 11) return;

    if (!start) {
      g.drawImage(background, paintX, paintY, null);
      drawBoxes(g);
      return;
    }
    if (!hide) {
      // paint once started with xp bar in here
    }

    if (lost) {
      g.drawString(state + "! Please restart script", 200, 200);
    }

    g.setColor(Color.black);
    g.drawString(state, 200, 200);
  }
Example #8
0
 @Override
 public boolean activate() {
   return Game.isLoggedIn() && GcSuperheater.isBanking;
 }
 @Override
 public void onStart() {
   if (Game.isLoggedIn()) {
     startWoodcuttingExp = Skills.getExperience(Skills.WOODCUTTING);
   }
 }
 @Override
 public boolean activate() {
   return Game.isLoggedIn();
 }
 /**
  * Waits for the timer to run out or the {@link Completion} to be met with a specified sleep
  * between checks
  *
  * @param intersleep The time (in millis) to wait between checks
  * @return the value of the Completion when the timer stops
  * @see TimedCondition#waitStop()
  */
 public boolean waitStop(final int intersleep) {
   while (Players.getLocal() != null && Game.isLoggedIn() && isRunning()) {
     Task.sleep(intersleep);
   }
   return isDone() && Game.isLoggedIn();
 }
Example #12
0
 @Override
 public void execute() {
   if (GlobalConstant.WIELDED_ID != -1
       && Settings.get(300) == 1000
       && Checks.getLP() < Skills.getRealLevel(Skills.CONSTITUTION) * 10 - 200) {
     if (Players.getLocal().getAppearance()[GlobalConstant.WEAPON] != GlobalConstant.EXCALIBUR
         && (Tabs.getCurrent().equals(Tabs.INVENTORY) || Tabs.INVENTORY.open())) {
       final Item excalibur = Inventory.getItem(GlobalConstant.EXCALIBUR);
       if (excalibur != null) {
         excalibur.getWidgetChild().click(true);
         PauseHandler.pause(
             new PauseHandler.Condition() {
               @Override
               public boolean validate() {
                 return Players.getLocal().getAppearance()[GlobalConstant.WEAPON]
                     == GlobalConstant.EXCALIBUR;
               }
             },
             (long) Random.nextInt(750, 1500));
       }
     } else if (Tabs.getCurrent().equals(Tabs.ATTACK) || Tabs.ATTACK.open()) {
       final WidgetChild bar = Widgets.get(884, 4);
       if (bar.validate()) {
         bar.click(true);
         PauseHandler.pause(
             new PauseHandler.Condition() {
               @Override
               public boolean validate() {
                 return Settings.get(300) != 1000;
               }
             },
             (long) Random.nextInt(400, 800));
       }
     }
     return;
   }
   if (GlobalConstant.KEEP_ALIVE
       && Checks.getLP() < Skills.getRealLevel(Skills.CONSTITUTION) * 0.4f * 10) {
     if (Checks.isOutside()) {
       if (Players.getLocal().getAnimation() == -1) {
         final WidgetChild[] widgets = {Widgets.get(750, 2), Widgets.get(750, 6)};
         if (widgets[0].validate() && widgets[1].validate()) {
           if (widgets[Random.nextInt(0, widgets.length)].interact("Rest"))
             PauseHandler.pause(
                 new PauseHandler.Condition() {
                   @Override
                   public boolean validate() {
                     return Players.getLocal().getAnimation() != -1;
                   }
                 },
                 (long) Random.nextInt(750, 1500));
         }
       }
       Task.sleep(400, 800);
     } else {
       if (Calculations.distanceTo(GlobalConstant.TILE_BANK) > 5) {
         if (Traverse.walk(GlobalConstant.TILE_BANK)) {
           PauseHandler.pause(
               new PauseHandler.Condition() {
                 @Override
                 public boolean validate() {
                   return Walking.getDestination() == null
                       || Calculations.distanceTo(Walking.getDestination()) < 8;
                 }
               },
               (long) Random.nextInt(500, 1000));
         }
       }
     }
   } else {
     if (Checks.isOutside()) {
       final SceneObject ladder = SceneEntities.getNearest(GlobalConstant.ROPE_DOWN_ID);
       if (ladder != null && ladder.interact("Climb"))
         PauseHandler.pause(
             new PauseHandler.Condition() {
               @Override
               public boolean validate() {
                 return !Checks.isOutside();
               }
             },
             750l);
       else if (ladder != null && Calculations.distanceTo(ladder) > 5)
         PauseHandler.walk(ladder, (long) Random.nextInt(250, 750));
     } else if (inCombat() || Players.getLocal().isInCombat()) {
       final Tile rockTile = GlobalConstant.TILE_ROCKS[Checks.isGold()][Mine.getCurrent()];
       if (true
           || Calculations.distanceTo(GlobalConstant.TILE_BANK)
               < Calculations.distanceTo(rockTile)) {
         if (Calculations.distanceTo(GlobalConstant.TILE_BANK) > 6
             && Traverse.walk(GlobalConstant.TILE_BANK)) {
           PauseHandler.pause(
               new PauseHandler.Condition() {
                 @Override
                 public boolean validate() {
                   return Walking.getDestination() == null
                       || Calculations.distanceTo(Walking.getDestination()) < 8;
                 }
               },
               (long) Random.nextInt(200, 500));
         }
       } else {
         final SceneObject rock = SceneEntities.getAt(rockTile);
         final NPC npc =
             NPCs.getNearest(
                 new Filter<NPC>() {
                   @Override
                   public boolean accept(final NPC npc) {
                     return npc.getInteracting() != null
                         && npc.getInteracting().equals(Players.getLocal())
                         && Arrays.binarySearch(GlobalConstant.LRC_NPC, npc.getId()) >= 0;
                   }
                 });
         if (rock != null && npc != null) {
           final Tile hardcodedSafe =
               GlobalConstant.MINE_GOLD && Mine.getCurrent() == 0
                   ? GlobalConstant.GOLD_SAFE_SPOT
                   : !GlobalConstant.MINE_GOLD && Mine.getCurrent() == 2
                       ? GlobalConstant.COAL_SAFE_SPOT
                       : null;
           if (hardcodedSafe != null) {
             hardcodedSafe
                 .randomize(0, Mine.getCurrent() == 2 ? 4 : 1, 1, Mine.getCurrent() == 0 ? -4 : 1)
                 .clickOnMap();
           } else {
             final Tile[] bounds = rock.getArea().getBoundingTiles();
             Arrays.sort(
                 bounds,
                 new Comparator<Tile>() {
                   @Override
                   public int compare(final Tile t1, final Tile t2) {
                     return Calculations.distance(t1, npc.getLocation())
                             < Calculations.distance(t2, npc.getLocation())
                         ? 1
                         : -1;
                   }
                 });
             final int[][] flags = Walking.getCollisionFlags(Game.getPlane());
             final Tile colOffset =
                 Walking.getCollisionOffset(Game.getPlane())
                     .derive(Game.getBaseX(), Game.getBaseY());
             Tile toWalk = null;
             for (final int[] offset : new int[][] {{0, 1}, {1, 0}, {0, -1}, {-1, 0}}) {
               final Tile derive = bounds[0].derive(offset[0], offset[1]);
               if (Nodes.walkable(flags, colOffset, derive)) {
                 if (toWalk == null
                     || Calculations.distance(derive, npc) > Calculations.distance(toWalk, npc))
                   toWalk = derive;
               }
             }
             if (toWalk != null) {
               if (!toWalk.isOnScreen()) Camera.turnTo(toWalk);
               toWalk.interact("Walk here");
             }
           }
           Task.sleep(100, 300);
           final int lp = Checks.getLP();
           final Timer timer = new Timer((long) Random.nextInt(7500, 10000));
           while (Players.getLocal().isInCombat()
               && Checks.getLP() >= lp
               && !Context.get().getScriptHandler().isPaused()
               && timer.isRunning()) Task.sleep(200, 800);
         }
       }
     }
   }
 }
Example #13
0
  public boolean paint(Graphics graphics) {
    if (!Game.isLoggedIn()) return false;
    try {
      Graphics2D g = (Graphics2D) graphics;
      PComponent clayout = null;
      try {
        clayout =
            new PColumnLayout(
                227,
                404,
                infoColumnValues,
                infoColumnData,
                new Font("Arial", 0, 9),
                PColumnLayout.ColorScheme.WHITE);
      } catch (Exception e) {
        e.printStackTrace();
      }
      getFrame("options").removeComponent(firstLayout);
      getFrame("options").removeComponent(secondLayout);
      int secondColx = -1;
      int bestLength = -1;
      firstColumn.clear();
      secondColumn.clear();
      if (checkBoxes.size() <= 6) firstColumn.putAll(checkBoxes);
      else {
        for (int i = 0; i < checkBoxes.size(); i++) {
          if (i <= 5) {
            String text;
            Iterator it = checkBoxes.keySet().iterator();
            for (int j = 0; j < i; j++) it.next();
            text = (String) it.next();
            int length = SwingUtilities.computeStringWidth(g.getFontMetrics(g.getFont()), text);
            if (length > bestLength) bestLength = length;
            firstColumn.put(text, checkBoxes.get(text));
          } else {
            String text;
            Iterator it = checkBoxes.keySet().iterator();
            for (int j = 0; j < i; j++) it.next();
            text = (String) it.next();
            secondColumn.put(text, checkBoxes.get(text));
          }
        }
      }
      secondColx = 8 + bestLength;
      firstLayout =
          new PCheckBoxLayout(
              8,
              407,
              firstColumn
                  .keySet()
                  .toArray(new String[(firstColumn.size() > 6) ? 6 : firstColumn.size()]),
              firstColumn
                  .values()
                  .toArray(new PCheckBox[(firstColumn.size() > 6) ? 6 : firstColumn.size()]),
              new Font("Arial", 0, 11),
              PCheckBoxLayout.ColorScheme.WHITE);
      secondLayout =
          new PCheckBoxLayout(
              secondColx + 12,
              407,
              secondColumn
                  .keySet()
                  .toArray(new String[(secondColumn.size() > 6) ? 6 : secondColumn.size()]),
              secondColumn
                  .values()
                  .toArray(new PCheckBox[(secondColumn.size() > 6) ? 6 : secondColumn.size()]),
              new Font("Arial", 0, 11),
              PCheckBoxLayout.ColorScheme.WHITE);
      getFrame("options").addComponent(firstLayout);
      getFrame("options").addComponent(secondLayout);
      if (showPaint) {
        Paint p = g.getPaint();
        g.setPaint(
            new GradientPaint(
                0, 1000, new Color(55, 55, 55, 240), 512, 472, new Color(15, 15, 15, 240)));
        g.fillRect(7, 396, 505, 128);
        final Point loc = Mouse.getLocation();
        if (Mouse.isPressed()) {
          g.fillOval(loc.x - 5, loc.y - 5, 10, 10);
          g.drawOval(loc.x - 5, loc.y - 5, 10, 10);
        }
        g.drawLine(0, loc.y + 1, 766, loc.y + 1);
        g.drawLine(0, loc.y - 1, 766, loc.y - 1);
        g.drawLine(loc.x + 1, 0, loc.x + 1, 505);
        g.drawLine(loc.x - 1, 0, loc.x - 1, 505);
        g.setPaint(p);
      }
      if (clayout != null) getFrame("info").addComponent(clayout);
      PaintController.onRepaint(graphics);
      if (clayout != null) getFrame("info").removeComponent(clayout);
      if (!showPaint) return false;
      String infoTxt = name + " - " + "v" + version;
      g.drawString(
          infoTxt,
          510 - SwingUtilities.computeStringWidth(g.getFontMetrics(g.getFont()), infoTxt),
          468);

      int offset = 0;
      for (Skill skill : skills) {
        if (skill.xpGained() > 0) {
          PSkill skillComp =
              new PSkill(8, 397 + offset, skill.getSkill(), PSkill.ColorScheme.GRAPHITE);
          if (!getFrame("info").containsComponent(skillComp)) {
            getFrame("info").addComponent(skillComp);
          }
          offset += 20;
        }
      }

      // == Mouse ==
      if (Mouse.isPressed()) {
        g.setColor(new Color(255, 252, 0, 150));

        g.setColor(new Color(255, 252, 0, 100));
      } else {
        g.setColor(new Color(255, 252, 0, 50));
      }

      g.setColor(new Color(0, 0, 0, 50));

      // == End mouse ==
    } catch (Exception ignored) {
      // if (Utils.isDevMode())
      //    ignored.printStackTrace();
    }
    return true;
  }
Example #14
0
  public boolean validate() {

    return !Game.isLoggedIn() || Squeal.isLogoutNeeded();
  }
Example #15
0
 @Override
 public boolean validate() {
   return Cons.WalkOut && Game.getClientState() != 12 && !Cons.Attacking;
 }
 private Tile toTile(int x, int y) {
   return new Tile(x, y, (plane == -1 ? Game.getPlane() : plane));
 }