WaypointUtil

[Open Assets] WaypointUtil 1.0

What permissions do you give others to modify and/or maintain your submission?
Modify: YES - Maintain: YES - I give permission for my entire submission to be modified by others or used in their own work. I give permission for my entire submission to be maintained by others as well.
While developing a feature for a mod I'm working on, I wanted to make use of the waypoints the game uses for its CPU and for S.P.B.s. Unfortunately I had to find out that this data is basically not directly exposed.
However with a bit digging into the source code, most of the functionality I needed could be restored.

Your primary way of interacting with this script is via the K_GetBestWaypointForMobj() and K_PathfindToWaypoint() functions.
waypoint.lua
FunctionReturn value(s)Description
K_GetFinishLineWaypoint()waypoint_tReturns the waypoint that was detected as finish line.
K_GetWaypointIsFinishline(waypoint_t waypoint)boolReturns if this waypoint is considered a finish line.
K_GetWaypointIsShortcut(waypoint_t waypoint)boolReturns if this waypoint is considered a shortcut.
K_GetWaypointIsEnabled(waypoint_t waypoint)boolReturns if this waypoint is enabled.
K_GetWaypointIsSpawnpoint(waypoint_t waypoint)boolReturns if this waypoint is a valid spawnpoint.
K_GetWaypointIsOnLine(waypoint_t waypoint)boolReturns if this waypoint is on a linedef.
K_GetWaypointNextID(waypoint_t waypoint)intReturns the ID of the next waypoint in the course.
K_GetWaypointID(waypoint_t waypoint)intReturns the ID of this waypoint.
K_GetWaypointFromID(int waypointID)waypoint_tReturns the waypoint with this ID.
K_GetClosestWaypointToMobj(mobj_t mobj)waypoint_tReturns the closest waypoint to the mobj.
K_GetBestWaypointForMobj(mobj_t mobj, [waypoint_t hint])waypoint_tReturns the "best" waypoint for the mobj, prioritizing waypoints closer to the finishline.
If hint is not null, the waypoint is considered always reachable.
K_GetWaypointHeapIndex(waypoint_t waypoint)intReturns the index of the waypoint in the internal table.
K_GetNumWaypoints()intReturns the number of waypoints created.
K_GetWaypointFromIndex(int waypointIndexwaypoint_tReturns the waypoint from its index in the internal table.
K_DistanceBetweenWaypoints(waypoint_t waypoint1, waypoint_t waypoint2)intReturns the approximate distance between the two waypoints.
K_PathfindToWaypoint(waypoint_t start, waypoint_t destination, bool useshortcuts, bool huntbackwards)bool, path_tTries to find a path between the two waypoints.
If useshortcuts is true allows the use of shortcuts.
If huntbackwards is true the algorithm will search in the opposite direction.
The returned path provides data over the found path.
FieldTypeDescription
arrayarray[pathnode_t]The path nodes visited, use the field nodedata to access the actual waypoint
totaldistintthe total length of the path, according to the distance heuristic.
K_CheckWaypointForMobj(waypoint_t waypoint, mobj_t mobj)boolReturns true if the mobj is the waypoint mobj the waypoint was created from.
K_SearchWaypointHeap(function(waypoint_t waypoint, * val) condition, * checkvalue)waypoint_tReturns the first waypoint matching the condition.
K_SearchWaypointHeapForMobj(mobj_t mobj)waypoint_tSearched for the waypoint created from the mobj.
astar.lua
FunctionReturn value(s)Description
K_PathfindAStar(pathsetup_t pathsetup)bool, path_tAttempts to find a path in the graph described by the pathsetup
FieldTypeDescription
get_nextfunction(nodedata)Returns an array of nodes to check next from this one
get_next_costsfunction(nodedata)Returns an array of the costs of the nodes to check next from this one
get_heuristicfunction(nodedata, nodedata)Returns the approximate cost of moving between two nodes.
traverseablefunction(nodedata, nodedata)Returns if the path can travel between two nodes
finishedfunction(node, setup)Returns if the pathfinding should consider the end reached at this node.
start_wpnodedataThe node the path starts from
end_wpnodedataThe node the path should try to reach

Note that this is meant as a library, and no guarantees are made towards performance on servers.
Additionally while this is a mostly 100% port of the C src code, some minor differences exist as I had to substitute certain functions.
Author
SilicDev
Downloads
114
Views
1,318
Extension type
pk3
File size
4.9 KB
MD5 Hash
8bd692cfe695b9a706f99e424d9edf6b
First release
Last update

More resources from SilicDev

Share this resource

Back
Top