So I've got a platformer pathfinding AI working in HMTL5, based on this set of scripts, except when I try to perform special operations on the actual path, the code 'exits' when there isn't even an exit statement and the path is thus never followed.
I'm trying to use two scripts:
//path_clean(ind)
//removes unnecessary points on a path
var n,x1,y1,x2,y2,x3,y3,mypath;
mypath=argument0;
if path_get_number(mypath)>2
{
for (n=1; n<path_get_number(mypath); n+=1)
{
x1=path_get_point_x(mypath,n-1)
y1=path_get_point_y(mypath,n-1)
x2=path_get_point_x(mypath,n)
y2=path_get_point_y(mypath,n)
x3=path_get_point_x(mypath,n+1)
y3=path_get_point_y(mypath,n+1)
if ((x2-x1)*(y3-y2)=(x3-x2)*(y2-y1) && (!place_meeting(x2*48,(y2*48)+48,obj_block) || y2 = y3))
{
path_delete_point(mypath,n)
n-=1
}
}
}
//create_nodes_path(path)
var pth,nodes,obj,nodex,nodey,node2y,node2x;
pth=argument0;
nodes=path_get_number(pth);
node_a = 0;
for(i=0;i<nodes+1;i+=1)
{
nodex=path_get_point_x(pth,i);
nodey=path_get_point_y(pth,i);
node2x=path_get_point_x(pth,i);
node2y=path_get_point_y(pth,i);
node_a[i,0] = (nodex * 48) + 24; //node x
node_a[i,1] = (nodey * 48) + 24; //node y
node_a[i,2] = 0; //type of jump; 0 = no jump; 1 = arc jump
node_a[i,3] = (node2x * 48) + 24; //jump x
node_a[i,4] = (node2y * 48) + 24; //jump y
if i<nodes
{
node2x=path_get_point_x(pth,i+1)
node2y=path_get_point_y(pth,i+1)
if !place_meeting(node2x*48,(node2y*48)+48,obj_block)
{
node2y=path_get_point_y(pth,i+2)
node2x=path_get_point_x(pth,i+2)
node_a[i,2] = 1
};
if node2y < nodey || (node2y > nodey && abs(node2x - nodex) > 1)
{
node_a[i,2] = 1
};
}
else
{
node2x=nodex
node2y=nodey
};
node_a[i,3] = (node2x * 48) + 24
node_a[i,4] = (node2x * 48) + 24
};
And both scripts cause the exact same problem. I've also been unable to nail down where exactly it's cutting off. The scripts are getting called here:
yy = y;
move_snap(48,1);
show_debug_message("Starting!")
pathx = x;
pathy = y;
x = xx;
y = yy;
if (platformer_astar(grd_ai,path_ai,(pathx)/48,(pathy-24)/48,round((obj_player.x)/48),round((obj_player.y-24)/48),height,jump,5,irritations))
{
show_debug_message("Cleaning path!");
path_clean(path_ai);
create_nodes_path(path_ai);
show_debug_message("Path cleaned!");
following=true
show_debug_message("Playing sound!");
h5s_play_sound(snd_swipe)
current_node = 0;
max_mode = path_get_number(path_ai);
path_start(path_ai,2,0,0);
path_scale = 48;
show_debug_message("Path begun!");
}
else
{
show_debug_message("Must teleport to reach player!")
x=obj_player.x
y=obj_player.y
};
And the debug text "Path cleaned!" is never outputted, until I remove BOTH scripts; leaving either in causes the code to exit upon being called. I've confirmed that the actual pathfinding scripts work perfectly in HTML5 (once I removed all the obsolete functions).
The functions above work fine in Windows, which makes me think there's a bug involving path functions in HTML5.
What on Earth is going on here?



Find content
Male







