Results 1 to 5 of 5

Thread: Need help with TPAs

  1. #1
    Join Date
    Mar 2012
    Location
    Grambling, LA
    Posts
    70
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Need help with TPAs

    Hi, this is my code which clicks the Hill Giant Dungeon door, east of the Cooks Guild. I tried to use TPAs to detect the door which has the same color as all trees around the door. The script works perfectly. However, I was wondering if there is a better way to rewrite this code.

    I tried to use FindObjTPA but it just randomly moves all around the screen before it finds my Door.

    This is my code.
    Simba Code:
    Function clickDoor:Boolean;
    var
      x, y, i, l, l1, dx, dy, doorColor, doorTol, startTime:Integer;
      TPA, TPA1: TPointArray;
      ATPA: T2DPointArray;
      Box1: TBox;
    begin
      doorColor := 2107434;
      doorTol := 15;

      MarkTime(startTime);
      while(TimeFromMark(startTime)<10000) do
      begin
        if FindColorsSpiralTolerance(MSCX,MSCY,TPA,doorColor,MSX1,MSY1,MSX2,MSY2,doorTol) then
        begin
          ATPA := SplitTPA(TPA,1);
          SortATPAFromFirstPoint(ATPA,Point(MSCX, MSCY));
          DebugATPA(ATPA,'');
          l := High(ATPA);
          for i:=0 to l do
          begin
            TPA1 := ATPA[i];
            l1 := High(TPA1);
            Box1 := GetTPABounds(TPA1);
            dx := Box1.X2-Box1.X1;
            dy := Box1.Y2-Box1.Y1;
            if (l1>400) and (l1<2200) and (dx<60) and (dy<80) then
                if MiddleTPAEx(TPA1, x, y) then
                begin
                  MMouse(x, y, 5, 5);
                  writeln('Points:'+IntToStr(l1)+' dx:'+IntToStr(dx)+' dy"'+IntToStr(dy));
                  if WaitUpTextMulti(['pen Door', 'pen', 'oor', 'Door'], 700+random(300)) then
                  begin
                    ClickMouse2(true);
                    if DidRedClick then
                    begin
                      Result:=True;
                      break;
                    end;
                  end;
                end;
          end;
        end;
      wait(800+random(200));
      end;
      wait(3000+random(500));
    end;

  2. #2
    Join Date
    Feb 2012
    Location
    SRL Jail
    Posts
    1,319
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I used a DTM for my Hill Giant script
    here it is

    Simba Code:
    begin //Door Opener
            Door := DTMFromString('mggAAAHicY2NgYIhiZGAoBmIbILYDYg9GiFg0lO0LxEFAbA/FigoSDIoqEgyWFpYMEhISDJoaimAxZqBZ2DAjDgwBADFoBkc=');
              if FindDTMRotated(Door, x, y, MSX1, MSY1, MSX2, MSY2, -Pi/4, Pi/4, Pi/60, GetIt) then // If it Finds my DTM at any Angle, then...
                begin
                  ClickMouse2(False); // Left Clicks rather than Right Click
                  ChooseOption('pen') // Chooses the Option 'Open'
                end;
          end;

    So its the door that requires the brass key, right? ^

  3. #3
    Join Date
    Mar 2012
    Location
    127.0.0.1
    Posts
    3,383
    Mentioned
    95 Post(s)
    Quoted
    717 Post(s)

    Default

    Add a search box, so it only searches the area by the door. It's what I do when finding small objects like a door with ACA.

  4. #4
    Join Date
    Mar 2012
    Location
    Grambling, LA
    Posts
    70
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by NKN View Post
    Add a search box, so it only searches the area by the door. It's what I do when finding small objects like a door with ACA.
    Could you give me an example and/or link to tutorial page which will help me add a search box, and searches the area by the door?


    Quote Originally Posted by JOEbot View Post
    I used a DTM for my Hill Giant script
    here it is

    Simba Code:
    begin //Door Opener
            Door := DTMFromString('mggAAAHicY2NgYIhiZGAoBmIbILYDYg9GiFg0lO0LxEFAbA/FigoSDIoqEgyWFpYMEhISDJoaimAxZqBZ2DAjDgwBADFoBkc=');
              if FindDTMRotated(Door, x, y, MSX1, MSY1, MSX2, MSY2, -Pi/4, Pi/4, Pi/60, GetIt) then // If it Finds my DTM at any Angle, then...
                begin
                  ClickMouse2(False); // Left Clicks rather than Right Click
                  ChooseOption('pen') // Chooses the Option 'Open'
                end;
          end;

    So its the door that requires the brass key, right? ^
    I really appreciate your code, I will certainly try it.
    Last edited by johnbrown8976; 04-25-2012 at 01:56 AM.

  5. #5
    Join Date
    Mar 2012
    Location
    127.0.0.1
    Posts
    3,383
    Mentioned
    95 Post(s)
    Quoted
    717 Post(s)

    Default

    Read my Autocoloring tutorial.
    It tells you how to make boxes.
    In my siggy.

Thread Information

Users Browsing this Thread

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

Tags for this Thread

Posting Permissions

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