Ejemplo n.º 1
0
 @Override
 public boolean validate() {
   /*    console.log("here");
   console.log(Player.getAnimation() <= 0);
   console.log(!(Player.isMoving()));*/
   return (Player.getAnimation() <= 0) && !(Player.isMoving());
 }
Ejemplo n.º 2
0
 @Override
 public void execute() {
   System.out.println(
       "Run away! " + MiscRangeGuild.RUNAWAY_TILE.distanceTo(Player.getRSPlayer().getPosition()));
   while (MiscRangeGuild.RUNAWAY_TILE.distanceTo(Player.getRSPlayer().getPosition()) > 5) {
     if (Walking.walkPath(MiscRangeGuild.RUNAWAY_PATH)) instance.sleep(2000);
   }
   MiscRangeGuild.runAway = false;
 }
Ejemplo n.º 3
0
  /**
   * Checks what npc in the array should be attacked.
   *
   * <p>Does canReach and isInCombat checks as well.
   *
   * @param npcs
   * @return the npc to attack, or null if input array was null.
   */
  public static RSNPC[] orderOfAttack(RSNPC[] npcs) {

    if (npcs.length > 0) {

      npcs = NPCs.sortByDistance(Player.getPosition(), npcs);

      List<RSNPC> orderedNPCs = new ArrayList<RSNPC>();

      for (RSNPC npc : npcs) {

        if (npc.isInCombat() || !npc.isValid() || !MovementMgr.canReach(npc)) continue;

        orderedNPCs.add(npc);
      }

      if (orderedNPCs.size() > 1) {

        if (getUtil().BOOL_TRACKER.USE_CLOSEST.next()) {

          // if the 2nd closest npc is within 3 tiles of the closest npc, attack the 2nd one first.
          if (orderedNPCs.get(0).getPosition().distanceTo(orderedNPCs.get(1)) <= 3)
            Collections.swap(orderedNPCs, 0, 1);
        }

        getUtil().BOOL_TRACKER.USE_CLOSEST.reset();
      }

      return orderedNPCs.toArray(new RSNPC[orderedNPCs.size()]);
    }

    return null;
  }
Ejemplo n.º 4
0
  @Override
  public void onPaint(Graphics g) {
    g.setColor(new Color(60, 60, 60));
    g.fillRect(4, 4, 275, 100);

    g.setColor(Color.WHITE);
    g.drawString("JJ's Gnome Agility", 10, 20);
    g.drawString("My position: " + Player.getPosition(), 10, 40);
    g.drawString("Animation ID: " + Player.getAnimation(), 10, 60);
    g.drawString("Uptext: " + Game.getUptext(), 10, 80);

    Obstacle ob = getNearestObstacle();
    g.drawString("Nearest obstacle: " + ob, 10, 100);
    g.setColor(Color.RED);
    Point[] pts = ob.getPoints();
    for (Point p : pts) {
      g.drawLine(p.x, p.y, p.x, p.y);
    }
  }
Ejemplo n.º 5
0
 /**
  * Waits a certain amount of time for the store screen to open
  *
  * @param ms amount of time to wait in ms
  * @return True if store opened within time limit
  */
 private boolean waitStoreOpen(int ms) {
   long t = System.currentTimeMillis();
   while (Timing.timeFromMark(t) < ms) {
     if (isStoreOpen()) {
       return true;
     } else if (Player.isMoving()) {
       t = System.currentTimeMillis();
     }
     General.sleep(ms / 20, ms / 10);
   }
   return false;
 }
Ejemplo n.º 6
0
  private Obstacle getNearestObstacle() {
    Obstacle[] obstacles = Obstacle.values();

    RSTile myPos = Player.getPosition();
    double nearest = myPos.distanceToDouble(obstacles[0].getLocation());
    int index = 0;

    for (int i = 1; i < obstacles.length; i++) {
      double distance = obstacles[i].getLocation().distanceToDouble(myPos);
      if (distance < nearest) {
        nearest = distance;
        index = i;
      }
    }

    return obstacles[index];
  }
Ejemplo n.º 7
0
  @Override
  public void execute() {
    if (Player.getPosition().getY() < 3690) vars.resetAgro = false;

    PathFinding.aStarWalk(Constants.forestTile);
  }