feat(teleport_items): add table-driven warp routing with strict parser and runtime equip/cooldown checks#4167
Open
boscv wants to merge 8 commits intoOpenKore:masterfrom
Open
feat(teleport_items): add table-driven warp routing with strict parser and runtime equip/cooldown checks#4167boscv wants to merge 8 commits intoOpenKore:masterfrom
boscv wants to merge 8 commits intoOpenKore:masterfrom
Conversation
Introduce support for a teleport_items table and use teleport/warp items in routing and teleport tasks. Adds tables/teleport_items.txt and a parseTeleportItems loader with a new %teleport_items global, plus unit tests. Implements Misc::getTeleportItemFromTable and integrates warp-by-item logic into Task::CalcMapRoute and Task::MapRoute (populateOpenListWithWarpByItems, candidate selection, per-map forbids and retry handling). Tracks per-item cooldowns (last_teleport_item_use) when sending item-use packets and exposes a config flag route_warpByItem (default 0) in control/config.txt. Also registers the new table in settings and updates test distfiles.
Parse optional equip-requirement fields for teleport items and enforce them when selecting items. FileParsers.pm: accept optional timeoutSec and optional requiredEquipSlot + requiredEquipItemID, validate and store them on each entry (timeout defaults to 0). Misc.pm: add isTeleportItemEquipRequirementSatisfied to verify required slot exists and the required item is equipped in that slot. Use this check in getTeleportItemFromTable and Task/CalcMapRoute.pm when filtering candidate warp items. Tests and fixtures: add teleport_items test fixture and assertions in FileParsersTest, and update tables/teleport_items.txt docs/examples to document the new optional fields.
Parse and enforce an optional max level for teleport/warp items. FileParsers now accepts an extra numeric optional argument (maxLvl) before timeoutSec and stores maxLevel in the entry. Misc and CalcMapRoute skip teleport entries when the character level is above maxLevel. Tests and teleport_items table/docs updated to reflect new syntax and example entries; test fixture updated to assert parsing of maxLevel. This enables items to be limited to characters at or below a specified level (0 disables the check).
Make teleport_items parsing stricter and add equip-requirement support. FileParsers.pm: use Globals equip slot lookup, adopt strict positional optional syntax ([maxLvl] [timeoutSec] [requiredEquipSlot requiredEquipItemID]), validate numeric fields and equip slot names, emit warnings for malformed lines, and skip invalid entries. CalcMapRoute.pm: carry teleportItemRequiredEquipSlot/ItemID through open/close lists. MapRoute.pm: import isTeleportItemEquipRequirementSatisfied and refuse to use teleport items when equip requirement is not satisfied. Tests/fixtures: update teleport_items.txt, add teleport_items_invalid.txt, and adjust FileParsersTest expectations to cover new parsing/validation behavior. tables/teleport_items.txt: document positional optional values and note how to specify only timeout by using maxLvl=0 first.
Contributor
Author
|
Still need some real testing, but pulling here for any suggestions |
Add isTeleportItemEquipRequirementSatisfied to Misc exports, switch MapRoute to call it as Misc::isTeleportItemEquipRequirementSatisfied (remove from import list), and clean up/reorder teleport_items.txt entries and formatting. These changes expose the equip-check function for external use and tidy the teleport item table.
Detect when a Task::Route error (CANNOT_CALCULATE_ROUTE or STUCK) is caused by a same-map warp that changed the map. If the map was changed and the first mapSolution entry refers to the same map (map == dest_map), treat the route as stale: advance to the next portal step (shift mapSolution), clear mapChanged and teleport-related flags (teleport, sentTeleport, teleportTime), and return. Adds a debug log for this case to avoid re-calculating a route invalidated by a same-map warp.
Add _isSameMapPortalStep helper to robustly detect same-map portal steps (prefer map==dest_map, fall back to parsing portal strings). Use this in Task::MapRoute to select the first inter-map portal, mark Route subtasks with stopWhenMapChanged for same-map starts, and advance mapSolution entries when a same-map warp finishes. Update Task::Route to honor stopWhenMapChanged by finishing the current segment on map change instead of recalculating the route. Include a Python runtime simulation test (maproute_same_map_runtime_sim.py) that verifies detection and expected step progression for a moc_para0b -> moc_para0b -> moc_para0b -> prontera -> payon sequence.
Contributor
Author
|
For some reason, intra-map portals where having calc erros on mapChange (?). |
Contributor
|
ow cool, I'll give it a try |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
tables/teleport_items.txt.route_warpByItemis enabled.Description
tables/teleport_items.txtwith documented syntax and examples forrandom,respawn,warp, andanymodes.parseTeleportItemsinsrc/FileParsers.pm:[maxLvl] [timeoutSec] [requiredEquipSlot requiredEquipItemID]%equipSlot_rlut(case-insensitive handling for slot names)src/functions.pl.src/Task/CalcMapRoute.pm:teleportItemID,timeoutSec, required equip slot/item) into map solution stepssrc/Task/MapRoute.pm:sendItemUselast_teleport_item_usesrc/Task/Teleport/Random.pmandsrc/Task/Teleport/Respawn.pmnow consult table rulessrc/Task/Teleport.pmrecords cooldown timestamps when a rule-based item is usedsrc/test/teleport_items.txt(valid cases)src/test/teleport_items_invalid.txt(invalid/malformed cases)src/test/FileParsersTest.pmassertions for both valid and invalid scenariossrc/test/Distfilesupdated to include new fixtureTesting
perl -I src src/test/FileParsersTest.pmmaxLevel,timeoutSec, equip requirements)prt_q -> 22849pvp_n_room -> 14528un_bk_q -> 22691verus04 -> 22611only when equip requirement is satisfied22508(moc_para01)