feat(shortestpath): avoid pathing next to aggressive NPCs (undead trees)#1809
feat(shortestpath): avoid pathing next to aggressive NPCs (undead trees)#1809bgatfa wants to merge 1 commit into
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughAdds a new 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@runelite-client/src/main/java/net/runelite/client/plugins/microbot/shortestpath/pathfinder/CollisionMap.java`:
- Around line 268-279: The reverse walking expansion in
CollisionMap.getReverseNeighbors is still creating unpenalized Nodes, so it
disagrees with the forward neighbor cost model and can let bidirectional
searches prefer hazard-adjacent routes. Update the reverse walking branch to
apply the same dangerous-NPC penalty logic used in the forward expansion,
reusing the same config.isAvoidDangerousNpcs, config.isDangerousAdjacentTile,
targets.contains, and DANGEROUS_TILE_PENALTY checks so both directions evaluate
the edge consistently.
In
`@runelite-client/src/main/java/net/runelite/client/plugins/microbot/shortestpath/ShortestPathConfig.java`:
- Around line 135-146: The config ordering in ShortestPathConfig has a duplicate
position value, making the settings UI order ambiguous. Update the `@ConfigItem`
on avoidDangerousNpcs in the sectionSettings group to use a unique position, and
renumber any following items in that section if needed so each setting has a
distinct order; use the existing useAgilityShortcuts and other nearby config
methods in ShortestPathConfig to locate the affected entries.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: ea23a094-14ec-406c-bfcc-42116aef02bb
⛔ Files ignored due to path filters (1)
runelite-client/src/main/resources/net/runelite/client/plugins/microbot/shortestpath/dangerous_tiles.tsvis excluded by!**/*.tsv
📒 Files selected for processing (3)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/shortestpath/ShortestPathConfig.javarunelite-client/src/main/java/net/runelite/client/plugins/microbot/shortestpath/pathfinder/CollisionMap.javarunelite-client/src/main/java/net/runelite/client/plugins/microbot/shortestpath/pathfinder/PathfinderConfig.java
4f776e7 to
00829cb
Compare
Aggressive NPCs such as the Draynor Manor undead trees attack any player who walks onto a tile next to them (0-3 dmg, aggressive at every combat level). The web walker routes the shortest path straight along the tree line, so long walks take repeated hits and can stall the walker adjacent to a tree. Add an "Avoid dangerous NPCs" pathfinder option (default on): - New dangerous_tiles.tsv lists hazard tiles (the Draynor undead trees). - PathfinderConfig expands each hazard tile to its 8-neighbour aggro ring and exposes isDangerousAdjacentTile(). - CollisionMap applies a g-cost penalty (not a hard block) to stepping into that ring when the option is on, in BOTH the forward (getNeighbors) and reverse (getReverseNeighbors) expansions, so the bidirectional search costs hazard edges consistently and can't pick a hazard-adjacent meeting. Paths keep >=2 tiles from a hazard when a detour exists; a true chokepoint still routes through. The check is a boolean + O(1) set lookup; no client-thread reads. - ShortestPathConfig gains the toggle; the sectionSettings positions are renumbered to stay unique. - Rs2Walker's unreachable-recovery fallback now also respects the ring: the planner avoids hazard tiles, but the runtime recovery click could otherwise park the player next to one and strand it in melee, so the recovery target is stepped back along the path to the nearest non-hazard tile. Data-driven: any hazard can be added by appending tiles to the tsv.
00829cb to
a23c705
Compare
What
Adds an Avoid dangerous NPCs pathfinder option (default on) that
routes the web walker around tiles adjacent to known aggressive-NPC hazards,
so the player isn't attacked while passing. Seeded with the Draynor Manor
undead trees.
Why
Undead trees (Draynor Manor front yard; also Haunted Woods) attack players
who path onto an adjacent tile — 0–3 damage, aggressive regardless of combat
level. The pathfinder draws the shortest route straight along them, so long
walks past Draynor take repeated hits and can stall the walker next to a tree.
How it works
dangerous_tiles.tsv(new resource) lists hazard tiles (x y plane).PathfinderConfigloads them and expands each to its 8-neighbour Chebyshev-1ring (the melee-aggro range);
isDangerousAdjacentTile(packed)exposes it.CollisionMapadds a g-cost penalty (DANGEROUS_TILE_PENALTY, not a block)to stepping into that ring when the option is on, in both the forward
(
getNeighbors) and reverse (getReverseNeighbors) expansions — so thebidirectional search costs hazard edges consistently and can't pick a
hazard-adjacent meeting point. Paths keep ≥2 tiles away when a reasonable
detour exists; a genuine chokepoint still routes through. Hot-loop cost is a
boolean + O(1)
HashSetlookup; no client-thread access.ShortestPathConfig.avoidDangerousNpcs()toggle, defaulttrue(
sectionSettingspositions renumbered to stay unique).Testing
at
dTree=1; option on → path detours todTree≥2with 0/16 combat.Since these NPCs only hit at 1 tile,
dTree≥2means the player is physicallyout of range. Re-run after the review fixes — unchanged.
shortestpathsuite (Tier1 regression, transport, confighash) and
ClientThreadGuardrailTestpass; no new client-thread violations.