Hey can someone help me with this script?
There's a few problems.
1.It staggers when it walks and wont show the full gani.
2.It can walk through anything.
3.When its hit its supposed to show text of its damage go up and a bit down.
NPC Code:
if (created) {setcharani popie,;initialize();setcharprop #P(1),hat#v(int(random(0,100))).png;
}
if (timeout&&this.found==0) {
for (i=-1;this.found==0;i+=1) {
this.found=1;
if (i>playerscount) i=-1;
}
timeout=.3
}
if (timeout&&this.found==1) {
if (abs(players[i].x-x)<=20&&abs(players[i].y-y)<=20) {
dir=getdir(players[i].x-x,players[i].y-y);
setcharani podies-walk,;
tx=players[i].x - x;
ty=players[i].y - y;
dist= (tx*tx+ty*ty)^0.5;
nx= (tx/dist)*1.2;
ny= (ty/dist)*1.2;
move nx,ny,1.2,4;
} else {setcharani podies,;message;this.found=0;timeout=.1}
if (players[i].x in |x-2,x+2|&&players[i].y in |y-2,y+2|) {setcharani podies-attack,;with(players[i]) {setani hurt,;playerhearts-=.5};sleep .5;timeout=1;}
timeout=.3;}
if (waS**t) {
message;setcharani podies,;
hearts-=.5;message #v(hearts);sleep 1;
checkdead()}
if (actionprojectile&&!hearts<=0) {
message;setcharani podies-hurt,;
hearts-=strtofloat(#p(1))*2;this.number=strtofloat(#p(1)) *2;
if (this.number != 0){
this.temp ++;
showtext 13,x,y-2*this.temp,veranda,r,#v(this.number);
if (this.temp = 4) this.number = 0;
}else{
hideimg 13;
this.temp = 0;
}
sleep 1;
checkdead();}
function initialize() {
setcharani podies,;setshape 1,50,50;
this.found=0;
hearts=30;
setcharani podies,;
timeout=.3;
}
function checkdead() {
if (hearts<=0) {setcharani podies-dead,;
with (players[i]) {
setplayerprop#c, I got some experience, yay!;
setstring client.playerexp,#v(strtofloat(#s(client.playerexp ))+3);
}
with (players[i+1]) {
setplayerprop#c, I got some experience, yay!;
setstring client.playerexp,#v(strtofloat(#s(client.playerexp ))+3);
}
with (players[i+2]) {
setplayerprop#c, I got some experience, yay!;
setstring client.playerexp,#v(strtofloat(#s(client.playerexp ))+3);
}
timeout=0;setcharani podies-dead,;sleep 2;hide;sleep 30; show;initialize()}
else timeout=.3;
}