Skip to content

Comments

Added Offensive Combat Prayers and Max Random Delays for Equipping Combat Gear#1515

Closed
SamBunker wants to merge 1 commit intochsami:mainfrom
SamBunker:combathotkeys.1.7.4
Closed

Added Offensive Combat Prayers and Max Random Delays for Equipping Combat Gear#1515
SamBunker wants to merge 1 commit intochsami:mainfrom
SamBunker:combathotkeys.1.7.4

Conversation

@SamBunker
Copy link
Contributor

Added offensive prayers hotkeys with dropdown menus for people to choose which offensive prayers for melee, range, and mage to use.

Added a max equipment delay setting with a default delay of 500 ms to randomize each equipped item. Originally, it seems each item equipped in the list of items had the same timing with little to no variation in timing.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 12, 2025

Walkthrough

This change adds Offensive Prayers and Defensive Prayers sections to CombatHotkeysConfig. It introduces enums (MeleePrayerOption, RangedPrayerOption, MagicPrayerOption) mapping to Rs2PrayerEnum, plus new keybind config items for offensive melee/range/magic and default selections. It adds Gear Equip Settings with a maxDelay (ms) config and reorders gearSetup sections. CombatHotkeysPlugin now handles new offensive prayer hotkeys, consuming events and toggling prayers based on config. equipGear is made instance-level and inserts a randomized delay (0 to maxDelay) after each item equip using Rs2Random.between and sleep.

Possibly related PRs

Pre-merge checks (2 passed, 1 warning)

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 17.65% 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 title succinctly and accurately captures the two primary changes in the PR: adding offensive combat prayer hotkeys and adding a configurable max random delay for equipping gear. It is specific, on-topic, and easy for teammates to scan in history.
Description Check ✅ Passed The PR description directly describes the main changes (offensive prayer hotkeys with dropdown selection and a default 500 ms max equipment delay to randomize equip timing) and matches the changeset content. It is on-topic and sufficiently informative for this lenient check.

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.

✨ 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

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

🧹 Nitpick comments (3)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/combathotkeys/CombatHotkeysPlugin.java (2)

91-99: Avoid multi-toggle if the same key is bound to multiple offensive prayers

Use else-if to ensure only one offensive prayer toggles per keypress if users accidentally reuse a key.

-        if (config.offensiveRangeKey().matches(e)) {
+        else if (config.offensiveRangeKey().matches(e)) {
             e.consume();
             Rs2Prayer.toggle(config.offensiveRangePrayer().getPrayer());
         }
 
-        if (config.offensiveMagicKey().matches(e)) {
+        else if (config.offensiveMagicKey().matches(e)) {
             e.consume();
             Rs2Prayer.toggle(config.offensiveMagicPrayer().getPrayer());
         }

15-15: Drop Rs2Random import if using Global.sleep(0, maxDelay)

Be consistent with existing utilities and avoid an unused import after the equipGear change.

-import net.runelite.client.plugins.microbot.util.math.Rs2Random;
runelite-client/src/main/java/net/runelite/client/plugins/microbot/combathotkeys/CombatHotkeysConfig.java (1)

319-329: Constrain maxDelay via @range to prevent invalid negatives/extremes

UI-level bounds reduce bad configs and complement the runtime clamp.

     @ConfigItem(
         keyName = "maxDelay",
         name = "Max Equip Delay (ms)",
         description = "Maximum random delay (in milliseconds) between equipping items",
         position = 0,
         section = gearEquipSettings
     )
+    @Range(min = 0, max = 2000)
     default int maxDelay() {
         return 500; // default max delay of 500ms
     }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f4cf2c2 and 5f865a7.

📒 Files selected for processing (2)
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/combathotkeys/CombatHotkeysConfig.java (8 hunks)
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/combathotkeys/CombatHotkeysPlugin.java (4 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/combathotkeys/CombatHotkeysPlugin.java (2)
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/inventory/Rs2Inventory.java (1)
  • Rs2Inventory (46-2324)

Comment on lines +158 to 168
private void equipGear(String gearListConfig) {
String[] itemIDs = gearListConfig.split(",");

for (String value : itemIDs) {
int itemId = Integer.parseInt(value);
Rs2Inventory.equip(itemId);

int delay = Rs2Random.between(0, config.maxDelay());
sleep(delay);
}
}
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

Make equipGear robust: skip blanks, handle parse errors, clamp delay, and use Global.sleep’s randomized overload

Parsing an empty/default gear list ("") or entries with whitespace will throw NumberFormatException. Also clamp negative maxDelay values to avoid invalid ranges. Prefer Global.sleep(0, maxDelay) to consolidate randomness and sleeping.

Apply:

-    private void equipGear(String gearListConfig) {
-        String[] itemIDs = gearListConfig.split(",");
-
-        for (String value : itemIDs) {
-            int itemId = Integer.parseInt(value);
-            Rs2Inventory.equip(itemId);
-
-            int delay = Rs2Random.between(0, config.maxDelay());
-            sleep(delay);
-        }
-    }
+    private void equipGear(String gearListConfig) {
+        if (gearListConfig == null || gearListConfig.isBlank()) {
+            return;
+        }
+        String[] itemIDs = gearListConfig.split(",");
+        final int maxDelay = Math.max(0, config.maxDelay());
+        for (String value : itemIDs) {
+            final String token = value.trim();
+            if (token.isEmpty()) continue;
+            try {
+                int itemId = Integer.parseInt(token);
+                Rs2Inventory.equip(itemId);
+            } catch (NumberFormatException ex) {
+                log.warn("Invalid gear id '{}'; skipping", value);
+            }
+            // uses Global.sleep(start, end) to randomize and sleep safely
+            sleep(0, maxDelay);
+        }
+    }
📝 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
private void equipGear(String gearListConfig) {
String[] itemIDs = gearListConfig.split(",");
for (String value : itemIDs) {
int itemId = Integer.parseInt(value);
Rs2Inventory.equip(itemId);
int delay = Rs2Random.between(0, config.maxDelay());
sleep(delay);
}
}
private void equipGear(String gearListConfig) {
if (gearListConfig == null || gearListConfig.isBlank()) {
return;
}
String[] itemIDs = gearListConfig.split(",");
final int maxDelay = Math.max(0, config.maxDelay());
for (String value : itemIDs) {
final String token = value.trim();
if (token.isEmpty()) continue;
try {
int itemId = Integer.parseInt(token);
Rs2Inventory.equip(itemId);
} catch (NumberFormatException ex) {
log.warn("Invalid gear id '{}'; skipping", value);
}
// uses Global.sleep(start, end) to randomize and sleep safely
sleep(0, maxDelay);
}
}
🤖 Prompt for AI Agents
In
runelite-client/src/main/java/net/runelite/client/plugins/microbot/combathotkeys/CombatHotkeysPlugin.java
around lines 158 to 168, make equipGear robust by trimming and skipping empty
entries from gearListConfig.split(","), wrapping Integer.parseInt in a try/catch
to skip entries that fail to parse (log/debug if desired), clamp
config.maxDelay() to a minimum of 0 before use, and replace the manual
random/delay code with a single call to Global.sleep(0, clampedMaxDelay) to
perform randomized sleeping reliably.

@chsami
Copy link
Owner

chsami commented Sep 13, 2025

Please make a PR to development and not main.

@chsami chsami closed this Sep 13, 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