here i didnt actually test this i just put on graal and clicked style and test to debug it but its just a base of what I was saying (prolly buggy) and i didnt do it using showcharacter either..
NPC Code:
// NPC by LiquidIce
this.maxstep = 5; //step length
if (playerenters&&isleader) {
init();
timeout=.1;
}
function init() {
setarray stepx,this.maxstep+1;
setarray stepy,this.maxstep+1;
for (this.i=0;this.i<this.maxstep;this.i++) {
stepx[this.i]=x;
stepy[this.i]=y;
}
}
if (timeout) {
if (stepx[0]=0||stepy[0]=0) {
randomstep();
}
else {
move();
movearray();
}
timeout=.1;
}
function move() {
x=stepx[0];
y=stepy[0];
}
function movearray() {
for (this.i=this.maxlength;this.i>=0;this.i=this.i-1) {
stepx[this.i]=stepx[this.i-1];
stepy[this.i]=stepy[this.i-1];
}
}
function randomstep() {
this.angle=random(0,6.28);
this.effect=random(-.2,.2);
for (this.i=0;this.i<this.maxstep;this.i++) {
this.x=sin(this.angle);
this.y=cos(this.angle);
if (this.i=0) { this.x+=x-.5;this.y+=y-.5; }
else {
this.x+=stepx[this.i-1]-.5;
this.y+=stepy[this.i-1]-.5;
}
if (onwall(this.x,this.y)) {
break;
}
stepx[this.i]=this.x;
stepy[this.i]=this.y;
this.angle+=this.effect;
}
}