astar.inc
Original include source with line numbers.
| 1 | #if defined _AStar_included |
| 2 | #endinput |
| 3 | #endif |
| 4 | #define _AStar_included |
| 5 | |
| 6 | /** Array:AStar(Float:Start[3], Float:Goal[3], StepSize = 30, Ignore = IGNORE_MONSTERS, IgnoreID = 0, GroundDistance = 35, Heuristic = 50); |
| 7 | * |
| 8 | * Finds a path between Start and Goal. |
| 9 | * |
| 10 | * |
| 11 | * Parameters: |
| 12 | * |
| 13 | * Float:Start[3] |
| 14 | * Starting position. |
| 15 | * |
| 16 | * Float:Goal[3] |
| 17 | * Hopefully the end position. |
| 18 | * |
| 19 | * (Optional) StepSize = 30 |
| 20 | * Defines how far between each step to take in a pattern of -X + X in all three dimensions. This means that diagonally, the step will be longer. |
| 21 | * |
| 22 | * (Optional) Ignore = IGNORE_MONSTERS |
| 23 | * Flags for the traceline check. |
| 24 | * |
| 25 | * (Optional) IgnoreID = 0 |
| 26 | * id of the calling player if IGNORE_MONSTERS is not set. Again, this is for the traceline. |
| 27 | * |
| 28 | * (Optional) GroundDistance = 35 |
| 29 | * Set the maximum distance from the ground for the point to be accepted as valid. If set to 0 this check is disabled, meaning pathfinding for flying entities. |
| 30 | * |
| 31 | * (Optional) Heuristic = 50 |
| 32 | * Optimization parameter. Decides how much importance the distance from the target has. |
| 33 | * Higher values might result in a faster execution but may also result in a suboptimal path. |
| 34 | * |
| 35 | * Returns a handle to a dynamic array that will contain each step between start and goal. |
| 36 | * On failure it will return Invalid_Array. |
| 37 | **/ |
| 38 | native Array:AStar(Float:Start[3], Float:Goal[3], StepSize = 30, Ignore = IGNORE_MONSTERS, IgnoreID = 0, GroundDistance = 35, Heuristic = 50, ...); |
| 39 | |
| 40 | /** AStarThreaded(Float:Start[3], Float:Goal[3], Handler[], StepSize = 30, Ignore = IGNORE_MONSTERS, IgnoreID = 0, GroundDistance = 35, Heuristic = 50); |
| 41 | * |
| 42 | * Finds a path between Start and Goal. |
| 43 | * |
| 44 | * |
| 45 | * Parameters: |
| 46 | * |
| 47 | * Float:Start[3] |
| 48 | * Starting position. |
| 49 | * |
| 50 | * Float:Goal[3] |
| 51 | * Hopefully the end position. |
| 52 | * |
| 53 | * Handler[] |
| 54 | * The function that will be called once the pathfinding is done. |
| 55 | * The format of the handler function should be as such: |
| 56 | * public PathDone(Index, Array:hPath, Float:Distance, NodesAdded, NodesValidated, NodesCleared) |
| 57 | * |
| 58 | * (Optional) StepSize = 30 |
| 59 | * Defines how far between each step to take in a pattern of -X + X in all three dimensions. This means that diagonally, the step will be longer. |
| 60 | * |
| 61 | * (Optional) Ignore = IGNORE_MONSTERS |
| 62 | * Flags for the traceline check. |
| 63 | * |
| 64 | * (Optional) IgnoreID = 0 |
| 65 | * id of the calling player if IGNORE_MONSTERS is not set. Again, this is for the traceline. |
| 66 | * |
| 67 | * (Optional) GroundDistance = 35 |
| 68 | * Set the maximum distance from the ground for the point to be accepted as valid. If set to 0 this check is disabled, meaning pathfinding for flying entities. |
| 69 | * |
| 70 | * (Optional) Heuristic = 50 |
| 71 | * Optimization parameter. Decides how much importance the distance from the target has. |
| 72 | * Higher values might result in a faster execution but may also result in a suboptimal path. |
| 73 | * |
| 74 | * Returns a que index that can be used in the handler to identify which path is complete. |
| 75 | * On failure it will return -1. |
| 76 | **/ |
| 77 | native AStarThreaded(Float:Start[3], Float:Goal[3], Handler[], StepSize = 30, Ignore = IGNORE_MONSTERS, IgnoreID = 0, GroundDistance = 35, Heuristic = 50, ...); |
| 78 | |
| 79 | |
| 80 | |
| 81 | // The following functions are only used with the AStar() function, not AStarThreaded(). |
| 82 | |
| 83 | /** |
| 84 | * AStar_GetDistance() |
| 85 | * |
| 86 | * Returns the distance of the last non-threaded path. |
| 87 | **/ |
| 88 | native Float:AStar_GetDistance(); |
| 89 | |
| 90 | /** |
| 91 | * AStar_GetNodesAdded() |
| 92 | * |
| 93 | * Returns the ammount of nodes that were created from the last non-threaded path. |
| 94 | **/ |
| 95 | native AStar_GetNodesAdded(); |
| 96 | |
| 97 | /** |
| 98 | * AStar_GetNodesValidated() |
| 99 | * |
| 100 | * Returns the ammount of nodes that were validated from the last non-threaded path. |
| 101 | **/ |
| 102 | native AStar_GetNodesValidated(); |
| 103 | |
| 104 | /** |
| 105 | * AStar_GetNodesValidated() |
| 106 | * |
| 107 | * Returns the ammount of nodes that were cleared from the last non-threaded path. |
| 108 | **/ |
| 109 | native AStar_GetNodesCleared(); |