**A* Pathfinding Module**

If you would like to know what the A* algorithm is and does.

http://en.wikipedia.org/wiki/A%2A

This is a module for developers, it allows them to use the A* pathfinding algorithm easily. Using a waypoint like system.

This will always find the shortest path along those waypoints.

**Download:** astar.lua

**Features:**

[list][*]Waypoint saving/loading.[*]Map based waypoint saving/loading.[/list]

**Addons for future updates:**

[list][*]Waypoint Editor.[/list]

**Module function list:**

[list][*]astar.CreateSolver[/list]

**Object function list.**

[list][*]Solver:AddNode <position> <extra cost> <data>[*]Solver:AddLink <first node> <second node>[*]Solver:GetNodeForPosition <position>[*]Solver:ClosestNodeForPosition <position>[*]Solver:Load <file>[*]Solver:Save <file>[*]Solver:SaveMap <name>[*]Solver:LoadMap <name>[*]List:Create <sortfunc>[*]List:Put <node>[*]List:Grab[*]List:HasElement[*]List:Empty

[*]Node.__eq[*]Node:CalculateCost <from start> <heuristic>[*]Node:SetExtraCost <cost>[*]Node:CreateLink <node>[*]Node:GetLinks

[/list]

**Block functions:**

Block functions are a way to tell the pathfinder whether or not you can travel from a -> b.

*Default functions:*

[list][*]astar.BLOCKFUNC_TRACE_WORLD[*]astar.BLOCKFUNC_TRACE_ALL[/list]

*Example block function:*

BLOCKFUNC_TRACE_WORLD = function( a, b )
local trace = {
start = a.position,
endpos = b.position,
mask = MASK_NPCWORLDSTATIC,
};
local tr = util.TraceLine( trace );
return tr.Hit;
end

AddLink will return false if the two nodes in question are already linked in some fashion. Everything was moved into the Solver class. That means you will now do

mysolver:FindPath( [node/pos], [node/pos], [optional block function] );