Skip to content

refactor(route): improve k-step npc dialog flow in auto-talk and map routing#4194

Open
boscv wants to merge 3 commits intoOpenKore:masterfrom
boscv:portals_update
Open

refactor(route): improve k-step npc dialog flow in auto-talk and map routing#4194
boscv wants to merge 3 commits intoOpenKore:masterfrom
boscv:portals_update

Conversation

@boscv
Copy link
Copy Markdown
Contributor

@boscv boscv commented Mar 21, 2026

Motivation

  • Allow airship portals to specify a rectangular waiting area so NPC boarding can be reliably detected and routed to the correct boarding cell.
  • Improve airship handling so the MapRoute task can move the actor into a free cell in the wait area and wait for the expected broadcast before initiating NPC conversation.
  • Improve handling of NPC conversation sequences that begin with k (approach + talk), so routing and auto-talk remain consistent and avoid duplicate TalkNPC flows.

Description

  • Extend parsePortalsAirship to accept an optional "x1-x2,y1-y2" wait area and populate wait_area on parsed portal entries, while preserving backwards compatibility with legacy quoted steps values.
  • Propagate wait_area into route calculation by adding wait_area to openlist/closelist values in Task::CalcMapRoute, so map solutions carry wait-area metadata.
  • Add _isInsideWaitArea and _pickAirshipWaitPos helpers (with isCellOccupied) in Task::MapRoute to pick a random unoccupied, walkable cell inside the wait area and route there before waiting for broadcast.
  • Update Task::MapRoute airship handling to:
    • match local broadcasts against airship_message;
    • move to a picked wait-area cell if not already inside it;
    • only proceed to NPC talk once a matching broadcast is received (or through existing dialogue steps).
  • Fix same-map wait-area behavior:
    • when already inside wait_area, mark wait_area_positioned immediately instead of trying to pick a different cell;
    • keep retry behavior when selecting/routing to a new wait cell fails.
  • Refactor autoNpcTalk in src/Misc.pm to:
    • replace ad-hoc route checks with _routeActionHasTalkNpcSubtask;
    • resolve sequence from active mapRoute/route through resolveAutoNpcTalkSequence;
    • strip a leading k approach step when appropriate before creating Task::TalkNPC.
  • Add _npcRouteDistancesFromSteps in src/Task/MapRoute.pm and apply it to NPC/airship routing:
    • derive distFromGoal and talk-trigger distance from route steps;
    • for k-prefixed sequences, require exact-tile approach (distFromGoal = 0, talk trigger distance = 0).
  • Update src/Task/TalkNPC.pm to drop a leading k when conversation is already active with the expected NPC, preventing repeated approach logic in an already-open dialog.
  • Keep existing retry/plugin flow for missing teleport behavior, including npc_airship_teleport_missing.
  • Add format documentation and example entries to tables/portals_airship.txt and tables/ROla/portals_airship.txt, including the wait-area parameter.

Refactor NPC auto-talk and portal-approach logic and update portal table.

- Misc.pm: Consolidate route-check logic and add helpers (_routeActionHasTalkNpcSubtask, resolveAutoNpcTalkSequence, _stripLeadingPortalApproachStep). Auto-created TalkNPC tasks now receive a resolved conversation sequence and improved debug output.
- Task/MapRoute.pm: Add _npcRouteDistancesFromSteps to detect a leading 'k' (direct approach) and compute route/dist-from-goal and talk-trigger distances. Use these values when queuing Route tasks and when deciding to initiate NPC interaction; improve debug messages.
- Task/TalkNPC.pm: If an active conversation started (leading 'k' step), drop the initial 'k' step from the task steps to avoid duplicating input.
- tables/ROla/portals.txt: Normalize header, comment out many unused/inexistent entries for ROla, and add updated Kafra/Zonda and New World warp entries for the server.

These changes ensure correct handling of portal-approach sequences (especially leading 'k' portal conversations), avoid duplicate talk actions, and provide updated portal mappings for the ROla server.
@boscv boscv changed the title ## Motivation Improve handling of NPC conversation sequences that begin with k (approach + talk), so routing and auto-talk remain consistent and avoid duplicate TalkNPC flows. ## Changes - Refactored autoNpcTalk in src/Misc.pm to: - replace ad-hoc route checks with _routeActionHasTalkNpcSubtask. - resolve sequence from active mapRoute/route through resolveAutoNpcTalkSequence. - strip the leading k approach step when appropriate before creating Task::TalkNPC. - Added _npcRouteDistancesFromSteps in src/Task/MapRoute.pm and applied it to NPC/airship routing: - derive distFromGoal and talk-trigger distance from route steps. - for k-prefixed sequences, require exact-tile approach (distFromGoal = 0, talk trigger distance = 0). - Updated src/Task/TalkNPC.pm to drop a leading k when conversation is already active with the expected NPC, preventing repeated approach logic in an already-open dialog. refactor(route): improve k-step npc dialog flow in auto-talk and map routing Mar 21, 2026
boscv added 2 commits March 21, 2026 13:33
Parse optional airship wait_area from portals_airship entries and store as x1/x2/y1/y2 on portal dests. Propagate wait_area through CalcMapRoute so route nodes include it. In MapRoute add helpers (_isInsideWaitArea, _pickAirshipWaitPos), use isCellOccupied, and implement logic to move the actor into a random free/walkable cell inside the wait area while waiting for the airship broadcast; keep backwards compatibility for legacy quoted steps. Also adjust plugin retry/error handling and update portal table files to include wait_area coordinates and reorganize some airship entries.
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