Skip to content

fix(questhelper): require LoS before direct interaction; default to first available action#1755

Open
runsonmypc wants to merge 1 commit intochsami:developmentfrom
runsonmypc:fix/quester-reachability-walker-fallback
Open

fix(questhelper): require LoS before direct interaction; default to first available action#1755
runsonmypc wants to merge 1 commit intochsami:developmentfrom
runsonmypc:fix/quester-reachability-walker-fallback

Conversation

@runsonmypc
Copy link
Copy Markdown
Contributor

Summary

  • applyNpcStep / applyObjectStep require line-of-sight before direct interaction; Rs2Walker.canReach() alone is insufficient because it pathfinds through closed doors. The walker now handles the door-opening before we click instead of us bouncing on "I can't reach that!".
  • chooseCorrect{Object,NPC,Item}Option fall back to the entity's first non-empty action when step text doesn't match a known verb, instead of returning empty / "use" / "Talk-to" blindly.
  • Null-guard event.getMenuOption() in four MenuOptionClicked subscribers (Rs2Gembag, PouchScript, QuestBankTabInterface, IncantationStep); they were spamming NPEs whenever a programmatic invoke fired with a null option. Also removed a stray System.out.println in PouchScript.

Test plan

  • Run a quest step where the target NPC/object is behind a closed door — verify the walker opens the door before the click instead of repeated "I can't reach that!" failures.
  • Run a quest step where the step text doesn't contain the action verb (e.g., "grab the sword" against an object whose only action is "Take") — verify the correct menu option is used.
  • Confirm the chat box no longer shows Cannot invoke "String.equals"/"contains"/"startsWith" because ... getMenuOption() is null during quest runs.
  • Smoke-test that a normal MenuOptionClicked with a non-null option still triggers the original code paths (gem bag empty/fill, pouch fill/empty, quest bank tab close, Shadow of the Storm incantation).

…irst available action

Three related improvements to the quest helper auto-runner so it stops
clicking through closed doors, picking the wrong menu option, and
crashing other plugins via null MenuOptionClicked events.

Reachability:
- applyNpcStep direct-click now also requires npc.hasLineOfSight().
  Rs2Walker.canReach() pathfinds through closed doors (the walker
  opens them en route), so canReach==true alone doesn't guarantee a
  direct interaction will succeed.
- applyObjectStep walk gate now also fires when LoS to the target is
  blocked, so the walker can route the player past the blocking
  geometry instead of us bouncing on "I can't reach that!".

Menu option selection:
- chooseCorrect{Object,NPC,Item}Option fall back to the entity's
  first non-empty action when no step-text keyword matches, instead
  of returning "" / "use" / "Talk-to" blindly.

Null safety on MenuOptionClicked subscribers:
- Rs2Gembag, PouchScript, QuestBankTabInterface and IncantationStep
  now early-return on null event.getMenuOption(); these previously
  threw NPEs whenever a programmatic menu invoke fired with a null
  option, spamming the chat box with stack traces.
- Removed a stray System.out.println in PouchScript.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: d9b3e324-3da5-4b72-9e78-f02664a34ae0

📥 Commits

Reviewing files that changed from the base of the PR and between 167777b and 869483d.

📒 Files selected for processing (5)
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/pouch/PouchScript.java
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/questhelper/QuestScript.java
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/questhelper/bank/banktab/QuestBankTabInterface.java
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/questhelper/helpers/quests/shadowofthestorm/IncantationStep.java
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/inventory/Rs2Gembag.java

Walkthrough

This pull request addresses null-safety across multiple microbot plugin files and refines interaction logic in the questhelper module. Changes include defensive null checks for event.getMenuOption() in five different files to prevent NullPointerException when menu options are absent. The QuestScript.java file receives the most substantial updates, incorporating line-of-sight validation for NPC targeting, walking-first preference for unreachable objects, and improved fallback logic for action selection across object, NPC, and inventory interactions.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.11% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main changes: requiring line-of-sight before direct interaction and defaulting to first available action when step text doesn't match.
Description check ✅ Passed The description is directly related to the changeset, detailing the null-guard additions, LoS requirement changes, fallback behavior updates, and test plan for verification.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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.

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.

1 participant