-
-
Notifications
You must be signed in to change notification settings - Fork 497
Stop on no runes #1473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stop on no runes #1473
Changes from all commits
e75d1a7
5b4e818
9b1bf1c
c3d1adf
3d8e567
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,4 +8,5 @@ public enum MagicActivity { | |
| TELEALCH, | ||
| STUNALCH, | ||
| STUNTELEALCH, // NEW | ||
| SPINFLAX, | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,148 @@ | ||
| package net.runelite.client.plugins.microbot.magic.aiomagic.scripts; | ||
|
|
||
| import net.runelite.api.Skill; | ||
| import net.runelite.api.gameval.ItemID; | ||
| import net.runelite.client.plugins.microbot.Microbot; | ||
| import net.runelite.client.plugins.microbot.Script; | ||
| import net.runelite.client.plugins.microbot.magic.aiomagic.AIOMagicPlugin; | ||
| import net.runelite.client.plugins.microbot.magic.aiomagic.enums.MagicState; | ||
| import net.runelite.client.plugins.microbot.util.antiban.Rs2Antiban; | ||
| import net.runelite.client.plugins.microbot.util.antiban.Rs2AntibanSettings; | ||
| import net.runelite.client.plugins.microbot.util.antiban.enums.Activity; | ||
| import net.runelite.client.plugins.microbot.util.bank.Rs2Bank; | ||
| import net.runelite.client.plugins.microbot.util.inventory.Rs2Inventory; | ||
| import net.runelite.client.plugins.microbot.util.magic.Rs2Magic; | ||
| import net.runelite.client.plugins.microbot.util.magic.Rs2Spells; | ||
| import net.runelite.client.plugins.microbot.util.magic.Runes; | ||
| import net.runelite.client.plugins.microbot.util.player.Rs2Player; | ||
|
|
||
| import javax.inject.Inject; | ||
| import java.util.concurrent.TimeUnit; | ||
|
|
||
| public class SpinFlaxScript extends Script { | ||
|
|
||
| private MagicState state; | ||
| private int castsDone; | ||
|
|
||
| private final AIOMagicPlugin plugin; | ||
|
|
||
| @Inject | ||
| public SpinFlaxScript(AIOMagicPlugin plugin) { | ||
| this.plugin = plugin; | ||
| } | ||
|
|
||
| public boolean run() { | ||
| Microbot.enableAutoRunOn = false; | ||
| Rs2Antiban.resetAntibanSettings(); | ||
| Rs2Antiban.antibanSetupTemplates.applyGeneralBasicSetup(); | ||
| Rs2AntibanSettings.simulateAttentionSpan = true; | ||
| Rs2AntibanSettings.nonLinearIntervals = true; | ||
| Rs2AntibanSettings.contextualVariability = true; | ||
| Rs2AntibanSettings.usePlayStyle = true; | ||
| Rs2Antiban.setActivity(Activity.CASTING_SPIN_FLAX); | ||
|
|
||
| mainScheduledFuture = scheduledExecutorService.scheduleWithFixedDelay(() -> { | ||
| try { | ||
| if (!Microbot.isLoggedIn()) return; | ||
| if (!super.run()) return; | ||
|
|
||
| if (!Rs2Player.getSkillRequirement(Skill.MAGIC, 76)) { | ||
| Microbot.showMessage("Spin Flax requires 76 Magic."); | ||
| shutdown(); | ||
| return; | ||
| } | ||
|
|
||
| if (state == null) { | ||
| state = MagicState.BANKING; | ||
| castsDone = 0; | ||
| } | ||
|
|
||
| switch (state) { | ||
| case BANKING: | ||
| Microbot.status = "Banking: prepare 25 flax"; | ||
| boolean isBankOpen = Rs2Bank.isNearBank(15) ? Rs2Bank.useBank() : Rs2Bank.walkToBankAndUseBank(); | ||
| if (!isBankOpen || !Rs2Bank.isOpen()) return; | ||
|
|
||
| Rs2Bank.depositAll(ItemID.BOW_STRING); | ||
| Rs2Inventory.waitForInventoryChanges(1200); | ||
|
|
||
| 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); } | ||
|
|
||
|
Comment on lines
+69
to
+84
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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); }
🤖 Prompt for AI Agents |
||
| if (!Rs2Bank.hasBankItem(ItemID.FLAX, 1)) { | ||
| Microbot.showMessage("No flax in bank."); | ||
| shutdown(); | ||
| return; | ||
| } | ||
|
|
||
| int empty = Rs2Inventory.emptySlotCount(); | ||
| if (empty < 25) { | ||
| Rs2Bank.depositAll(ItemID.BOW_STRING); | ||
| Rs2Inventory.waitForInventoryChanges(1200); | ||
| empty = Rs2Inventory.emptySlotCount(); | ||
| if (empty < 25) return; // wait next tick | ||
| } | ||
|
|
||
| if (!Rs2Bank.withdrawX(ItemID.FLAX, 25)) return; | ||
| Rs2Inventory.waitForInventoryChanges(1200); | ||
|
|
||
| Rs2Bank.closeBank(); | ||
| castsDone = 0; | ||
| state = MagicState.CASTING; | ||
| break; | ||
|
|
||
| case CASTING: | ||
| Microbot.status = "Casting: Spin Flax (" + castsDone + "/5)"; | ||
|
|
||
| if (!Rs2Inventory.hasItem(ItemID.FLAX)) { | ||
| state = MagicState.BANKING; | ||
| break; | ||
| } | ||
|
|
||
| if (!Rs2Magic.hasRequiredRunes(Rs2Spells.SPIN_FLAX)) { | ||
| Microbot.showMessage("Out of runes for Spin Flax"); | ||
| shutdown(); | ||
| return; | ||
| } | ||
|
|
||
| if (castsDone >= 5) { | ||
| state = MagicState.BANKING; | ||
| break; | ||
| } | ||
|
|
||
| if (!Rs2Magic.cast(Rs2Spells.SPIN_FLAX)) { | ||
| Microbot.log("Unable to cast Spin Flax"); | ||
| state = MagicState.BANKING; | ||
| break; | ||
| } | ||
| Rs2Player.waitForXpDrop(Skill.MAGIC, 10000, false); | ||
| castsDone++; | ||
| break; | ||
| } | ||
|
|
||
| } catch (Exception ex) { | ||
| System.out.println(ex.getMessage()); | ||
| } | ||
| }, 0, 1000, TimeUnit.MILLISECONDS); | ||
| return true; | ||
| } | ||
|
|
||
| @Override | ||
| public void shutdown() { | ||
| Rs2Antiban.resetAntibanSettings(); | ||
| super.shutdown(); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -40,6 +40,12 @@ public boolean run() { | |||||||||||||||||||||
| if (!super.run()) return; | ||||||||||||||||||||||
| long startTime = System.currentTimeMillis(); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if (!Rs2Magic.canCast(plugin.getCombatSpell().getMagicAction())) { | ||||||||||||||||||||||
| Microbot.showMessage("Out of runes for " + plugin.getCombatSpell().name()); | ||||||||||||||||||||||
| shutdown(); | ||||||||||||||||||||||
| return; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
Comment on lines
+43
to
+47
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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
Suggested change
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if (Rs2Magic.getCurrentAutoCastSpell() != plugin.getCombatSpell()) { | ||||||||||||||||||||||
| Rs2Combat.setAutoCastSpell(plugin.getCombatSpell(), false); | ||||||||||||||||||||||
| return; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong display name for UNSTRUNG_SYMBOL breaks widget clicks.
Crafting widget button is “unstrung symbol”; using “holy symbol” will likely fail selection.
📝 Committable suggestion
🤖 Prompt for AI Agents