Results 1 to 9 of 9

Thread: Need Help With FindObject!

  1. #1
    Join Date
    May 2013
    Location
    USA
    Posts
    6
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default Need Help With FindObject!

    My problem is not it actually finding the object it finds that perfectly. What it does is finds all of them but moves the mouse to all of them and tries to click all of them. Obviously what I want it to do is to choose one of the ones it finds and clicks it.

    I looked at tutorials but I can't seem to put my mind together to figure it out, even if you point me in the right direction than actually doing it for me is just as nice.

    I appreciate any help I can get.


    Code:
    function FindObject(var fx, fy: Integer): Boolean;
    var
      arP, arAP: TPointArray;
      arC, arUC: TIntegerArray;
      ararP: T2DPointArray;
      tmpCTS, i, j, arL, arL2: Integer;
      P: TPoint;
      X, Y, Z: Extended;
    begin
      tmpCTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.06, 0.12);
    
      if not(FindColorsTolerance(arP, MineColor, MSX1, MSY1, MSX2, MSY2, 6)) then
      begin
        Writeln('Failed to find the color, no object found.');
        ColorToleranceSpeed(tmpCTS);
        SetColorSpeed2Modifiers(0.2, 0.2);
        Exit;
      end;
    
      arC := GetColors(arP);
      arUC := arC;
      ClearSameIntegers(arUC);
      arL := High(arUC);
      arL2 := High(arC);
    
      for i := 0 to arL do
      begin
        ColorToXYZ(arC[i], X, Y, Z);
    
        if (X >= 10.15) and (X <= 18.75) and (Y >= 12.39) and (Y <= 22.97) and (Z >= 16.87) and (Z <= 31.89) then
        begin
          for j := 0 to arL2 do
          begin
            if (arUC[i] = arC[j]) then
            begin
              SetLength(arAP, Length(arAP) + 1);
              arAP[High(arAP)] := arP[j];
            end;
          end;
        end;
      end;
    
      SortTPAFrom(arAP, Point(MSCX, MSCY));
      ararP := SplitTPAEx(arAP, 10, 10);
      arL := High(ararP);
    
      for i := 0 to arL do
      begin
        if (Length(ararP[i]) < 10) then Continue;
        P := MiddleTPA(ararP[i]);
        MMouse(P.x, P.y, 5, 5);
        Wait(100 + Random(100));
        ClickMouse(P.x, P.y, mouse_Left);
        if (IsUpText('Mine')) then
        begin;
          Result := True;
          Break;
        end;
      end;
    
      ColorToleranceSpeed(tmpCTS);
      SetColorSpeed2Modifiers(0.2, 0.2);
    
      if (i = arL + 1) then
      begin
        Writeln('FindObject could not find object.');
        Exit;
      end;
    
      GetMousePos(fx, fy);
    end;

  2. #2
    Join Date
    Apr 2013
    Location
    England
    Posts
    223
    Mentioned
    2 Post(s)
    Quoted
    106 Post(s)

    Default

    from a quick read through, it seems you are left clicking and then checking for upText which leads to break, surely you want to check upText then leftClick then break ...

    Simba Code:
    for i := 0 to arL do
      begin
        if (Length(ararP[i]) < 10) then Continue;
        P := MiddleTPA(ararP[i]);
        MMouse(P.x, P.y, 5, 5);
        Wait(100 + Random(100));
        ClickMouse(P.x, P.y, mouse_Left);
        if (IsUpText('Mine')) then
        begin;
          Result := True;
          Break;
        end;
      end;

    i believe should be:

    Simba Code:
    for i := 0 to arL do
      begin
        if (Length(ararP[i]) < 10) then Continue;
        P := MiddleTPA(ararP[i]);
        MMouse(P.x, P.y, 5, 5);
        Wait(100 + Random(100));
        //ClickMouse(P.x, P.y, mouse_Left);                // not here, otherwise you will move before upText is checked
        if (IsUpText('Mine')) then
        begin;
          MouseClick2(True);                              // just a left click as no need to move mouse
          Result := True;
          Break;
        end;
      end;

  3. #3
    Join Date
    May 2013
    Location
    USA
    Posts
    6
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    Thank You very much EngageTheRage, I'll test it out in a bit.
    Last edited by Tehmoo; 06-12-2013 at 03:36 PM. Reason: Updating

  4. #4
    Join Date
    May 2013
    Location
    USA
    Posts
    6
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    I still have a problem with it clicking. It doesn't seem to be using
    Code:
     if (IsUpText('Mine'))
    so it won't click.
    Also to mention this is for a private server but that really shouldn't be stopping it from not checking. the uptext. Also when I use MouseClick2(true) it gives me an identifier error, not sure if im missing an include somewhere.

  5. #5
    Join Date
    Jun 2012
    Posts
    4,867
    Mentioned
    74 Post(s)
    Quoted
    1663 Post(s)

    Default

    Quote Originally Posted by Tehmoo View Post
    I still have a problem with it clicking. It doesn't seem to be using
    Code:
     if (IsUpText('Mine'))
    so it won't click.
    Also to mention this is for a private server but that really shouldn't be stopping it from not checking. the uptext. Also when I use MouseClick2(true) it gives me an identifier error, not sure if im missing an include somewhere.
    Private servers have different uptexts so you'll have to make your own character set. Use
    Simba Code:
    ClickMouse2(True);
    to click.

  6. #6
    Join Date
    May 2013
    Location
    USA
    Posts
    6
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    Thank you, as for making the character set is there a tutorial for it. I'll look but in case I don't find one can you lead me to a link for it. That would be great.

  7. #7
    Join Date
    Jun 2012
    Posts
    4,867
    Mentioned
    74 Post(s)
    Quoted
    1663 Post(s)

    Default

    Quote Originally Posted by Tehmoo View Post
    Thank you, as for making the character set is there a tutorial for it. I'll look but in case I don't find one can you lead me to a link for it. That would be great.
    There's a tutorial here. I haven't used it or made my own fonts before but Shuttleu has other tutorials that I've read which are good so I'm sure this one will be too

  8. #8
    Join Date
    May 2013
    Location
    USA
    Posts
    6
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    Thanks so much. I really appreciate it.

  9. #9
    Join Date
    Jun 2012
    Posts
    4,867
    Mentioned
    74 Post(s)
    Quoted
    1663 Post(s)

    Default

    Quote Originally Posted by Tehmoo View Post
    Thanks so much. I really appreciate it.
    No problem, good luck with your 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
  •