Skip to content

Comments

Stop on no runes#1473

Merged
chsami merged 5 commits intochsami:developmentfrom
heap-overfl0w:stop-on-no-runes
Sep 4, 2025
Merged

Stop on no runes#1473
chsami merged 5 commits intochsami:developmentfrom
heap-overfl0w:stop-on-no-runes

Conversation

@heap-overfl0w
Copy link
Contributor

  • Current AIO magic implementation only showed a log when out of runes but did not properly shutdown. It will now shutdown when out of runes.

…quirements satisfied to do so.

Fixed a deprecated API call with Simon Templeton by using Rs2NpcModel instead.
Handled issue where the banking branch tried to withdraw “gems” even when none were required for things like Unstrung symbols and Tiaras.
…s but did not properly shutdown. It will now shutdown when out of runes.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 4, 2025

Walkthrough

This PR updates PyramidCourse to import Rs2NpcModel/Rs2Magic, switches Rs2Inventory.useItemOnNpc to accept Rs2NpcModel, and adds Humidify-based handling for empty waterskins. JewelryScript changes a gem-null check to use Gem.NONE. Jewelry enum gains TIARA and UNSTRUNG_SYMBOL. AIOMagic adds SpinFlaxScript wiring and a new MagicActivity SPINFLAX, plus a new SpinFlaxScript class. Multiple magic scripts add pre-cast rune checks with user messages and early shutdowns (AlchScript, SplashScript, StunAlchScript, StunTeleAlchScript, TeleAlchScript). Thieving adds Fortis Gem stall support (enum, mapper, model) and removes a debug print.

Possibly related PRs

✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/crafting/jewelry/JewelryScript.java (3)

451-465: isAlching() wrongly returns true when rune pouch is missing.

This short-circuits into ALCHING without required runes/pouch, causing a spin. Fix the readiness predicate.

-        return notedJewelryAmount <= natureRuneAmount || (plugin.isUseRunePouch() && !Rs2Inventory.hasRunePouch());
+        // Ready only if we have enough runes; if using a pouch, it must be present
+        return notedJewelryAmount <= natureRuneAmount
+                && (!plugin.isUseRunePouch() || Rs2Inventory.hasRunePouch());

333-342: Add pre-cast “stop on no runes” guard in ALCHING.

Without a pre-check, the loop can keep attempting casts when out of runes. Shut down immediately to match the PR objective.

                         Rs2ItemModel notedJewelry = Rs2Inventory.get(plugin.getJewelry().getItemID() + 1);
                         if (notedJewelry.getSlot() != 11) {
                             Rs2Inventory.moveItemToSlot(notedJewelry, 11);
                             return;
                         }
 
+                        // Stop immediately if out of nature runes
+                        int availableNats = getNatureRunesInInventory();
+                        if (availableNats <= 0 || (plugin.isUseRunePouch() && !Rs2Inventory.hasRunePouch())) {
+                            Microbot.showMessage("Out of nature runes. Stopping.");
+                            shutdown();
+                            return;
+                        }
+
                         Rs2Magic.alch(notedJewelry);

419-428: Operator precedence bug in hasFinishedCrafting().

Ternary binds to hasItem && hasNoGem, so the left-hand hasItem is ignored when hasNoGem is false. This can incorrectly mark crafting as finished.

-        return Rs2Inventory.hasItem(plugin.getJewelry().getItemID()) 
-                && hasNoGem ? !hasCraftingItem : !hasCraftingItem && !hasCutGem;
+        return Rs2Inventory.hasItem(plugin.getJewelry().getItemID())
+                && (hasNoGem ? !hasCraftingItem : (!hasCraftingItem && !hasCutGem));
🧹 Nitpick comments (1)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/magic/aiomagic/scripts/TeleAlchScript.java (1)

79-83: Check teleport runes before alching to avoid a “stray” alch when tele runes are out

Small QoL: pre-check tele runes before alch so we don’t alch an item and then immediately shut down on tele runes.

Apply:

@@
-                        Rs2Magic.alch(alchItem, 100, 150);
+                        // Ensure we have tele runes before consuming an alch
+                        if (!Rs2Magic.hasRequiredRunes(plugin.getTeleportSpell().getRs2Spell())) {
+                            Microbot.showMessage("Out of runes for " + plugin.getTeleportSpell().name());
+                            shutdown();
+                            return;
+                        }
+                        Rs2Magic.alch(alchItem, 100, 150);
@@
-                        if (!Rs2Magic.hasRequiredRunes(plugin.getTeleportSpell().getRs2Spell())) {
-                            Microbot.showMessage("Out of runes for " + plugin.getTeleportSpell().name());
-                            shutdown();
-                            return;
-                        }
+                        // (moved pre-check above)
📜 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 19fa74d and 3d8e567.

📒 Files selected for processing (16)
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/agility/courses/PyramidCourse.java (3 hunks)
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/crafting/jewelry/JewelryScript.java (1 hunks)
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/crafting/jewelry/enums/Jewelry.java (1 hunks)
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/magic/aiomagic/AIOMagicPlugin.java (2 hunks)
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/magic/aiomagic/enums/MagicActivity.java (1 hunks)
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/magic/aiomagic/scripts/AlchScript.java (1 hunks)
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/magic/aiomagic/scripts/SpinFlaxScript.java (1 hunks)
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/magic/aiomagic/scripts/SplashScript.java (1 hunks)
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/magic/aiomagic/scripts/StunAlchScript.java (1 hunks)
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/magic/aiomagic/scripts/StunTeleAlchScript.java (2 hunks)
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/magic/aiomagic/scripts/TeleAlchScript.java (2 hunks)
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/magic/aiomagic/scripts/TeleportScript.java (1 hunks)
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/thieving/stalls/StallThievingScript.java (0 hunks)
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/thieving/stalls/constants/ThievingSpot.java (1 hunks)
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/thieving/stalls/constants/ThievingSpotMapper.java (2 hunks)
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/thieving/stalls/model/FortisGemStallThievingSpot.java (1 hunks)
💤 Files with no reviewable changes (1)
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/thieving/stalls/StallThievingScript.java
🧰 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/agility/courses/PyramidCourse.java
🧬 Code graph analysis (8)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/thieving/stalls/model/FortisGemStallThievingSpot.java (3)
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/player/Rs2Player.java (1)
  • Rs2Player (67-2070)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/magic/aiomagic/scripts/TeleAlchScript.java (1)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/magic/Rs2Magic.java (1)
  • Rs2Magic (44-608)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/magic/aiomagic/scripts/StunAlchScript.java (1)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/magic/Rs2Magic.java (1)
  • Rs2Magic (44-608)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/magic/aiomagic/scripts/TeleportScript.java (1)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/magic/Rs2Magic.java (1)
  • Rs2Magic (44-608)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/magic/aiomagic/scripts/SplashScript.java (1)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/magic/Rs2Magic.java (1)
  • Rs2Magic (44-608)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/magic/aiomagic/scripts/StunTeleAlchScript.java (1)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/magic/Rs2Magic.java (1)
  • Rs2Magic (44-608)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/magic/aiomagic/scripts/SpinFlaxScript.java (3)
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/magic/Rs2Magic.java (1)
  • Rs2Magic (44-608)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/player/Rs2Player.java (1)
  • Rs2Player (67-2070)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/agility/courses/PyramidCourse.java (3)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/magic/Rs2Magic.java (1)
  • Rs2Magic (44-608)
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)
🔇 Additional comments (14)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/magic/aiomagic/scripts/AlchScript.java (1)

65-69: LGTM: early shutdown on rune depletion is correct

User-visible message + shutdown() prevents tight-looping when out of runes. Matches PR intent.

runelite-client/src/main/java/net/runelite/client/plugins/microbot/magic/aiomagic/enums/MagicActivity.java (1)

11-12: I've provided a script to list and inspect MagicActivity.java and all its usages; this will reveal any ordinal-based indexing, serialization, or switch statements to update for the new SPINFLAX constant.

runelite-client/src/main/java/net/runelite/client/plugins/microbot/magic/aiomagic/scripts/StunAlchScript.java (1)

54-63: LGTM: consistent early-out for missing alch/stun runes

Clear user messages and shutdown() on insufficiency for both spells. Prevents wasting ticks and aligns with the PR goal.

runelite-client/src/main/java/net/runelite/client/plugins/microbot/magic/aiomagic/scripts/TeleAlchScript.java (1)

53-55: LGTM: alch rune depletion now shuts down cleanly

User message + shutdown() is consistent with the new policy.

runelite-client/src/main/java/net/runelite/client/plugins/microbot/magic/aiomagic/scripts/StunTeleAlchScript.java (2)

52-63: Pre-checks may overcount runes if default filter includes bank/combo

Same caveat as TeleportScript: confirm hasRequiredRunes(...) is scoped to accessible runes only (inventory/equipment/rune pouch). Otherwise the script may not shut down when it should.


96-100: LGTM: early stop on missing teleport runes

The pre-check with user message + shutdown aligns with the PR goal and prevents wasted actions.

runelite-client/src/main/java/net/runelite/client/plugins/microbot/agility/courses/PyramidCourse.java (3)

19-22: LGTM: imports for Rs2NpcModel/Rs2Magic/MagicAction

Necessary for the new APIs and Humidify flow.


1163-1163: LGTM: migrate to Rs2NpcModel-based API

Switching to useItemOnNpc(int, Rs2NpcModel) avoids the deprecated overload and matches current utilities.


1205-1234: LGTM: Humidify handling when all waterskins are empty

The cast-and-wait flow is reasonable; fallback to drop on no-cast keeps the course moving.

runelite-client/src/main/java/net/runelite/client/plugins/microbot/thieving/stalls/constants/ThievingSpotMapper.java (1)

18-20: LGTM: Fortis Gem stall mapping added correctly.

Mapping and DI field look consistent with the new enum and model.

runelite-client/src/main/java/net/runelite/client/plugins/microbot/thieving/stalls/constants/ThievingSpot.java (1)

7-9: LGTM: New enum value.

FORTIS_GEM_STALL addition is consistent with mapper/model wiring.

runelite-client/src/main/java/net/runelite/client/plugins/microbot/magic/aiomagic/AIOMagicPlugin.java (1)

114-151: LGTM: Activity wiring and shutdown coverage.

SPINFLAX start/stop hooks look correct; shutdown now covers stunTeleAlch and spinFlax safely.

runelite-client/src/main/java/net/runelite/client/plugins/microbot/thieving/stalls/model/FortisGemStallThievingSpot.java (1)

22-41: LGTM: Safe-spot gating and stall interaction look sound

Flow is simple and defensively returns on failure points (walk, lookup, interact). Banking logic is minimal and safe. No blockers from my side.

runelite-client/src/main/java/net/runelite/client/plugins/microbot/magic/aiomagic/scripts/SpinFlaxScript.java (1)

115-119: Nice: Shutdown on rune depletion aligns with PR goal

The CASTING guard cleanly stops the script when runes aren’t sufficient. This directly satisfies “Stop on no runes.”

Comment on lines +18 to 20
TIARA("tiara", ItemID.TIARA, Gem.NONE, ItemID.TIARA_MOULD, JewelryType.SILVER, null, 23),
UNSTRUNG_SYMBOL("holy symbol", ItemID.UNSTRUNG_SYMBOL, Gem.NONE, ItemID.HOLY_MOULD, JewelryType.SILVER, null, 16),
OPAL_RING("opal ring", ItemID.OPAL_RING, Gem.OPAL, ItemID.RING_MOULD, JewelryType.SILVER, EnchantSpell.LEVEL_1, 1),
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Wrong display name for UNSTRUNG_SYMBOL breaks widget clicks.

Crafting widget button is “unstrung symbol”; using “holy symbol” will likely fail selection.

-    UNSTRUNG_SYMBOL("holy symbol", ItemID.UNSTRUNG_SYMBOL, Gem.NONE, ItemID.HOLY_MOULD, JewelryType.SILVER, null, 16),
+    UNSTRUNG_SYMBOL("unstrung symbol", ItemID.UNSTRUNG_SYMBOL, Gem.NONE, ItemID.HOLY_MOULD, JewelryType.SILVER, null, 16),
📝 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
TIARA("tiara", ItemID.TIARA, Gem.NONE, ItemID.TIARA_MOULD, JewelryType.SILVER, null, 23),
UNSTRUNG_SYMBOL("holy symbol", ItemID.UNSTRUNG_SYMBOL, Gem.NONE, ItemID.HOLY_MOULD, JewelryType.SILVER, null, 16),
OPAL_RING("opal ring", ItemID.OPAL_RING, Gem.OPAL, ItemID.RING_MOULD, JewelryType.SILVER, EnchantSpell.LEVEL_1, 1),
TIARA("tiara", ItemID.TIARA, Gem.NONE, ItemID.TIARA_MOULD, JewelryType.SILVER, null, 23),
UNSTRUNG_SYMBOL("unstrung symbol", ItemID.UNSTRUNG_SYMBOL, Gem.NONE, ItemID.HOLY_MOULD, JewelryType.SILVER, null, 16),
OPAL_RING("opal ring", ItemID.OPAL_RING, Gem.OPAL, ItemID.RING_MOULD, JewelryType.SILVER, EnchantSpell.LEVEL_1, 1),
🤖 Prompt for AI Agents
In
runelite-client/src/main/java/net/runelite/client/plugins/microbot/crafting/jewelry/enums/Jewelry.java
around lines 18 to 20, the UNSTRUNG_SYMBOL enum uses the display name "holy
symbol" which doesn't match the crafting widget text "unstrung symbol" and
prevents correct widget clicks; update the enum entry to use the exact display
name "unstrung symbol" (replace "holy symbol") so selection matches the UI, and
run a quick search for any other references expecting the old display name to
update them accordingly.

Comment on lines +69 to +84
boolean hasAstralInv = Rs2Inventory.hasItem(Runes.ASTRAL.getItemId());
boolean hasNatureInv = Rs2Inventory.hasItem(Runes.NATURE.getItemId());
boolean hasAirInv = Rs2Inventory.hasItem(Runes.AIR.getItemId());

boolean hasAstralBank = Rs2Bank.hasItem(Runes.ASTRAL.getItemId());
boolean hasNatureBank = Rs2Bank.hasItem(Runes.NATURE.getItemId());
boolean hasAirBank = Rs2Bank.hasItem(Runes.AIR.getItemId());

if (!hasAstralBank && !hasAstralInv) { Microbot.showMessage("Astral runes not found in bank."); shutdown(); return; }
if (!hasNatureBank && !hasNatureInv) { Microbot.showMessage("Nature runes not found in bank."); shutdown(); return; }
if (!hasAirBank && !hasAirInv) { Microbot.showMessage("Air runes not found in bank."); shutdown(); return; }

if (hasAstralBank) { if (!Rs2Bank.withdrawAll(Runes.ASTRAL.getItemId())) return; Rs2Inventory.waitForInventoryChanges(1200); }
if (hasNatureBank) { if (!Rs2Bank.withdrawAll(Runes.NATURE.getItemId())) return; Rs2Inventory.waitForInventoryChanges(1200); }
if (hasAirBank) { if (!Rs2Bank.withdrawAll(Runes.AIR.getItemId())) return; Rs2Inventory.waitForInventoryChanges(1200); }

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Critical: False shutdown when runes are in rune pouch

The early rune checks only consider inventory/bank and ignore the rune pouch. Players with runes in the pouch will get an unnecessary shutdown despite being able to cast. Use Rs2Magic.hasRequiredRunes(...) (which already accounts for inventory/equipment/pouch) to decide shutdown vs. withdrawal.

Apply this diff to make the bank step pouch-aware and only stop when neither local sources nor bank can satisfy runes:

-                        boolean hasAstralInv = Rs2Inventory.hasItem(Runes.ASTRAL.getItemId());
-                        boolean hasNatureInv = Rs2Inventory.hasItem(Runes.NATURE.getItemId());
-                        boolean hasAirInv = Rs2Inventory.hasItem(Runes.AIR.getItemId());
-
+                        boolean haveRunesLocal = Rs2Magic.hasRequiredRunes(Rs2Spells.SPIN_FLAX);
                         boolean hasAstralBank = Rs2Bank.hasItem(Runes.ASTRAL.getItemId());
                         boolean hasNatureBank = Rs2Bank.hasItem(Runes.NATURE.getItemId());
                         boolean hasAirBank = Rs2Bank.hasItem(Runes.AIR.getItemId());
 
-                        if (!hasAstralBank && !hasAstralInv) { Microbot.showMessage("Astral runes not found in bank."); shutdown(); return; }
-                        if (!hasNatureBank && !hasNatureInv) { Microbot.showMessage("Nature runes not found in bank."); shutdown(); return; }
-                        if (!hasAirBank && !hasAirInv) { Microbot.showMessage("Air runes not found in bank."); shutdown(); return; }
+                        if (!haveRunesLocal && !hasAstralBank && !hasNatureBank && !hasAirBank) {
+                            Microbot.showMessage("Spin Flax: no required runes in inventory/equipment/pouch or bank. Stopping.");
+                            shutdown();
+                            return;
+                        }
 
                         if (hasAstralBank) { if (!Rs2Bank.withdrawAll(Runes.ASTRAL.getItemId())) return; Rs2Inventory.waitForInventoryChanges(1200); }
                         if (hasNatureBank) { if (!Rs2Bank.withdrawAll(Runes.NATURE.getItemId())) return; Rs2Inventory.waitForInventoryChanges(1200); }
                         if (hasAirBank)    { if (!Rs2Bank.withdrawAll(Runes.AIR.getItemId())) return;    Rs2Inventory.waitForInventoryChanges(1200); }

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In
runelite-client/src/main/java/net/runelite/client/plugins/microbot/magic/aiomagic/scripts/SpinFlaxScript.java
around lines 69 to 84, the code checks only inventory and bank for
astral/nature/air runes and performs a shutdown even if the player has runes in
the pouch; replace those inventory-only prechecks with a single check using
Rs2Magic.hasRequiredRunes(...) which accounts for inventory, equipment and rune
pouch to decide whether to continue or shutdown; if
Rs2Magic.hasRequiredRunes(...) returns false then check the bank for required
runes and withdraw them (as the current withdraw calls do), otherwise skip
shutdown/withdrawal because the pouch covers the requirement; ensure the
shutdown occurs only when neither Rs2Magic.hasRequiredRunes(...) nor the bank
can supply the runes.

Comment on lines +43 to +47
if (!Rs2Magic.canCast(plugin.getCombatSpell().getMagicAction())) {
Microbot.showMessage("Out of runes for " + plugin.getCombatSpell().name());
shutdown();
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Don’t use canCast() to gate “out of runes” shutdown; it conflates UI/spellbook/level with rune shortage

canCast(MagicAction) can fail for reasons other than runes (e.g., wrong spellbook/UI state), causing premature shutdown with a misleading message. Check runes explicitly.

Use a rune-only check and keep autocast setup logic intact:

-                if (!Rs2Magic.canCast(plugin.getCombatSpell().getMagicAction())) {
-                    Microbot.showMessage("Out of runes for " + plugin.getCombatSpell().name());
-                    shutdown();
-                    return;
-                }
+                if (!Rs2Magic.hasRequiredRunes(plugin.getCombatSpell().getRs2Spell())) {
+                    Microbot.showMessage("Out of runes for " + plugin.getCombatSpell().name());
+                    shutdown();
+                    return;
+                }
📝 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
if (!Rs2Magic.canCast(plugin.getCombatSpell().getMagicAction())) {
Microbot.showMessage("Out of runes for " + plugin.getCombatSpell().name());
shutdown();
return;
}
if (!Rs2Magic.hasRequiredRunes(plugin.getCombatSpell().getRs2Spell())) {
Microbot.showMessage("Out of runes for " + plugin.getCombatSpell().name());
shutdown();
return;
}

Comment on lines +48 to +52
if (!Rs2Magic.hasRequiredRunes(plugin.getTeleportSpell().getRs2Spell())) {
Microbot.showMessage("Out of runes for " + plugin.getTeleportSpell().name());
shutdown();
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Confirm rune source filter; avoid counting bank/combo runes in the stop check

If hasRequiredRunes(Spell) uses a default filter that includes bank/combo runes, this pre-check can return true while the cast still fails, preventing the intended shutdown. Ensure the check is restricted to inventory/equipment/rune pouch only, or verify that the default filter already excludes bank/combo sources.

Run to locate the default filter and its composition:


🏁 Script executed:

#!/bin/bash
rg -nP "DEFAULT_RUNE_FILTER|enum\s+RuneFilter|class\s+RuneFilter" -C2 runelite-client/src/main/java
rg -n "hasRequiredRunes\\(Spell" runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/magic/Rs2Magic.java -n -C3

Length of output: 5309


🏁 Script executed:

#!/bin/bash
sed -n '1,200p' runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/magic/RuneFilter.java

Length of output: 615


Exclude combo runes in the pre-cast check
DEFAULT_RUNE_FILTER has includeComboRunes=true, so hasRequiredRunes(spell) may count combo runes and return true even if the cast will fail. Change the check to use a filter that disables combo runes:

RuneFilter filter = RuneFilter.builder()
    .includeComboRunes(false)
    .build();

if (!Rs2Magic.hasRequiredRunes(plugin.getTeleportSpell().getRs2Spell(), filter)) {
    Microbot.showMessage("Out of runes for " + plugin.getTeleportSpell().name());
    shutdown();
    return;
}
🤖 Prompt for AI Agents
In
runelite-client/src/main/java/net/runelite/client/plugins/microbot/magic/aiomagic/scripts/TeleportScript.java
around lines 48 to 52, the pre-cast rune check uses
Rs2Magic.hasRequiredRunes(spell) which uses DEFAULT_RUNE_FILTER
(includeComboRunes=true) and can falsely pass when only combo runes are
available; fix it by creating a RuneFilter with includeComboRunes set to false
and call Rs2Magic.hasRequiredRunes(plugin.getTeleportSpell().getRs2Spell(),
filter) so the check ignores combo runes and accurately detects missing runes,
then keep the existing Microbot.showMessage/shutdown flow.

@chsami chsami merged commit 5319a9d into chsami:development Sep 4, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants