Exemple #1
0
 public void setCameraRelativeTo(final Locatable reference) {
   final Tile playerTile = Players.getLocal().getLocation();
   final Tile referenceTile = reference.getLocation();
   if (playerTile.getX() < referenceTile.getX()) {
     Camera.setAngle(Random.nextInt(250, 270));
   } else if (playerTile.getX() > referenceTile.getX()) {
     Camera.setAngle(Random.nextInt(80, 100));
   } else if (playerTile.getY() > referenceTile.getY()) {
     Camera.setAngle(Random.nextInt(170, 180));
   } else if (playerTile.getY() < referenceTile.getY()) {
     Camera.setAngle(Random.nextInt(350, 360));
   }
 }
Exemple #2
0
 @Override
 public void execute() {
   if (LootHandler.getLoot() != null) {
     LootHandler.loot();
   }
   if (Players.getLocal().getInteracting() == null) {
     final NPC mob = getNearest();
     if (mob != null) {
       // Logger.log("Attacking closest aggressive npc");
       MonsterKiller.status = "Attacking closest aggressive npc";
       if (!Misc.isOnScreen(mob)) {
         if (FighterGUI.useFastCamera) {
           MCamera.turnTo(mob, 50);
         } else {
           Camera.turnTo(mob, 5);
         }
       }
       // Misc.interact(mob, "Attack");
       mob.interact("Attack", mob.getName());
       new TimedCondition(1500) {
         @Override
         public boolean isDone() {
           return Players.getLocal().getInteracting() != null;
         }
       }.waitStop();
     }
   }
 }
Exemple #3
0
 public static void climbUpLadder() {
   while (!(surface).validate()) {
     SceneObject ladder = SceneEntities.getNearest(LADDER_ID_BOTTOM);
     if (ladder != null) {
       Camera.turnTo(ladder);
       while (Players.getLocal().isMoving()) sleep(100, 200);
       ladder.click(true);
       sleep(750, 1500);
     }
   }
 }
Exemple #4
0
 @Override
 public void execute() {
   // Walking.walk(new Tile());
   try {
     System.out.println("Clicking Fairy Ring 1");
     SceneObject fairyRing = SceneEntities.getNearest(Variables.fairyRings[0]);
     Camera.setNorth();
     fairyRing.interact("Use");
   } catch (Exception e) {
     System.out.println("Fairy ring is null now");
   }
   sleep(10000);
 }
 @Override
 public void execute() {
   SceneObject willowTree = SceneEntities.getNearest(WILLOW_TREE_IDS);
   if (willowTree != null) {
     if (willowTree.isOnScreen()) {
       interact(willowTree, 1, 7, "Chop");
       Status = "Chopping";
       Task.sleep(1000, 1500);
     } else {
       Camera.turnTo(willowTree);
       Walking.walk(willowTree);
     }
   }
 }
Exemple #6
0
  // Author: Zasz
  public static void takeitem(GroundItem item) {
    Point point = item.getCentralPoint();
    point = new Point(point.x - 3, point.y - 10);
    boolean taken = false;
    for (int i = 0; i < 7; i++) {
      Mouse.move(point.x, point.y);
      Time.sleep(50);
      // log.info(item.getGroundItem().getName());
      if (Menu.select("Take", item.getGroundItem().getName())) {
        Sleeping.waitWhileMoving();
        taken = true;
        break;
      }
      if (i > 5) {
        Camera.setAngle(Camera.getAngleTo(Random.nextInt(15, 25)));
      }
      point = new Point(point.x + i, point.y + i);
    }

    if (taken) {
      addLootTaken(item.getGroundItem(), item.getGroundItem().getStackSize());
    }
  }
Exemple #7
0
  @Override
  public void execute() {

    switch (Random.nextInt(0, 200)) {
      case 0:
        Camera.setAngle(Random.nextInt(10, 80));
        break;
      case 1:
        Camera.setAngle(Random.nextInt(80, 220));
        break;
      case 2:
        Tabs.STATS.open();
        Mouse.move(644, 465);
        sleep(1000, 2000);
        Tabs.INVENTORY.open();
        break;
      case 3:
        Tabs.FRIENDS.open();
        sleep(1000, 2000);
        Tabs.INVENTORY.open();
        break;
    }
  }
Exemple #8
0
 @Override
 public void execute() {
   SceneObject firePit = SceneEntities.getNearest(Constants.LIT_FIRE_PIT);
   if (firePit != null) {
     if (Settings.root.getRoot() == 2) {
       if (Players.getLocal().getAnimation() == -1 && !Players.getLocal().isMoving()) {
         if (firePit.getLocation().distanceTo() > 5) {
           Walking.walk(firePit.getLocation());
         } else {
           if (!firePit.isOnScreen()) {
             Camera.turnTo(firePit);
           } else {
             Inventory.getItem(Constants.INVENTORY_STRAIGHT_ROOT_ID)
                 .getWidgetChild()
                 .interact("use");
             firePit.interact("Use", "Straight root -> Firepit");
           }
         }
       }
     } else {
       Settings.burning = doAction("Add", firePit);
     }
   } else {
     firePit = SceneEntities.getNearest(Constants.UNLIT_FIRE_PIT);
     if (firePit != null) {
       Settings.burning = doAction("Light", firePit);
     } else {
       firePit = SceneEntities.getNearest(Constants.EMPTY_FIRE_PIT);
       if (firePit != null) {
         if (Settings.root.getRoot() == 2) {
           System.out.println("Find a world you can leech in.");
           Sagaie.stop = -1;
         } else {
           Settings.burning = doAction("Add", firePit);
         }
       }
     }
   }
   if (Settings.root.getRoot() == 2) {
     final Timer timeout = new Timer(5000);
     while (timeout.isRunning() && !validate(Constants.FLETCH_WIDGET)) {
       Task.sleep(50);
     }
     if (validate(Constants.FLETCH_WIDGET)) {
       Widgets.get(1370, 38).click(true);
       Task.sleep(2000);
     }
   }
 }
Exemple #9
0
  @Override
  public void execute() {

    int currentHp = Integer.parseInt(Widgets.get(748, 8).getText());
    if (currentHp < Data.totalHp * 0.5) {
      Item food = Inventory.getItem(Methods.getFoodId());
      if (food != null) {
        Data.status = "Eating food.";
        food.getWidgetChild().click(true);
      }
    }

    SceneObject rock = SceneEntities.getNearest(64699);
    Data.status = "Doing jump...";
    if (rock.isOnScreen()) {
      if (!Players.getLocal().isMoving() && Players.getLocal().getAnimation() == -1) {
        rock.interact("Cross");
        Task.sleep(Random.nextInt(400, 600));
      }
    } else {
      Camera.setPitch(Random.nextInt(5, 25));
      Camera.turnTo(rock, Random.nextInt(-25, 25));
    }
  }
Exemple #10
0
  @Override
  public void run() {
    Filter attackingGhoul =
        new Filter<NPC>() {
          public boolean accept(NPC npc) {
            return npc.getName().equals("Hellhound") && npc.getInteracting() == Players.getLocal();
          }
        };

    Filter freeGhoulToAttack =
        new Filter<NPC>() {
          public boolean accept(NPC npc) {
            return !npc.isInCombat() && npc.getName().equals("Hellhound");
          }
        };

    if (NPCs.getNearest(attackingGhoul) != null) Main.Hellhound = NPCs.getNearest(attackingGhoul);
    else Main.Hellhound = NPCs.getNearest(freeGhoulToAttack);

    if (Main.Hellhound.isOnScreen()) {
      if (Main.Hellhound.getInteracting() == null
          && !underAttack()
          && Main.Hellhound.isOnScreen()
          && Main.Hellhound != null) {
        Mouse.move(Main.Hellhound.getCentralPoint().x, Main.Hellhound.getCentralPoint().y);
        Time.sleep(50);
        if (!Menu.select("Attack")) {
          Mouse.move(Main.Hellhound.getCentralPoint().x, Main.Hellhound.getCentralPoint().y);
          Time.sleep(50);
          Menu.select("Attack");
        }
      }
    } else {
      if (Calculations.distance(Players.getLocal().getLocation(), Main.Hellhound.getLocation())
          <= 5) {
        Camera.turnTo(Main.Hellhound);
      } else {
        Walking.walk(Main.Hellhound.getLocation());
      }
    }
    Time.sleep(Random.nextInt(1000, 1200));
    while (Players.getLocal().isMoving() && !Main.Hellhound.isInCombat()) {
      Time.sleep(100);
    }
  }
 void executeAntiban() {
   int dx, dy;
   int r = Random.nextInt(0, 4);
   switch (r) {
     case 0:
     case 1:
     default:
       Status = "AntiBan";
       Camera.setAngle(Random.nextInt(20, 300));
       break;
     case 2:
     case 3:
       Status = "AntiBan";
       dx = Random.nextInt(-30, 30);
       dy = Random.nextInt(-30, 30);
       Mouse.move(Mouse.getX() + dx, Mouse.getY() + dy);
       Task.sleep(20, 150);
       break;
   }
 }
Exemple #12
0
 private boolean doAction(final String action, final SceneObject obj) {
   if (Players.getLocal().getAnimation() == -1 && !Players.getLocal().isMoving()) {
     if (obj.getLocation().distanceTo() > 5) {
       Walking.walk(obj.getLocation());
     } else {
       if (!obj.isOnScreen()) {
         Camera.turnTo(obj);
       } else {
         if (obj.interact(action, obj.getDefinition().getName())) {
           final Timer timeout = new Timer(3000);
           while (Players.getLocal().getAnimation() == -1 && timeout.isRunning()) {
             Task.sleep(50);
           }
           return true;
         }
       }
     }
   }
   return false;
 }
Exemple #13
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);
         }
       }
     }
   }
 }