diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/equipment/Rs2Equipment.java b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/equipment/Rs2Equipment.java index f917104088c..a54bab557f4 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/equipment/Rs2Equipment.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/equipment/Rs2Equipment.java @@ -168,7 +168,7 @@ public static boolean isWearing(String[] names, EquipmentInventorySlot[] searchS } private static boolean unEquip(Rs2ItemModel item) { - return interact(item, "remove"); + return interact(item, "Remove"); } public static boolean unEquip(Predicate predicate) { @@ -376,7 +376,7 @@ public static void invokeMenu(Rs2ItemModel rs2Item, String action) { rectangle = getSafeBounds(InterfaceID.WORNITEMS,24); } - Microbot.doInvoke(new NewMenuEntry(param0, param1, menuAction.getId(), identifier, -1, rs2Item.getName()), rectangle); + Microbot.doInvoke(new NewMenuEntry(action, param0, param1, menuAction.getId(), identifier, -1, target), rectangle); //Rs2Reflection.invokeMenu(param0, param1, menuAction.getId(), identifier, rs2Item.id, action, target, -1, -1); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/gameobject/Rs2Cannon.java b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/gameobject/Rs2Cannon.java index fcaab7f99c7..03e45635995 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/gameobject/Rs2Cannon.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/gameobject/Rs2Cannon.java @@ -4,6 +4,7 @@ import net.runelite.api.TileObject; import net.runelite.api.VarPlayer; import net.runelite.api.coords.WorldArea; +import net.runelite.api.gameval.VarPlayerID; import net.runelite.client.plugins.cannon.CannonPlugin; import net.runelite.client.plugins.microbot.Microbot; import net.runelite.client.plugins.microbot.util.inventory.Rs2Inventory; @@ -32,6 +33,7 @@ public static boolean repair() { Microbot.status = "Repairing Cannon"; Rs2GameObject.interact(brokenCannon, "Repair"); + sleepUntil(() -> !Rs2GameObject.exists(brokenCannon.getId()),5000); return true; } @@ -72,4 +74,65 @@ public static boolean refill(int cannonRefillAmount) { return true; } + public static boolean pickup() { + + Microbot.status = "Picking up Cannon"; + + TileObject cannon = Rs2GameObject.findObject(new Integer[]{ObjectID.DWARF_MULTICANNON, ObjectID.DWARF_MULTICANNON_43027}); + if (cannon == null) return false; + + // Create centered WorldArea (3x3 area with cannon at center) + WorldArea cannonLocation = new WorldArea( + cannon.getWorldLocation().getX() - 1, + cannon.getWorldLocation().getY() - 1, + 3, 3, + cannon.getWorldLocation().getPlane() + ); + if (!cannonLocation.toWorldPoint().equals(CannonPlugin.getCannonPosition().toWorldPoint())) return false; + Microbot.pauseAllScripts.compareAndSet(false, true); + int attempts = 0; + while (Rs2GameObject.exists(cannon.getId()) && Rs2Inventory.emptySlotCount() >= 4 && attempts < 3){ + Rs2GameObject.interact(cannon, "Pick-up"); + sleepUntil(() -> !Rs2GameObject.exists(cannon.getId()),5000); + if(!Rs2GameObject.exists(cannon.getId())){ + return true; + } + attempts++; + } + Microbot.pauseAllScripts.compareAndSet(true, false); + return false; + } + + public static boolean start() { + if (!Rs2Inventory.hasItemAmount("cannonball", 30, true)) { + //System.out.println("Not enough cannonballs!"); + return false; + } + + Microbot.status = "Starting up Cannon"; + + TileObject cannon = Rs2GameObject.findObject(new Integer[]{ObjectID.DWARF_MULTICANNON, ObjectID.DWARF_MULTICANNON_43027}); + if (cannon == null) return false; + + // Create centered WorldArea (3x3 area with cannon at center) + WorldArea cannonLocation = new WorldArea( + cannon.getWorldLocation().getX() - 1, + cannon.getWorldLocation().getY() - 1, + 3, 3, + cannon.getWorldLocation().getPlane() + ); + if (!cannonLocation.toWorldPoint().equals(CannonPlugin.getCannonPosition().toWorldPoint())) return false; + int attempts = 0; + while (Microbot.getClientThread().runOnClientThreadOptional(() -> Microbot.getClient().getVarpValue(VarPlayerID.MCANNONMULTI)).orElse(0) == 0 && attempts < 3){ + Microbot.log("Starting Cannon"); + Rs2GameObject.interact(cannon, "Fire"); + sleepUntil(()-> Microbot.getClientThread().runOnClientThreadOptional(() -> Microbot.getClient().getVarpValue(VarPlayerID.MCANNONMULTI)).orElse(0) == 1048576); + sleep(250); + if (Microbot.getClientThread().runOnClientThreadOptional(() -> Microbot.getClient().getVarpValue(VarPlayerID.MCANNONMULTI)).orElse(0) == 1048576){ + return true; + } + attempts++; + } + return false; + } }