Results 1 to 6 of 6

Thread: CountOptions(Texts: TStringArray)]: integer;

  1. #1
    Join Date
    Aug 2008
    Location
    Finland
    Posts
    2,851
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Lightbulb CountOptions(Texts: TStringArray)]: integer;

    Usage:

    ChooseOption
    --Take Raw Chicken
    --Take Feather
    --Examine Raw Chicken
    --Examine Feather

    SCAR Code:
    writeln(IntToStr(CountOptions(['Take'])));
    ---> 2

    writeln(IntToStr(CountOptions(['hick', 'eath'])));
    ---> 4

    Code:
    SCAR Code:
    function CountOptions(Texts: TStringArray): Integer;
    var
       B: TBox;
       TPA, TextTPA: TPointArray;
       aTPA: T2DPointArray;
       I, C, H, HH, ii: Integer;
       P: TPoint;
       Occurances: array [0..2] of TPointArray;
       SmallBoxes: TBoxArray;
    begin
      GetClientDimensions(B.X2, B.Y2);
      B.X1 := 0;
      B.Y1 := 0;
      SetLength(aTPA, 2);
      FindColorsTolerance(aTPA[0], 4409686, B.X1, B.Y1, B.X2, B.Y2, 0);
      FindColorsTolerance(aTPA[1], 4016722, B.X1, B.Y1, B.X2, B.Y2, 0);
      TPA := MergeATPA(aTPA);
      SetLength(aTPA, 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;
     
    ///////////////////////////////////////
      SetLength(SmallBoxes, (B.y2 - B.y1)/15);
      for i := 0 to High(SmallBoxes) do
      begin
        SmallBoxes[i].x1 := B.x1;
        SmallBoxes[i].y1 := B.y1 + i * 15 + 3;
        SmallBoxes[i].x2 := B.x2;
        SmallBoxes[i].y2 := B.y1 + (i + 1) * 15 + 3;
      end;
     
      for ii := 0 to High(Texts) do
      begin
        TextTPA := LoadTextTPA(Texts[ii], UpChars, HH);
        for i := 0 to High(SmallBoxes) do
        begin
          FindColorsTolerance(Occurances[0], 1845035, SmallBoxes[i].X1, SmallBoxes[i].Y1 - 5, SmallBoxes[i].X2, SmallBoxes[i].Y2 + 5, 0);
          FindColorsTolerance(Occurances[1], clBlack, SmallBoxes[i].X1, SmallBoxes[i].Y1 - 5, SmallBoxes[i].X2, SmallBoxes[i].Y2 + 5, 0);
          FindColorsTolerance(Occurances[2], 6121839, SmallBoxes[i].X1, SmallBoxes[i].Y1 - 5, SmallBoxes[i].X2, SmallBoxes[i].Y2 + 5, 0);
          TPA := MergeATPA(Occurances);
          ClearDoubleTPA(TPA);
          TPA := ReturnPointsNotInTPA(TPA, SmallBoxes[i]);
          if FindTextTPAInTPA(HH, TextTPA, TPA, TPA) then
            Inc(result);
        end;
      end;
    end;

    EDIT: Took away an unnecessary line
    Last edited by marpis; 08-13-2009 at 02:59 AM.

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

    Default

    If ChooseOptionMultiEx returned an x and y cord then this could be made much shorter :/. Good work though, rep++.

  3. #3
    Join Date
    Jul 2007
    Location
    Right now? Chair.
    Posts
    8,488
    Mentioned
    3 Post(s)
    Quoted
    12 Post(s)

    Default

    Nicely done, however, how is this useful? I'm not disregarding it, just can't think of a specific use myself.

    ~RM

    I & I know Zion. It is in the spirit, body and mind of every one of us
    RMouse(obj: TMSIObject): boolean;

  4. #4
    Join Date
    Aug 2008
    Location
    Finland
    Posts
    2,851
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by Rasta Magician View Post
    Nicely done, however, how is this useful? I'm not disregarding it, just can't think of a specific use myself.

    ~RM
    i used it like this:
    1. Search for bones with uptext 'Take'
    2. Rightclick. If CountOptions(['Take']) > 1 then there is more than one item to loot
    3. ChooseOption('Take'), wait while moving
    4. If in step 2 we had more than 1 loot, move mouse to your feet and repeat clicking there until(not IsUptext('Take'))

  5. #5
    Join Date
    Jul 2007
    Location
    Right now? Chair.
    Posts
    8,488
    Mentioned
    3 Post(s)
    Quoted
    12 Post(s)

    Default

    Quote Originally Posted by marpis View Post
    i used it like this:
    1. Search for bones with uptext 'Take'
    2. Rightclick. If CountOptions(['Take']) > 1 then there is more than one item to loot
    3. ChooseOption('Take'), wait while moving
    4. If in step 2 we had more than 1 loot, move mouse to your feet and repeat clicking there until(not IsUptext('Take'))
    Very interesting.

    ~RM

    I & I know Zion. It is in the spirit, body and mind of every one of us
    RMouse(obj: TMSIObject): boolean;

  6. #6
    Join Date
    Aug 2008
    Location
    Finland
    Posts
    2,851
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by Rasta Magician View Post
    Very interesting.

    ~RM
    Well, this way you can loot all the loots that the monster drops with only one color and without bot-like MMousing to your feet after every loot

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
  •