NPC Code:
if (created) {toweapons walking;}
if (playerenters){this.m=.1;this.oldx = playerx;this.oldy = playery;}
if (isweapon||timeout){this.mx=0;this.my=0;this.ok=1;
this.dir=10*this.my+this.mx;this.rx=1;this.ry=1;
if (playerx<this.oldx) {this.mx=this.m;}
if (playery<this.oldy) {this.my=this.m;}
if (playerx>this.oldx) {this.mx=-1*this.m;}
if (playery>this.oldy) {this.my=-1*this.m;}
if (this.mx<0) {this.rx=4-1;}
if (this.mx>0) {this.rx=-1.5-1;}
for (i=1;i<=2;i+=.25; ) {this.rx+=.25;
for (this.ry=1;this.ry<=2.5;this.ry+=.5) {
if (onwall(playerx+this.rx+this.mx,playery+this.ry)) {this.ok=0;}}}
if (this.ok==1) {playerx-=this.mx;}
if (this.my<0) {this.ry=4.5-1.5;}
if (this.my>0) {this.ry=-1-1.5;}
for (i=1;i<=3;i+=.25; ) {this.ry+=.25;
for (this.rx=.75;this.rx<=2.5;this.rx+=.5) {
if (onwall(playerx+this.rx,playery+this.ry+this.my)) {this.ok=0;}}}
if (this.ok==1) {playery-=this.my;}
this.oldx = playerx;
this.oldy = playery;
timeout=.05;
}
the scripts works fine, i just need some help with the onwall for playerdir 1 (to the left)