Closed ghost closed 2 years ago
I would suggest a custom moveTo
function similar to this:
const moveTo = (x: number, y: number, z: number, timeoutSec = 20) => {
return new Promise((resolve, reject) => {
l2.moveTo(x, y, z);
const t = setInterval(() => {
if (Math.abs(l2.Me.X - x) <= 50 && Math.abs(l2.Me.Y - y) <= 50) {
resolve(true);
clearInterval(t);
}
timeoutSec--;
if (timeoutSec <= 0) {
reject("Timeout on moving to location.");
clearInterval(t);
}
}, 1000);
});
};
I have an array with several game coordinates (x, y, z)
My doubt is How to check if the char arrived at the coordinate sent for me to send the next array list coordinate
Currently mine is already going straight to the last coordinate of the list is making the char get stuck in some obstacle.