Results 1 to 4 of 4

Thread: How do I find a NPC?

  1. #1
    Join Date
    Sep 2009
    Posts
    37
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Question How do I find a NPC?

    So I am currently working on a script, as u can tell my me having a quesion about scripting lol.... But anyways, in this script I need to find the NPC so I can Right Click him, etc... I know about the right clicking part and all, but Im not really quite sure how to find the NPC... Should I use a DTM, I dont think so since he moves... Plus there are other NPC's around him that look exactly like him, but have a different name... Please someone help me! It will be greatly appreciated!

    P.S. I have seen the FindNPC and GetNPC functions from the Reflection files, but I have no earthly idea of what they do, so if those are the best way to do this then just teach me what those do and how to use them if possible =) thank you!!!!!

    P.S.S. Im fairly new to scripting... I would say I am an Intermediate scripter.... Freshman in College, working towards a Computer Science Major...

    Well thanks to everyone that reads this and many more thanks to anyone who can help me =) Thanks alot!
    ~-~ Quit Rs 4 Klit Rs ~-~

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

    Default

    This gives you the name and id of all currently loaded npcs:
    Simba Code:
    procedure SearchNPCs;
    var
      a: Integer;
      NPCs: TNPCArray;
    begin
      NPCs := GetNPCs(False);
      for a := 0 to high(NPCs) do
      begin
        writeln(NPCs[a].Name + ToStr(NPCs[a].ID);
      end;
    end;

    After you run this, record the Id of the npc you want, then run this:
    Simba Code:
    function InteractNPC(Name: string): Boolean;
    var
      ID, height, a: Integer;
      NPC: TNPC;
      NPC_Tile: TPoint;
    begin
      ID := 0; //<---------replace 0 with id of npc
      Result := False;
      NPC := GetNPCMulti([ID]);
      NPC_Tile := TileToMS(NPC.Tile, NPC.height);
      Mouse(NPC_Tile.x, NPC_Tile.y, 0, 0, False);
      WaitOptionMultiEx(['alk-'], 'action', ClickLeft, 1000);
      while (a < 5) and (IsMoving) do
      begin
        wait(700 + randomrange(-50, 200));
        R_FindRandoms;
        Inc(a);
      end;
      wait(1218 + random(100));
      if InteractingWithMe(NPC) then
        Result := True;
    end;

  3. #3
    Join Date
    Feb 2009
    Location
    Irvine, CA
    Posts
    2,873
    Mentioned
    8 Post(s)
    Quoted
    138 Post(s)

    Default

    Well, it really depends if you want to use reflection or color. Color is more complex, but in the long run will create a more stable function. Reflection is easy to code, but liable to break.

    If you want to do this in color, then try looking at some of the tutorials about TPointArrays (Commonly abbreviated as "TPA"). A TPointArray is exactly what the name implies; an array of points on the screen. The points are gathered by various methods, the most common being functions in Simba like "FindColorsTolerance." These functions look for colors on the screen, and store the points where the colors are found in the TPA. The TPA is then split into an "Array of TPointArray", (abbreviated ATPA commonly) by using one of the functions in the wizzyplugin, like TPAtoATPA or SplitTPA; a list of the functions in the wizzyplugin and what they do can be found in SRL\SRL\Misc\wizzyplugin.scar.

    Reflection uses java hooking methods to read the client. You could supply an NPC's name or ID and use the functions in the Reflection include to find all the NPCs that match the criteria. You can then sort through this "TNPCArray" to find an NPC that matches all of the things you need (e.g. an NPC whose name is "Guard", is not in a fight, and is nearer to you than any other NPCs like this). Once you've done that, you can use either "TileToMS" or "TileToMSEx" to generate a TPoint that will click the tile the NPC you've found is on.

    That's a quick rundown of the 2 methods you could use to find an NPC in Simba. Post back with questions or for clarification.

  4. #4
    Join Date
    Nov 2007
    Location
    46696E6C616E64
    Posts
    3,069
    Mentioned
    44 Post(s)
    Quoted
    302 Post(s)

    Default

    Do a TPA search with all of his colors (with tolerances), then combine the arrays and do ATPA conversion with the NPC size, then sort from MS center and loop through all found from nearest and when found the right uptext, right click it.
    There used to be something meaningful here.

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
  •