Mist's code that Bucket Mouse mentioned should be sufficient. But there is a limitation to the AI scripts that might be relevant for this sort of behavior. As you probably already know, when you set an AI behavior for an object, you can set a timer that goes from 0 to 15. Setting it to 0 means that the timer will go off at a random time, which means that there is no way to have a timer go off every frame. It's been a while since I was playing around with this, but I think that I calculated that setting it to 1 one was equal to about a quarter of a second. Whatever it was, this means that occasionally you will observe the object with this AI Script taking a moment before it will update its movement. Again, this is probably not that big of a deal for how you want to use it (it might even add a bit of an impression of character to your NPC), but I thought you might want to know.