Once again this is an opportunity where arguments would be useful, if they were..
NPC Code:
function checkd(x,y) {
if (count<51) {
if (onwall(x,y)) {
count++;
if (playerdir == 0) { checkd(x,y+.1); }
if (playerdir == 1) { checkd(x-.1,y); }
if (playerdir == 2) { checkd(x,y-.1); }
if (playerdir == 3) { checkd(x+.1,y); }
}
else {
showimg 1,myimage,x,y;
}
}
}
if (created) {
myimage = "followingthing.gif";
}
if (playertouchesme) {
// Start following
timeout = .1;
this.follow = 1;
}
if (timeout) {
if (this.follow = 1) {
if (playerdir == 0) { checkd(x+1.5,y+4)) }
if (playerdir == 1) { checkd(x+4,y-1.5)) }
if (playerdir == 2) { checkd(x+1.5,y-4)) }
if (playerdir == 3) { checkd(x-4,y-1.5)) }
}
timeout=.1;
}
Presumably this will check to see if theres a wall in its way 50 times before stopping (which probably doesn't work because I'm a bad coder) and it'll make the image follow you within 4 spaces, but it's useless because i cant define arguements with functions.
It probably wouldnt work anyway (as you can see i have 0 self esteem) if I could