var is_server=0; var character={ x:0, real_x:0, y:0, real_y:0, map:"main", base:{h: 8, v: 7, vn: 2}, processor:true, } var smart={ moving:false, map:"main",x:0,y:0, on_done:function(){}, plot:null, edge:20, // getting 20px close to the target is enough baby_edge:80, // start treading lightly when 60px close to the target or starting point try_exact_spot: false, use_town:false, prune:{ smooth:true, map:true, }, flags:{} }; function game_log(x) { console.log("[MGL]: "+x); } var queue=[],visited={},start=0,best=null; var moves=[[0,15],[0,-15],[15,0],[-15,0]]; var baby_steps=[[0,5],[0,-5],[5,0],[-5,0]]; // baby_steps is a new logic, used just around the target or starting point, to get out of tough spots [08/03/19] function plot(index) { if(index==-1) return; plot(queue[index].i); // Recursively back-tracks the path we came from smart.plot.push(queue[index]); } function qpush(node) { // If we haven't visited this location, adds the location to the queue if(smart.prune.map && smart.flags.map && node.map!=smart.map) return; if(visited[node.map+"-"+node.x+"-"+node.y]) return; if(!node.i) node.i=start; // set the index, to aid the plot function queue.push(node); visited[node.map+"-"+node.x+"-"+node.y]=true; } function smooth_path() { var i=0,j; while(i