before I forget, it would be a better idea to set dx and dy variables and use those instead of making all those sin and cos calculations
NPC Code:
dx = cos(this.angle);
dy = sin(this.angle);
while (i<this.dis){
newx = gox + dx;
newy = goy - dy;
if (onwall(newx+1.5,newy+2) || onwater(newx+1.5,newy+2))
break;
gox = newx;
goy = newy;
i++;
}