Try this:
Code:
//skill1: TurnSpeed 10
//skill2: MoveSpeed 10
action patrol_path()
{
// attach entity to nearest path
result = path_scan(me,my.x,my.pan,vector(360,180,1000);
if (result == 0) { return; } // no path found
var NodePos[3];
// find first waypoint
var node = 1; // start at first node
path_getnode(my,node,NodePos,NULL);
var angle[3];
var Gravity;
while (1)
{
// find direction
result = vec_to_angle(angle,vec_diff(temp,NodePos,my.x));
// near target? Find next waypoint of the path
if (result < 25)
{
node = path_nextnode(my,node,1);
path_getnode(my,node,NodePos,NULL);
}
my.skill21 = c_trace(my.x,vector(0,0,-10000),use_box|ignore_me|ignore_passents|ignore_passable);
if(my.skill21 > 5)
{
Gravity -= time_step;
}else
{
if(my.skill21 < 0)
{
Gravity += time_step;
}else
{
Gravity = 0;
}
}
// turn and walk towards target
my.pan += ((angle.pan > my.pan)-(angle.pan < my.pan))*time_step*my.TurnSpeed;
c_move(me,vector(my.MoveSpeed*time_step,0,Gravity),nullvector,glide|ignore_passents|ignore_passable);
wait(1);
}
}
Add it to the bottom of your mainscript file.
Place the model into your level, next to the path and give the patrol_path action to it.
If you get any errors please post them and I will try to fix it, cause I´m to lazy to create my own testlevel (which means, that I haven´t tested the script).
Slin