ID:935116
 
Keywords: ai, guard, mob, patrol, routine
(See the best response by NNAAAAHH.)
Problem description:

I'm having trouble piecing together how to handle setting it up so that guard mobs will follow a patrol route. I did a bunch of searches but there don't seem to be any topics or demos on the subject.

patrol

Going off of the mock-up, I'd like guards to walk along the yellow path constantly, trying to find players. I'd also like to pull off special cases, such as the one path that branches off where they'll move along it, look around, then make their way back to the main path and continue patrol. If they spot a mob they should be able to leave the path and go after them, and if they kill or lose the player, return to the path and control to patrol.
I guess you could make some objs at points along the route and make the guard move toward a certain one based upon its current position. You could have a variable store what point it has passed, but that could all be a little much, I'm not sure.
Best response
You could place the turfs into a list, then flow through the list as you go along
mob/guard/list/pathway=new()//You would have to fill this with turfs,
//you can choose the locations yourself at one point
//or make something to fill it automaticly, though that'd
//be harder to fill like that in-game.
//Not imposible, just gonna take some trial and error.
//Then you can just use the list to force the mob to walk around
//and then if(prob()) to decide if he should walk off-path.
var/a=1
while(src)
for(mob/player/m in view(src))//Do whatever you need to.
//You could even set a variable before the for()
//so you can ensure he follows after the mob
//and not the pre-defined path.
step_to(pathway[a])
a++
if(a>pathway.len) a=1
Any luck here? If you've yet to find a way to resolve this, I'd happily take my time out to help you further.
In response to NNAAAAHH
I haven't had much time to sit down and program so I've yet to give it a try. I'll get back to you on this once I've had a chance.
Didn't I tell you a way to accomplish this, LA?