Originally Posted by
Gleeok
I thought those npc attributes were read-only? Does it work? They still shoot weapons while frozen though I'm guessing.
It appears to.
They were doing the whole 'jumping around' thing before, but when I put in that step and rate bit they stopped.
I've only actually tried with with Gibdos though =P
Code:
int nearestnpc(int x, int y){
int enum = Screen->NumNPCs();
int xd[10]; int yd[10];
npc e[10];
for(i=0;i<enum;i++){
xd[i] = 0; yd[i] = 0;
e[i] = Screen->LoadNPC(i+1);
xd[i] = Abs(e[i]->X-x);
yd[i] = Abs(e[i]->Y-y);
if(xd[i]<24 && yd[i]<24){return i; i = enum;}
}
}
That would be the one I wrote earlier.
Except I don't acutally need the arrays do I.
That's a bit different to the one I'm actually using in my script, my script's one does I think.
Code:
int npcdist(int x, int y, int dist){
int enum = Screen->NumNPCs();
int xd; int yd;
for(i=0;i<enum;i++){
xd = 0; yd = 0;
npc e = Screen->LoadNPC(i+1);
xd = Abs(e->X-x);
yd = Abs(e->Y-y);
if(xd<dist && yd<dist){return i; i = enum;}
}
}
Returns the first npc that's dist pixels from (x,y).