Results 1 to 21 of 21

Thread: DTM help

  1. #1
    Join Date
    Dec 2011
    Posts
    327
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default DTM help

    Edit: Can anyone answer this?
    Does anyone know how to stop a DTM from searching after it's already clicked the DTM?



    I'm making another dtm for port sarim, fishing shops' door. For my harpoon buying script but I'm having a lot of trouble making it.
    Every time I set the color tolerance between 1 and 9 it is unable to find the door but if I set it to 10 it clicks on the door and then the mouse starts to randomly hover all over my the screen going for the same color.
    This is confusing me a lot, since I've made a DTM for this door that worked perfectly but it broke today.
    The angle is fine and I have selected the runescape client/ smart. I've tried everything I can think of.
    No TPAs, bitmaps, findcustom, etc work in this room for that door.
    Last edited by Deadly Serious; 01-17-2012 at 11:46 PM.

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

    Default

    Don't use dtms for mainscreen object detection, use tpa's/atpa's(if they don't work give us a screenshot and the rest of us here can help) they're far more accurate. As for your mouse moving randomly, you probably didn't tell it stop searching for the dtm after you clicked it.

  3. #3
    Join Date
    Dec 2011
    Posts
    327
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by KingKong View Post
    Don't use dtms for mainscreen object detection, use tpa's/atpa's(if they don't work give us a screenshot and the rest of us here can help) they're far more accurate. As for your mouse moving randomly, you probably didn't tell it stop searching for the dtm after you clicked it.
    TPAs don't work in there, there are things with the same color tolerance and height in there. How do I stop the DTM from searching after you click it?

  4. #4
    Join Date
    Dec 2011
    Posts
    353
    Mentioned
    3 Post(s)
    Quoted
    8 Post(s)

    Default

    Quote Originally Posted by Deadly Serious View Post
    TPAs don't work in there, there are things with the same color tolerance and height in there. How do I stop the DTM from searching after you click it?
    Im sure tpas do work in there, why shouldn't it?

    anyways u can use this:
    Simba Code:
    if DTMRotated(DTM, x, y, MMX1, MMY1, MMX2, MMY2) then
    begin
    Mouse(x, y, 5, 5, true);
    end;

  5. #5
    Join Date
    Dec 2011
    Posts
    327
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by NexPB View Post
    Im sure tpas do work in there, why shouldn't it?

    anyways u can use this:
    Simba Code:
    if DTMRotated(DTM, x, y, MMX1, MMY1, MMX2, MMY2) then
    begin
    Mouse(x, y, 5, 5, true);
    end;
    It auto corrects runescapes' random small rotation every trip.
    TPAs don't work there because there's 2 boxes that stack up which are nearly the same height/ width, which are exactly the same color on spots if you get the color picker and check.
    Edit: I fixed it, I put 10 tolerance for the main point and then I put 5 tolerance for the subpoints and it seemed to work.
    Edit: Spoke to soon, does the hovering shit again :S
    Last edited by Deadly Serious; 01-17-2012 at 10:17 PM.

  6. #6
    Join Date
    Oct 2011
    Posts
    805
    Mentioned
    21 Post(s)
    Quoted
    152 Post(s)

    Default

    Post screenshot here ,maybe someone will be able to help you with finding function.

  7. #7
    Join Date
    Dec 2011
    Posts
    327
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

  8. #8
    Join Date
    Dec 2011
    Posts
    353
    Mentioned
    3 Post(s)
    Quoted
    8 Post(s)

    Default

    Quote Originally Posted by Deadly Serious View Post
    It auto corrects runescapes' random small rotation every trip.
    TPAs don't work there because there's 2 boxes that stack up which are nearly the same height/ width, which are exactly the same color on spots if you get the color picker and check.
    Edit: I fixed it, I put 10 tolerance for the main point and then I put 5 tolerance for the subpoints and it seemed to work.
    Edit: Spoke to soon, does the hovering shit again :S
    Here is my object clicking and finding method maybe you can use it if u credit me

    Simba Code:
    function ClickObject(col, col2, tol: integer; uptext, action: String; LeftClick: boolean): boolean;
    var
    i, x, y, cts: Integer;
    tpa: TPointArray;
    atpa: T2DPointArray;
    pt: TPoint;
    begin
      cts := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      FindColorsTolerance(tpa, col, MSX1, MSY1, MSX2, MSY2, tol);
      if Length(tpa) = 0 then FindColorsTolerance(tpa, col2, MSX1, MSY1, MSX2, MSY2, tol);
      ColorToleranceSpeed(cts);
      atpa := TPAtoATPA(tpa, High(tpa));
      SortATPAFrom(atpa, Point(MSCX, MSCY));
      for i := 0 to High(atpa) do
      begin
        pt := MiddleTPA(atpa[i]);
        MMouse(pt.x, pt.y, 4, 4);
        wait(300 + random(250));
        if (IsUpText(uptext)) then
        begin
          writeln('Found object.');
          GetMousePos(x, y);
          if (not(LeftClick)) then
          begin
            Mouse(x, y, 0, 0, False);
            wait(500 + random(150));
            ChooseOption(action);
            if (DidRedClick) then
            wait(1250 + random(500));
            result := true;
            Exit;
          end else
          if (LeftClick) then
          begin
            Mouse(x, y, 0, 0, true);
            if (DidRedClick) then
            wait(750 + random(350));
            result := true;
            Exit;
          end;
        end;
      end;
    end;

  9. #9
    Join Date
    Feb 2009
    Location
    Hungary (GMT + 1)
    Posts
    1,774
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    doorprofiles.simba

    Very neat stuff.
    I don't think it will work though, colors changed at minimum, but other things may be broken too. Either try to fix it yourself, file a bug at the tracker or just use it as an idea.
    Yeah, if it works it should solve your problems if I get correctly what problems you got .

    It's in srl's misc folder btw.
    There are plenty very very useful, yet quiet forgotten functions.

  10. #10
    Join Date
    Sep 2010
    Location
    Azeroth
    Posts
    395
    Mentioned
    0 Post(s)
    Quoted
    17 Post(s)

    Default

    you CLEARLY have A GIANT WHITE line to work with the top to the wall to the door

  11. #11
    Join Date
    Dec 2011
    Posts
    327
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by NexPB View Post
    Here is my object clicking and finding method maybe you can use it if u credit me

    Simba Code:
    function ClickObject(col, col2, tol: integer; uptext, action: String; LeftClick: boolean): boolean;
    var
    i, x, y, cts: Integer;
    tpa: TPointArray;
    atpa: T2DPointArray;
    pt: TPoint;
    begin
      cts := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      FindColorsTolerance(tpa, col, MSX1, MSY1, MSX2, MSY2, tol);
      if Length(tpa) = 0 then FindColorsTolerance(tpa, col2, MSX1, MSY1, MSX2, MSY2, tol);
      ColorToleranceSpeed(cts);
      atpa := TPAtoATPA(tpa, High(tpa));
      SortATPAFrom(atpa, Point(MSCX, MSCY));
      for i := 0 to High(atpa) do
      begin
        pt := MiddleTPA(atpa[i]);
        MMouse(pt.x, pt.y, 4, 4);
        wait(300 + random(250));
        if (IsUpText(uptext)) then
        begin
          writeln('Found object.');
          GetMousePos(x, y);
          if (not(LeftClick)) then
          begin
            Mouse(x, y, 0, 0, False);
            wait(500 + random(150));
            ChooseOption(action);
            if (DidRedClick) then
            wait(1250 + random(500));
            result := true;
            Exit;
          end else
          if (LeftClick) then
          begin
            Mouse(x, y, 0, 0, true);
            if (DidRedClick) then
            wait(750 + random(350));
            result := true;
            Exit;
          end;
        end;
      end;
    end;

    I'll try it and I'll credit you if it works.

    Quote Originally Posted by Sabzi View Post
    doorprofiles.simba

    Very neat stuff.
    I don't think it will work though, colors changed at minimum, but other things may be broken too. Either try to fix it yourself, file a bug at the tracker or just use it as an idea.
    Yeah, if it works it should solve your problems if I get correctly what problems you got .

    It's in srl's misc folder btw.
    There are plenty very very useful, yet quiet forgotten functions.
    Looks interesting, I'll try it soon.

    Quote Originally Posted by wantonman View Post
    you CLEARLY have A GIANT WHITE line to work with the top to the wall to the door
    If I used that line it'll just start hovering all over the room, since it's all the same color.

  12. #12
    Join Date
    Dec 2007
    Posts
    2,112
    Mentioned
    71 Post(s)
    Quoted
    580 Post(s)

    Default

    I'd Make the compass to north, find the red line on the Minimap, Use MMToMS then Do a spiral TPA search?

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

    Default

    Quote Originally Posted by Deadly Serious View Post
    TPAs don't work in there, there are things with the same color tolerance and height in there.
    Tried using more than one color from the door?

  14. #14
    Join Date
    Dec 2011
    Posts
    327
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by pur3b100d View Post
    I'd Make the compass to north, find the red line on the Minimap, Use MMToMS then Do a spiral TPA search?
    Hm, I might need to do a little bit more research before I could pull that off :P


    Quote Originally Posted by KingKong View Post
    Tried using more than one color from the door?
    Yes, I've used multiple colors, receiving the same outcome.

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

    Default

    Quote Originally Posted by Deadly Serious View Post
    Hm, I might need to do a little bit more research before I could pull that off :P




    Yes, I've used multiple colors, receiving the same outcome.
    I meant use, more than one color at the same time to find the door. That shouldn't fail. Also you should sort your ATPA properly, nothing is impossible, just very hard.

  16. #16
    Join Date
    Oct 2011
    Posts
    805
    Mentioned
    21 Post(s)
    Quoted
    152 Post(s)

    Default

    I'm working on it. On your screenshot i reduced objects to 3..


    However testing in game is much harder ,I've got here 10-20 separated objects.



    I have now simple idea how to do it. I think my function is a bit overpowered for this search (I tangled 3 colors to find objects) So:
    • simple make door color TPA (FindColorstolerance) ,but search inside box appointed by walls of building (FindColorstolerance and GetTpaBounds)
    • make ATPA (TPAtoATPAEx)
    • now sort subTPAs by higher y position of their middle point (MiddleTPA) --> higher y position means that object is more on south
    • As long as compas is faced north mouse will find doors at first try (ATPA[0] = doors)


    Only thing I'm afraid is color changing.

  17. #17
    Join Date
    Dec 2011
    Posts
    327
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by beginner5 View Post
    I'm working on it. On your screenshot i reduced objects to 3..


    However testing in game is much harder ,I've got here 10-20 separated objects.



    I have now simple idea how to do it. I think my function is a bit overpowered for this search (I tangled 3 colors to find objects) So:
    • simple make door color TPA (FindColorstolerance) ,but search inside box appointed by walls of building (FindColorstolerance and GetTpaBounds)
    • make ATPA (TPAtoATPAEx)
    • now sort subTPAs by higher y position of their middle point (MiddleTPA) --> higher y position means that object is more on south
    • As long as compas is faced north mouse will find doors at first try (ATPA[0] = doors)


    Only thing I'm afraid is color changing.
    Thanks for all that, mate. You've obviously put a lot of effort into that and I'll try to implement it into my script when I get a chance.

  18. #18
    Join Date
    Oct 2011
    Posts
    805
    Mentioned
    21 Post(s)
    Quoted
    152 Post(s)

    Default

    I'm doing this for myself. I just started exploring ATPA and it was challenge.And I like hard challenges It gave me opportunity to learn a lot about ATPA stuff.

    Done:


    I will post the code when I clean it up. However I suggest you to make your own function ,it's great way to learn something.

    Have fun
    Simba Code:
    program PortSarimDoorOpener; // by beginner5

    { Opening doors to Port Sarim fishing shop. Edge of doors must be visible }
    {$DEFINE SRL5}
    {$DEFINE SMART}
    {$i srl/srl.simba}

    var
    tries: integer;
    opened : boolean;
    procedure start;
    begin
      ClearDebug;
      Smart_Server := 139;
      Smart_Members := True;
      Smart_Signed := True;
      Smart_SuperDetail := False;
      activateclient;
      SetupSRL;

    end;

    //Returns random point in box -- by beginner5
    function RandomPointInBox (box :Tbox):Tpoint;
    begin
      Result.x:=box.x1+random(box.x2-box.x1);
      Result.y:=box.y1+random(box.y2-box.y1);
    end;

    // Sorting ATPA by x or y position of SubTPA's middle points. -- by beginner5
    procedure SortATPAbyMidTPA(var ATPA: T2DPointArray; SortByX , SortUp : boolean);
    var a,hi ,x,y:integer;
    SortArr :Tintegerarray;
    begin
      hi := High(ATPA);
      setlength(SortArr,hi+1);
      if (SortByX) then
      begin
        for a:= 0 to hi do
        begin
          MiddleTPAEx(ATPA[a],x,y);
          SortArr[a]:=x;
        end;
      end else begin
        for a:= 0 to hi do
        begin
          MiddleTPAEx(ATPA[a],x,y);
          SortArr[a]:=y;
        end;
      end;
      QuickATPASort(SortArr,ATPA,0,hi,SortUp);
    end;

    // Result is TPA of that points from tpa1 ,which has in neighborhood any point from tpa2. -- by beginner5
    function AND_TPA (tpa1 , tpa2 :TpointArray ; MinDist ,MaxDist : extended) : TPointArray;
    var
    a : integer;
    temp_tpa1 :tPointarray;
    begin
     Setlength(Result,0);
     for a:=0 to High(tpa2) do
     begin
       temp_tpa1 := tpa1;  // Don't want FilterPointsDist overwrite tpa1
       FilterPointsDist(temp_tpa1,MinDist,MaxDist,tpa2[a].x,tpa2[a].y);
       CombineTPAWrap(Result,temp_tpa1,Result);
     end;
    // Need here function which remove duplicated points from tpa.
    end;

    function FindDoor : T2dPointArray;
    var
    WallColor , DoorEdgeColor ,AdditionalDoorColor ,AdditionalDoorColor2 : integer;
    TPA1 ,TPA2 ,TPA3 ,TPA4 : TPointArray;
    houseBox :TBox;
    begin
    /////////////SETUP/////////////
    WallColor := 13955062;
    DoorEdgeColor := 3627875 ;
    AdditionalDoorColor := 3361102 ;
    AdditionalDoorColor2 := 604482 ;
    ///////////////////////////////

      if FindColorstolerance(TPA4,WallColor,msx1,msy1,msx2,msy2,15) then
        houseBox :=GetTpaBounds(TPA4) else writeln('Cannot find wall - update color!');

      FindColorstolerance(TPA1,DoorEdgeColor ,houseBox.x1,houseBox.y1,houseBox.x2+10,houseBox.y2+10,10);
      FindColorstolerance(TPA2,AdditionalDoorColor ,houseBox.x1,houseBox.y1,houseBox.x2+10,houseBox.y2+10,10);
      FindColorstolerance(TPA3,AdditionalDoorColor2 ,houseBox.x1,houseBox.y1,houseBox.x2+10,houseBox.y2+10,15);

      RAaSTPAEx(TPA1,10,10);
      RAaSTPAEx(TPA2,10,10);
      RAaSTPAEx(TPA3,10,10);

      TPA1:=AND_TPA(TPA1,TPA2,0,15);
      TPA1:=AND_TPA(TPA1,TPA3,0,15);
      TPAtoATPAExWrap(TPA1,50,2,Result);
      if (High(Result)=-1) then
      begin
          writeln('ATPA is empty! Something with colors');
          terminatescript;
      end;
      SortATPAbyMidTPA(Result,False,False);
    end;

    function OpenDoor (ATPA : T2dPointArray) : Boolean;
    var a, x ,y : integer;
    TPAbox : Tbox ;
    begin
      for a:=0 to 5 do
      begin
        TPAbox := GetTpaBounds(ATPA[a]);
        x:=RandomPointInBox(TPAbox).x;
        y:=RandomPointInBox(TPAbox).y;
        MMouse(x,y,1,1);
        wait(100+random(200));
        if IsUpTextMultiCustom(['open','oor']) then break;
        wait(100+random(200));
      end;
      Result := IsUpTextMultiCustom(['open','oor']);

    end;
    /////////////////////////////// Main Loop /////////////////////////
    begin
      start;
      ClickNorth(0);
      for tries:=0 to 5 do
      begin
        if (OpenDoor (FindDoor ) ) then
        begin
          ClickMouse2(0);
          opened := True;
          break;
        end else writeln('Opening failed');
      end;
      if (opened) then
        writeln ('Doors was opened!') else writeln ('Cannot open doors ,maybe they are already opened?');
    end.
    Last edited by bg5; 01-18-2012 at 06:33 AM.

  19. #19
    Join Date
    Dec 2011
    Posts
    327
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by beginner5 View Post
    I'm doing this for myself. I just started exploring ATPA and it was challenge.And I like hard challenges It gave me opportunity to learn a lot about ATPA stuff.

    Done:


    I will post the code when I clean it up. However I suggest you to make your own function ,it's great way to learn something.

    Have fun
    Simba Code:
    program PortSarimDoorOpener; // by beginner5

    { Opening doors to Port Sarim fishing shop. Edge of doors must be visible }
    {$DEFINE SRL5}
    {$DEFINE SMART}
    {$i srl/srl.simba}

    var
    tries: integer;
    opened : boolean;
    procedure start;
    begin
      ClearDebug;
      Smart_Server := 139;
      Smart_Members := True;
      Smart_Signed := True;
      Smart_SuperDetail := False;
      activateclient;
      SetupSRL;

    end;

    //Returns random point in box -- by beginner5
    function RandomPointInBox (box :Tbox):Tpoint;
    begin
      Result.x:=box.x1+random(box.x2-box.x1);
      Result.y:=box.y1+random(box.y2-box.y1);
    end;

    // Sorting ATPA by x or y position of SubTPA's middle points. -- by beginner5
    procedure SortATPAbyMidTPA(var ATPA: T2DPointArray; SortByX , SortUp : boolean);
    var a,hi ,x,y:integer;
    SortArr :Tintegerarray;
    begin
      hi := High(ATPA);
      setlength(SortArr,hi+1);
      if (SortByX) then
      begin
        for a:= 0 to hi do
        begin
          MiddleTPAEx(ATPA[a],x,y);
          SortArr[a]:=x;
        end;
      end else begin
        for a:= 0 to hi do
        begin
          MiddleTPAEx(ATPA[a],x,y);
          SortArr[a]:=y;
        end;
      end;
      QuickATPASort(SortArr,ATPA,0,hi,SortUp);
    end;

    // Result is TPA of that points from tpa1 ,which has in neighborhood any point from tpa2. -- by beginner5
    function AND_TPA (tpa1 , tpa2 :TpointArray ; MinDist ,MaxDist : extended) : TPointArray;
    var
    a : integer;
    temp_tpa1 :tPointarray;
    begin
     Setlength(Result,0);
     for a:=0 to High(tpa2) do
     begin
       temp_tpa1 := tpa1;  // Don't want FilterPointsDist overwrite tpa1
       FilterPointsDist(temp_tpa1,MinDist,MaxDist,tpa2[a].x,tpa2[a].y);
       CombineTPAWrap(Result,temp_tpa1,Result);
     end;
    // Need here function which remove duplicated points from tpa.
    end;

    function FindDoor : T2dPointArray;
    var
    WallColor , DoorEdgeColor ,AdditionalDoorColor ,AdditionalDoorColor2 : integer;
    TPA1 ,TPA2 ,TPA3 ,TPA4 : TPointArray;
    houseBox :TBox;
    begin
    /////////////SETUP/////////////
    WallColor := 13955062;
    DoorEdgeColor := 3627875 ;
    AdditionalDoorColor := 3361102 ;
    AdditionalDoorColor2 := 604482 ;
    ///////////////////////////////

      if FindColorstolerance(TPA4,WallColor,msx1,msy1,msx2,msy2,15) then
        houseBox :=GetTpaBounds(TPA4) else writeln('Cannot find wall - update color!');

      FindColorstolerance(TPA1,DoorEdgeColor ,houseBox.x1,houseBox.y1,houseBox.x2+10,houseBox.y2+10,10);
      FindColorstolerance(TPA2,AdditionalDoorColor ,houseBox.x1,houseBox.y1,houseBox.x2+10,houseBox.y2+10,10);
      FindColorstolerance(TPA3,AdditionalDoorColor2 ,houseBox.x1,houseBox.y1,houseBox.x2+10,houseBox.y2+10,15);

      RAaSTPAEx(TPA1,10,10);
      RAaSTPAEx(TPA2,10,10);
      RAaSTPAEx(TPA3,10,10);

      TPA1:=AND_TPA(TPA1,TPA2,0,15);
      TPA1:=AND_TPA(TPA1,TPA3,0,15);
      TPAtoATPAExWrap(TPA1,50,2,Result);
      if (High(Result)=-1) then
      begin
          writeln('ATPA is empty! Something with colors');
          terminatescript;
      end;
      SortATPAbyMidTPA(Result,False,False);
    end;

    function OpenDoor (ATPA : T2dPointArray) : Boolean;
    var a, x ,y : integer;
    TPAbox : Tbox ;
    begin
      for a:=0 to 5 do
      begin
        TPAbox := GetTpaBounds(ATPA[a]);
        x:=RandomPointInBox(TPAbox).x;
        y:=RandomPointInBox(TPAbox).y;
        MMouse(x,y,1,1);
        wait(100+random(200));
        if IsUpTextMultiCustom(['open','oor']) then break;
        wait(100+random(200));
      end;
      Result := IsUpTextMultiCustom(['open','oor']);

    end;
    /////////////////////////////// Main Loop /////////////////////////
    begin
      start;
      ClickNorth(0);
      for tries:=0 to 5 do
      begin
        if (OpenDoor (FindDoor ) ) then
        begin
          ClickMouse2(0);
          opened := True;
          break;
        end else writeln('Opening failed');
      end;
      if (opened) then
        writeln ('Doors was opened!') else writeln ('Cannot open doors ,maybe they are already opened?');
    end.
    I hope you don't mind, I posted the link on my harpoon buyer on where to find the door detection fix.
    If you want me to, I'll take down the link.
    Thank you very much, for all the time and effort you've spent into developing that.

  20. #20
    Join Date
    Jan 2012
    Posts
    10
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    can you please pm me a working harpoon buy/sell bot please or post a acctual link up ?

  21. #21
    Join Date
    Dec 2011
    Posts
    327
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by YILDIRIM View Post
    can you please pm me a working harpoon buy/sell bot please or post a acctual link up ?
    There's one in my signature. Unfortunately you have to fix a few common errors that occur in scripting. It isn't that hard, I posted up a link on where you can find nearly all the fixes to my script.

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
  •