Tree farm run improvements#1484
Conversation
…pawn times. - Added fuzzy gem bag support because I don't have an account to test this with. My implementation passes the eye test but will need actual testing.
…ragonstones, our gem bag will never be "completely full" (consisting of >= 60 gems of all 5 types) and could cause unnecessary fill attempts. Let's check the 4 types individually.
…to add-worldhopping-and-gem-bag
…d to be enabled -> Forced Item mode before withdrawing essentials(spade, rake, saplings, teleports, runes), so they always come out unnoted and usable. Also grouped items by withdrawal mode for better segregation.
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThis PR removes the Quest Helper Integration section from README.md. It refactors FarmTreeRunScript banking to a two-phase withdrawal (unnoted then noted), introducing ensureWithdrawAsItem/ensureWithdrawAsNote toggling via Rs2Widget and per-item checks with short waits. It updates FortisGemStallThievingSpot with anti-detection world-hopping when players are nearby or stall/action is missing, adds gem bag detection/open/fill logic, and revises banking to deposit specific uncut gems, empty the gem bag, and close the bank. New private helpers support gem and inventory checks. No exported/public signatures change. Possibly related PRs
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…s and was largely inefficient -> Now we compute an inventory delta: keep required items (including noted variants), deposit only others, and withdraw only deficits (unnoted for tools/saplings, noted for payments). Meaning, we can start with a Rake and Spade and it keep those items because we already have them in our inventory. Same for runes - If we have 3 Fire runes in our inventory and we need a total of 30, it will withdraw the needed 27.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/farmTreeRun/FarmTreeRunScript.java (1)
426-426: Remove redundant ensureWithdrawAsItem call.Mode is enforced again right before the unnoted withdrawals; the earlier call is unnecessary.
- ensureWithdrawAsItem();Also applies to: 548-548
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
README.md(0 hunks)runelite-client/src/main/java/net/runelite/client/plugins/microbot/farmTreeRun/FarmTreeRunScript.java(5 hunks)runelite-client/src/main/java/net/runelite/client/plugins/microbot/thieving/stalls/model/FortisGemStallThievingSpot.java(2 hunks)
💤 Files with no reviewable changes (1)
- README.md
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-08-25T15:51:39.272Z
Learnt from: runsonmypc
PR: chsami/Microbot#1417
File: runelite-client/src/main/java/net/runelite/client/plugins/microbot/agility/AgilityScript.java:13-13
Timestamp: 2025-08-25T15:51:39.272Z
Learning: Both net.runelite.api.ItemID and net.runelite.api.gameval.ItemID are valid import paths in the RuneLite codebase. The microbot plugins consistently use net.runelite.api.ItemID as their established pattern.
Applied to files:
runelite-client/src/main/java/net/runelite/client/plugins/microbot/thieving/stalls/model/FortisGemStallThievingSpot.java
🧬 Code graph analysis (1)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/thieving/stalls/model/FortisGemStallThievingSpot.java (4)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/Global.java (1)
Global(10-171)runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/gameobject/Rs2GameObject.java (1)
Rs2GameObject(36-2002)runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/inventory/Rs2Inventory.java (1)
Rs2Inventory(60-2244)runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/player/Rs2Player.java (1)
Rs2Player(67-2070)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Build
🔇 Additional comments (2)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/farmTreeRun/FarmTreeRunScript.java (1)
541-547: Two-phase withdrawal is a solid fix for noted/unnoted pitfalls.Splitting into unnoted vs noted phases with explicit mode flips removes the racey in-loop toggling and should prevent unusable noted essentials. Looks good.
Also applies to: 548-557, 559-571
runelite-client/src/main/java/net/runelite/client/plugins/microbot/thieving/stalls/model/FortisGemStallThievingSpot.java (1)
39-42: LGTM: safer thieving flow and bank handling.
- Early hop on nearby player and on invalid/missing stall reduces flaggable behavior.
- Gem bag state gating (check/open/fill) is correct; banking empties and preserves the bag.
Also applies to: 45-50, 52-57, 63-76, 82-92
| private void ensureWithdrawAsItem() { | ||
| final int ITEM_TOGGLE_COMPONENT = 786456; // Item toggle ID in Bank | ||
| for (int i = 0; i < 3; i++) { | ||
| if (Rs2Bank.hasWithdrawAsItem()) return; | ||
| Rs2Widget.clickWidget(ITEM_TOGGLE_COMPONENT); | ||
| sleepUntil(Rs2Bank::hasWithdrawAsItem, 600); | ||
| } | ||
| } | ||
|
|
||
| private void ensureWithdrawAsNote() { | ||
| final int NOTE_TOGGLE_COMPONENT = 786458; // Note toggle ID in Bank | ||
| for (int i = 0; i < 3; i++) { | ||
| if (Rs2Bank.hasWithdrawAsNote()) return; | ||
| Rs2Widget.clickWidget(NOTE_TOGGLE_COMPONENT); | ||
| sleepUntil(Rs2Bank::hasWithdrawAsNote, 600); | ||
| } | ||
| } |
There was a problem hiding this comment.
💡 Verification agent
🧩 Analysis chain
Avoid brittle hard-coded bank widget IDs; enforce failure fast if toggle doesn’t stick.
Directly clicking widget IDs 786456/786458 is fragile across client updates; if these change, withdrawals silently happen in the wrong mode and break runs. At minimum, fail fast when the target state isn’t reached after retries. Prefer centralizing the toggle in Rs2Bank (e.g., a setWithdrawMode API) or referencing stable WidgetInfo constants if available.
Run this to see if a dedicated toggle API already exists in the repo:
Apply this defensive check so we don’t proceed in the wrong mode:
private void ensureWithdrawAsItem() {
final int ITEM_TOGGLE_COMPONENT = 786456; // Item toggle ID in Bank
for (int i = 0; i < 3; i++) {
if (Rs2Bank.hasWithdrawAsItem()) return;
Rs2Widget.clickWidget(ITEM_TOGGLE_COMPONENT);
sleepUntil(Rs2Bank::hasWithdrawAsItem, 600);
}
+ if (!Rs2Bank.hasWithdrawAsItem()) {
+ Microbot.log("Failed to switch bank withdraw mode to Item; aborting to avoid withdrawing noted essentials.");
+ shutdown();
+ plugin.reportFinished("Withdraw mode toggle (Item) failed", false);
+ }
}
private void ensureWithdrawAsNote() {
final int NOTE_TOGGLE_COMPONENT = 786458; // Note toggle ID in Bank
for (int i = 0; i < 3; i++) {
if (Rs2Bank.hasWithdrawAsNote()) return;
Rs2Widget.clickWidget(NOTE_TOGGLE_COMPONENT);
sleepUntil(Rs2Bank::hasWithdrawAsNote, 600);
}
+ if (!Rs2Bank.hasWithdrawAsNote()) {
+ Microbot.log("Failed to switch bank withdraw mode to Note; aborting to avoid withdrawing unnoted payments.");
+ shutdown();
+ plugin.reportFinished("Withdraw mode toggle (Note) failed", false);
+ }
}🏁 Script executed:
#!/bin/bash
# Look for existing withdraw-mode helpers we can reuse instead of hard-coding widget ids.
rg -nP 'hasWithdrawAs(Item|Note)|setWithdraw|toggleWithdraw|withdrawAs(Item|Note)' -C2 -- runelite-client/srcLength of output: 8912
Centralize bank withdraw toggles and fail-fast on mode mismatch
Replace the hard-coded widget loops in ensureWithdrawAsItem/ensureWithdrawAsNote with the existing Rs2Bank API (setWithdrawAsItem()/setWithdrawAsNote()), remove the magic IDs, and after your retry+sleepUntil ensure Rs2Bank.hasWithdrawAsItem()/hasWithdrawAsNote() still succeeds—otherwise log and abort to avoid silent mis-withdrawals.
🤖 Prompt for AI Agents
In
runelite-client/src/main/java/net/runelite/client/plugins/microbot/farmTreeRun/FarmTreeRunScript.java
around lines 951 to 967, the two methods use hard-coded widget IDs and manual
click loops; replace them to call Rs2Bank.setWithdrawAsItem() and
Rs2Bank.setWithdrawAsNote() respectively, remove the magic IDs and manual click
logic, keep the retry+sleepUntil behavior but call the Rs2Bank query to verify
state after retries, and if Rs2Bank.hasWithdrawAsItem()/hasWithdrawAsNote()
still returns false log an error and abort/throw to fail fast to prevent silent
wrong-mode withdrawals.
Rake/spade and saplings were withdrawn as noted if noted mode happened to be enabled -> Forced Item mode before withdrawing essentials (spade, rake, saplings, teleports, runes), so they always come out unnoted and usable. Also grouped items by withdrawal mode for better segregation.
Depositing entire inventory on start caused unnecessary re-withdrawals and was largely inefficient -> Now we compute an inventory delta: keep required items (including noted variants), deposit only others, and withdraw only deficits (unnoted for tools/saplings, noted for payments). Meaning, we can start with a Rake and Spade and it keep those items because we already have them in our inventory. Same for runes - If we have 3 Fire runes in our inventory and we need a total of 30, it will withdraw the needed 27.