Why wont this work?
NPC Code:
if (playerenters) {
drawunderplayer;
dontblock;
timereverywhere;
timeout = .5;
}
if (timeout){
this.dir = random( 1, 5 );
if (this.dir=1 && !onwall(x+1,y)){y-=1;}
if (this.dir=2 && !onwall(x+.5,y+2)){y+=1;}
if (this.dir=3 && !onwall(x,y)){y-=1;}
if (this.dir=4 && !onwall(x,y)){y-=1;}
timeout = .5;
}