Difference between revisions of "MIST hex aStar"
From DCS World Wiki - Hoggitworld.com
(Created page with "{{Mission Scripting |fName= mist.hex.aStar| |vNum = Mist 4.6 |desc= Uses the A* algorithm to calculate the shortest path between a start point hexA and the destination of h...") |
(No difference)
|
Revision as of 22:47, 8 September 2026
mist.hex.aStar
| Added with: Mist 4.6 |
| Description |
| Uses the A* algorithm to calculate the shortest path between a start point hexA and the destination of hexB given anything blocking the route as defined by blockers. |
| Syntax |
| table mist.hex.aStar(table hexA ,table hexB , table blockers ) |
| Valid Input Values: |
| {q = 4, r = 2, s = -6}
hash: "2 4 -6" |
| Return value: |
| table |
| Return example: |
| Usage Examples: |
| The following will draw on the map the path generated between the trigger zones "start" and "dest". Two group's routes are being used to define islands that must be routed around.
local avoid = {mist.hex.getFromRoute(mist.getGroupPoints("island1")), mist.hex.getFromRoute(mist.getGroupPoints("island2"))}
local mergedBlockers = {}
for i = 1, #avoid do -- need to merge
for hexName, hexVal in pairs(avoid[i]) do
mergedBlockers[hexName] = hexVal
end
end
local startHex = mist.hex.pointToHex(trigger.misc.getZone("start").point)
local destHex = mist.hex.pointToHex(trigger.misc.getZone("dest").point)
local path = mist.hex.aStar(startHex, destHex, mergedBlockers)
if type(path) == "table" then
for i = 1, #path-1 do
mist.marker.add({mType = "arrow", color = {0, 0, 1, 0.5}, lineType = 1, points = {path[i+1], path[i]},})
end
end
|
| Notes: |
| Related Functions |
| to, getRadius, setRadius, add, subtract,scale, rotate_left, rotate_right, neighbor, getNeighborCount, diagonalNeighbor, length, distance, round, lerp, cubeScale, cubeRing, cubeSpiral, lineDraw, cubeToAxial, axialToCube, pointToHex, makeVek2, makeVec3, makeVec3GL, hash, hashToHex, draw, aStar, getFromRoute |
