Results 1 to 9 of 9

Thread: NPC Locating Reflection/Reflection2

  1. #1
    Join Date
    Aug 2009
    Location
    Nova Scotia, Canada
    Posts
    604
    Mentioned
    0 Post(s)
    Quoted
    56 Post(s)

    Default NPC Locating Reflection/Reflection2

    Anyone have code for finding NPCs that works, either in Reflection or (better still) Reflection 2?

    Tried this code with Simba 0.96 and Reflection and a fresh install of Simba 0.97rc6 with Reflection 2 (on 2 separate machines). Neither finds a thing.

    Usage: Login and stand next to a chicken.

    Simba Code:
    program new;

    {$DEFINE SMART}
    {$i SRL\SRL.scar}
    {$i Reflection\Reflection.simba}

    var
      NPCs: TNPCArray;
      I: integer;

    begin
      Smart_Server := 152;
      Smart_Signed := True;
      Smart_Members:= False;
      Smart_SuperDetail := False;
      SetupSRL;
      ClearDebug;

      NPCs := GetNPCs('Chicken');
      if (Length(NPCs) = 0) then
      begin
        writeln('No NPCs Found.');
        exit;
      end;
      for I := 0 to High(NPCs) do
      begin
        writeln(Format('Name: %s, ID: %d, Tile(%d,%d)', [NPCs[I].Name, NPCs[I].ID, NPCs[I].Tile.X, NPCs[I].Tile.Y]));
      end;
    end.
    Never ever approach a computer saying or even thinking "I will just do this quickly".

  2. #2
    Join Date
    Aug 2007
    Location
    in a random little world
    Posts
    5,778
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

  3. #3
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    Are u trying to debug NPC's?? If your not then grab the ID's of it and then findNPC by ID.. else make sure its not a NULL Npc like the varrock monk
    I am Ggzz..
    Hackintosher

  4. #4
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    Simba Code:
    program NPCFinder;
      {$define SMART}
      {$i srl/srl.scar}
      {$i Reflection/Reflection.simba}

      Procedure DeclarePlayers;
      begin
        HowManyPlayers := 1;
        NumberOfPlayers(HowManyPlayers);
        CurrentPlayer := 0;
        with Players[0] do
        begin
          Name := '';
          Pass := '';
          Nick := '';
          Pin  := '';
          Active := True;
        end;
      end;

      Procedure DisplayNPCs;
      Var
        N: TNPC;
      begin
        Wait(500);
        ClearDebug;
        N := R_GetNPCAt(Point(R_GetMyPos.x,R_GetMyPos.y+1),False);
        if (N = NULL_NPC) then
          Exit;
        Writeln('ID: '+IntToStr(N.ID)+' at Tile('+IntToStr(N.Tile.X)+','+IntToStr(N.Tile.Y)+')');
      end;

    begin
      Smart_Server := 86;
      Smart_Members := True;
      Smart_Signed := True;
      Smart_SuperDetail := False;
      SetupSRL;
      DeclarePlayers;

      repeat
        DisplayNPCs;
      until(false)
    end.

    This will output the NPC (ID/Tile) 1 tile north of your position.

    Edit:
    By the way, this is R2.

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


  5. #5
    Join Date
    Aug 2009
    Location
    Nova Scotia, Canada
    Posts
    604
    Mentioned
    0 Post(s)
    Quoted
    56 Post(s)

    Default

    Quote Originally Posted by Flight View Post
    This will output the NPC (ID/Tile) 1 tile north of your position.
    This completely fails to find anything.

    Quote Originally Posted by Shuttleu View Post
    do you have the latest hooks?

    what hook revision do you have?

    ~shut
    659 Rev 4. Both are running that. Manually updated hooks to 660 rev 1 (which I should not have to do?) and now my script above works. Flight's still does not.

    I should have thought of that. Have had ongoing problems with hooks not updating in a timely manner. Thanks for the help guys. Was just being stupid and not checking my hooks version.

    Edit: Spoke too soon. It works under Reflection. Reflection2 still finds diddly squat.
    Edit2: Updated wrong hooks file on my Reflection2 machine. Grrr. Drives me crazy.
    Last edited by Bixby Sayz; 08-01-2011 at 06:12 PM.
    Never ever approach a computer saying or even thinking "I will just do this quickly".

  6. #6
    Join Date
    Jul 2008
    Location
    Canada
    Posts
    1,612
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Use Rsbot if you want the easy way out

  7. #7
    Join Date
    Feb 2008
    Posts
    748
    Mentioned
    1 Post(s)
    Quoted
    14 Post(s)

    Default

    Calling R_UpdateHooks() at the start of your script?

  8. #8
    Join Date
    Aug 2009
    Location
    Nova Scotia, Canada
    Posts
    604
    Mentioned
    0 Post(s)
    Quoted
    56 Post(s)

    Default

    Quote Originally Posted by Smarter Child View Post
    Use Rsbot if you want the easy way out
    Grabbed the latest but it keeps throwing an error everytime I turn on show NPCs. Can't win.
    Never ever approach a computer saying or even thinking "I will just do this quickly".

  9. #9
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    In my debug script change this:

    Simba Code:
    N := R_GetNPCAt(Point(R_GetMyPos.x,R_GetMyPos.y+1),False);
        if (N = NULL_NPC) then
          Exit;

    to this:

    Simba Code:
    N := R_GetNPCAt(Point(R_GetMyPos.x,R_GetMyPos.y+1),True);
        if (N.ID = -1) then
          Exit;

    That includes 'nulled' NPCs in the search.

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


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
  •