temp.dx = this.path[this.pathpos][1] - this.x; temp.dy = this.path[this.pathpos][2] - this.y; temp.dist = (dx ^ 2 + dy ^ 2) ^ 0.5; if (abs(temp.dist) <= 0.5) { this.x += temp.dx; this.y += temp.dy; setPathPos(this.pathpos + 1); dropPresent(); // Chooses wether to drop or not drop a gift setCharAni("zone2_idle",""); } else { if (temp.dist > temp.speed) { temp.dx *= temp.speed / temp.dist; temp.dy *= temp.speed / temp.dist; temp.dist = temp.speed; } else { timegap = max(0.1,temp.dist / temp.speed); } move(temp.dx,temp.dy,timegap,16); }