- 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.
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.
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
astar.lua
Function | Return value(s) | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
K_GetFinishLineWaypoint() | waypoint_t | Returns the waypoint that was detected as finish line. | |||||||||
K_GetWaypointIsFinishline(waypoint_t waypoint) | bool | Returns if this waypoint is considered a finish line. | |||||||||
K_GetWaypointIsShortcut(waypoint_t waypoint) | bool | Returns if this waypoint is considered a shortcut. | |||||||||
K_GetWaypointIsEnabled(waypoint_t waypoint) | bool | Returns if this waypoint is enabled. | |||||||||
K_GetWaypointIsSpawnpoint(waypoint_t waypoint) | bool | Returns if this waypoint is a valid spawnpoint. | |||||||||
K_GetWaypointIsOnLine(waypoint_t waypoint) | bool | Returns if this waypoint is on a linedef. | |||||||||
K_GetWaypointNextID(waypoint_t waypoint) | int | Returns the ID of the next waypoint in the course. | |||||||||
K_GetWaypointID(waypoint_t waypoint) | int | Returns the ID of this waypoint. | |||||||||
K_GetWaypointFromID(int waypointID) | waypoint_t | Returns the waypoint with this ID. | |||||||||
K_GetClosestWaypointToMobj(mobj_t mobj) | waypoint_t | Returns the closest waypoint to the mobj. | |||||||||
K_GetBestWaypointForMobj(mobj_t mobj, [waypoint_t hint]) | waypoint_t | Returns 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) | int | Returns the index of the waypoint in the internal table. | |||||||||
K_GetNumWaypoints() | int | Returns the number of waypoints created. | |||||||||
K_GetWaypointFromIndex(int waypointIndex | waypoint_t | Returns the waypoint from its index in the internal table. | |||||||||
K_DistanceBetweenWaypoints(waypoint_t waypoint1, waypoint_t waypoint2) | int | Returns the approximate distance between the two waypoints. | |||||||||
K_PathfindToWaypoint(waypoint_t start, waypoint_t destination, bool useshortcuts, bool huntbackwards) | bool, path_t | Tries 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.
| |||||||||
K_CheckWaypointForMobj(waypoint_t waypoint, mobj_t mobj) | bool | Returns true if the mobj is the waypoint mobj the waypoint was created from. | |||||||||
K_SearchWaypointHeap(function(waypoint_t waypoint, * val) condition, * checkvalue) | waypoint_t | Returns the first waypoint matching the condition. | |||||||||
K_SearchWaypointHeapForMobj(mobj_t mobj) | waypoint_t | Searched for the waypoint created from the mobj. |
Function | Return value(s) | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
K_PathfindAStar(pathsetup_t pathsetup) | bool, path_t | Attempts to find a path in the graph described by the pathsetup
|
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.