Results 1 to 9 of 9

Thread: checking for ChooseOption but not using it?

  1. #1
    Join Date
    Mar 2007
    Posts
    151
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default checking for ChooseOption but not using it?

    Is there a way I can check if there is an option available, without clicking that option...

    I'm trying to minimise the time between waiting and clicking the ChooseOption, so rather than doing something like

    SCAR Code:
    wait(500 +random(250));
    ChooseOption('whatever');

    I instead do

    SCAR Code:
    Repeat
      wait(500 +random(250));
      Inc(x);
    Until (It sees the ChooseOption but does not click it) or (x > 6);

  2. #2
    Join Date
    Dec 2007
    Location
    192.168.1.73
    Posts
    2,439
    Mentioned
    6 Post(s)
    Quoted
    119 Post(s)

    Default

    If you look into the includes folder, you can edit it so it won't click, so just make your own function the same as ChooseOptionMultiEx, comment out the functions that use the mouse, and use it like that.

    SCAR Code:
    function ChooseOptionMultiEx(Texts: TStringArray; TextType: String): Boolean;
    var
       B, T: TBox;
       TPA, TextTPA: TPointArray;
       aTPA: T2DPointArray;
       I, C, H, HH, ii, L: Integer;
       P: TPoint;
       Occurances: array [0..4] of TPointArray;
       Colors: TIntegerArray;
    begin
      Result := False;
      GetClientDimensions(B.X2, B.Y2);
      B.X1 := 0;
      B.Y1 := 0;
      FindColorsTolerance(TPA, 4674653, B.X1, B.Y1, B.X2, B.Y2, 0);
      If Length(TPA) < 10 Then
        Exit;
      B.X2 := 0;
      B.Y2 := 0;

      P := TPA[0];
      H := High(TPA);
      Dec(H);
      For I := 0 To H Do
        If TPA[i].X = TPA[I+1].X - 1 Then
        Begin
          If C > 5 Then
          Begin
            B.X1 := P.X;
            B.Y1 := P.Y;
            Break;
          End Else
            C := C + 1;
        End
        Else
        Begin
          P := TPA[I + 1];
          C := 0;
        End;
      If I = Length(TPA) Then
      Begin
        WriteLn('Choose Option Menu Getting Failed');
        Exit;
      End;
      InvertTPA(TPA);
      C := 0;
      P := TPA[0];
      H := High(TPA);
      Dec(H);
      For I := 0 To H Do
        If TPA[i].X = TPA[I+1].X + 1 Then
        Begin
          If C > 5 Then
          Begin
            B.X2 := P.X;
            B.Y2 := P.Y;
            Break;
          End Else
            C := C + 1;
        End Else
        Begin
          P := TPA[I + 1];
          C := 0;
        End;
      If I = Length(TPA) Then
      Begin
        WriteLn('Choose Option Menu Getting Failed');
        Exit;
      End;

      TPA := [];
      Colors := [16777215, 4231423, 2070783, 65535, 16776960];
      case LowerCase(TextType) of
        'action', 'player': FindColorsTolerance(Occurances[0], Colors[0], B.x1, B.y1, B.x2, B.y2, 3);
        'item'  : begin
                    FindColorsTolerance(Occurances[1], Colors[1], B.x1, B.y1, B.x2, B.y2, 3);
                    FindColorsTolerance(Occurances[2], Colors[2], B.x1, B.y1, B.x2, B.y2, 3);
                  end;
        'npc'   : FindColorsTolerance(Occurances[3], Colors[3], B.x1, B.y1, B.x2, B.y2, 3);
        'object': FindColorsTolerance(Occurances[4], Colors[4], B.x1, B.y1, B.x2, B.y2, 3);
        else
        begin
          FindColorsTolerance(Occurances[0], 4674653, B.X1, B.Y1, B.X2, B.Y2, 0);
          FindColorsTolerance(Occurances[1], clBlack, B.X1, B.Y1, B.X2, B.Y2, 0);
          TPA := MergeATPA(Occurances);
          TPA := ReturnPointsNotInTPA(TPA, B);
        end;
      end;
      if High(TPA) < 1 then TPA := MergeATPA(Occurances);
      aTPA := SplitTPAEx(TPA, 7, 1);
      SortATPAFromFirstPoint(aTPA, Point(B.x1, B.y1));

      H := High(Texts);
      L := High(aTPA);
     // for i := 0 to L do
     //   DebugTPA(atpa[i], inttostr(i));

      For I :=0 To H do
      begin
        TextTPA := LoadTextTPA(Texts[I], UpChars, HH);
        for ii := 0 to L do
          If FindTextTPAInTPA(HH, TextTPA, aTPA[ii], TPA) Then
          Begin
            T := GetTPABounds(TPA);
            Result := True;
            //Mouse(B.X1 + 5, T.y1 - 2, B.X2 - B.X1 - 5, T.Y2 - T.Y1, True);
            Exit;
          End;
      end;

      //MMouse(B.X1 - 50, B.Y1 - 50, 40, B.Y2 - B.Y1);
      Wait(200 + Random(100));
    end;

    ChooseOptionMultiEx already has an inbuilt method of checking whether the text is there, and returns the function as true if that text is there.

    Note: you can shrink this function a lot, but I'll leave the decision of what to remove up to you

  3. #3
    Join Date
    Mar 2007
    Posts
    151
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    <3 10chars

  4. #4
    Join Date
    Sep 2007
    Location
    Pennsylvania
    Posts
    3,396
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Couldn't you just do something like:
    SCAR Code:
    marktime(chooseopt);
      repeat
        wait(50+Random(20));
      until(ChooseOption('blah')) or (TimeFromMark(chooseopt) > 2500);

    ? Because if I understand correctly after you see that the ChooseOption is there you will do ChooseOption('blah') anyway.

  5. #5
    Join Date
    Feb 2007
    Location
    PA, USA
    Posts
    5,240
    Mentioned
    36 Post(s)
    Quoted
    496 Post(s)

    Default

    I made one that works

    SCAR Code:
    function IsOption(txt: string): Boolean;
    var
      x1, y1, x2, y2, LeftCorner, RightCorner, x, y: Integer;
    begin
      LeftCorner := BitmapFromString(6, 5, 'beNpjYIgNccdEDKiAHBEAciwJsQ==');
      RightCorner := BitmapFromString(6, 6, 'beNoLcY8NQSAGBgZkLkk' +
           'iDKgATQ0IAQDo1Rop');
      if (FindBitmap(LeftCorner, x1, y1)) and (FindBitmap(RightCorner, x2, y2)) then
      begin
        if (FindText(x, y, txt, upchars, x1, y1, x2, 502)) then
        begin
          Result := True;
        end
        else
        begin
          MMouse(x1 - 90, y1 - 50, 40, y2-y1);
          Wait(200 + Random(100));
        end;
      end;
      FreeBitmap(LeftCorner);
      FreeBitmap(RightCorner);
    end;

    credit

  6. #6
    Join Date
    Apr 2007
    Location
    Perth, Australia
    Posts
    3,926
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    In the Open Dev svn (and soon to be in the Public SVN when Rev 33 is released) is a function called OptionExists that checks if an option exists.

  7. #7
    Join Date
    Feb 2007
    Location
    PA, USA
    Posts
    5,240
    Mentioned
    36 Post(s)
    Quoted
    496 Post(s)

    Default

    It should be named IsOption... don't u think that name fits better?>

  8. #8
    Join Date
    Apr 2007
    Location
    Perth, Australia
    Posts
    3,926
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by footballjds View Post
    It should be named IsOption... don't u think that name fits better?>
    Hmm not really. 'if OptionExists then' is easier to understand that 'if IsOption then'. Although I suppose the naming convention for such functions would mean IsOption is the better name.

  9. #9
    Join Date
    Mar 2007
    Posts
    4,810
    Mentioned
    3 Post(s)
    Quoted
    3 Post(s)

    Default

    Or Maybe - IsOptionInTheOptionMenuWhichTheScriptHasJustClickd

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
  •