action test_pather()
{
path_set(my, "path_000");
var start_node = ll_pfind_getClosestNode(my, my.x, 1000, NULL);
var dest_node = ll_pfind_getClosestNode(my, target_pos.x, 1000, NULL);
LL_LIST *path = ll_pfind_getPathToTarget(my, start_node, dest_node, ll_pfind_astarCost);
LL_PFIND_PATH_NODE *node= (LL_PFIND_PATH_NODE *)path->first->data; // new
while(1)
{
if (path) // path has been found
{
if (path->count > 0) // path is not empty yet
{
// get the next node of the path
node = (LL_PFIND_PATH_NODE *)path->first->data;
// move to the node
// get the direction from the entity MY to the entity YOU
var temp;
vec_set(temp,your.x);
vec_sub(temp,my.x);
vec_to_angle(my.pan,temp); // now MY looks at YOU
c_move(my,node->pos,nullvector,GLIDE);
// [the destination should be: node->pos]
// if the entity has reached the node
if (vec_dist(&my->x, &node->pos) < 50)
{
// remove it from the path
ll_list_remove(path, path->first, ll_pfind_destroyPathNode);
}
}
else // path has been traversed completely
{
ll_list_destroy(path, NULL); // remove it
path = NULL;
}
}
wait(1);
}
}