Skip to content

Comments

AIO Fighter - Fixes and improvements #1445

Merged
chsami merged 7 commits intochsami:developmentfrom
See1Duck:development
Sep 3, 2025
Merged

AIO Fighter - Fixes and improvements #1445
chsami merged 7 commits intochsami:developmentfrom
See1Duck:development

Conversation

@See1Duck
Copy link
Contributor

@See1Duck See1Duck commented Aug 30, 2025

Changelog

LootingParameters: Added eatFoodForSpace option and improved item looting logic.

LootScript: Rolled back breaking changes; added support for checking the "eat for space" setting.

NpcManager: Fixed getClosestLocation to restore original bank item usage after pathfinding.

AttackNpcScript: Improved antiban logic for combat state handling.

FlickerScript: Fixed lastAttack logic by including NPC animation checks for force reset condition.

Summary by CodeRabbit

  • New Features

    • Smarter looting with category handlers (coins, bones, ashes, runes, arrows, untradeables).
    • Combined name- and value-based looting modes with configurable ranges and radius.
    • Optional auto-eat to free inventory space for loot.
  • Bug Fixes

    • More reliable combat handling when antiban logic isn’t active.
    • Improved flick timing by better detecting NPC attack animations.
    • Safer looting with despawn awareness and ownership respect.
    • More consistent pathfinding behavior around temporary settings.
  • Refactor

    • Streamlined looting pipeline for greater consistency and maintainability.

See1Duck and others added 6 commits August 30, 2025 05:29
feat(LootingParameters): add eatFoodForSpace option and improve item looting logic
fix(AttackNpcScript): improve antiban logic for combat state handling
refactor: rollback all the unnecessary changes that broke the looting
add: looting will now check the eat for space setting
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 30, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Refactors looting into a parameterized pipeline with unified filtering in Rs2GroundItem and a new eat-for-space flag. Adjusts combat gating in AttackNpcScript to consider antiban and in-combat state. Broadens FlickerScript reset condition. Temporarily toggles pathfinder’s bank-item usage in Rs2NpcManager with partial restoration coverage.

Changes

Cohort / File(s) Summary
AIO Fighter Combat Logic
runelite-client/src/main/java/net/runelite/client/plugins/microbot/aiofighter/combat/AttackNpcScript.java, .../aiofighter/combat/FlickerScript.java
AttackNpcScript: replaces strict action-cooldown gate with branch: use antiban cooldown when enabled/chance>0, else proceed when Rs2Combat.inCombat(). FlickerScript: resetLastAttack now also forces reset when NPC is animating (animation != -1).
Looting Pipeline Refactor
.../aiofighter/loot/LootScript.java, .../util/grounditem/LootingParameters.java, .../util/grounditem/Rs2GroundItem.java
LootScript: modular, style-based looting; removes old scanning, adds constructor; centralizes space/combat checks; adds category handlers; uses LootingParameters. LootingParameters: adds eatFoodForSpace, Lombok getters/setters. Rs2GroundItem: introduces unified predicate-driven lootWithFilter, ownership/range filters, despawn threshold, space checks (including eat food), and normalized name handling; aligns existing methods to core pipeline.
NPC Pathfinding Toggle
.../util/npc/Rs2NpcManager.java
Temporarily enables ShortestPath pathfinder’s useBankItems during closest-location computation; restores the original value on the main success path; some early returns skip restoration.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant User
  participant LootScript
  participant Rs2GroundItem
  participant Inventory
  participant Antiban as Antiban/Config
  participant World as GroundItems

  User->>LootScript: run()
  LootScript->>Antiban: read looterStyle, params, toggles
  alt Style: Names
    LootScript->>Rs2GroundItem: lootItemsBasedOnNames(params)
  else Style: Value
    LootScript->>Rs2GroundItem: lootItemBasedOnValue(params)
  else Categories
    LootScript->>Rs2GroundItem: lootCoins/lootRunes/... (params)
  end
  Rs2GroundItem->>World: scan items (range/ownership)
  Rs2GroundItem->>Rs2GroundItem: filter by predicate (names/value/category)
  Rs2GroundItem->>Inventory: ensureSpaceFor(item) (may eat food)
  alt Despawn wait needed
    Rs2GroundItem->>World: wait until safe to loot
  end
  Rs2GroundItem-->>LootScript: success/failure
  LootScript->>LootScript: pause other scripts on success
  LootScript-->>User: done
Loading
sequenceDiagram
  autonumber
  participant CombatLoop as AttackNpcScript
  participant Antiban
  participant Rs2Combat

  CombatLoop->>Antiban: check antibanEnabled, actionCooldownChance
  alt antiban enabled & chance > 0
    CombatLoop->>Antiban: proceed only if actionCooldownActive
  else fallback
    CombatLoop->>Rs2Combat: inCombat()?
    alt in combat
      CombatLoop->>CombatLoop: handleItemOnNpcToKill(...)
    end
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Suggested reviewers

  • g-mason0

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: 6

Caution

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

⚠️ Outside diff range comments (1)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/npc/Rs2NpcManager.java (1)

294-337: Fix pathfinder flag leak: restore useBankItems on all paths (use try/finally).

Early returns (no locations/valid centers/coords) bypass the restoration, leaving isUseBankItems enabled globally. Wrap the body in try/finally or restore before each return.

Apply:

 public static MonsterLocation getClosestLocation(String npcName, int minClustering, boolean avoidWilderness) {
-        boolean originalUseBankItems = ShortestPathPlugin.getPathfinderConfig().isUseBankItems();
-        ShortestPathPlugin.getPathfinderConfig().setUseBankItems(true);
+        final var cfg = ShortestPathPlugin.getPathfinderConfig();
+        final boolean originalUseBankItems = cfg.isUseBankItems();
+        cfg.setUseBankItems(true);
         Microbot.log(Level.INFO,"Finding closest location for: " + npcName);
 
-        List<MonsterLocation> allLocations = getNpcLocations(npcName);
-        if (allLocations.isEmpty()) {
-            Microbot.log(Level.INFO,"No locations found for " + npcName);
-            return null;
-        }
+        try {
+            List<MonsterLocation> allLocations = getNpcLocations(npcName);
+            if (allLocations.isEmpty()) {
+                Microbot.log(Level.INFO,"No locations found for " + npcName);
+                return null;
+            }
 
             List<String> allNames = allLocations.stream()
                     .map(MonsterLocation::getLocationName)
                     .collect(Collectors.toList());
             Microbot.log(Level.INFO,"Found " + allLocations.size() + " locations for " + npcName + ": " + String.join(", ", allNames));
 
             List<MonsterLocation> validLocations = allLocations.stream()
                     .filter(loc -> loc.getCoords().size() > minClustering)
                     .filter(loc -> !avoidWilderness || !loc.getLocationName().contains("Wilderness"))
                     .collect(Collectors.toList());
-        if (validLocations.isEmpty()) {
-            Microbot.log(Level.INFO,"No valid locations after filtering for " + npcName);
-            return null;
-        }
+            if (validLocations.isEmpty()) {
+                Microbot.log(Level.INFO,"No valid locations after filtering for " + npcName);
+                return null;
+            }
 
             List<WorldPoint> centers = validLocations.stream()
                     .map(MonsterLocation::getBestClusterCenter)
                     .filter(Objects::nonNull)
                     .collect(Collectors.toList());
-        if (centers.isEmpty()) {
-            Microbot.log(Level.INFO,"Could not compute any centers for " + npcName);
-            return null;
-        }
+            if (centers.isEmpty()) {
+                Microbot.log(Level.INFO,"Could not compute any centers for " + npcName);
+                return null;
+            }
 
             // 6) Find nearest and return
             int idx = Rs2Walker.findNearestAccessibleTarget(centers, true);
             MonsterLocation closest = validLocations.get(idx);
             if (closest.getCoords().isEmpty()) {
                 Microbot.log(Level.INFO,"Closest location had no coords for " + npcName);
                 return null;
             }
 
             Microbot.log(Level.INFO,"Closest location for " + npcName + ": " + closest.getLocationName());
-        ShortestPathPlugin.getPathfinderConfig().setUseBankItems(originalUseBankItems);
-        return closest;
+            return closest;
+        } finally {
+            cfg.setUseBankItems(originalUseBankItems);
+        }
     }
🧹 Nitpick comments (12)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/grounditem/LootingParameters.java (1)

65-75: Constructor wiring looks correct; consider documenting eatFoodForSpace semantics.

Brief Javadoc on when food is eaten (any HP vs only if healing) will avoid misuse.

runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/grounditem/Rs2GroundItem.java (2)

35-35: Clarify despawn threshold units and intent.

Add a comment (ticks, ~600ms per tick) and rationale for 150 to guide tuning.


296-303: Consider adding optional line-of-sight to the base filter.

Previous value-based looting used hasLineOfSight; dropping it may increase misclick/pathing attempts through obstacles. Make LoS an opt-in on LootingParameters or include it here.

runelite-client/src/main/java/net/runelite/client/plugins/microbot/aiofighter/loot/LootScript.java (9)

21-23: Remove empty constructor unless framework requires it

Redundant if no reflective instantiation depends on it.


40-46: Short-circuit after a successful loot to reduce redundant passes

When style is MIXED, both name- and value-based looters run every tick. Consider bailing once one succeeds to save cycles and clicks.


47-53: Category handlers run unconditionally each tick; consider early-exit on success

Have the handlers return boolean and stop further handlers when one loots an item. This reduces overwork and duplicate targeting.


54-56: Log the stack trace for easier diagnosis

Use the logger and include the exception.

-                Microbot.log("Looterscript: " + ex.getMessage());
+                log.error("LootScript error", ex);

62-77: Arrow stack threshold should be configurable

Hardcoding minQuantity=10 can be too rigid. Add a config value (e.g., minArrowStackToLoot) and use it here.


107-108: Remove leading spaces in name filters

Relying on trimming in downstream helpers is fragile; pass clean needles.

-                    " ashes"
+                    "ashes"
-                    " rune"
+                    "rune"

Also applies to: 126-127


139-151: Names arg likely unused for coins/untradables

lootCoins/lootUntradables typically ignore name filters. Keeping dummy strings adds noise.

Also applies to: 157-171


28-28: Consider making the 200 ms tick configurable

Expose as config.lootIntervalMs() to tune load vs responsiveness.


34-36: Replace deprecated Rs2Inventory.getEmptySlots() with emptySlotCount()

Rs2Inventory.getEmptySlots() is defined but marked @deprecated; switch to emptySlotCount() to remove deprecated API usage.

-                if (((Rs2Inventory.isFull() || Rs2Inventory.getEmptySlots() <= minFreeSlots) && !config.eatFoodForSpace()) || (Rs2Player.isInCombat() && !config.toggleForceLoot())) {
+                if (((Rs2Inventory.isFull() || Rs2Inventory.emptySlotCount() <= minFreeSlots) && !config.eatFoodForSpace()) || (Rs2Player.isInCombat() && !config.toggleForceLoot())) {
📜 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 9a9cf66 and 6dc57e7.

📒 Files selected for processing (6)
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/aiofighter/combat/AttackNpcScript.java (2 hunks)
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/aiofighter/combat/FlickerScript.java (1 hunks)
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/aiofighter/loot/LootScript.java (1 hunks)
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/grounditem/LootingParameters.java (5 hunks)
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/grounditem/Rs2GroundItem.java (4 hunks)
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/npc/Rs2NpcManager.java (2 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: Krulvis
PR: chsami/Microbot#1422
File: runelite-client/src/main/java/net/runelite/client/plugins/microbot/aiofighter/combat/BuryScatterScript.java:36-45
Timestamp: 2025-08-23T10:39:13.332Z
Learning: In the AIOFighter BuryScatterScript, when Rs2Magic.canCast() returns true for Sinister Offering (bones) or Demonic Offering (ashes) but there are fewer than 3 items, the script intentionally waits without fallback to accumulate more items for better XP efficiency. Fallback to manual bury/scatter should only occur when the spells cannot be cast.
📚 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/aiofighter/combat/AttackNpcScript.java
🧬 Code graph analysis (3)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/aiofighter/combat/AttackNpcScript.java (1)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/combat/Rs2Combat.java (1)
  • Rs2Combat (27-244)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/aiofighter/loot/LootScript.java (2)
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-2062)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/grounditem/Rs2GroundItem.java (2)
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-2062)
⏰ 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 (5)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/aiofighter/combat/FlickerScript.java (1)

176-178: Ignore forceReset over-trigger concern

resetLastAttack(true) is only called once—in AIOFighterPlugin.java:451 on hitsplat events—with no looping or repeated invocations, so it cannot spam resets during long animations.

Likely an incorrect or invalid review comment.

runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/grounditem/LootingParameters.java (1)

6-12: LGTM: Lombok getters/setters and eatFoodForSpace field added.

Defaulting eatFoodForSpace to false via constructors is sane; public setter allows opt-in.

runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/grounditem/Rs2GroundItem.java (1)

555-565: LGTM: canTakeGroundItem correctly handles stackables vs empty slots.

This helper makes space checks clearer and re-usable.

runelite-client/src/main/java/net/runelite/client/plugins/microbot/aiofighter/loot/LootScript.java (2)

154-171: Terminology consistency: untradable vs untradeable

Config uses “Untradables” while the needle is “untradeable”. Ensure downstream filters don’t rely on this string; otherwise align spelling.


173-201: Parameterized looting via LootingParameters is a solid improvement

Cleaner API surface and centralized filtering/space handling. Nice.

@chsami chsami merged commit ae74da5 into chsami:development Sep 3, 2025
1 of 2 checks passed
@chsami chsami mentioned this pull request Sep 3, 2025
@coderabbitai coderabbitai bot mentioned this pull request Sep 17, 2025
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.

3 participants