@@ -18,17 +18,26 @@ if (self.pathfinding == undefined) {
1818
1919 var dist = point_distance (0 , 0 , dx, dz);
2020
21- // if you're right on top of a node, stop
22- if (dist <= 0.1 ) {
23- dx = 0 ;
24- dz = 0 ;
25- array_delete (self.pathfinding , 0 , 1 );
26- if (array_length (self.pathfinding ) == 0 ) {
27- self.pathfinding = undefined;
28- }
2921 // if you're close to a node, set the speed to the vector in the direction of the node
30- } else if (dist <= speed_walk) {
22+ if (dist <= speed_walk) {
23+ // if you're right on top of a node, stop
24+ if (dist <= 0.1 ) {
25+ dx = 0 ;
26+ dz = 0 ;
27+ }
3128 array_delete (self.pathfinding , 0 , 1 );
29+
30+ // a possible improvement (not yet working)
31+ /*
32+ for (var i = 1, n = array_length(self.pathfinding); i < n; i++) {
33+ var node = self.pathfinding[i];
34+ if (get_line_of_sight(self, self.x, self.y, self.z, node.x, node.y, node.z)) {
35+ array_delete(self.pathfinding, 0, i);
36+ show_debug_message("line of sight found")
37+ break;
38+ }
39+ }
40+ */
3241 if (array_length (self.pathfinding ) == 0 ) {
3342 self.pathfinding = undefined;
3443 }
0 commit comments