/** * 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; }
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; }
@Override public void execute() { NPC stiles = NPCs.getNearest(11267); if (Inventory.getCount(379) == 26) { Variables.status = "Noting cooked lobbies"; if (stiles.isOnScreen()) { stiles.interact("Exchange"); while (Inventory.getCount(379) > 0) { sleep(10, 20); } } sleep(200, 300); while (Variables.twentySeconds.isRunning()) { if (Players.getLocal().isIdle()) { break; } } } if (Inventory.getCount(379) == 0) { Walking.findPath(new Tile(2868, 3146, 0)).traverse(); } }
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); } } } } } }
public Item findItem(boolean noted, boolean equip) { if (noted && canNote()) { return (equip ? Equipment.getItem(itemId, notedId) : Inventory.getItem(itemId, notedId)); } else { return (equip ? Equipment.getItem(itemId) : Inventory.getItem(itemId)); } }
@Override public boolean activate() { return ((Inventory.contains(Constants.INVENTORY_CURLY_ROOT_ID) || Inventory.contains(Constants.INVENTORY_STRAIGHT_ROOT_ID)) && !validate(Constants.WAITFOR_WIDGET) && !validate(Constants.FLETCH_WIDGET) && Inventory.isFull()); }
public boolean finished() { if (Inventory.getCount(Ids.FLASK_SUMMONING[0]) != 1) return false; if (Inventory.getCount(Ids.FLASK_RANGING[0]) != 2) return false; if (Inventory.getCount(Ids.UNICORN_POUCH[0]) != 2) return false; if (Inventory.getItem(Ids.UNICORN_SCROLL[0]).getStackSize() != 100) return false; if (Inventory.getCount(Ids.FOOD_SHARK[0]) != 14) return false; return true; }
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)); } } } } }
public boolean activate() { try { if (Players.getLocal() == null) return false; if (Inventory.getCount(Constants.CLAY_ID) == 0) { return false; } return Inventory.isFull() && !Players.getLocal().isInCombat() && !softeningTimer.isRunning(); } catch (Exception e) { Utilities.showDebug("SoftenClay-Activate: " + e.getLocalizedMessage()); } return false; }
@Override public boolean activate() { System.out.println("Testing Click Fairy"); return Players.getLocal() != null && Inventory.getCount() == 1 && SceneEntities.getNearest(Variables.fairyRings[0]) != null; }
@Override public void execute() { // TODO Auto-generated method stub try { SceneObject well = SceneEntities.getNearest(Constants.WELL_ID); Timer wait = new Timer(1000); if (!Constants.edgevillArea.contains(Players.getLocal())) { Teleport.teleportTo(Teleport.EDGEVILL); } if (well != null) { if (well.isOnScreen()) { if (Bank.isOpen()) Bank.close(); if (Widgets.get(905, 14).validate()) { boolean isInteracted = false; if (Widgets.get(905, 14).getBoundingRectangle().contains(Mouse.getLocation())) { Mouse.click(true); isInteracted = true; } else { Widgets.get(905, 14).interact("Make All"); isInteracted = true; } Task.sleep(1000); if (isInteracted) { Utilities.showDebug( "Softening clays for profit of " + Progress.profitSoftening + "gp each."); softeningTimer.setEndIn(2500); } } else { if (!softeningTimer.isRunning()) { if (Inventory.selectItem(Constants.CLAY_ID)) { if (well.interact("Use")) { Utilities.showDebug("Interacting well."); Mouse.move(271, 475, 5, 5); } } wait.setEndIn(2000); while (wait.isRunning() && !Widgets.get(905, 14).validate()) { if (Players.getLocal().isMoving()) wait.setEndIn(1000); Task.sleep(100); } } } } else { Utilities.showDebug("Found well but not on screen. Walking.."); Walking.walk(Walking.findPath(well).getEnd()); wait.setEndIn(3000); while (wait.isRunning() && !well.isOnScreen()) { Task.sleep(300); } } } } catch (Exception e) { } ; }
public boolean containsLoot(int[][] ids) { for (Item i : Inventory.getItems()) { if (!contains(i.getId(), ids)) { return true; } } return false; }
public Item findItem(final int stack) { return Inventory.getItem( new Filter<Item>() { @Override public boolean accept(Item i) { return (i.getId() == itemId || canNote() && i.getId() == notedId) && i.getStackSize() >= stack; } }); }
@Override public void act() { try { moveFromBank(); while (!Inventory.isFull()) fish(); moveToBank(); bank(); } catch (Exception e) { errorCount++; System.out.println("Caught an error: " + e); } }
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"; } } } }
@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); } } }
public static boolean inventorySpace() { if (Inventory.getCount() == 28) { if (dropGems()) return false; if (wickedHood) { state = "wicked hood banking"; } else if (castleWarsBank) { state = "teleporting to castle wars"; } else { // we should validate that we are near the path or break the // script. if (Calculations.distanceTo(surface) < 30) { state = "walking to bank"; } if (!WalkToBank.checkIfNearPath()) { state = "walking to bank"; } } return true; } return false; }
@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)); } }
@Override public boolean activate() { return Inventory.isFull(); }
public boolean validate() { return !Inventory.isFull(); }
@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; }
public boolean containsAtleastOneOf(int[] ids) { for (int i : ids) if (Inventory.contains(i)) return true; return false; }
@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); } } } } }
@Override public boolean activate() { return !Inventory.isFull() && Players.getLocal().getAnimation() == -1; }
public static void DyanmicSleep() { Area InsideBank = Areas.Bank; String SleepType = SleepName; // Dynamic Sleeps switch (SleepType) { case "EnterAlter": // Dynamic EnterAlter Sleep while (tenSeconds.isRunning()) { dynamicSleepStatus = "In EnterAlter"; Area OutsideAlter = Areas.AlterEntrence; if (!OutsideAlter.contains(Players.getLocal().getLocation())) { dynamicSleepStatus = "Not In"; break; } } break; case "CraftRunes": // Dynamic Crafting Runes Sleep while (tenSeconds.isRunning()) { dynamicSleepStatus = "In CraftRunes"; if (Inventory.getItem(CRAFTEDRUNE_ID) != null) { dynamicSleepStatus = "Not In"; break; } } break; case "ExitPortal": // Dynamic Leaving Alter Sleep while (tenSeconds.isRunning()) { dynamicSleepStatus = "In ExitPortal"; Area InsideAlter = Areas.InsideAlter; if (!InsideAlter.contains(Players.getLocal().getLocation())) { dynamicSleepStatus = "Not In"; break; } } break; case "Resting": // Dynamic Resting Sleep while (twoMinutes.isRunning()) { dynamicSleepStatus = "In Resting"; int EnergyLevel = Walking.getEnergy(); if (EnergyLevel == Random.nextInt(90, 100)) { dynamicSleepStatus = "Not In"; break; } } break; case "OpenBank": // Dynamic Bank is Open Sleep while (tenSeconds.isRunning()) { dynamicSleepStatus = "In OpenBank"; if (Bank.isOpen()) { dynamicSleepStatus = "Not In"; break; } } break; case "PlayerIsIdle": // Dynamic Player is Idle Sleep while (tenSeconds.isRunning()) { dynamicSleepStatus = "In PlayerIsIdle"; if (Players.getLocal().isIdle()) { dynamicSleepStatus = "Not In"; break; } } break; case "EssenceInInventory": // Dynamic Essences in Inventory Sleep while (tenSeconds.isRunning()) { dynamicSleepStatus = "In EssenceInInventory"; if (Inventory.getItem(ESSENCE_ID) == null) { dynamicSleepStatus = "Not In"; break; } } break; } }
public int numberOfPotions(int[] ids) { int count = 0; for (int i : ids) if (Inventory.contains(i)) count = count + Inventory.getCount(i); return count; }
@Override public boolean activate() { return (Inventory.getCount(379) == 26 || Inventory.getCount(379) == 0) && Areas.NoteGuyArea.contains(Players.getLocal().getLocation()); }
public final int getCount(boolean noted) { return getCount(noted, Inventory.getItems()); }
@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; } }
public void withdrawInventory() { if (Inventory.getCount(Ids.FLASK_RANGING[0]) != 2) { Log.log("withdrawing", "Ranging Flasks"); Log.log("amount", "Have: " + Inventory.getCount(Ids.FLASK_RANGING[0])); withdrawItem(Ids.FLASK_RANGING, 2); } if (Inventory.getCount(Ids.FLASK_SUMMONING[0]) != 1) { Log.log("withdrawing", "Summoning Flasks"); Log.log("amount", "Have: " + Inventory.getCount(Ids.FLASK_SUMMONING[0])); withdrawItem(Ids.FLASK_SUMMONING, 1); } if (Inventory.getCount(Ids.UNICORN_POUCH[0]) != 2) { Log.log("withdrawing", "Unicorn Pouch"); Log.log("amount", "Have: " + Inventory.getCount(Ids.UNICORN_POUCH[0])); withdrawItem(Ids.UNICORN_POUCH, 2); } if (Inventory.getItem(Ids.UNICORN_SCROLL[0]) == null || Inventory.getItem(Ids.UNICORN_SCROLL[0]) != null && Inventory.getItem(Ids.UNICORN_SCROLL[0]).getStackSize() != 100) { Log.log("withdrawing", "Unicorn Scroll"); Log.log( "amount", "Have: " + (Inventory.getItem(Ids.UNICORN_SCROLL[0]) != null ? Inventory.getItem(Ids.UNICORN_SCROLL[0]).getStackSize() : 0)); withdrawItem(Ids.UNICORN_SCROLL, 100); } if (Inventory.getCount(Ids.FOOD_SHARK[0]) != 14) { Log.log("withdrawing", "Shark"); Log.log("amount", "Have: " + Inventory.getCount(Ids.FOOD_SHARK[0])); withdrawItem(Ids.FOOD_SHARK, 14); } }