Barrows: Improved readability, removed a lot of duplicate code.#1386
Barrows: Improved readability, removed a lot of duplicate code.#1386gmason0 merged 5 commits intochsami:developmentfrom
Conversation
|
@Gage307 - Can you please rebase this branch to remove the old commits from the pull request. |
Oh I see, thank you as always! |
WalkthroughRefactors Barrows combat flow by introducing parameterized prayer activation and consolidating brother detection/fighting into a new method. Streamlines supply/banking and brew consumption. Adjusts tunnel/chest interaction calls accordingly. Adds anti-ban initialization to Blue Dragons plugin startup. Blue Dragons script sees whitespace-only edits. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant P as Player
participant BS as BarrowsScript
participant PM as Prayer Manager
participant B as Barrows Brother (NPC)
participant H as Hint Arrow
Note over BS: New flow
P->>BS: Start run / step
BS->>BS: checkForAndFightBrother(config)
alt Brother present (mound/tunnel)
BS->>H: Read target from hint arrow
BS->>PM: activatePrayer(prayer)
loop Engage until death/lost
BS->>B: Attack / Re-attack if needed
BS->>BS: Validate LOS / proximity (tunnel guards)
H-->>BS: Update arrow status
alt Brother dead or arrow lost
BS->>PM: deactivate prayer
BS-->>P: Exit fight path
end
end
else No brother
BS-->>P: Continue navigation/open chest/etc.
end
sequenceDiagram
autonumber
participant BD as BlueDragonsPlugin
participant AB as Anti-Ban System
participant T as Setup Templates
participant ACT as Activity Tracker
BD->>BD: startUp()
BD->>AB: activateAntiban()
BD->>AB: resetAntibanSettings()
BD->>T: applyCombatSetup()
BD->>ACT: setActivity(KILLING_BLUE_DRAGONS)
BD-->>BD: Proceed to script run
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
| Rs2Bank.depositAll("Blue dragonhide"); | ||
| } | ||
| logOnceToChat("Withdrawing food for combat.", true, config); | ||
| String[] thingsWeWantToKeep = {config.foodType().getName(), "Law rune", "Air rune", "Water rune", "Falador teleport", "Dusty key"}; |
There was a problem hiding this comment.
isn't this dependant on what you use for your teleport? I can understand some people would like to bank runes for extra space.
There was a problem hiding this comment.
- have Falador teleport (runes/teletab) - from the description of the plugin.
The only time the inventory will have law, air, or water runes is if the user wants to use their spell book teleports. Otherwise they'd just be using a tablet. The script won't pickup those runes; they're too low value.
gmason0
left a comment
There was a problem hiding this comment.
I appreciate your continued efforts in your plugins gage!
When you have some time, if you could please take a look at the microbot plugin hub project & start to see how you can migrate your plugins over to the plugin hub!
|
@Gage307 - Are you able to resolve merge conflicts here? |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (7)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/zerozero/bluedragons/BlueDragonsPlugin.java (1)
47-55: Initialize anti-ban before starting the script — add cleanup on shutdown.Startup sequence makes sense: activate -> reset -> apply combat template -> set activity. To prevent anti-ban state leaking into other plugins after this one stops, reset anti-ban in
shutDown()(and optionally set a neutral activity if the API supports it).Apply this diff to perform cleanup on shutdown:
@@ @Override protected void shutDown() { script.logOnceToChat("Stopping Blue Dragons plugin...", false, config); overlayManager.remove(overlay); + // Reset antiban so subsequent plugins don't inherit Blue Dragons state. + Rs2Antiban.resetAntibanSettings(); + // Optional (if supported by your enum/API): + // Rs2Antiban.setActivity(Activity.IDLE); script.shutdown(); }runelite-client/src/main/java/net/runelite/client/plugins/microbot/barrows/BarrowsScript.java (6)
366-370: Chest flow: early-return is fine; consider short backoff if open fails.
- The early
returnwhen "Open" fails prevents cascading actions in a bad UI state — good.- Minor: consider a short backoff (e.g.,
sleep(600,1200)) before returning to avoid tight-loop spam if the chest is temporarily un-interactable.Also applies to: 379-380, 389-391, 393-394
927-931: Logging threshold is hard-coded and misleading.Message says “less than 180” even though the threshold is
minRuneAmt. Log the actual threshold to avoid operator confusion.Apply this diff:
- Microbot.log("We have less than 180 " + neededRune); + Microbot.log("We have <= " + minRuneAmt + " " + neededRune);
942-984: Pre-fight supplies gating is comprehensive; one minor UX nit.Checks for ring, spade, food, teleports, brews, prayer restores, and run energy look good. To reduce duplicate logs across ticks, consider gating repeated “shouldBank” logs behind a cooldown or using a
logOncepattern similar to other classes.
1045-1050: Use idempotent prayer toggle to reduce race surfaces.You already guard with
isPrayerActive, but using the booleantoggleoverload ensures the prayer is turned on even if varbits change between the check and the toggle.Apply this diff:
- drinkPrayerPot(); - Rs2Prayer.toggle(prayer); + drinkPrayerPot(); + Rs2Prayer.toggle(prayer, true);
1184-1190: LoS break is tunnels-only — add a general escape hatch to prevent stalling.You only break on lack of line-of-sight when
inTunnels. If a brother is hint-arrowed but not visible outside tunnels (e.g., blocked by geometry), the loop can spin. Consider a time/iteration cap with a graceful break or a reposition attempt outside tunnels too.
1026-1043: String equality insetAutoCastshould use.equals, not==.While literals may be interned, using
==for string comparison is brittle and error-prone. Recommend.equalsfor correctness.Apply this diff:
- if(neededRune == "Wrath rune"){ + if ("Wrath rune".equals(neededRune)) { @@ - if(neededRune == "Blood rune"){ + if ("Blood rune".equals(neededRune)) { @@ - if(neededRune == "Death rune"){ + if ("Death rune".equals(neededRune)) {
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (3)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/barrows/BarrowsScript.java(14 hunks)runelite-client/src/main/java/net/runelite/client/plugins/microbot/zerozero/bluedragons/BlueDragonsPlugin.java(2 hunks)runelite-client/src/main/java/net/runelite/client/plugins/microbot/zerozero/bluedragons/BlueDragonsScript.java(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/barrows/BarrowsScript.java (4)
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/equipment/Rs2Equipment.java (1)
Rs2Equipment(27-485)runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/player/Rs2Player.java (1)
Rs2Player(67-2062)runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/prayer/Rs2Prayer.java (1)
Rs2Prayer(21-222)
⏰ 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 (8)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/zerozero/bluedragons/BlueDragonsPlugin.java (1)
10-11: Anti-ban imports look good and scoped.New imports are minimal and only used in this class. No conflicts detected.
runelite-client/src/main/java/net/runelite/client/plugins/microbot/zerozero/bluedragons/BlueDragonsScript.java (1)
399-399: Whitespace-only change.No functional changes; safe to include.
runelite-client/src/main/java/net/runelite/client/plugins/microbot/barrows/BarrowsScript.java (6)
146-146: Boolean condition simplification improves readability.
if (!inTunnels && !shouldBank)is clearer and equivalent to the previous check.
238-244: Parameterized prayer activation is clearer and safer.Switching to
activatePrayer(brother.getWhatToPray())removes the hidden dependency onNeededPrayerand makes intent explicit at the call site.
279-279: Centralized fight orchestration viacheckForAndFightBrother(config)is a solid refactor.Good consolidation; reduces duplication and tightens the combat flow around a single entry point.
293-306: SyncNeededPrayerwith selected tunnel brother before traveling.Assigning
NeededPrayer = brother.getWhatToPray()ahead of tunnel entry keeps anti-pattern helpers consistent if they rely on this field.
1257-1265: Forgotten brew prioritization is correct and avoids waste.Drinking lower-dosed brews first is a sensible inventory-optimization.
1045-1050: No stale call sites detected after renames
- Verified that there are no zero-arg
activatePrayer()usages anywhere in the repo.- Verified that there are no lingering calls to
checkForBrother(...).All existing call sites have been updated to the new signatures.
runelite-client/src/main/java/net/runelite/client/plugins/microbot/barrows/BarrowsScript.java
Show resolved
Hide resolved
Of course; and I'll check it out thank you! |
I see my commits from 2 days ago were also included in this PR. These were already merged. Let me know if I need to fix it; sorry about that.
Summary by CodeRabbit
New Features
Improvements