コード例 #1
0
ファイル: Equipment.java プロジェクト: Greyn/RSBot-API
 /**
  * Equips an item if it is in the inventory
  *
  * @param itemIds the ids of the item(s) that need(s) to be equipped
  * @return <tt>true</tt> if an item was successfully equipped otherwise <tt>false</tt>
  */
 public static boolean equip(final int... itemIds) {
   final Item item = Inventory.getItem(itemIds);
   if (item != null) {
     int index = -1;
     for (final int itemId : itemIds) {
       if ((index = Inventory.indexOf(itemId)) != -1) {
         break;
       }
     }
     final WidgetChild item_child = item.getWidgetChild();
     for (String action : item_child.getActions()) {
       if (action == null) {
         continue;
       }
       if (action.contains("Equip") || action.contains("Wear") || action.contains("Wield")) {
         item_child.interact(action);
       }
     }
     for (int i = 0; i < 100; i++) {
       if (!item.equals(Inventory.getItemAt(index))) {
         return true;
       }
       Task.sleep(10);
     }
   }
   return false;
 }
コード例 #2
0
ファイル: Main.java プロジェクト: byeqt/AIOShiloGemMinerAll
  public static boolean dropGems() { // this should work fine...
    if (totalTypes == 0) {
      return false;
    }
    boolean dropped = false;

    // wow harder to drop stuff then i thought.
    while (Inventory.contains(gemDropList)) {
      for (int i = 0; i < gemIds.length; i++) {
        if (gemsToDrop.get(gemIds[i])) {
          for (int j = 0; j < 28; j++) {
            Item current = Inventory.getItemAt(j);
            if (current != null) {
              if (current.getId() == gemIds[i]) {
                current.getWidgetChild().interact("Drop");
                Task.sleep(200, 350);
                dropped = true;
              }
            }
          }
        }
      }
    }
    if (dropped) return true;
    return false;
  }
コード例 #3
0
ファイル: Glass.java プロジェクト: Ricky54326/RSBotScripting
 public static void make() {
   if (Bank.isOpen()) {
     Bank.close();
   } else {
     if (Inventory.getCount(Variables.glassID) != 0) {
       Variables.status = "Crafting";
       Item glass = Inventory.getItem(Variables.glassID);
       if (Widgets.get(1371, 0).validate()) {
         if (Widgets.get(1370, 56).getText().equals(Variables.urnType)) {
           Crafting.clickStart();
           final Timer glassTimer = new Timer(60000);
           while (glassTimer.isRunning() && Inventory.getCount(Variables.glassID) != 0) {
             Task.sleep(50);
           }
         } else {
           Widgets.get(1371, 44).getChild(20).click(true);
           Task.sleep(500, 600);
           Crafting.clickStart();
           final Timer glassTimer = new Timer(60000);
           while (glassTimer.isRunning() && Inventory.getCount(Variables.glassID) != 0) {
             Task.sleep(50);
           }
         }
       } else {
         if (glass != null) {
           if (glass.getWidgetChild() != null) {
             Variables.status = "Crafting";
             glass.getWidgetChild().click(true);
             Task.sleep(800, 900);
           }
         }
       }
     }
   }
 }
コード例 #4
0
ファイル: Banking.java プロジェクト: Azaxirus/RSBot
 public boolean containsLoot(int[][] ids) {
   for (Item i : Inventory.getItems()) {
     if (!contains(i.getId(), ids)) {
       return true;
     }
   }
   return false;
 }
コード例 #5
0
 public int getCount(boolean noted, Item... items) {
   noted &= canNote();
   int ret = 0;
   for (Item i : items) {
     if (i == null) continue;
     if (i.getId() == itemId || noted && i.getId() == notedId) ret += i.getStackSize();
   }
   return ret;
 }
コード例 #6
0
 /**
  * Gets the count of a set of items
  *
  * @param countStack Should the method count item stacks?
  * @param itemFilter The filter to compare against
  * @return The amount of items matching the filter
  */
 public static int getCount(final boolean countStack, final Filter<Item> itemFilter) {
   final Item[] items = getItems();
   int count = 0;
   for (final Item item : items) {
     if (item != null && itemFilter.accept(item)) {
       count += countStack ? item.getStackSize() : 1;
     }
   }
   return count;
 }
コード例 #7
0
ファイル: Equipment.java プロジェクト: Greyn/RSBot-API
 /**
  * Unequips an item if it is present in the current equipment
  *
  * @param itemIds the ids of the item(s) that need(s) to be unequipped
  * @return <tt>true</tt> if an item was successfully unequipped otherwise <tt>false</tt>
  */
 public static boolean unequip(final int... itemIds) {
   final int count = getCount(itemIds);
   final Item item = getItem(itemIds);
   if (item != null) {
     if (item.getWidgetChild().interact("Remove")) {
       Task.sleep(250, 500);
       return getCount(itemIds) < count;
     }
   }
   return false;
 }
コード例 #8
0
ファイル: FightTask.java プロジェクト: Re4PzZ/Re4PzZ
 public static void eat() {
   if (Players.getLocal().getHpPercent() < 80 && Inventory.getCount(Main.Food) > 0) {
     for (Item food : Inventory.getItems()) {
       if (food.getId() == Main.Food) {
         if (food.getWidgetChild().click(true)) {
           Time.sleep(Random.nextInt(500, 2500));
         }
       }
     }
   }
 }
コード例 #9
0
ファイル: Equipment.java プロジェクト: Greyn/RSBot-API
 /**
  * Checks whether one of the provided item ids is an equipped item.
  *
  * @param itemIds the item ids to check for
  * @return <tt>true</tt> if one of the provided items is an equipped item; otherwise
  *     <tt>false</tt>
  * @see #containsAll(int...)
  */
 public static boolean containsOneOf(final int... itemIds) {
   for (final Item item : getItems()) {
     final int itemId = item.getId();
     for (final int id : itemIds) {
       if (itemId == id) {
         return true;
       }
     }
   }
   return false;
 }
コード例 #10
0
 public static Item getItem(final int... ids) {
   final Item[] items = getItems(false);
   for (final Item item : items) {
     final int item_id = item.getId();
     for (final int id : ids) {
       if (item_id == id) {
         return item;
       }
     }
   }
   return null;
 }
コード例 #11
0
 void dropAllExcept(int lowerBound, int upperBound, int... dontDropThis) {
   for (Item i : Inventory.getItems()) {
     for (int id : dontDropThis) {
       if (!(i.getId() == id)) {
         Mouse.hop(
             i.getWidgetChild().getAbsoluteX() + Random.nextInt(lowerBound, upperBound),
             i.getWidgetChild().getAbsoluteY() + Random.nextInt(lowerBound, upperBound));
         i.getWidgetChild().interact("Drop");
         Status = "Dropping logs";
       }
     }
   }
 }
コード例 #12
0
ファイル: Equipment.java プロジェクト: Greyn/RSBot-API
 /**
  * Gets the first item in the inventory with an id matching the argument(s) from the last known
  * array of items
  *
  * @param itemIds the id(s) to search for
  * @return an <code>Item</code> with an id matching the argument(s)
  */
 public static Item getCachedItem(final int... itemIds) {
   for (final Item item : getCachedItems()) {
     if (item == null) {
       continue;
     }
     for (final int itemId : itemIds) {
       if (itemId == item.getId()) {
         return item;
       }
     }
   }
   return null;
 }
コード例 #13
0
ファイル: Equipment.java プロジェクト: Greyn/RSBot-API
 /**
  * Gets the count of all equipped items matching with any of the provided ids ignoring stack
  * sizes.
  *
  * @param itemIds the item ids to look for
  * @return the count
  */
 public static int getCount(final int... itemIds) {
   int count = 0;
   for (final Item item : getItems()) {
     if (item == null) {
       continue;
     }
     final int itemId = item.getId();
     for (final int id : itemIds) {
       if (itemId == id) {
         count++;
         break;
       }
     }
   }
   return count;
 }
コード例 #14
0
ファイル: Looting.java プロジェクト: IDKZ/TFighterBeyond
 private static void addLootTaken(Item itemToAdd, int amount) {
   String name = itemToAdd.getName();
   if (lootTaken.get(name) != null) {
     int newAmount = amount + lootTaken.get(name);
     lootTaken.remove(name);
     lootTaken.put(name, newAmount);
   } else {
     lootTaken.put(name, amount);
   }
 }
コード例 #15
0
ファイル: Equipment.java プロジェクト: Greyn/RSBot-API
 /**
  * Checks whether all of the provided item ids are equipped items.
  *
  * @param itemIds the item ids to look for
  * @return <tt>true</tt> if all of the provided item ids are equipped items; otherwise
  *     <tt>false</tt>
  * @see #containsOneOf(int...)
  */
 public static boolean containsAll(final int... itemIds) {
   final Item[] items = getItems();
   for (final Item item : items) {
     if (item == null) {
       continue;
     }
     boolean hasItem = false;
     final int itemId = item.getId();
     for (final int id : itemIds) {
       if (itemId == id) {
         hasItem = true;
         break;
       }
     }
     if (!hasItem) {
       return false;
     }
   }
   return true;
 }
コード例 #16
0
ファイル: DoJump.java プロジェクト: radlad/wildernessagility
  @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));
    }
  }
コード例 #17
0
 /**
  * Selects the specified item in the inventory
  *
  * @param item The item to select.
  * @return <tt>true</tt> if the item was selected; otherwise <tt>false</tt>.
  */
 public static boolean selectItem(final Item item) { // TODO fix index 0
   final int itemID = item.getId();
   Item selItem = getSelectedItem();
   if (selItem != null && selItem.getId() == itemID) {
     return true;
   }
   if (selItem != null) {
     selItem.getWidgetChild().interact("Use");
     Task.sleep(Random.nextInt(500, 700));
   }
   if (!item.getWidgetChild().interact("Use")) {
     return false;
   }
   for (int c = 0; c < 5 && (selItem = getSelectedItem()) == null; c++) {
     Task.sleep(Random.nextInt(500, 700));
   }
   return selItem != null && selItem.getId() == itemID;
 }
コード例 #18
0
ファイル: EvadeCombat.java プロジェクト: Float-/SemiCaverns
 @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);
         }
       }
     }
   }
 }
コード例 #19
0
ファイル: Banker.java プロジェクト: carbage/GC-Scripts
  @Override
  public void execute() {
    if (Bank.open()) {
      GcSuperheater.logger.log("Opened bank.");
      for (Item i : Inventory.getItems()) {
        if (i != null && i.getId() != Runes.NATURE && i.getId() != Runes.FIRE) {
          Bank.deposit(i.getId(), Amount.ALL);
        }
      }
      int slotsAvailable = 0;
      for (Item i : Inventory.getAllItems(false)) {
        if (i == null) {
          ++slotsAvailable;
        }
      }

      int primaryOreId = GcSuperheater.primaryOre[0];
      Item primaryOre = Bank.getItem(primaryOreId);
      int primaryOreAmount = GcSuperheater.primaryOre[1];
      int primaryOreWithdrawAmount = 0;

      int secondaryOreId = 0;
      Item secondaryOre = null;
      int secondaryOreAmount = 0;
      int secondaryOreWithdrawAmount = 0;

      if (GcSuperheater.secondaryOre != null) {
        secondaryOre = Bank.getItem(GcSuperheater.secondaryOre[0]);
        secondaryOreId = GcSuperheater.secondaryOre[0];
        secondaryOreAmount = GcSuperheater.secondaryOre[1];
        while (slotsAvailable >= (primaryOreAmount + secondaryOreAmount)) {
          ++primaryOreWithdrawAmount;
          secondaryOreWithdrawAmount += secondaryOreAmount;
          slotsAvailable -= primaryOreAmount + secondaryOreAmount;
        }
      } else {
        primaryOreWithdrawAmount = slotsAvailable;
      }

      if (primaryOre != null) {
        primaryOre = Bank.getItem(primaryOreId);
        Bank.search(primaryOre.getName());
        GcSuperheater.logger.log(
            "Withdrawing " + primaryOreWithdrawAmount + " " + primaryOre.getName() + ".");
        Bank.withdraw(primaryOreId, primaryOreWithdrawAmount);
      } else {
        GcSuperheater.logger.log("Out of primary ore, stopping.");
        GcSuperheater.problemFound = true;
      }

      if (secondaryOre != null) {
        secondaryOre = Bank.getItem(secondaryOreId);
        Bank.search(secondaryOre.getName());
        GcSuperheater.logger.log(
            "Withdrawing " + secondaryOreWithdrawAmount + " " + secondaryOre.getName() + ".");
        Bank.withdraw(secondaryOreId, secondaryOreWithdrawAmount);
      } else {
        GcSuperheater.logger.log("Out of secondary ore, stopping.");
        GcSuperheater.problemFound = true;
      }

      primaryOreWithdrawAmount = 0;
      secondaryOreWithdrawAmount = 0;

      Bank.close();
      GcSuperheater.isBanking = false;
      GcSuperheater.logger.log("Finished banking.");
    } else {
      GcSuperheater.logger.log("Unable to bank, stopping.");
      GcSuperheater.problemFound = true;
      return;
    }
  }
コード例 #20
0
ファイル: AbilityHandler.java プロジェクト: unknown909/RSBot
  @Override
  public int loop() {

    try {

      if (MonsterKiller.mainWeapon != -1
          && getWeaponSlotId() != MonsterKiller.mainWeapon
          && !waitingForRejuv) {
        Item weapon = Inventory.getItem(MonsterKiller.mainWeapon);
        if (weapon != null) {
          weapon.getWidgetChild().click(true);
          return 1000;
        }
      }

      if (MonsterKiller.offWeapon != -1
          && getShieldSlotId() != MonsterKiller.offWeapon
          && !waitingForRejuv) {
        Item weapon = Inventory.getItem(MonsterKiller.offWeapon);
        if (weapon != null) {
          weapon.getWidgetChild().click(true);
          return 1000;
        }
      }

      if (!momentumIsEnabled()) {
        if (!needsToRejuvenate()) {
          if (Players.getLocal().getInteracting() != null) {
            BookAbility toSend = null;
            if (toSend == null) toSend = getAbility(AbilityType.ULTIMATE);
            if (toSend == null) toSend = getAbility(AbilityType.THRESHOLD);
            if (toSend == null) toSend = getAbility(AbilityType.BASIC);
            if (toSend != null) sendAbility(toSend);
          }
        } else {
          if (getAdrenalinePercent() == 100) {
            if (getShieldSlotId() != -1 && MonsterKiller.shieldId == -1) {
              waitingForRejuv = true;
              sendAbility(BookAbility.REJUVENATE);
              Task.sleep(5000);
              waitingForRejuv = false;
              return 500;
            }
            if (getShieldSlotId() == MonsterKiller.shieldId) {
              waitingForRejuv = true;
              sendAbility(BookAbility.REJUVENATE);
              Task.sleep(10000);
              waitingForRejuv = false;
              return 500;
            } else {
              Item shield = Inventory.getItem(MonsterKiller.shieldId);
              if (shield != null) {
                waitingForRejuv = true;
                shield.getWidgetChild().click(true);
                return 1000;
              }
            }
          }
        }
      }
    } catch (Exception a) {
      a.printStackTrace();
    }
    return FighterGUI.abilityDelay;
  }