Skip to content

Comments

feat(Rs2Cannon): Added pickup and start for cannon fix(Rs2Equipment): doInvoke with option and target#1579

Closed
Sorries wants to merge 2 commits intochsami:mainfrom
Sorries:development
Closed

feat(Rs2Cannon): Added pickup and start for cannon fix(Rs2Equipment): doInvoke with option and target#1579
Sorries wants to merge 2 commits intochsami:mainfrom
Sorries:development

Conversation

@Sorries
Copy link

@Sorries Sorries commented Oct 20, 2025

  • Added pickup and start for cannon ( the start should be incorporated within qolCannonScript before refill() )
  • Fix the NewMenuEntry when doInvoke as old one would set target as ""

fix(Rs2Equipment): doInvoke with option and target
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 20, 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

This PR modifies equipment and cannon interaction handling. In Rs2Equipment.java, the NewMenuEntry constructor calls are updated to pass explicit action and target string parameters instead of using positional parameters with item names, and the unEquip logic now uses a capitalized "Remove" string. In Rs2Cannon.java, two new public static methods—pickup() and start()—are added to handle cannon pickup and firing operations with attempt limits and position validation, plus an import for VarPlayerID is added and the repair() method receives an additional sleepUntil call.

Possibly related PRs

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The pull request title specifically references both major components of the changeset: the Rs2Cannon additions (pickup and start methods) and the Rs2Equipment fix (doInvoke with option and target). The title directly corresponds to the two primary file modifications described in the raw summary and aligns with the stated objectives. While the title attempts to cover both changes in a single line, making it somewhat lengthy, it is specific and descriptive rather than vague or generic, and clearly communicates what was changed.
Description Check ✅ Passed The pull request description is clearly related to the changeset, explicitly mentioning both the cannon pickup and start functionality additions as well as the NewMenuEntry fix when using doInvoke. The description provides context around these changes, including a note about where the cannon start method should be incorporated and clarification about the target parameter issue being fixed. The description is not vague and meaningfully conveys information about what was changed.

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

Comment @coderabbitai help to get the list of available commands and usage tips.

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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7d0eefa and ef604ef.

📒 Files selected for processing (2)
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/equipment/Rs2Equipment.java (2 hunks)
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/gameobject/Rs2Cannon.java (3 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/**/*.java

📄 CodeRabbit inference engine (AGENTS.md)

runelite-client/src/main/java/net/runelite/client/plugins/microbot/**/*.java: Place all gameplay automation code under runelite-client/src/main/java/net/runelite/client/plugins/microbot
Prefix configuration interfaces with the plugin name (e.g., ExampleConfig) within microbot plugins

Files:

  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/gameobject/Rs2Cannon.java
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/equipment/Rs2Equipment.java
runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/**/*.java

📄 CodeRabbit inference engine (AGENTS.md)

Put shared helpers under .../microbot/util

Files:

  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/gameobject/Rs2Cannon.java
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/equipment/Rs2Equipment.java
**/*.java

📄 CodeRabbit inference engine (AGENTS.md)

**/*.java: Use tabs for indentation, follow the brace placement style exemplified in MicrobotPlugin.java, and keep lines under 120 characters
Use UpperCamelCase for types and lowerCamelCase for members

Files:

  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/gameobject/Rs2Cannon.java
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/equipment/Rs2Equipment.java
🧠 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/util/gameobject/Rs2Cannon.java

Comment on lines 100 to 102
Microbot.pauseAllScripts.compareAndSet(true, false);
return true;
}
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

pickup() always returns true even if pickup failed.

If attempts exhaust or not enough slots, the method still returns true. Return success based on the cannon actually disappearing.

-        Microbot.pauseAllScripts.compareAndSet(true, false);
-        return true;
+        Microbot.pauseAllScripts.compareAndSet(true, false);
+        return !Rs2GameObject.exists(cannon.getId());
📝 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
Microbot.pauseAllScripts.compareAndSet(true, false);
return true;
}
Microbot.pauseAllScripts.compareAndSet(true, false);
return !Rs2GameObject.exists(cannon.getId());
}
🤖 Prompt for AI Agents
In
runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/gameobject/Rs2Cannon.java
around lines 100-102, the pickup() method always returns true even when pickup
fails; change the logic to return true only when the cannon is actually removed
from the world (e.g., wait/poll until the cannon game object is no longer
present or inventory/cannon-slot state confirms pickup) and return false when
attempts are exhausted or there aren’t enough inventory slots; keep the existing
pause/resume calls but use a success flag based on the disappearance check and
ensure timeouts/attempt limits cause a false return.

Comment on lines +116 to +123
WorldArea cannonLocation = new WorldArea(
cannon.getWorldLocation().getX() - 1,
cannon.getWorldLocation().getY() - 1,
3, 3,
cannon.getWorldLocation().getPlane()
);
if (!cannonLocation.toWorldPoint().equals(CannonPlugin.getCannonPosition().toWorldPoint())) return false;
int attempts = 0;
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 | 🟠 Major

Same center-vs-corner mismatch in start().

The position check compares the area’s SW corner, not the center.

         WorldArea cannonLocation = new WorldArea(
                 cannon.getWorldLocation().getX() - 1,
                 cannon.getWorldLocation().getY() - 1,
                 3, 3,
                 cannon.getWorldLocation().getPlane()
         );
-        if (!cannonLocation.toWorldPoint().equals(CannonPlugin.getCannonPosition().toWorldPoint())) return false;
+        var sw = cannonLocation.toWorldPoint();
+        var center = new net.runelite.api.coords.WorldPoint(sw.getX() + 1, sw.getY() + 1, sw.getPlane());
+        if (!center.equals(CannonPlugin.getCannonPosition().toWorldPoint())) return false;
📝 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
WorldArea cannonLocation = new WorldArea(
cannon.getWorldLocation().getX() - 1,
cannon.getWorldLocation().getY() - 1,
3, 3,
cannon.getWorldLocation().getPlane()
);
if (!cannonLocation.toWorldPoint().equals(CannonPlugin.getCannonPosition().toWorldPoint())) return false;
int attempts = 0;
WorldArea cannonLocation = new WorldArea(
cannon.getWorldLocation().getX() - 1,
cannon.getWorldLocation().getY() - 1,
3, 3,
cannon.getWorldLocation().getPlane()
);
var sw = cannonLocation.toWorldPoint();
var center = new net.runelite.api.coords.WorldPoint(sw.getX() + 1, sw.getY() + 1, sw.getPlane());
if (!center.equals(CannonPlugin.getCannonPosition().toWorldPoint())) return false;
int attempts = 0;
🤖 Prompt for AI Agents
In
runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/gameobject/Rs2Cannon.java
around lines 116 to 123, the area-to-position comparison uses
cannonLocation.toWorldPoint(), which yields the SW corner, so the equality check
is comparing corners instead of centers; change the comparison to use the area's
center (e.g., getCentralWorldPoint() or compute x+1,y+1 for a 3x3 area) and
compare that center WorldPoint to
CannonPlugin.getCannonPosition().toWorldPoint(); update the conditional
accordingly so it returns false only when the centers differ.

Comment on lines +124 to +135
while (Microbot.getClientThread().runOnClientThreadOptional(() -> Microbot.getClient().getVarpValue(VarPlayerID.MCANNONMULTI)).orElse(0) == 0 && attempts < 3){
Microbot.log("Starting Cannon");
Rs2GameObject.interact(cannon, "Fire");
sleepUntil(()-> Microbot.getClientThread().runOnClientThreadOptional(() -> Microbot.getClient().getVarpValue(VarPlayerID.MCANNONMULTI)).orElse(0) == 1048576);
sleep(250);
if (Microbot.getClientThread().runOnClientThreadOptional(() -> Microbot.getClient().getVarpValue(VarPlayerID.MCANNONMULTI)).orElse(0) == 1048576){
return true;
}
attempts++;
}
return false;
}
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 | 🟠 Major

start() lacks pause/unpause symmetry and early return inside loop complicates it.

Other cannon ops pauseAllScripts; start() should too, without leaking the paused state.

-        int attempts = 0;
-        while (Microbot.getClientThread().runOnClientThreadOptional(() -> Microbot.getClient().getVarpValue(VarPlayerID.MCANNONMULTI)).orElse(0) == 0 && attempts < 3){
-            Microbot.log("Starting Cannon");
-            Rs2GameObject.interact(cannon, "Fire");
-            sleepUntil(()-> Microbot.getClientThread().runOnClientThreadOptional(() -> Microbot.getClient().getVarpValue(VarPlayerID.MCANNONMULTI)).orElse(0) == 1048576);
-            sleep(250);
-            if (Microbot.getClientThread().runOnClientThreadOptional(() -> Microbot.getClient().getVarpValue(VarPlayerID.MCANNONMULTI)).orElse(0) == 1048576){
-                return true;
-            }
-            attempts++;
-        }
-        return false;
+        Microbot.pauseAllScripts.compareAndSet(false, true);
+        boolean started = false;
+        int attempts = 0;
+        while (Microbot.getClientThread().runOnClientThreadOptional(() ->
+                Microbot.getClient().getVarpValue(VarPlayerID.MCANNONMULTI)).orElse(0) == 0 && attempts < 3) {
+            Microbot.log("Starting Cannon");
+            Rs2GameObject.interact(cannon, "Fire");
+            sleepUntil(() -> Microbot.getClientThread().runOnClientThreadOptional(() ->
+                    Microbot.getClient().getVarpValue(VarPlayerID.MCANNONMULTI)).orElse(0) == 1048576);
+            sleep(250);
+            started = Microbot.getClientThread().runOnClientThreadOptional(() ->
+                    Microbot.getClient().getVarpValue(VarPlayerID.MCANNONMULTI)).orElse(0) == 1048576;
+            if (started) break;
+            attempts++;
+        }
+        Microbot.pauseAllScripts.compareAndSet(true, false);
+        return started;

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/util/gameobject/Rs2Cannon.java
around lines 124 to 135, start() currently pauses scripts asymmetrically and
returns early from inside the loop which can leak paused state; wrap the whole
start logic with a pause/unpause pair that records whether scripts were already
paused, call Microbot.pauseAllScripts() before the loop, then use try { ... }
finally { if we paused them here then Microbot.unpauseAllScripts(); } and remove
the early return inside the loop (use a success flag or break) so unpause always
runs before returning.

@chsami
Copy link
Owner

chsami commented Oct 20, 2025

Does not meet coding standard

@chsami chsami closed this Oct 20, 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.

2 participants