hi there. I have a basic understanding with c script, and have problem with my ai.At present this script patrols path,on click talks, what i want it to do is to also rotate to face player then go back to patrolling path.
so here is my script. All help greatly appreciated.
function click_woman1 ()//this is to get actor to talk while following using patrol path. I have tried a few like wait c_rotate but just arent sure how to do this..
{ var MySound2;
MySound2 = NULL;
my.event = NULL;
if(event_type == event_click)
{
MySound2 = snd_play(guard1, 100, 0);
}
while(MySound2!=NULL && snd_playing(MySound2))
{
wait(1);
}
my.event = click_woman1;
}
// Desc: move along a path
//
// uses _FORCE, _MOVEMODE, _WALKFRAMES, _WALKSOUND
action my_patrol_path
{
my.enable_click = on;
my.event = click_woman1;
actor_init();
// attach next path
temp.pan = 360;
temp.tilt = 180;
temp.z = 1000;
var node;
node = c_scan(my.x,my.pan,temp,SCAN_PATHS);
//node = path_scan(me,my.x,my.pan,temp);
if (node == 0) { my._MOVEMODE = 0; } // no path found
node = 1; // start at first node
// find first waypoint
ent_waypoint(my._TARGET_X,1);
while (my._MOVEMODE > 0)
{
// find direction
temp.x = MY._TARGET_X - MY.X;
temp.y = MY._TARGET_Y - MY.Y;
temp.z = 0;
result = vec_to_angle(my_angle,temp);
force = MY._FORCE;
// near target? Find next waypoint
// compare radius must exceed the turning cycle!
if (result < 25) {
ent_nextpoint(my._TARGET_X);
//node = path_nextnode(my,node,1);
//path_nodepos(my,node,my._TARGET_X);
}
// turn and walk towards target
actor_turnto(my_angle.PAN);
actor_move();
// Wait one tick, then repeat
wait(1);
}
}