Perhaps it would be easier to prepare several "actions" for the NPC, and execute them randomly?
// endless loop
while(true)
{
// choose a random action
switch(Random(0, 3))
{
case 0:
// say something and wait
this.Talk("Damn, I'm so bored.");
Sleep(2000);
break;
case 1:
// walk around
this.GoTo(100, 200);
Sleep(2000);
this.GoTo(300, 400);
Sleep(2000);
this.GoTo(100, 200);
break;
case 2:
// play some animation
this.PlayAnim("smoke_cigarette.sprite");
break;
case 3:
// do nothing for a while
Sleep(3000);
break;
}
}