ID:167661
 
Im making some AI code and of course i have several proc's dealing with how the mob will work.

My problem is if I have the mob running a proc that will not be over for a few seconds, such as it's walking to a certain destonation, how would I make it stop/pause that proc if it needs to, for instance it's attacked.
mob
var/attacked=0
proc
Walking(var/turf/T)
if(!T)return
while(!src.attacked)
step_towards(src,T)

Set a variable to see if they are being attacked then use while() to check if they are or are not being attack. If they aren't, use step_towards() to have them move one step closer to the target destination.
In response to Exophus
Ahhhhhh, fill my procs of a MOB AI Daily life with While loops, very cool. thx