Features & Functionality:
- This library utilizes turf.Enter() to determine if a turf is passable. If your game requires special rules, simply override turf.Enter() as you normally would. (e.g. "don't count a mob obstructing the path here if I can't see them.")
- This library requires you create a new proc: turf.GetMovementCost(var/atom/movable). This is used to weigh the most efficient movement for a given atom. However, if your game does not use variable movement costs, simply have GetMovementCost() return a value greater than 0 (recommended: 1). See the included demo code for an example.
- To utilize A* pathing, request a list of turfs making up the path via the GetAStarPath() proc:
var/list/turf/whateverPathVariableName = GetAStarPath(movableAtomDoingTheMoving,destinationToGoTo)
// Alternate method using atom/movable.GetAStarPathTo on a /mob/player variable initialized as playerMob
var/list/turf/whateverPathVariableName = playerMob.GetAStarPathTo(destinationToGoTo)
For an even easier implementation, you can simply use this proc:
// Method involving simply using step_towards_astar_Path() with the same example of a /mob/player initialized as playerMob.
step_towards_astar_path(playerMob,destinationToGoTo)
That functions identically to the BYOND step_towards() function except it uses the AStar pathing. It will automatically store pathing information on the movable atoms as required. - GetAStarPath and GetAStarPathTo can take an additional numeric argument after the destination representing a minimum distance from the destination space. (Default: 0) This is useful if you want to stop pathing at a certain distance away from the goal. Setting this too high will likely result in significant slowdown.
- GM Verbs for pathing debugging are included. By default, this code is removed in order to improve efficiency. To enable it, add the following line before the first //BEGIN in the main .dme file:
#DEFINE PATHING_DEBUG
- Tweakable global variables allow for further refinement of how pathing occurs and whether or not diagonal movement is allowed (including a definable multiple of increased movement cost for diagonal movement). These are set to typical default values and need not be changed unless your game calls for it.
Warning: Cannot path between multiple maps. This is because there are many possible implementations you can have that would use multiple maps. To work around this, just use Easy AStar to path on the same maps, and then use alternate pathing methods to facilitate movement between maps.
Release Notes:
7/7/11 - Several versions released today.v1.6
Made the step_towards_astar_path pathing data list into a variable of type tmp so it will not save on your mobs.
Fixed bug in step_towards_astar_path() related to paths of length one being unable to reach destinations 2 distance away if they were not able to be reached via a standard step_towards.
Made demo more robust with a larger interface and runtime compile toggled methods of pathing.
v1.5
Added support for two more functions:
atom/movable.GetAStarPathTo() works identically to GetAStarPath but does not require the movable atom is passed as the first arg.
Global function step_towards_astar_path() works identically to step_towards except it utilizes astar pathing. The list of turfs is managed automatically.
v1.4
For improved efficiency, all pathing debug code is now removed at compile time unless you #DEFINE PATHING_DEBUG in your .dme file before the first //BEGIN.
v1.3
Changed implementation of maximum distance from destination mechanic to utilize a whole list of turfs to check against for pathing success instead of simply attempting to path to the nearest enterable turf from the start.
4/6/10 - v1.2 released. Changed GM debugging command to include less machine-intensive version. Made granting/removing GM verbs easier by moving them to a global proc list. Set pathing process to background to prevent from timing out on extremely long pathing assignments.
3/13/10 - v1.1 released. Commented out some unnecessary variable checks and optimized list handling for even more efficiency.
3/13/10 - v1.0 released. Improved in terms of efficiency, correct pathing accuracy, and features.
To give some credit where it was due: procs from AbyssDragon's Basic Math were utilized to boost efficiency.
1) I don't like how the debug stuff is so tightly interwoven with the rest of the lib. It should instead be a optional, modular component.
2) The ability to disregard dense objects occupying a tile while obeying tile density itself.