View Full Version : NPCs
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?
Dervish
04-15-2011, 11:52 PM
Count npcs ? :s
Count npcs ? :s
You mean like getnpcs and count how many and if one has disappeared then blah?
Yeah, but if one disappeared elsewhere then you wouldnt know if that was the one your fighting.
HarryJames
04-15-2011, 11:56 PM
While infight do wait(333);
Should work for what you want, obviously you can change for an eating procedure and some antiban etc :)
Thanks :) I tried that before but I forgot to add something to detect fight start so I thought it was bugged
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?
KingKong
04-18-2011, 04:27 AM
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?
I dont think its possible for two npcs to have the same ids/index. and as for finding the npcs that move, just put the finding npcs func/proc in a loop and itll find it
masterBB
04-18-2011, 09:56 AM
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:
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;
(note that I didn't tested this code)
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:
function fastInfight:Boolean;
var
me:TMe;
begin
me:getMe;
Result := (me.interacting > 0);
end;
Capricorn
04-18-2011, 10:12 AM
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:
You would probably think that and it would make 100% sense for it to work that way until you find out the indexes for NPCs change randomly about every 10-15 seconds.
HarryJames
04-18-2011, 10:27 AM
They will only change like a few times, just store those IDs in a TIntegerArray?
masterBB
04-18-2011, 03:07 PM
You would probably think that and it would make 100% sense for it to work that way until you find out the indexes for NPCs change randomly about every 10-15 seconds.
True, forgot that.
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;) )
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
function updateNPC(ID:int):TNPC;
var
currentNPC:TNPC;
begin
Result := NULL_NPC;
if (AreWeInteracting(currentNPC)) then
if (currentNPC.ID = ID) then
Result := currentNPC;
end;
function updateNPC(ID:int):TNPC;
var
currentNPC:TNPC;
begin
Result := NULL_NPC;
if (AreWeInteracting(currentNPC)) then
if (currentNPC.ID = ID) then
Result := currentNPC;
end;
Yea, but what if you're not interacting with the NPC and you want to update it anyways?
hey will only change like a few times, just store those IDs in a TIntegerArray?
I think there has to be some other way...
superuser
04-18-2011, 11:15 PM
edit: faster example than HarryJames his suggestion would be:
function fastInfight:Boolean;
var
me:TMe;
begin
me:getMe;
Result := (me.interacting > 0);
end;
Doesn't really work if your script is using summoning familiars, like Bunyips while fighting.
masterBB
04-18-2011, 11:24 PM
Yea, but what if you're not interacting with the NPC and you want to update it anyways?
I think there has to be some other way...
Unless there is only one of them, there isn't. In what situation would you like to update it? Maybe there is some unique way?
When I'm going to walk to it i would like to see if its already being attacked or what tile its on...
Powered by vBulletin® Version 4.2.1 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.