From 408583f75471a92d6131869a58595aaa7f3b0154 Mon Sep 17 00:00:00 2001 From: Gage307 Date: Thu, 29 Jan 2026 01:28:13 -0500 Subject: [PATCH] Rev killer, Barrows updates (#298) * fix(BarrowsScript): numerous bug fixes * fix(RevKillerScript): numerous bug fixes --- .../microbot/barrows/BarrowsScript.java | 128 ++++++----- .../microbot/revkiller/revKillerScript.java | 202 ++++++++++++------ 2 files changed, 215 insertions(+), 115 deletions(-) diff --git a/src/main/java/net/runelite/client/plugins/microbot/barrows/BarrowsScript.java b/src/main/java/net/runelite/client/plugins/microbot/barrows/BarrowsScript.java index 6b63421544..e39399e3a6 100644 --- a/src/main/java/net/runelite/client/plugins/microbot/barrows/BarrowsScript.java +++ b/src/main/java/net/runelite/client/plugins/microbot/barrows/BarrowsScript.java @@ -1,11 +1,17 @@ package net.runelite.client.plugins.microbot.barrows; +import com.google.inject.Inject; import net.runelite.api.*; import net.runelite.api.coords.WorldPoint; import net.runelite.client.plugins.microbot.Microbot; import net.runelite.client.plugins.microbot.Script; +import net.runelite.client.plugins.microbot.api.npc.Rs2NpcCache; +import net.runelite.client.plugins.microbot.api.player.Rs2PlayerCache; import net.runelite.client.plugins.microbot.api.tileitem.Rs2TileItemCache; import net.runelite.client.plugins.microbot.api.tileitem.models.Rs2TileItemModel; +import net.runelite.client.plugins.microbot.api.tileobject.Rs2TileObjectCache; +import net.runelite.client.plugins.microbot.api.tileobject.models.Rs2TileObjectModel; +import net.runelite.client.plugins.microbot.breakhandler.BreakHandlerScript; import net.runelite.client.plugins.microbot.util.Rs2InventorySetup; import net.runelite.client.plugins.microbot.util.bank.Rs2Bank; import net.runelite.client.plugins.microbot.util.bank.enums.BankLocation; @@ -13,8 +19,6 @@ import net.runelite.client.plugins.microbot.util.coords.Rs2WorldArea; import net.runelite.client.plugins.microbot.util.dialogues.Rs2Dialogue; import net.runelite.client.plugins.microbot.util.equipment.Rs2Equipment; -import net.runelite.client.plugins.microbot.util.gameobject.Rs2GameObject; -import net.runelite.client.plugins.microbot.util.grounditem.Rs2GroundItem; import net.runelite.client.plugins.microbot.util.inventory.Rs2Inventory; import net.runelite.client.plugins.microbot.util.inventory.Rs2ItemModel; import net.runelite.client.plugins.microbot.util.keyboard.Rs2Keyboard; @@ -31,7 +35,6 @@ import net.runelite.client.plugins.microbot.util.walker.Rs2Walker; import net.runelite.client.plugins.microbot.util.widget.Rs2Widget; -import javax.inject.Inject; import java.awt.event.KeyEvent; import java.util.ArrayList; import java.util.List; @@ -70,7 +73,10 @@ public class BarrowsScript extends Script { private ScheduledFuture WalkToTheChestFuture; @Inject - Rs2TileItemCache rs2TileItemCache; + Rs2NpcCache rs2NpcCache; + @Inject Rs2TileItemCache rs2TileItemCache; + @Inject Rs2PlayerCache rs2PlayerCache; + @Inject Rs2TileObjectCache rs2TileObjectCache; @@ -145,11 +151,11 @@ public boolean run(BarrowsConfig config, BarrowsPlugin plugin) { if(config.selectedToBarrowsTPMethod().getToBarrowsTPMethodItemID() == ItemID.TELEPORT_TO_HOUSE) { if (!inTunnels && !shouldBank && Rs2Player.getWorldLocation().distanceTo(new WorldPoint(3573, 3296, 0)) > 60) { //needed to intercept the walker - if(Rs2GameObject.getGameObject(4525) == null){ + if(rs2TileObjectCache.query().withId(4525).nearest() == null){ Rs2Inventory.interact("Teleport to house", "Inside"); sleepUntil(() -> Rs2Player.getAnimation() == 4069, Rs2Random.between(2000, 4000)); sleepUntil(() -> !Rs2Player.isAnimating(), Rs2Random.between(6000, 10000)); - sleepUntil(() -> Rs2GameObject.getGameObject(4525) != null, Rs2Random.between(6000, 10000)); + sleepUntil(() -> rs2TileObjectCache.query().withId(4525).nearest() != null, Rs2Random.between(6000, 10000)); } handlePOH(config); return; @@ -157,6 +163,16 @@ public boolean run(BarrowsConfig config, BarrowsPlugin plugin) { } if(!inTunnels && !shouldBank) { + + if(!BreakHandlerScript.lockState.get()){ + if(BreakHandlerScript.breakIn < 60 && BreakHandlerScript.breakIn != -1){ + Microbot.log("Going on break soon, doing nothing."); + return; + } + } + + BreakHandlerScript.lockState.set(true); + for (BarrowsBrothers brother : BarrowsBrothers.values()) { Rs2WorldArea mound = brother.getHumpWP(); NeededPrayer = brother.whatToPray; @@ -253,7 +269,7 @@ public boolean run(BarrowsConfig config, BarrowsPlugin plugin) { } // we're in the mound, prayer is active - GameObject sarc = Rs2GameObject.getGameObject("Sarcophagus"); + Rs2TileObjectModel sarc = rs2TileObjectCache.query().withIds(20770,20720,20722,20771,20721,20772).nearest(); Rs2NpcModel currentBrother = null; Microbot.log("Found the Sarcophagus"); while(currentBrother == null) { @@ -261,7 +277,7 @@ public boolean run(BarrowsConfig config, BarrowsPlugin plugin) { if (!super.isRunning()) break; - if (Rs2GameObject.interact(sarc, "Search")) { + if (sarc.click("Search")) { sleepUntil(() -> Rs2Player.isMoving(), Rs2Random.between(1000, 3000)); sleepUntil(() -> !Rs2Player.isMoving() || Rs2Player.isInCombat(), Rs2Random.between(3000, 6000)); // the brother could take a second to spawn in. @@ -320,11 +336,11 @@ public boolean run(BarrowsConfig config, BarrowsPlugin plugin) { digIntoTheMound(tunnelMound); while(!Rs2Dialogue.isInDialogue()) { - GameObject sarc = Rs2GameObject.getGameObject("Sarcophagus"); + Rs2TileObjectModel sarc = rs2TileObjectCache.query().withIds(20770,20720,20722,20771,20721,20772).nearest(); if (!super.isRunning()) break; - if (Rs2GameObject.interact(sarc, "Search")) { + if (sarc.click("Search")) { sleepUntil(() -> Rs2Player.isMoving(), Rs2Random.between(1000, 3000)); sleepUntil(() -> !Rs2Player.isMoving() || Rs2Player.isInCombat(), Rs2Random.between(3000, 6000)); sleepUntil(() -> Rs2Dialogue.isInDialogue(), Rs2Random.between(3000, 6000)); @@ -380,15 +396,16 @@ public boolean run(BarrowsConfig config, BarrowsPlugin plugin) { solvePuzzle(); checkForAndFightBrother(config); - if(Rs2GameObject.findObjectById(20973) != null - && (Rs2GameObject.hasLineOfSight(Rs2GameObject.findObjectById(20973)) - || Rs2Player.distanceTo(Rs2GameObject.findObjectById(20973).getWorldLocation()) < 4)){ + Rs2TileObjectModel barrowsChest = rs2TileObjectCache.query().withId(20973).nearest(); + + if(barrowsChest != null && + (barrowsChest.getWorldLocation().distanceTo(Rs2Player.getWorldLocation()) < 5)){ //chest ID: 20973 stopFutureWalker(); - TileObject chest = Rs2GameObject.findObjectById(20973); - if(Rs2GameObject.interact(chest, "Open")){ + + if(barrowsChest.click("Open")){ sleepUntil(()-> hintNpcModel()!=null && hintNpcModel().getWorldLocation().distanceTo(Rs2Player.getWorldLocation()) <= 5, Rs2Random.between(4000,6000)); } else { return; @@ -404,7 +421,7 @@ public boolean run(BarrowsConfig config, BarrowsPlugin plugin) { break; } - if (Rs2GameObject.interact(chest, "Search")) { + if(barrowsChest.click("Search")){ sleep(500, 1500); } @@ -453,7 +470,7 @@ public boolean run(BarrowsConfig config, BarrowsPlugin plugin) { outOfSupplies(config); //walk to and open the bank Rs2Bank.walkToBankAndUseBank(BankLocation.FEROX_ENCLAVE); - //unlock + BreakHandlerScript.lockState.set(false); } else { Rs2Food ourfood = config.food(); int ourFoodsID = ourfood.getId(); @@ -678,24 +695,25 @@ public void closeBank(){ public void handlePOH(BarrowsConfig config){ if(config.selectedToBarrowsTPMethod().getToBarrowsTPMethodItemID() == ItemID.TELEPORT_TO_HOUSE){ - if(Rs2GameObject.getGameObject(4525) != null){ + Rs2TileObjectModel pohThing = rs2TileObjectCache.query().withId(4525).nearest(); + if(pohThing != null){ Microbot.log("We're in our POH"); - GameObject rejPool = Rs2GameObject.getGameObject(it->it!=null&&it.getId() == 29238 || it.getId() == 29239 || it.getId() == 29241 || it.getId() == 29240); + Rs2TileObjectModel rejPool = rs2TileObjectCache.query().withIds(29238,29239,29241,29240).nearest(); if(rejPool != null){ - if(Rs2GameObject.interact(rejPool, "Drink")){ + if(rejPool.click("Drink")){ sleepUntil(()-> Rs2Player.isMoving(), Rs2Random.between(2000,4000)); sleepUntil(()-> !Rs2Player.isMoving(), Rs2Random.between(10000,15000)); } } - GameObject regularPortal = Rs2GameObject.getGameObject("Barrows Portal"); + Rs2TileObjectModel regularPortal = rs2TileObjectCache.query().withName("Barrows Portal").nearest(); if(regularPortal != null){ - while(Rs2GameObject.getGameObject(4525) != null){ + while(pohThing != null){ if(!super.isRunning()){break;} if(!Rs2Player.isMoving()){ - if(Rs2GameObject.interact(regularPortal, "Enter")){ + if(regularPortal.click("Enter")){ sleepUntil(()-> Rs2Player.isMoving(), Rs2Random.between(2000,4000)); sleepUntil(()-> !Rs2Player.isMoving(), Rs2Random.between(10000,15000)); - sleepUntil(()-> Rs2GameObject.getGameObject("Barrows Portal") == null, Rs2Random.between(10000,15000)); + sleepUntil(()-> rs2TileObjectCache.query().withName("Barrows Portal").nearest() == null, Rs2Random.between(10000,15000)); } } } @@ -795,10 +813,13 @@ public void goToTheMound(Rs2WorldArea moundArea){ randomMoundTile = moundArea.toWorldPointList().get(Rs2Random.between(0,(totalTiles-1))); //strange old man body blocking us - if(Rs2Npc.getNpc("Strange Old Man")!=null){ - if(Rs2Npc.getNpc("Strange Old Man").getWorldLocation() != null){ - if(Rs2Npc.getNpc("Strange Old Man").getWorldLocation() == randomMoundTile){ - while(Rs2Npc.getNpc("Strange Old Man").getWorldLocation() == randomMoundTile){ + + net.runelite.client.plugins.microbot.api.npc.models.Rs2NpcModel strangeOldMan = rs2NpcCache.query().withName("Strange Old Man").nearest(); + + if(strangeOldMan !=null){ + if(strangeOldMan.getWorldLocation() != null){ + if(strangeOldMan.getWorldLocation() == randomMoundTile){ + while(strangeOldMan.getWorldLocation() == randomMoundTile){ if(!super.isRunning()){break;} randomMoundTile = moundArea.toWorldPointList().get(Rs2Random.between(0,(totalTiles-1))); sleep(250,500); @@ -814,14 +835,15 @@ public void goToTheMound(Rs2WorldArea moundArea){ } public void leaveTheMound(){ - if(Rs2GameObject.getGameObject("Staircase", true) != null) { - if (Rs2GameObject.hasLineOfSight(Rs2GameObject.getGameObject("Staircase", true))) { + Rs2TileObjectModel stairs = rs2TileObjectCache.query().withIds(20668,20669,20670,20671,20672,20667).nearest(); + if(stairs != null) { + if (Rs2Walker.canReach(stairs.getWorldLocation())) { if (Rs2Player.getWorldLocation().getPlane() == 3) { while (Rs2Player.getWorldLocation().getPlane() == 3) { Microbot.log("Leaving the mound"); if (!super.isRunning()) break; - if (Rs2GameObject.interact("Staircase", "Climb-up")) { + if (stairs.click("Climb-up")) { sleepUntil(() -> Rs2Player.getWorldLocation().getPlane() != 3, Rs2Random.between(3000, 6000)); } @@ -839,14 +861,15 @@ public void leaveTheMound(){ } public void lootChampionScroll(){ - Rs2TileItemModel championScroll = rs2TileItemCache.query().where(x -> x.getId() == ItemID.SKELETON_CHAMPION_SCROLL).nearest(); + Rs2TileItemModel championScroll = rs2TileItemCache.query().withId(ItemID.SKELETON_CHAMPION_SCROLL).nearest(); if(championScroll != null){ - while(rs2TileItemCache.query().where(x -> x.getId() == ItemID.SKELETON_CHAMPION_SCROLL).nearest() != null && !Rs2Inventory.contains(championScroll.getId())){ + if(championScroll.isReachable() && championScroll.isLootAble()){ + while(rs2TileItemCache.query().withId(ItemID.SKELETON_CHAMPION_SCROLL).nearest() != null && !Rs2Inventory.contains(championScroll.getId())){ if(!super.isRunning()) break; - - Rs2GroundItem.interact(championScroll.getName(), "Take"); + championScroll.click("Take"); sleepUntil(()-> !Rs2Player.isMoving() && Rs2Inventory.contains(championScroll.getId()), Rs2Random.between(4000,12000)); } + } } } @@ -855,15 +878,16 @@ public void gainRP(BarrowsConfig config){ int RP = Microbot.getVarbitValue(Varbits.BARROWS_REWARD_POTENTIAL); if(RP>870) return; - Rs2NpcModel skele = Rs2Npc.getNpc("Skeleton"); + + net.runelite.client.plugins.microbot.api.npc.models.Rs2NpcModel skele = rs2NpcCache.query().withName("Skeleton").nearest(); if(skele == null || skele.isDead()) return; - if(Rs2Npc.hasLineOfSight(skele)){ + if(skele.hasLineOfSight()){ stopFutureWalker(); if(!Rs2Player.isInCombat()){ - if(Rs2Npc.attack(skele)){ + if(skele.click("Attack")){ sleepUntil(()-> Rs2Player.isInCombat()&&!Rs2Player.isMoving(), Rs2Random.between(4000,8000)); } } @@ -901,8 +925,9 @@ public void gainRP(BarrowsConfig config){ } if(hintNpcModel()!=null) { - Rs2NpcModel barrowsbrother = hintNpcModel(); - if(Rs2Npc.hasLineOfSight(barrowsbrother)) { + Rs2NpcModel barrowsbrotherHint = hintNpcModel(); + net.runelite.client.plugins.microbot.api.npc.models.Rs2NpcModel brother = rs2NpcCache.query().withName(barrowsbrotherHint.getName()).nearest(); + if(brother !=null && brother.hasLineOfSight()) { Microbot.log("The brother is here."); break; } @@ -1107,10 +1132,10 @@ public void reJfount(){ if(Rs2Bank.closeBank()) sleepUntil(()-> !Rs2Bank.isOpen(), Rs2Random.between(2000,4000)); } else { - GameObject rej = Rs2GameObject.getGameObject("Pool of Refreshment", true); + Rs2TileObjectModel rej = rs2TileObjectCache.query().withId(39651).nearest(); if(rej == null) break; Microbot.log("Drinking"); - if(Rs2GameObject.interact(rej, "Drink")){ + if(rej.click("Drink")){ sleepUntil(()-> Rs2Player.isMoving(), Rs2Random.between(1000,3000)); sleepUntil(()-> !Rs2Player.isMoving(), Rs2Random.between(5000,10000)); sleepUntil(()-> Rs2Player.isAnimating(), Rs2Random.between(1000,4000)); @@ -1150,9 +1175,11 @@ public Rs2NpcModel hintNpcModel(){ public void checkForAndFightBrother(BarrowsConfig config){ if (hintNpcModel() != null) { - stopFutureWalker(); + Rs2NpcModel currentBrother = hintNpcModel(); //Rs2NpcCache.getNpcsStream().filter(it->it.getName().equals(hintNpcModel().getName())).findFirst().orElse(null); Rs2PrayerEnum neededprayer = Rs2PrayerEnum.PROTECT_MELEE; - if (hintNpcModel() != null && Rs2Npc.hasLineOfSight(hintNpcModel())) { + if (hintNpcModel() != null && currentBrother !=null) { + stopFutureWalker(); + if(hintNpcModel().getName().contains("Ahrim")) neededprayer = Rs2PrayerEnum.PROTECT_MAGIC; if(hintNpcModel().getName().contains("Karil")) neededprayer = Rs2PrayerEnum.PROTECT_RANGE; @@ -1160,11 +1187,14 @@ public void checkForAndFightBrother(BarrowsConfig config){ while(hintNpcModel() != null){ Microbot.log("Fighting the brother."); - if (!super.isRunning()) break; + if (!super.isRunning()){ + Microbot.log("Super isn't running!"); + break; + } if(inTunnels) { - if (!Rs2Npc.hasLineOfSight(hintNpcModel())) { + if (!Rs2Npc.hasLineOfSight(currentBrother)) { Microbot.log("No LOS!"); break; } @@ -1179,12 +1209,12 @@ public void checkForAndFightBrother(BarrowsConfig config){ } if(hintNpcModel() != null && Rs2Player.getInteracting() != null && !Rs2Player.getInteracting().getName().equals(hintNpcModel().getName())){ - if(Rs2Npc.interact(hintNpcModel(), "Attack")){ + if(Rs2Npc.attack(currentBrother)){ sleepUntil(()-> Rs2Player.isInCombat(), Rs2Random.between(3000,6000)); } } else { if(!Rs2Player.isInCombat()){ - if(Rs2Npc.interact(hintNpcModel(), "Attack")){ + if(Rs2Npc.attack(currentBrother)){ sleepUntil(()-> Rs2Player.isInCombat(), Rs2Random.between(3000,6000)); } } @@ -1229,7 +1259,7 @@ private void walkToChest(){ return; } - Rs2Walker.walkTo(Chest); + Rs2Walker.walkTo(Chest, 2); } catch (Exception e) { Microbot.log("walkToChest failed: " + e.getMessage()); } diff --git a/src/main/java/net/runelite/client/plugins/microbot/revkiller/revKillerScript.java b/src/main/java/net/runelite/client/plugins/microbot/revkiller/revKillerScript.java index e922c4c1f2..5910d34743 100644 --- a/src/main/java/net/runelite/client/plugins/microbot/revkiller/revKillerScript.java +++ b/src/main/java/net/runelite/client/plugins/microbot/revkiller/revKillerScript.java @@ -1,5 +1,6 @@ package net.runelite.client.plugins.microbot.revkiller; +import com.google.inject.Inject; import com.google.inject.Provides; import net.runelite.api.*; import net.runelite.api.Point; @@ -10,6 +11,12 @@ import net.runelite.client.game.ItemManager; import net.runelite.client.plugins.microbot.Microbot; import net.runelite.client.plugins.microbot.Script; +import net.runelite.client.plugins.microbot.api.npc.Rs2NpcCache; +import net.runelite.client.plugins.microbot.api.player.Rs2PlayerCache; +import net.runelite.client.plugins.microbot.api.tileitem.Rs2TileItemCache; +import net.runelite.client.plugins.microbot.api.tileitem.models.Rs2TileItemModel; +import net.runelite.client.plugins.microbot.api.tileobject.Rs2TileObjectCache; +import net.runelite.client.plugins.microbot.api.tileobject.models.Rs2TileObjectModel; import net.runelite.client.plugins.microbot.breakhandler.BreakHandlerScript; import net.runelite.client.plugins.microbot.util.Rs2InventorySetup; import net.runelite.client.plugins.microbot.util.bank.Rs2Bank; @@ -19,7 +26,6 @@ import net.runelite.client.plugins.microbot.util.dialogues.Rs2Dialogue; import net.runelite.client.plugins.microbot.util.equipment.JewelleryLocationEnum; import net.runelite.client.plugins.microbot.util.equipment.Rs2Equipment; -import net.runelite.client.plugins.microbot.util.gameobject.Rs2GameObject; import net.runelite.client.plugins.microbot.util.grounditem.LootingParameters; import net.runelite.client.plugins.microbot.util.grounditem.Rs2GroundItem; import net.runelite.client.plugins.microbot.util.inventory.Rs2Inventory; @@ -77,6 +83,12 @@ revKillerConfig provideConfig(ConfigManager configManager) { private long startTime = System.currentTimeMillis(); public volatile boolean firstRun = false; + @Inject + Rs2NpcCache rs2NpcCache; + @Inject Rs2TileItemCache rs2TileItemCache; + @Inject Rs2PlayerCache rs2PlayerCache; + @Inject Rs2TileObjectCache rs2TileObjectCache; + public boolean run(revKillerConfig config) { this.config = config; @@ -116,6 +128,13 @@ public boolean run(revKillerConfig config) { if(firstRun || weDied) { Microbot.log("It's our first run or we died!"); + if(firstRun && Rs2Npc.getNpc(config.selectedRev().getName()) != null){ + // we're all ready geared and there + firstRun = false; + Microbot.log("It's our first run and we're all ready here!"); + return; + } + sleep(10000,20000); //Allow us some time to fully die so we properly match that equipment is missing. replace with a sleepUntil if (!inventorySetup.doesEquipmentMatch()) { if(!Rs2Bank.isOpen()){ @@ -167,6 +186,16 @@ public boolean run(revKillerConfig config) { } if(!areWeEquipped()||isItTimeToGo()){ + if(WeAreInTheCaves()){ + if(goodLootOnGround()){ + if(areWeEquipped()){ + if(!isPkerAround()){ + Microbot.log("Returning, there's still loot on the ground"); + return; + } + } + } + } Bankfortrip(); } @@ -199,10 +228,15 @@ public void EatFood(){ } public boolean playerCheck(){ - List playerlist = new ArrayList(); - playerlist.addAll(Rs2Player.getPlayers(it->it!=null&&it.getWorldLocation().distanceTo(Rs2Player.getWorldLocation())<= 8&&!it.equals(Rs2Player.getLocalPlayer())).collect(Collectors.toList())); + String myName = Rs2Player.getLocalPlayer().getName(); - if(!playerlist.isEmpty()){ + List nearbyPlayers = + Microbot.getRs2PlayerCache() + .query() + .where(p -> p.getWorldLocation().distanceTo(Rs2Player.getWorldLocation()) <= 8 && !p.getName().equalsIgnoreCase(myName)) + .toList(); + + if(!nearbyPlayers.isEmpty()){ if(!Rs2Player.isInCombat()) { Microbot.log("There's another player here hopping."); hopToNewWorld(); @@ -229,6 +263,16 @@ public boolean weAreInCombat(){ return false; } + public boolean goodLootOnGround(){ + if(Rs2GroundItem.lootItemBasedOnValue(500,12)) return true; + if(Microbot.getRs2TileItemCache().query().where(it->it.getWorldLocation().distanceTo(Rs2Player.getWorldLocation()) < 10 && it.getTotalGeValue() > 500).nearest() != null) return true; + return false; + } + + public Rs2NpcModel revenentKnight() { + return Rs2Npc.getNpc(7939); + } + public void kiteTheKnight(){ WorldPoint startTile = new WorldPoint(3237,10225,0); WorldPoint secondTile = new WorldPoint(3244,10225,0); @@ -250,8 +294,8 @@ public void kiteTheKnight(){ return; } else { Microbot.log("We need to click the rev."); - if(Rs2Npc.getNpc("Revenant knight")!=null && Rs2Npc.getNpc("Revenant knight").getWorldLocation().distanceTo(jammedTile)<=2) { - if (Rs2Npc.interact(Rs2Npc.getNpc("Revenant knight"), "Attack")) { + if(revenentKnight()!=null && revenentKnight().getWorldLocation().distanceTo(jammedTile)<=2) { + if (Rs2Npc.interact(revenentKnight(), "Attack")) { Microbot.log("We attacked the knight"); return; } @@ -261,7 +305,7 @@ public void kiteTheKnight(){ } } else { //if we come back from the bank and the rev is all ready jammed. - if(Rs2Npc.getNpc("Revenant knight")!=null && Rs2Npc.getNpc("Revenant knight").getWorldLocation().distanceTo(jammedTile)<=2){ + if(revenentKnight()!=null && revenentKnight().getWorldLocation().distanceTo(jammedTile)<=2){ if(!weAreInCombat()){ if(playerCheck()){return;} if(!Rs2Player.getWorldLocation().equals(fifthTile)){ @@ -269,7 +313,7 @@ public void kiteTheKnight(){ sleepUntil(() -> Rs2Player.isMoving(), Rs2Random.between(1000, 3000)); sleepUntil(() -> !Rs2Player.isMoving(), Rs2Random.between(2000, 3000)); } - if (Rs2Npc.interact(Rs2Npc.getNpc("Revenant knight"), "Attack")) { + if (Rs2Npc.interact(revenentKnight(), "Attack")) { Microbot.log("We attacked the knight"); return; } @@ -279,8 +323,8 @@ public void kiteTheKnight(){ if(playerCheck()){return;} - if(Rs2GroundItem.isItemBasedOnValueOnGround(500,10)){ - return; + if(goodLootOnGround()){ + return; } if(!areWeEquipped()||isItTimeToGo()){ @@ -304,9 +348,9 @@ public void kiteTheKnight(){ if(Rs2Player.getWorldLocation().equals(startTile)){ if(playerCheck()){return;} - if(Rs2Npc.getNpc("Revenant knight") == null) return; + if(revenentKnight() == null) return; - if(Rs2Npc.attack("Revenant knight")){ + if(Rs2Npc.interact(revenentKnight(), "Attack")){ Microbot.log("We attacked the knight"); sleepUntil(()-> Rs2Player.isMoving(), Rs2Random.between(1000,3000)); sleepUntil(()-> !Rs2Player.isMoving(), Rs2Random.between(2000,3000)); @@ -329,17 +373,17 @@ public void kiteTheKnight(){ } if(Rs2Player.getWorldLocation().equals(secondTile)){ - if(Rs2Npc.getNpc("Revenant knight")!=null){ - if(!Rs2Npc.getNpc("Revenant knight").getWorldLocation().equals(thirdTile)){ + if(revenentKnight()!=null){ + if(!revenentKnight().getWorldLocation().equals(thirdTile)){ int io = 0; int tries = Rs2Random.between(40,80); - while(!Rs2Npc.getNpc("Revenant knight").getWorldLocation().equals(thirdTile)){ + while(!revenentKnight().getWorldLocation().equals(thirdTile)){ if(!super.isRunning()){break;} if(isPkerAround()){break;} if(!WeAreInTheCaves()){break;} if(io > tries){break;} if(!Microbot.isLoggedIn()){return;} - if(Rs2Npc.getNpc("Revenant knight").getWorldLocation().distanceTo(Rs2Player.getWorldLocation())<=1 && !Rs2Npc.getNpc("Revenant knight").getWorldLocation().equals(thirdTile)){ + if(revenentKnight().getWorldLocation().distanceTo(Rs2Player.getWorldLocation())<=1 && !revenentKnight().getWorldLocation().equals(thirdTile)){ Microbot.log("Rev is on a bad tile breaking loop"); return; } @@ -348,14 +392,14 @@ public void kiteTheKnight(){ Rs2Walker.walkCanvas(secondTile); sleepUntil(()-> Rs2Player.getWorldLocation().equals(secondTile), Rs2Random.between(3000,6000)); } - sleepUntil(()-> Rs2Npc.getNpc("Revenant knight").getWorldLocation().equals(thirdTile), Rs2Random.between(250,500)); + sleepUntil(()-> revenentKnight().getWorldLocation().equals(thirdTile), Rs2Random.between(250,500)); io++; } } } } - if(Rs2Npc.getNpc("Revenant knight").getWorldLocation().equals(thirdTile)){ + if(revenentKnight().getWorldLocation().equals(thirdTile)){ moveCameraToTile(fourthTile); Rs2Walker.walkCanvas(fourthTile); sleepUntil(()-> Rs2Player.isMoving(), Rs2Random.between(1000,3000)); @@ -375,7 +419,7 @@ public void kiteTheKnight(){ } if(Rs2Player.getWorldLocation().equals(fifthTile)) { - if (Rs2Npc.attack("Revenant knight")) { + if (Rs2Npc.interact(revenentKnight(), "Attack")) { Microbot.log("We attacked the knight"); Microbot.log("Rev should be locked"); } @@ -457,7 +501,7 @@ public void WalkToRevs(){ } else { if(!Rs2Dialogue.isInDialogue()){ Microbot.log("At the cave, clicking."); - if(Rs2GameObject.interact(31555, "Enter")){ + if(Microbot.getRs2TileObjectCache().query().withId(31555).nearest().click("Enter")){ sleepUntil(()-> Rs2Dialogue.isInDialogue(), generateRandomNumber(1000,3000)); } } @@ -708,7 +752,8 @@ public void enablePrayer(){ } public void fightrev(revKillerConfig config){ - Rs2NpcModel Rev = (Rs2Npc.getNpc(config.selectedRev().getName())); + Rs2NpcModel Rev = Rs2Npc.getNpc(config.selectedRev().getName()); + if(Rev!=null){ if(playerCheck()){return;} @@ -718,11 +763,10 @@ public void fightrev(revKillerConfig config){ hopWorldsBasedOnTimer(); } - if(Rev==null){return;} - Microbot.log("Attacking Rev"); + if (Rs2Npc.interact(Rev, "Attack")) { - sleepUntil(() -> Rev.isDead() || !Rs2Player.isInCombat() || Rs2GroundItem.isItemBasedOnValueOnGround(500,12) || isItTimeToGo() || Rs2Player.getHealthPercentage() <= generateRandomNumber(70, 80), generateRandomNumber(60000, 120000)); + sleepUntil(() -> Rev.isDead() || !Rs2Player.isInCombat() || isItTimeToGo() || Rs2Player.getHealthPercentage() <= generateRandomNumber(70, 80), generateRandomNumber(60000, 120000)); hoppedWorld=false; } } @@ -732,7 +776,7 @@ public void fightrev(revKillerConfig config){ Microbot.log("Rev is attacking us attacking back."); if (Rs2Npc.interact(Rev, "Attack")) { hoppedWorld=false; - sleepUntil(() -> Rev.isDead() || !Rs2Player.isInCombat() || Rs2GroundItem.isItemBasedOnValueOnGround(500, 12) || isItTimeToGo() || Rs2Player.getHealthPercentage() <= generateRandomNumber(70, 80), generateRandomNumber(60000, 120000)); + sleepUntil(() -> Rev.isDead() || !Rs2Player.isInCombat() || isItTimeToGo() || Rs2Player.getHealthPercentage() <= generateRandomNumber(70, 80), generateRandomNumber(60000, 120000)); } } } @@ -826,12 +870,13 @@ public void reJfount(){ sleepUntil(()-> !Rs2Bank.isOpen(), Rs2Random.between(2000,4000)); } } else { - GameObject rej = Rs2GameObject.get("Pool of Refreshment", true); + Rs2TileObjectModel rej = Microbot.getRs2TileObjectCache().query().withId(39651).nearest(); + if(rej == null){ return; } Microbot.log("Drinking"); - if(Rs2GameObject.interact(rej, "Drink")){ + if(rej.click("Drink")){ sleepUntil(()-> Rs2Player.isMoving(), Rs2Random.between(1000,3000)); sleepUntil(()-> !Rs2Player.isMoving(), Rs2Random.between(5000,10000)); sleepUntil(()-> Rs2Player.isAnimating(), Rs2Random.between(1000,4000)); @@ -896,6 +941,8 @@ public void equipArrows(){ } public void specialAttack(){ + if(Rs2Equipment.get(EquipmentInventorySlot.WEAPON).getName().toLowerCase().contains("crossbow")) return; + if(50>generateRandomNumber(0,100)) { if (Rs2Combat.getSpecEnergy() >= generateRandomNumber(600,1000)) { if(!Rs2Combat.getSpecState()) { @@ -937,29 +984,61 @@ public void drinkStamPotion(){ } public void loot(){ - if(Rs2GroundItem.isItemBasedOnValueOnGround(500,10)){ - while(Rs2GroundItem.isItemBasedOnValueOnGround(500,10)){ - if(!super.isRunning()){ - break; + List itemsOnGround = Microbot.getRs2TileItemCache().query().where(it -> it.getWorldLocation().distanceTo(Rs2Player.getWorldLocation()) < 12 && !it.getName().contains("arrow") && it.getTotalGeValue() > 500).toList(); + List BlightedItemsOnGround = Microbot.getRs2TileItemCache().query().where(it -> it.getWorldLocation().distanceTo(Rs2Player.getWorldLocation()) < 12 + && (it.getName().toLowerCase().contains("blighted") + || it.getName().toLowerCase().contains("dragonhide") + || it.getName().toLowerCase().contains("cave teleport") + || it.getName().toLowerCase().contains("ancient") + || it.getName().toLowerCase().contains("(u)") + || it.getName().toLowerCase().contains("avarice"))).toList(); + + if(!itemsOnGround.isEmpty()){ + for (Rs2TileItemModel theItem : itemsOnGround) { + if(Rs2Inventory.isFull()){ + if(Rs2Inventory.contains(it->it.isFood())){ + Rs2Inventory.interact(Rs2Inventory.getInventoryFood().get(0), "Eat"); + sleepUntil(()-> !Rs2Player.isAnimating() && !Rs2Inventory.isFull(), 1500); + } } + if(!Rs2Inventory.isFull()){ + if(Microbot.getRs2TileItemCache().query().withId(theItem.getId()).nearest() != null){ + Microbot.getRs2TileItemCache().query().withId(theItem.getId()).nearest().click("Take"); + Rs2Inventory.waitForInventoryChanges(Rs2Random.between(4000,6000)); + } + } + } + } + + if(!BlightedItemsOnGround.isEmpty()){ + for (Rs2TileItemModel theItem : BlightedItemsOnGround) { if(Rs2Inventory.isFull()){ - if(Rs2Inventory.contains(ItemID.SHARK)){ - if(Rs2Inventory.interact(ItemID.SHARK, "Eat")){ - sleepUntil(()-> !Rs2Player.isAnimating(),generateRandomNumber(2000,3500)); - } - } else { - break; + if(Rs2Inventory.contains(it->it.isFood())){ + Rs2Inventory.interact(Rs2Inventory.getInventoryFood().get(0), "Eat"); + sleepUntil(()-> !Rs2Player.isAnimating() && !Rs2Inventory.isFull(), 1500); } } - String[] arr1={"Rune arrow","Amethyst arrow"}; - //Rs2GroundItem.lootItemBasedOnValue(new LootingParameters(500,50000000, 10,1,1,false,false)) - if(Rs2GroundItem.lootItemBasedOnValue(new LootingParameters(500,50000000,10,1,1,false,false,arr1))){ - sleepUntil(()-> Rs2Player.isMoving(), Rs2Random.between(750,1500)); - if(Rs2Player.isMoving()){ - sleepUntil(()-> !Rs2Player.isMoving(), Rs2Random.between(3000,6000)); + if(!Rs2Inventory.isFull()){ + if(Microbot.getRs2TileItemCache().query().withId(theItem.getId()).nearest() != null){ + Microbot.getRs2TileItemCache().query().withId(theItem.getId()).nearest().click("Take"); + Rs2Inventory.waitForInventoryChanges(Rs2Random.between(4000,6000)); } - } else { - break; + } + } + } + + if(Rs2GroundItem.isItemBasedOnValueOnGround(500, 12)){ + while(Rs2GroundItem.isItemBasedOnValueOnGround(500, 12)){ + if(!super.isRunning()) break; + if(Rs2Inventory.isFull()){ + if (Rs2Inventory.getInventoryFood() != null && !Rs2Inventory.getInventoryFood().isEmpty()) { + Rs2Inventory.interact(Rs2Inventory.getInventoryFood().get(0).getName(), "Eat"); + sleepUntil(()-> !Rs2Player.isAnimating() && !Rs2Inventory.isFull(), 1500); + } + } + + if(Rs2GroundItem.lootItemBasedOnValue(500,12)){ + Rs2Inventory.waitForInventoryChanges(Rs2Random.between(4000,6000)); } } } @@ -975,24 +1054,15 @@ public void OpenTheInv(){ } } - public void stuckAtEnclave(){ - WorldPoint stuckSpot = new WorldPoint(3124,3636,0); - if(Rs2Player.getWorldLocation().equals(stuckSpot)){ - Microbot.log("We're stuck outside of the enclave"); - if(Rs2GameObject.exists(39653)){ - if(Rs2GameObject.interact(39653, "Pass-Through")){ - sleepUntil(()-> Rs2Player.isMoving(), Rs2Random.between(2000,4000)); - sleepUntil(()-> !Rs2Player.isMoving(), Rs2Random.between(4000,8000)); - } - } - } - } - private void teleToFerox(){ - if (Rs2Equipment.interact(EquipmentInventorySlot.RING, "Ferox Enclave")) { - sleepUntil(()-> Rs2Player.isAnimating(), generateRandomNumber(2000,4000)); - sleepUntil(()-> !Rs2Player.isAnimating(), generateRandomNumber(6000,10000)); - Microbot.log("Teleing"); + if(Rs2Equipment.isWearing(it->it!=null&&it.getName().toLowerCase().contains("ring of dueling"))) { + if (Rs2Equipment.interact(EquipmentInventorySlot.RING, "Ferox Enclave")) { + sleepUntil(() -> Rs2Player.isAnimating(), generateRandomNumber(2000, 4000)); + sleepUntil(() -> !Rs2Player.isAnimating(), generateRandomNumber(6000, 10000)); + Microbot.log("Teleing"); + } + } else { + Rs2Walker.walkTo(BankLocation.FEROX_ENCLAVE.getWorldPoint()); } } @@ -1019,7 +1089,6 @@ public void Bankfortrip(){ if(!WeAreInTheCaves()) { Microbot.log("Walking and using bank"); OpenTheInv(); - stuckAtEnclave(); stopTeleSpam(); Rs2Bank.walkToBankAndUseBank(BankLocation.FEROX_ENCLAVE); } @@ -1209,10 +1278,11 @@ public void Bankfortrip(){ if(howtobank <= 40){ Microbot.log("Withdrawing Ranging potion"); if(!Rs2Inventory.contains(it->it!=null&&it.getName().contains("Ranging"))){ - if(Rs2Bank.count("Ranging potion(4)") > 0){ + if(Rs2Bank.getBankItem("Ranging potion(4)") != null || Rs2Bank.getBankItem("Ranging potion(3)") != null){ if(!Rs2Inventory.contains(it->it!=null&&it.getName().contains("Ranging"))){ - Rs2Bank.withdrawX("Ranging potion(4)", 2); - sleepUntil(()-> Rs2Inventory.contains(it->it!=null&&it.getName().contains("Ranging")), generateRandomNumber(5000,15000)); + if(Rs2Bank.withdrawX(it->it!=null && it.getName().contains("Ranging potion") && !it.getName().contains("(1)") && !it.getName().contains("(2)"), 2)){ + sleepUntil(()-> Rs2Inventory.contains(it->it!=null&&it.getName().contains("Ranging")), generateRandomNumber(5000,15000)); + } } } else { Microbot.log("Out of ranging potions");