Is it possible for more than one NPC to have the same ID or Index? If so then how can you tell if an NPC has disappeared?
Is it possible for more than one NPC to have the same ID or Index? If so then how can you tell if an NPC has disappeared?
"Logic never changes, just the syntax" - Kyle Undefined?
Remember, The Edit Button Is There For A Reason!!!

Count npcs ? :s
"Logic never changes, just the syntax" - Kyle Undefined?
Remember, The Edit Button Is There For A Reason!!!
Should work for what you want, obviously you can change for an eating procedure and some antiban etcSimba Code:While infight do wait(333);![]()
ThanksI tried that before but I forgot to add something to detect fight start so I thought it was bugged
"Logic never changes, just the syntax" - Kyle Undefined?
Remember, The Edit Button Is There For A Reason!!!
Bump... So is it possible for more than one NPC to have the same ID and/or Index?
Also, since NPC's move around alot is there a way to update an NPC? like get the new tile and stuff?
"Logic never changes, just the syntax" - Kyle Undefined?
Remember, The Edit Button Is There For A Reason!!!
Every NPC has its own index. It's possible to track an NPC by its index. The ID however is shared with all NPCs of the same type.
It's possible to update an NPCs tile by using something similar as this:
(note that I didn't tested this code)Simba Code:function updateNPC(theNPC:TNPC):TNPC;
var
allNPCs:TNPCArray;
i,hi:Integer;
begin
allNPCs := GetNPCs(theNPC.ID);
hi := High(allNPCs);
for i := 0 to hi do
if(allNPCs[i].index = theNPC.index) then
begin
Result := allNPCs[i];
break;
end;
end;
But why do you want to update the NPC? Tracking an NPC is really not worth the trouble in a fighting script.
edit: faster example than HarryJames his suggestion would be:
Simba Code:function fastInfight:Boolean;
var
me:TMe;
begin
me:getMe;
Result := (me.interacting > 0);
end;
Last edited by masterBB; 04-18-2011 at 10:04 AM.
True, forgot that.
Simba Code:function updateNPC(ID:int):TNPC;
var
allNPCs:TNPCArray;
currentNPC:TNPC;
i,hi:Integer;
begin
if not(AreWeInteracting(currentNPC)) then
Exit;
if not(currentNPC.ID = ID) then
Exit;
allNPCs := GetNPCs(ID);
hi := High(allNPCs);
for i := 0 to hi do
if(allNPCs[i].index = currentNPC.index) then
begin
Result := allNPCs[i];
break;
end;
end;
this could be written much shorter ofcourse(how stupid can I be)
Simba Code:function updateNPC(ID:int):TNPC;
var
currentNPC:TNPC;
begin
if not(AreWeInteracting(currentNPC)) then
Exit;
if not(currentNPC.ID = ID) then
Exit;
Result := currentNPC;
end;
Still sleeping :O
Simba Code:function updateNPC(ID:int):TNPC;
var
currentNPC:TNPC;
begin
Result := NULL_NPC;
if (AreWeInteracting(currentNPC)) then
if (currentNPC.ID = ID) then
Result := currentNPC;
end;
Last edited by masterBB; 04-18-2011 at 03:15 PM.
When I'm going to walk to it i would like to see if its already being attacked or what tile its on...
"Logic never changes, just the syntax" - Kyle Undefined?
Remember, The Edit Button Is There For A Reason!!!
There are currently 1 users browsing this thread. (0 members and 1 guests)