View Single Post
  #1  
Old 07-24-2004, 09:55 PM
falco10291029 falco10291029 is offline
BEst User EVER!
Join Date: Apr 2004
Posts: 1,186
falco10291029 is on a distinguished road
Npc attacking doors

NPC Code:

if (created) {
found=0;
hearts=0;

showcharacter;
ap=99;
timeout=.1;

}

if (timeout&&found==0) {
for (this.i=int(random(0,npcscount));found=0;this.i++) {
if (npcs[this.i].hearts>0) found=1;
if (this.i>npcscount) this.i-=npcscount;

}
timeout=.1}
if (timeout&&found==1) {

if (npcs[this.i].hearts<=1) {
found==0;
timeout=.1;
i=0;
}
setcharani walk,;
if (npcs[this.i].x>x&&(abs(npcs[this.i].x-x)>abs(npcs[this.i].y-y))) {
dir=3;
}
if (npcs[this.i].x<x&&(abs(npcs[this.i].x-x)>abs(npcs[this.i].y-y))) {
dir=1;
}
if (npcs[this.i].y>y&&(abs(npcs[this.i].x-x)<abs(npcs[this.i].y-y))) {dir=2;
}
if (npcs[this.i].y<y&&(abs(npcs[this.i].x-x)<abs(npcs[this.i].y-y))) {dir=0;
}
tx =npcs[this.i].x - x;
ty = npcs[this.i].y - y;
dist = (tx*tx+ty*ty)^0.5;
nx = (tx/dist)*1.4;
ny = (ty/dist)*1.4;
move nx,ny,1.4,;
if (npcs[this.i].x in |x-2,x+2|&&npcs[this.i].y in |y-2,y+2|) {
setcharani sword,;
npcs[this.i].hearts-=2;
sleep .25;
if (npcs[this.i].hearts<=0) {
found==0;
timeout=.1;
}
}

timeout=.3
}






Ok, this is supposed to find npcs that are enemies with hearts, and destroy them, then retarget, but it not only wont retarget, sometimes the first target will be a door or something. Why the heck does it do this is it my mistake or a bug in graal programming?
__________________
BEst Insult ever: If I had a dollar for every brain you DIDNT have, i'd have one dollar!

Last edited by falco10291029; 07-25-2004 at 12:18 AM..
Reply With Quote