From c443910a47cde8e64cfc800dff879f29c745c688 Mon Sep 17 00:00:00 2001 From: krulvis Date: Tue, 9 Sep 2025 21:02:52 +0200 Subject: [PATCH 1/2] feat(Rs2Walker): support PoH Fairy rings and using 'last-destination' --- .../microbot/util/walker/Rs2Walker.java | 89 ++++++++++--------- 1 file changed, 46 insertions(+), 43 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/walker/Rs2Walker.java b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/walker/Rs2Walker.java index 0c20efd0dad..fd4664fb6d5 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/walker/Rs2Walker.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/walker/Rs2Walker.java @@ -2545,64 +2545,67 @@ private static boolean handleGlider(Transport transport) { private static boolean handleFairyRing(Transport transport) { - Rs2ItemModel startingWeapon = null; + Rs2ItemModel startingWeapon = null; - TileObject fairyRingObject = PohTeleports.isInHouse() ? PohTeleports.getFairyRings() : Rs2GameObject.getAll(o -> Objects.equals(o.getWorldLocation(), transport.getOrigin())).stream().findFirst().orElse(null); - if (fairyRingObject == null) return false; + TileObject fairyRingObject = PohTeleports.isInHouse() ? PohTeleports.getFairyRings() : Rs2GameObject.getAll(o -> Objects.equals(o.getWorldLocation(), transport.getOrigin())).stream().findFirst().orElse(null); + if (fairyRingObject == null) return false; - if (!PohTeleports.isInHouse() && !Rs2GameObject.canWalkTo(fairyRingObject, 25)) return false; + if (!PohTeleports.isInHouse() && !Rs2GameObject.canWalkTo(fairyRingObject, 25)) return false; - boolean hasLumbridgeElite = Microbot.getVarbitValue(VarbitID.LUMBRIDGE_DIARY_ELITE_COMPLETE) == 1; + boolean hasLumbridgeElite = Microbot.getVarbitValue(VarbitID.LUMBRIDGE_DIARY_ELITE_COMPLETE) == 1; - if (!hasLumbridgeElite) { - if (Rs2Equipment.isWearing(EquipmentInventorySlot.WEAPON)) { - startingWeapon = Rs2Equipment.get(EquipmentInventorySlot.WEAPON); - } + if (!hasLumbridgeElite) { + if (Rs2Equipment.isWearing(EquipmentInventorySlot.WEAPON)) { + startingWeapon = Rs2Equipment.get(EquipmentInventorySlot.WEAPON); + } - if (!Rs2Equipment.isWearing("Dramen staff") && !Rs2Equipment.isWearing("Lunar staff")) { - if (Rs2Inventory.contains("Dramen staff")) { - Rs2Inventory.equip("Dramen staff"); - sleepUntil(() -> Rs2Equipment.isWearing("Dramen staff")); - } else if (Rs2Inventory.contains("Lunar staff")) { - Rs2Inventory.equip("Lunar staff"); - sleepUntil(() -> Rs2Equipment.isWearing("Lunar staff")); - } else { - return false; - } - } - } + if (!Rs2Equipment.isWearing("Dramen staff") && !Rs2Equipment.isWearing("Lunar staff")) { + if (Rs2Inventory.contains("Dramen staff")) { + Rs2Inventory.equip("Dramen staff"); + sleepUntil(() -> Rs2Equipment.isWearing("Dramen staff")); + } else if (Rs2Inventory.contains("Lunar staff")) { + Rs2Inventory.equip("Lunar staff"); + sleepUntil(() -> Rs2Equipment.isWearing("Lunar staff")); + } else { + return false; + } + } + } String lastDestinationAction = "last-destination-" + transport.getDisplayInfo(); String treeLastDestinationAction = "Ring-last-destination (" + transport.getDisplayInfo() + ")"; ObjectComposition composition = Rs2GameObject.convertToObjectComposition(fairyRingObject); log.info("Interacting with Fairy Ring @ {}", fairyRingObject.getWorldLocation()); + // we can use the last-destination to handle fairy rings if (Rs2GameObject.hasAction(composition, lastDestinationAction, true)) { - return Rs2GameObject.interact(fairyRingObject, lastDestinationAction); - }else if (Rs2GameObject.hasAction(composition, treeLastDestinationAction, true)) { - return Rs2GameObject.interact(fairyRingObject, treeLastDestinationAction); - } - if (Rs2GameObject.hasAction(composition, "Configure", true)) { - Rs2GameObject.interact(fairyRingObject, "Configure"); - } else if (Rs2GameObject.hasAction(composition, "Ring-configure", true)) { - Rs2GameObject.interact(fairyRingObject, "Ring-configure"); - } - sleepUntil(() -> !Rs2Player.isMoving() && !Rs2Widget.isHidden(ComponentID.FAIRY_RING_TELEPORT_BUTTON), 10000); + Rs2GameObject.interact(fairyRingObject, lastDestinationAction); + } else if (Rs2GameObject.hasAction(composition, treeLastDestinationAction, true)) { + Rs2GameObject.interact(fairyRingObject, treeLastDestinationAction); + } else { + // We have to configure fairy rings through the interface + if (Rs2GameObject.hasAction(composition, "Configure", true)) { + Rs2GameObject.interact(fairyRingObject, "Configure"); + } else if (Rs2GameObject.hasAction(composition, "Ring-configure", true)) { + Rs2GameObject.interact(fairyRingObject, "Ring-configure"); + } + sleepUntil(() -> !Rs2Player.isMoving() && !Rs2Widget.isHidden(ComponentID.FAIRY_RING_TELEPORT_BUTTON), 10000); - rotateSlotToDesiredRotation(SLOT_ONE, Rs2Widget.getWidget(SLOT_ONE).getRotationY(), getDesiredRotation(transport.getDisplayInfo().charAt(0)), SLOT_ONE_ACW_ROTATION, SLOT_ONE_CW_ROTATION); - rotateSlotToDesiredRotation(SLOT_TWO, Rs2Widget.getWidget(SLOT_TWO).getRotationY(), getDesiredRotation(transport.getDisplayInfo().charAt(1)), SLOT_TWO_ACW_ROTATION, SLOT_TWO_CW_ROTATION); - rotateSlotToDesiredRotation(SLOT_THREE, Rs2Widget.getWidget(SLOT_THREE).getRotationY(), getDesiredRotation(transport.getDisplayInfo().charAt(2)), SLOT_THREE_ACW_ROTATION, SLOT_THREE_CW_ROTATION); - Rs2Widget.clickWidget(ComponentID.FAIRY_RING_TELEPORT_BUTTON); + rotateSlotToDesiredRotation(SLOT_ONE, Rs2Widget.getWidget(SLOT_ONE).getRotationY(), getDesiredRotation(transport.getDisplayInfo().charAt(0)), SLOT_ONE_ACW_ROTATION, SLOT_ONE_CW_ROTATION); + rotateSlotToDesiredRotation(SLOT_TWO, Rs2Widget.getWidget(SLOT_TWO).getRotationY(), getDesiredRotation(transport.getDisplayInfo().charAt(1)), SLOT_TWO_ACW_ROTATION, SLOT_TWO_CW_ROTATION); + rotateSlotToDesiredRotation(SLOT_THREE, Rs2Widget.getWidget(SLOT_THREE).getRotationY(), getDesiredRotation(transport.getDisplayInfo().charAt(2)), SLOT_THREE_ACW_ROTATION, SLOT_THREE_CW_ROTATION); + Rs2Widget.clickWidget(ComponentID.FAIRY_RING_TELEPORT_BUTTON); + } - sleepUntil(() -> Rs2Player.hasSpotAnimation(fairyRingGraphicId)); - sleepUntil(() -> Objects.equals(Rs2Player.getWorldLocation(), transport.getDestination()) && !Rs2Player.hasSpotAnimation(fairyRingGraphicId), 10000); + sleepUntil(() -> Rs2Player.getGraphicId() == fairyRingGraphicId); + sleepUntil(() -> Objects.equals(Rs2Player.getWorldLocation(), transport.getDestination()) && Rs2Player.getGraphicId() != fairyRingGraphicId, 10000); - if (startingWeapon != null) { - Rs2ItemModel finalStartingWeapon = startingWeapon; - Rs2Inventory.equip(finalStartingWeapon.getId()); - sleepUntil(() -> Rs2Equipment.isWearing(finalStartingWeapon.getId())); - } - return true; + if (startingWeapon != null) { + Rs2ItemModel finalStartingWeapon = startingWeapon; + Rs2Inventory.equip(finalStartingWeapon.getId()); + sleepUntil(() -> Rs2Equipment.isWearing(finalStartingWeapon.getId())); + } + return true; } /** From aa979535706806584ca72b56badf06ee5ebe1f62 Mon Sep 17 00:00:00 2001 From: krulvis Date: Tue, 9 Sep 2025 21:41:46 +0200 Subject: [PATCH 2/2] chore: add default sleep to make bot happy --- .../client/plugins/microbot/util/walker/Rs2Walker.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/walker/Rs2Walker.java b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/walker/Rs2Walker.java index fd4664fb6d5..dad9b48914b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/walker/Rs2Walker.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/walker/Rs2Walker.java @@ -2572,7 +2572,7 @@ private static boolean handleFairyRing(Transport transport) { } } - String lastDestinationAction = "last-destination-" + transport.getDisplayInfo(); + String lastDestinationAction = "last-destination (" + transport.getDisplayInfo() + ")"; String treeLastDestinationAction = "Ring-last-destination (" + transport.getDisplayInfo() + ")"; ObjectComposition composition = Rs2GameObject.convertToObjectComposition(fairyRingObject); log.info("Interacting with Fairy Ring @ {}", fairyRingObject.getWorldLocation()); @@ -2597,7 +2597,7 @@ private static boolean handleFairyRing(Transport transport) { Rs2Widget.clickWidget(ComponentID.FAIRY_RING_TELEPORT_BUTTON); } - sleepUntil(() -> Rs2Player.getGraphicId() == fairyRingGraphicId); + sleepUntil(() -> Rs2Player.getGraphicId() == fairyRingGraphicId, 5000); sleepUntil(() -> Objects.equals(Rs2Player.getWorldLocation(), transport.getDestination()) && Rs2Player.getGraphicId() != fairyRingGraphicId, 10000); if (startingWeapon != null) {