Results 1 to 13 of 13

Thread: NPC Finding [Struggling hard]

  1. #1
    Join Date
    Feb 2013
    Location
    Narnia
    Posts
    615
    Mentioned
    8 Post(s)
    Quoted
    252 Post(s)

    Default NPC Finding [Struggling hard]

    so for almost two weeks now ive been trying to rewrite my function to talk to an NPC (the competition judge at the range guild) that has the exact same colors as nearby guards (which i do not want to click on AT ALL) but for what ever function i use the script will eventually ignore the check up text and click on a guard. ive been told to try ATPA's and TPA's so i did but it still clicks on the guards and its really slowed down my script. Not sure if i called everything right or if im missing some important things? im still relatively new hence all the selfcomments and this is my first ATPA/TPA attempt at finding something. need some real help and suggestions! *starting to pull my hair out*

    Simba Code:
    procedure Start_Comp;

    Var
       JudgeHeadTPA: TPointArray;
       JudgeHeadATPA, JudgeBodyATPA: T2DPointArray;
       tempCTS, i, jx, jy, judgefindtimer: Integer;

    begin
      writeln('searching');
      tempCTS := GetColorToleranceSpeed; //normal CTS
      SetColorToleranceSpeed(2); //new CTS
      SetToleranceSpeed2Modifiers(0.00,0.11); //enter hue and sat mods found with ACA

      FindColorsTolerance(JudgeHeadTPA, 6774623, MSX1, MSY1, MSX2, MSY2, 12); //enter the color and tolerance ACA found. Make appropriate parameters

      SetColorToleranceSpeed(tempCTS); //change back to normal
      SetToleranceSpeed2Modifiers(0.02, 0.02); //change back to normal
      //JudgeHeadATPA := TPAToATPAEx(JudgeHeadTPA, 7, 5);
      JudgeHeadATPA := SplitTPAEx(JudgeHeadTPA, 7,5); //width and height searching bounds
      SortATPASize(JudgeHeadATPA, True);
      SortATPAFromFirstPoint(JudgeHeadATPA, Point(MSCX, MSCY));

      for i := 0 To High(JudgeHeadATPA) do
      begin
        marktime(judgefindtimer);
        SMART_DrawDotsEx(True, JudgeHeadATPA[i], clLime);
        MiddleTPAEx(JudgeHeadATPA[i], jx, jy);
        MMouse(jx, jy, 3, 3);
        if (IsUpTextMultiCustom(['-', 'omp'])) then
        begin
          ClickMouse2(mouse_left);
          break;
        end;
        if(timefrommark(judgefindtimer) > 10000) then
        begin
          writeln('negatory');
          Logout;
          TerminateScript;
        end;
      end;
    end;

    View my OSR Script Repository!


    Botted to max
    Guides: How to Report Bugs to the Scripter
    ~~~~ Moved to Java. Currently Lurking ~~~~

  2. #2
    Join Date
    Feb 2012
    Location
    Wonderland
    Posts
    1,988
    Mentioned
    41 Post(s)
    Quoted
    272 Post(s)

    Default

    Not sure if this is the end-goal you're looking for or not, but from mustering up some code on the tired/sluggish brain of mine (at the moment), I think this may help point you (at minimum) in the right direction.
    I spaced the code out into somewhat repetitive format, yet it shouldn't affect your script immensely, but should also help show the flow of code calls being done. It can get tricky sorting out false-positives, so even more checks couldn't hurt (ex. superuser has a nice surface object / small guide on what I'm talking about).

    Nonetheless
    Simba Code:
    function TalkToNPC(): Boolean; // result in a boolean type, because it is useful to know if we talked to the NPC or not
    var
      i, t, TempCTS: Integer;
      OldHue, OldSat: Extended;
      Pt: TPoint;
      TPA: TPointArray;
      ATPA: T2DPointArray;
    begin
      Result := False;

      // Save old CTS 2 stuffs, then setup the new stuffs to seach with
      TempCTS := GetColorToleranceSpeed();
      GetColorspeed2Modifiers(OldHue, OldSat);
      ColorToleranceSpeed(2);
      SetColorspeed2Modifiers(0.00, 0.11);

      // tpa search + length check for inadequate results
      FindColorsTolerance(TPA, 6774623, MSX1, MSY1, MSX2, MSY2, 12);
      if (Length(TPA) < 1) then
      begin
        ColorToleranceSpeed(TempCTS);
        SetColorspeed2Modifiers(OldHue, OldSat);
      end;

      // atpa split + length check for inadequate results
      SplitTPAExWrap(TPA, 7, 5, ATPA);
      if (Length(ATPA) < 1) then
      begin
        ColorToleranceSpeed(TempCTS);
        SetColorspeed2Modifiers(OldHue, OldSat);
      end;

      // atpa sorting
      SortATPASize(ATPA, True);
      SortATPAFromFirstPoint(ATPA, Point(MSCX, MSCY));

      // remove tpa's in the atpa that exceed a large-ish distances (in terms of searching for a NPC's head)
      for i := 0 to high(ATPA) do
        if (Distance(ATPA[i][Low(ATPA[i])].x, ATPA[i][Low(ATPA[i])].y,
              ATPA[i][High(ATPA[i])].x, ATPA[i][High(ATPA[i])].y) > 2 shl 4) then
          DeleteValueInATPA(ATPA, i);
      // atpa length check for inadequate results
      if (Length(ATPA) < 1) then
      begin
        ColorToleranceSpeed(TempCTS);
        SetColorspeed2Modifiers(OldHue, OldSat);
      end;

      // remove tpa's in the atpa that don't match at least 10 points/pixels and are under 100 too
      for i := 0 to high(ATPA) do
        if not ((Length(ATPA[i]) < 100) and (Length(ATPA[i]) > 10)) then
          DeleteValueInATPA(ATPA, i);
      // atpa length check for inadequate results
      if (Length(ATPA) < 1) then
      begin
        ColorToleranceSpeed(TempCTS);
        SetColorspeed2Modifiers(OldHue, OldSat);
      end;

      // Mark time marker, used potentially later if we exceed 10 seconds
      MarkTime(t);
      for i := 0 to high(ATPA) do
      begin
        MiddleTPAEx(ATPA[i], Pt.x, Pt.y);
        MMouse(Pt.x, Pt.y, 3, 3);
        if (IsUpTextMultiCustom(['-', 'omp'])) then
        begin
          Result := True; // reached objective
          ClickMouse2(Mouse_Left);
          Break;
        end;
        if (TimeFromMark(t) > 10000) then
        begin
          LogOut;
          Break;
        end;
      end;
    end;

    Cheers,
    LJ

  3. #3
    Join Date
    Feb 2013
    Location
    Narnia
    Posts
    615
    Mentioned
    8 Post(s)
    Quoted
    252 Post(s)

    Default

    cool ill try this in a bit and let you know. and ya, I had a failsafe ready, the judgebodyatpa, but I wanted to make sure that wasnt screwing it up. I have a pending question in that section aswell :P

    thanks Lj!

    View my OSR Script Repository!


    Botted to max
    Guides: How to Report Bugs to the Scripter
    ~~~~ Moved to Java. Currently Lurking ~~~~

  4. #4
    Join Date
    Jan 2012
    Posts
    1,104
    Mentioned
    18 Post(s)
    Quoted
    211 Post(s)

    Default

    I had the same problem. Uptext reading is sometimes buggy and one mistake can kill you easily (if you dont check for combat).
    This is why I switched to right clicking to find the Judge. Also you should sort the ATPA from the point where you found the ranger last time (global variable) so it finds the ranger faster.

  5. #5
    Join Date
    Feb 2013
    Location
    Narnia
    Posts
    615
    Mentioned
    8 Post(s)
    Quoted
    252 Post(s)

    Default

    Quote Originally Posted by Shatterhand View Post
    I had the same problem. Uptext reading is sometimes buggy and one mistake can kill you easily (if you dont check for combat).
    This is why I switched to right clicking to find the Judge. Also you should sort the ATPA from the point where you found the ranger last time (global variable) so it finds the ranger faster.
    Mine too I had right click but as I started learning more I thought I could prevent the guard clicking and could use the left click. You dont think right clicking the Judge hours on end wont get flagged for bot-like? its looking like my only solution to not attacking a guard. and by archer did you mean judge? its good to know im not doing something wrong then and it is sometimes buggy lol been pulling my hair out for over two weeks. thanks

    View my OSR Script Repository!


    Botted to max
    Guides: How to Report Bugs to the Scripter
    ~~~~ Moved to Java. Currently Lurking ~~~~

  6. #6
    Join Date
    Feb 2013
    Location
    Narnia
    Posts
    615
    Mentioned
    8 Post(s)
    Quoted
    252 Post(s)

    Default

    Quote Originally Posted by Le Jingle View Post
    Not sure if this is the end-goal you're looking for or not, but from mustering up some code on the tired/sluggish brain of mine (at the moment), I think this may help point you (at minimum)
    so it found the judge but it would never click him, it would mouse over him then go to my inv tab and keep hovering around the tab. definetly helpful though. how do know what size or length of a ATPA you are looking for?? like 'if (Length(ATPA) < 1) then' what does that mean?

    Simba Code:
    function Start_Comp(): Boolean; // result in a boolean type, because it is useful to know if we talked to the NPC or not
    var
      i, t, TempCTS: Integer;
      OldHue, OldSat: Extended;
      Pt: TPoint;
      TPA: TPointArray;
      ATPA: T2DPointArray;
    begin
      Result := False;

      // Save old CTS 2 stuffs, then setup the new stuffs to seach with
      TempCTS := GetColorToleranceSpeed();
      GetColorspeed2Modifiers(OldHue, OldSat);
      ColorToleranceSpeed(2);
      SetColorspeed2Modifiers(0.00, 0.11);

      // tpa search + length check for inadequate results
      FindColorsTolerance(TPA, 6774623, MSX1, MSY1, MSX2, MSY2, 12);
      if (Length(TPA) < 1) then
      begin
        ColorToleranceSpeed(TempCTS);
        SetColorspeed2Modifiers(OldHue, OldSat);
      end;

      // atpa split + length check for inadequate results
      SplitTPAExWrap(TPA, 7, 5, ATPA);
      if (Length(ATPA) < 1) then
      begin
        ColorToleranceSpeed(TempCTS);
        SetColorspeed2Modifiers(OldHue, OldSat);
      end;

      // atpa sorting
      SortATPASize(ATPA, True);
      SortATPAFromFirstPoint(ATPA, Point(MSCX, MSCY));

      // remove tpa's in the atpa that exceed a large-ish distances (in terms of searching for a NPC's head)
      for i := 0 to high(ATPA) do
        if (Distance(ATPA[i][Low(ATPA[i])].x, ATPA[i][Low(ATPA[i])].y,
              ATPA[i][High(ATPA[i])].x, ATPA[i][High(ATPA[i])].y) > 2 shl 4) then
          DeleteValueInATPA(ATPA, i);
      // atpa length check for inadequate results
      if (Length(ATPA) < 1) then
      begin
        ColorToleranceSpeed(TempCTS);
        SetColorspeed2Modifiers(OldHue, OldSat);
      end;

      // remove tpa's in the atpa that don't match at least 10 points/pixels and are under 100 too
      for i := 0 to high(ATPA) do
        if not ((Length(ATPA[i]) < 100) and (Length(ATPA[i]) > 10)) then
          DeleteValueInATPA(ATPA, i);
      // atpa length check for inadequate results
      if (Length(ATPA) < 1) then
      begin
        ColorToleranceSpeed(TempCTS);
        SetColorspeed2Modifiers(OldHue, OldSat);
      end;

      // Mark time marker, used potentially later if we exceed 10 seconds
      MarkTime(t);
      for i := 0 to high(ATPA) do
      begin
        writeln('found');
        MiddleTPAEx(ATPA[i], Pt.x, Pt.y);
        SMART_DebugATPA(False, ATPA);
        MMouse(Pt.x, Pt.y, 3, 3);
        if (IsUpTextMultiCustom(['omp', 'tition'])) then
        begin
          writeln('found again');
          Result := True; // reached objective
          ClickMouse2(Mouse_Left);
          writeln('did click');
          Break;
        end;
        if (TimeFromMark(t) > 10000) then
        begin
          LogOut;
          Break;
        end;
    end;
    end;

    View my OSR Script Repository!


    Botted to max
    Guides: How to Report Bugs to the Scripter
    ~~~~ Moved to Java. Currently Lurking ~~~~

  7. #7
    Join Date
    Sep 2012
    Location
    Here.
    Posts
    2,007
    Mentioned
    88 Post(s)
    Quoted
    1014 Post(s)

    Default

    Quote Originally Posted by ibot_dung11 View Post
    so it found the judge but it would never click him, it would mouse over him then go to my inv tab and keep hovering around the tab. definetly helpful though. how do know what size or length of a ATPA you are looking for?? like 'if (Length(ATPA) < 1) then' what does that mean?

    Simba Code:
    function Start_Comp(): Boolean; // result in a boolean type, because it is useful to know if we talked to the NPC or not
    var
      i, t, TempCTS: Integer;
      OldHue, OldSat: Extended;
      Pt: TPoint;
      TPA: TPointArray;
      ATPA: T2DPointArray;
    begin
      Result := False;

      // Save old CTS 2 stuffs, then setup the new stuffs to seach with
      TempCTS := GetColorToleranceSpeed();
      GetColorspeed2Modifiers(OldHue, OldSat);
      ColorToleranceSpeed(2);
      SetColorspeed2Modifiers(0.00, 0.11);

      // tpa search + length check for inadequate results
      FindColorsTolerance(TPA, 6774623, MSX1, MSY1, MSX2, MSY2, 12);
      if (Length(TPA) < 1) then
      begin
        ColorToleranceSpeed(TempCTS);
        SetColorspeed2Modifiers(OldHue, OldSat);
      end;

      // atpa split + length check for inadequate results
      SplitTPAExWrap(TPA, 7, 5, ATPA);
      if (Length(ATPA) < 1) then
      begin
        ColorToleranceSpeed(TempCTS);
        SetColorspeed2Modifiers(OldHue, OldSat);
      end;

      // atpa sorting
      SortATPASize(ATPA, True);
      SortATPAFromFirstPoint(ATPA, Point(MSCX, MSCY));

      // remove tpa's in the atpa that exceed a large-ish distances (in terms of searching for a NPC's head)
      for i := 0 to high(ATPA) do
        if (Distance(ATPA[i][Low(ATPA[i])].x, ATPA[i][Low(ATPA[i])].y,
              ATPA[i][High(ATPA[i])].x, ATPA[i][High(ATPA[i])].y) > 2 shl 4) then
          DeleteValueInATPA(ATPA, i);
      // atpa length check for inadequate results
      if (Length(ATPA) < 1) then
      begin
        ColorToleranceSpeed(TempCTS);
        SetColorspeed2Modifiers(OldHue, OldSat);
      end;

      // remove tpa's in the atpa that don't match at least 10 points/pixels and are under 100 too
      for i := 0 to high(ATPA) do
        if not ((Length(ATPA[i]) < 100) and (Length(ATPA[i]) > 10)) then
          DeleteValueInATPA(ATPA, i);
      // atpa length check for inadequate results
      if (Length(ATPA) < 1) then
      begin
        ColorToleranceSpeed(TempCTS);
        SetColorspeed2Modifiers(OldHue, OldSat);
      end;

      // Mark time marker, used potentially later if we exceed 10 seconds
      MarkTime(t);
      for i := 0 to high(ATPA) do
      begin
        writeln('found');
        MiddleTPAEx(ATPA[i], Pt.x, Pt.y);
        SMART_DebugATPA(False, ATPA);
        MMouse(Pt.x, Pt.y, 3, 3);
        if (WaitUpTextMultiCustom(['omp', 'tition'], 600)) then
        begin
          writeln('found again');
          Result := True; // reached objective
          ClickMouse2(Mouse_Left);
          writeln('did click');
          Break;
        end else begin
          writeLn('Uptext is actually: ' + GetUpText);
        end;
        if (TimeFromMark(t) > 10000) then
        begin
          LogOut;
          Break;
        end;
    end;
    end;
    I edited the code in my code to something I think should help (basically added a wait to your highlight of the judge and if it fails, prints out the uptext it's grabbing so you can debug your TStringArray you're passing it). Try that?

  8. #8
    Join Date
    Feb 2012
    Location
    Wonderland
    Posts
    1,988
    Mentioned
    41 Post(s)
    Quoted
    272 Post(s)

    Default

    Quote Originally Posted by Kevin View Post
    I edited the code in my code to something I think should help (basically added a wait to your highlight of the judge and if it fails, prints out the uptext it's grabbing so you can debug your TStringArray you're passing it). Try that?
    This could indeed be a cause to the explained error. Waiting may help increase your success in clicking the NPC, as well as possibly trying to right click him and using a wait choose option function (this could be one of a multitude of other approaches) to check the options text for your desired result.

  9. #9
    Join Date
    Feb 2013
    Location
    Narnia
    Posts
    615
    Mentioned
    8 Post(s)
    Quoted
    252 Post(s)

    Default

    ill give that a try, seems like it will help quite a bit!

    what about surfaces? how do i decide what surface part or colors to use? do i litteraly need to use every color on the judge or can i pick certain colors/parts as i do with ATPA and FindObj

    View my OSR Script Repository!


    Botted to max
    Guides: How to Report Bugs to the Scripter
    ~~~~ Moved to Java. Currently Lurking ~~~~

  10. #10
    Join Date
    Feb 2012
    Location
    Wonderland
    Posts
    1,988
    Mentioned
    41 Post(s)
    Quoted
    272 Post(s)

    Default

    Quote Originally Posted by ibot_dung11 View Post
    ill give that a try, seems like it will help quite a bit!

    what about surfaces? how do i decide what surface part or colors to use? do i litteraly need to use every color on the judge or can i pick certain colors/parts as i do with ATPA and FindObj
    Well, iirc, there are many properties to be used to help narrow your specific surface object in question. If parts of the surface are confusing, then asking on superuser's thread as well as reading tutorials about object finding via colors in the tutorial section may help in the process of defining what colors and what to set up in your code for precise and accurate searches/locating.
    -Lj

  11. #11
    Join Date
    Feb 2013
    Location
    Narnia
    Posts
    615
    Mentioned
    8 Post(s)
    Quoted
    252 Post(s)

    Default

    it appears the waituptext has fixed it, didnt know that function exhisted. thanks guys
    what would you say is a human like time between moving the mouse to a position x,y then clicking? i think theres a function for it but idk the name
    Last edited by Sk1nyNerd; 05-04-2013 at 08:24 PM.

    View my OSR Script Repository!


    Botted to max
    Guides: How to Report Bugs to the Scripter
    ~~~~ Moved to Java. Currently Lurking ~~~~

  12. #12
    Join Date
    Jan 2012
    Posts
    1,104
    Mentioned
    18 Post(s)
    Quoted
    211 Post(s)

    Default

    Quote Originally Posted by ibot_dung11 View Post
    what would you say is a human like time between moving the mouse to a position x,y then clicking? i think theres a function for it but idk the name
    What do you mean? You cant decide if its the judge without moving the mouse on it.

  13. #13
    Join Date
    Feb 2013
    Location
    Narnia
    Posts
    615
    Mentioned
    8 Post(s)
    Quoted
    252 Post(s)

    Default

    Quote Originally Posted by Shatterhand View Post
    What do you mean? You cant decide if its the judge without moving the mouse on it.
    the mouse is already on the judge. becase when u move your mouse to a postion you dont instantly click when you get there, there's a lag time. nah mean? lol

    View my OSR Script Repository!


    Botted to max
    Guides: How to Report Bugs to the Scripter
    ~~~~ Moved to Java. Currently Lurking ~~~~

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
  •