/*
???
pathwalker_a
A7 Lite-C
ENTITY loops / moves (x,y,z) along path
(optional) ENTITY turns (pan, tilt) to next node
???
*/
// temp variables
VECTOR* v2 = {x=0; y=0; z=0;}
VECTOR* v3 = {x=0; y=0; z=0;}
ANGLE* a1 = {pan=0; tilt=0; roll=0;}
// skills
#define _nodeId skill71
#define _nodeDir skill72
action pathwalker_a() {
wait(1);
// attach entity to nearest path
my._nodeId = path_scan(me,my.x,my.pan,vector(360,180,1000));
my._nodeDir = 1;
//my._nodeId = 1;
if (my._nodeId != 0) {
while(me != NULL) {
if (path_getnode(me, my._nodeId, v3, NULL) == 0) {
my._nodeDir *= -1;
my._nodeId += my._nodeDir;
path_getnode(me, my._nodeId, v3, NULL);
}
if (vec_dist(my.x, v3) < 25) {
my._nodeId += my._nodeDir;
}
// v3 is destination VECTOR
vec_diff(v2, v3, my.x); // v2 is destination direction
// turn ENTITY towards node
vec_to_angle(a1, v2);
my.pan += ang(a1.pan - my.pan) * 0.5*time_step;
my.tilt += ang(a1.tilt - my.tilt) * 0.5*time_step;
// move ENTITY
vec_normalize(v2, 1);
vec_scale(v2, 10 * time_step);
c_move(me, nullvector, v2, GLIDE | IGNORE_PUSH);
wait(1);
}
}
}