Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public class RcScript extends Script {
private final WorldPoint outsideWrathRuins = new WorldPoint(2445, 2818, 0);
private final WorldPoint wrathRuinsLoc = new WorldPoint(2445, 2824, 0);

private volatile boolean forceDrinkAtFerox = false;

public static final int pureEss = 7936;
public static final int feroxPool = 39651;
public static final int monasteryRegion = 10290;
Expand Down Expand Up @@ -330,8 +332,9 @@ private void handleFillPouch() {
}

private void handleFeroxRunEnergy() {
if (Rs2Player.getRunEnergy() < 45) {
Microbot.log("We are thirsty...let us Drink");
if (forceDrinkAtFerox || Rs2Player.getRunEnergy() <= 15 || Rs2Player.getHealthPercentage() <= 20) {
Microbot.log("We are thirsty...let us Drink");
forceDrinkAtFerox = true;
if (plugin.getMyWorldPoint().distanceTo(feroxPoolWp) > 5) {
Microbot.log("Walking to Ferox pool");
Rs2Walker.walkTo(feroxPoolWp);
Expand All @@ -344,6 +347,7 @@ private void handleFeroxRunEnergy() {
}
sleepUntil(() -> (!Rs2Player.isInteracting()) && !Rs2Player.isAnimating() && Rs2Player.getRunEnergy() > 90);
sleepGaussian(1100, 200);
forceDrinkAtFerox = false;
}
}

Expand Down Expand Up @@ -456,7 +460,12 @@ private void handleWrathWalking() {
Microbot.log("Interacting with myth cape");
Rs2Inventory.interact(mythCape, "Teleport");
sleepUntil(() -> plugin.getMyWorldPoint().getRegionID() == mythicStatueRegion);
sleepGaussian(1100, 200);
sleepGaussian(600, 200);

GameObject statue = Rs2GameObject.get("Mythic Statue");
if (statue != null && !Rs2Player.isAnimating()) {
Rs2GameObject.interact(statue, "Teleport");
}

if (plugin.getMyWorldPoint().getRegionID() == mythicStatueRegion) {
Microbot.log("Walking to Wrath ruins");
Expand Down Expand Up @@ -707,6 +716,13 @@ private void handleCrafting() {
Microbot.log("Crafting runes");
handleEmptyPouch();
}

handleFeroxRunEnergy();

if (plugin.isBreakHandlerEnabled()) {
BreakHandlerScript.setLockState(false);
}

Comment on lines +720 to +725
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Don’t call handleFeroxRunEnergy from CRAFTING; set the flag and let teleport logic consume it.

Calling handleFeroxRunEnergy here can trigger a long “walk to Ferox” from within altar regions. Safer: mark intent via forceDrinkAtFerox and allow handleBankTeleport (now prioritizing Ferox when needRefill) to route correctly. If we happen to already be at/near Ferox, still allow immediate drink.

-        handleFeroxRunEnergy();
+        if (Teleports.FEROX_ENCLAVE.matchesRegion(plugin.getMyWorldPoint().getRegionID())
+            || plugin.getMyWorldPoint().distanceTo(feroxPoolWp) < 25) {
+            handleFeroxRunEnergy();
+        } else {
+            // Defer to bank teleport routing; this prevents long world-walks from altars.
+            forceDrinkAtFerox = true;
+        }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
handleFeroxRunEnergy();
if (plugin.isBreakHandlerEnabled()) {
BreakHandlerScript.setLockState(false);
}
// Only immediately handle Ferox run energy if we're in or very near Ferox;
// otherwise defer to teleport routing via forceDrinkAtFerox.
if (Teleports.FEROX_ENCLAVE.matchesRegion(plugin.getMyWorldPoint().getRegionID())
|| plugin.getMyWorldPoint().distanceTo(feroxPoolWp) < 25)
{
handleFeroxRunEnergy();
}
else
{
// Defer to bank teleport routing; prevents long world-walks from altars.
forceDrinkAtFerox = true;
}
if (plugin.isBreakHandlerEnabled())
{
BreakHandlerScript.setLockState(false);
}
🤖 Prompt for AI Agents
In
runelite-client/src/main/java/net/runelite/client/plugins/microbot/frosty/frostyrc/RcScript.java
around lines 720 to 725, remove the direct call to handleFeroxRunEnergy and
instead set the forceDrinkAtFerox flag so teleport/banking logic can consume the
intent; ensure handleBankTeleport (which now prioritizes Ferox when needRefill)
will route to Ferox and call handleFeroxRunEnergy when it performs the teleport,
and add a short conditional to still call handleFeroxRunEnergy immediately only
if the player is already at or very near Ferox to avoid long unwanted walks from
altar regions.

state = State.BANKING;
}

Expand All @@ -731,7 +747,13 @@ private void handleBankTeleport() {
Rs2Tab.switchToEquipmentTab();
sleepGaussian(1300, 200);

List<Teleports> bankTeleport = Arrays.asList(
boolean needRefill = (forceDrinkAtFerox || Rs2Player.getRunEnergy() <= 15 || Rs2Player.getHealthPercentage() <= 20);
List<Teleports> bankTeleport = needRefill
? Arrays.asList(
Teleports.FEROX_ENCLAVE,
Teleports.CRAFTING_CAPE,
Teleports.FARMING_CAPE)
: Arrays.asList(
Teleports.CRAFTING_CAPE,
Teleports.FARMING_CAPE,
Teleports.FEROX_ENCLAVE
Expand All @@ -745,6 +767,10 @@ private void handleBankTeleport() {
Rs2Equipment.interact(bankTeleportsId, teleport.getInteraction());
sleepUntil(() -> teleport.matchesRegion(plugin.getMyWorldPoint().getRegionID()));
sleepGaussian(1100, 200);
if (teleport == Teleports.FEROX_ENCLAVE) {
forceDrinkAtFerox = true;
handleFeroxRunEnergy();
}
teleportUsed = true;
break;
}
Expand Down