GeneratePathWeighted

GeneratePath a path between two positions for the given map ID, attaching an extra weight to each poly edge examined.

GeneratePathWeighted(x1, y1, z1, x2, y2, z2, mapId, callback) : {{ x, y, z }...}

Example

Generate a path between the player and target.

local px, py, pz = ObjectPosition('player')
local tx, ty, tz = ObjectPosition('target')
local mapID = GetMapID()
 
local weighted = function(ax, ay, az, bx, by, bz)
local extraWeight = 0.0 -- float
-- poly edge A is ax, ay, az
-- poly edge B is bx, by, bz
-- callback is for movement between poly edge A and B
 
-- higher weights are avoided
return extraWeight
end
 
local path = GeneratePathWeighted(px, py, pz, tx, ty, tz, mapID, weighted)