Results 1 to 15 of 15

Thread: NPCs

  1. #1
    Join Date
    Dec 2009
    Location
    R_GetPlayerLoc;
    Posts
    2,235
    Mentioned
    0 Post(s)
    Quoted
    14 Post(s)

    Default 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?
    "Logic never changes, just the syntax" - Kyle Undefined?

    Remember, The Edit Button Is There For A Reason!!!

  2. #2
    Join Date
    Dec 2007
    Posts
    2,766
    Mentioned
    2 Post(s)
    Quoted
    37 Post(s)

    Default

    Count npcs ? :s

  3. #3
    Join Date
    Dec 2009
    Location
    R_GetPlayerLoc;
    Posts
    2,235
    Mentioned
    0 Post(s)
    Quoted
    14 Post(s)

    Default

    Quote Originally Posted by Dervish View Post
    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.
    "Logic never changes, just the syntax" - Kyle Undefined?

    Remember, The Edit Button Is There For A Reason!!!

  4. #4
    Join Date
    Feb 2007
    Posts
    849
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Simba Code:
    While infight do wait(333);
    Should work for what you want, obviously you can change for an eating procedure and some antiban etc
    ________________________________________
    14:19 < cycrosism> I wonder what she would have done without it
    14:19 < cycrosism> without me*
    Cycrosism is now an it.
    Quote Originally Posted by Dervish View Post
    /Facedesk.

  5. #5
    Join Date
    Dec 2009
    Location
    R_GetPlayerLoc;
    Posts
    2,235
    Mentioned
    0 Post(s)
    Quoted
    14 Post(s)

    Default

    Thanks I 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!!!

  6. #6
    Join Date
    Dec 2009
    Location
    R_GetPlayerLoc;
    Posts
    2,235
    Mentioned
    0 Post(s)
    Quoted
    14 Post(s)

    Default

    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!!!

  7. #7
    Join Date
    Nov 2010
    Location
    Australia
    Posts
    1,472
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    Quote Originally Posted by Yago View Post
    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

  8. #8
    Join Date
    Oct 2006
    Location
    Netherlands
    Posts
    3,285
    Mentioned
    105 Post(s)
    Quoted
    494 Post(s)

    Default

    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:
    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;
    (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:
    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.

  9. #9
    Join Date
    Sep 2006
    Location
    Canada
    Posts
    1,124
    Mentioned
    0 Post(s)
    Quoted
    5 Post(s)

    Default

    Quote Originally Posted by masterBB View Post
    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.



  10. #10
    Join Date
    Feb 2007
    Posts
    849
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    They will only change like a few times, just store those IDs in a TIntegerArray?
    ________________________________________
    14:19 < cycrosism> I wonder what she would have done without it
    14:19 < cycrosism> without me*
    Cycrosism is now an it.
    Quote Originally Posted by Dervish View Post
    /Facedesk.

  11. #11
    Join Date
    Oct 2006
    Location
    Netherlands
    Posts
    3,285
    Mentioned
    105 Post(s)
    Quoted
    494 Post(s)

    Default

    Quote Originally Posted by Capricorn View Post
    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.

    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.

  12. #12
    Join Date
    Dec 2009
    Location
    R_GetPlayerLoc;
    Posts
    2,235
    Mentioned
    0 Post(s)
    Quoted
    14 Post(s)

    Default

    Quote Originally Posted by masterBB View Post

    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;
    Yea, but what if you're not interacting with the NPC and you want to update it anyways?

    Quote Originally Posted by HarryJames
    hey will only change like a few times, just store those IDs in a TIntegerArray?
    I think there has to be some other way...
    "Logic never changes, just the syntax" - Kyle Undefined?

    Remember, The Edit Button Is There For A Reason!!!

  13. #13
    Join Date
    May 2007
    Posts
    527
    Mentioned
    12 Post(s)
    Quoted
    109 Post(s)

    Default

    Quote Originally Posted by masterBB View Post
    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;
    Doesn't really work if your script is using summoning familiars, like Bunyips while fighting.

  14. #14
    Join Date
    Oct 2006
    Location
    Netherlands
    Posts
    3,285
    Mentioned
    105 Post(s)
    Quoted
    494 Post(s)

    Default

    Quote Originally Posted by Yago View Post
    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?

  15. #15
    Join Date
    Dec 2009
    Location
    R_GetPlayerLoc;
    Posts
    2,235
    Mentioned
    0 Post(s)
    Quoted
    14 Post(s)

    Default

    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!!!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •