Results 1 to 3 of 3

Thread: function FindTehWhirlPool(Handle: boolean): boolean;

  1. #1
    Join Date
    Nov 2007
    Location
    Nowhereville
    Posts
    1,155
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default function FindTehWhirlPool(Handle: boolean): boolean;

    I never get whirlpools for some reason but I decided to do this. Please post your whirlpool colors.

    Here it is.


    SCAR Code:
    function FindTehWhirlPool(Handle: boolean): boolean;
    var x, y: integer;
      WhirlPoints: TPointArray;
      WhirlBox, OtherSkipBox: TBox;
    begin
      if FindColorsSpiralTolerance(x, y, WhirlPoints, {put color here please}, MSX1, MSY1, MSX2, MSY2, 4) then
      begin
        Result := True;
        WhirlBox.x1 := Low(WhirlPoints.x);
        WhirlBox.y1 := Low(WhirlPoints.y);
        WhirlBox.x2 := High(WhirlPoints.x);
        WhirlBox.y2 := High(WhirlPoints.y);
        if Handle then
        begin
          repeat
            Wait(1);
          until(not(FindColorSkipBox(x, y, {color here}, WhirlBox.x1, WhirlBox.y1, WhirlBox.x2, WhirlBox.y2, OtherSkipBox));
        end;
      end;
    end;
    Formerly known as Cut em2 it

  2. #2
    Join Date
    Dec 2006
    Location
    Copy pastin to my C#
    Posts
    3,788
    Mentioned
    8 Post(s)
    Quoted
    29 Post(s)

    Default

    Nice, but it wouldn't compile.

    FindColorsSpiralTolerance is a procedure.

    You are supposed to work with the points, do a SplitTPA, then look through the TPAA if any of the TPAs has enough points for a whirlpool (over 50) and if is, then result true. You should use CTS(2) so you are okay with one color and about 15 Tol etc.

    Also, you haven't even used the SkipBox, so why use FindColorSkipBox?
    And you also need tolerance for the Handling part.

    Also, are you sure the first point of the TPA is the top right corner?
    No, but would be if you would use FindColorsTolerance without the Spiral, because it looks from x1,y1 to x2,y2 (High would be the down right).

    Hope I didn't go too far, and hope you like constructive critisism.



    EDIT: I do not mean that use FindColorsTolerance for whole MM, make params for the x1, y1, x2, y2 because people would use it around the fishing spot.



    EDIT EDIT: Lets play:
    SCAR Code:
    Type
      TWPH = (StopFishing, WaitAway);  // WPH = Whirlpool handler.
      // StopFishing stops the fishing and waits until its gone.
      // WaitAway waits until it isn't there.


    Function BoxFromTPA(TPA: TPointArray): TBox;
    Var
      L, I: Integer;
    Begin
      L := High(TPA);
      MiddleTPAEx(TPA, Result.x1, Result.y1);
      Result.x2 := Result.x1 + 1;
      Result.y2 := Result.y1 + 1;
      For I := 0 To L Do
      Begin
        If (TPA[i].x < Result.x1) And (TPA[i].y < Result.y1) Then
        Begin
          Result.x1 := TPA[i].x;
          Result.y1 := TPA[i].y;
        End;
        If (TPA[i].x > Result.x2) And (TPA[i].y > Result.y2) Then
        Begin
          Result.x2 := TPA[i].x;
          Result.y2 := TPA[i].y;
        End;
      End;
    End;


    Function FindWhirlPool(Handle: Boolean; HowHandle: TWPH; x1, y1, x2, y2: Integer): Boolean;
    Var
      CTS, X, Y, L, C, I, WM: Integer;
      wPools: Array of TPointArray;
      wPts: TPointArray;
      TB: TBox;
    Begin
      If Not LoggedIn Then Exit;
      CTS := GetColorToleranceSpeed;
      If Not CTS = 2 Then ColorToleranceSpeed(2);
      FindColorsSpiralTolerance(MSCX, MSCY, wPts, 0{a color from whirlpool here},
      x1, y1, x2, y2, 15);
      wPools := SplitTPA(wPts);
      L := High(wPools);
      SetArrayLength(wPts, 0);
      For I := 0 To L Do
      Begin
        If GetArrayLength(wPools[i]) >= 50 Then
        Begin
          Writeln('*** Whirlpool Detected ***');
          SetArrayLength(wPts, GetArrayLength(wPools[i]));
          wPts := wPools[i];
          Result := True;
          Break;
        End;
      End;
      If Handle Then
      Begin
        If HowHandle = StopFishing Then
        Begin
          MouseFindFlag(MMCX, MMCY, -1, -1);
          Wait(500 + Random(250));
        End Else
        Begin
          TB := BoxFromTPA(wPts);
          MiddleTPAEx(wPts, X, Y);
          C := GetColor(X, Y);
          WM := GetSystemTime;
          While FindColorTolerance(X, Y, C, TB.x1, TB.y1, TB.x2, TB.y2, 5) Do
            If GetSystemTime - WM > 12000 + Random(1000) Then
              Break;
        End;
      End;
      ColorToleranceSpeed(CTS);
    End;

  3. #3
    Join Date
    Nov 2006
    Location
    NSW, Australia
    Posts
    3,487
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by n3ss3s View Post
    Nice, but it wouldn't compile.

    FindColorsSpiralTolerance is a procedure.

    You are supposed to work with the points, do a SplitTPA, then look through the TPAA if any of the TPAs has enough points for a whirlpool (over 50) and if is, then result true. You should use CTS(2) so you are okay with one color and about 15 Tol etc.

    Also, you haven't even used the SkipBox, so why use FindColorSkipBox?
    And you also need tolerance for the Handling part.

    Also, are you sure the first point of the TPA is the top right corner?
    No, but would be if you would use FindColorsTolerance without the Spiral, because it looks from x1,y1 to x2,y2 (High would be the down right).

    Hope I didn't go too far, and hope you like constructive critisism.



    EDIT: I do not mean that use FindColorsTolerance for whole MM, make params for the x1, y1, x2, y2 because people would use it around the fishing spot.



    EDIT EDIT: Lets play:
    SCAR Code:
    Type
      TWPH = (StopFishing, WaitAway);  // WPH = Whirlpool handler.
      // StopFishing stops the fishing and waits until its gone.
      // WaitAway waits until it isn't there.


    Function BoxFromTPA(TPA: TPointArray): TBox;
    Var
      L, I: Integer;
    Begin
      L := High(TPA);
      MiddleTPAEx(TPA, Result.x1, Result.y1);
      Result.x2 := Result.x1 + 1;
      Result.y2 := Result.y1 + 1;
      For I := 0 To L Do
      Begin
        If (TPA[i].x < Result.x1) And (TPA[i].y < Result.y1) Then
        Begin
          Result.x1 := TPA[i].x;
          Result.y1 := TPA[i].y;
        End;
        If (TPA[i].x > Result.x2) And (TPA[i].y > Result.y2) Then
        Begin
          Result.x2 := TPA[i].x;
          Result.y2 := TPA[i].y;
        End;
      End;
    End;


    Function FindWhirlPool(Handle: Boolean; HowHandle: TWPH; x1, y1, x2, y2: Integer): Boolean;
    Var
      CTS, X, Y, L, C, I, WM: Integer;
      wPools: Array of TPointArray;
      wPts: TPointArray;
      TB: TBox;
    Begin
      If Not LoggedIn Then Exit;
      CTS := GetColorToleranceSpeed;
      If Not CTS = 2 Then ColorToleranceSpeed(2);
      FindColorsSpiralTolerance(MSCX, MSCY, wPts, 0{a color from whirlpool here},
      x1, y1, x2, y2, 15);
      wPools := SplitTPA(wPts);
      L := High(wPools);
      SetArrayLength(wPts, 0);
      For I := 0 To L Do
      Begin
        If GetArrayLength(wPools[i]) >= 50 Then
        Begin
          Writeln('*** Whirlpool Detected ***');
          SetArrayLength(wPts, GetArrayLength(wPools[i]));
          wPts := wPools[i];
          Result := True;
          Break;
        End;
      End;
      If Handle Then
      Begin
        If HowHandle = StopFishing Then
        Begin
          MouseFindFlag(MMCX, MMCY, -1, -1);
          Wait(500 + Random(250));
        End Else
        Begin
          TB := BoxFromTPA(wPts);
          MiddleTPAEx(wPts, X, Y);
          C := GetColor(X, Y);
          WM := GetSystemTime;
          While FindColorTolerance(X, Y, C, TB.x1, TB.y1, TB.x2, TB.y2, 5) Do
            If GetSystemTime - WM > 12000 + Random(1000) Then
              Break;
        End;
      End;
      ColorToleranceSpeed(CTS);
    End;
    His name isn't in yellow, by the way
    [CENTER][img]http://signatures.mylivesignature.com/54486/113/4539C8FAAF3EAB109A3CC1811EF0941B.png[/img][/CENTER]
    [CENTER][BANANA]TSN ~ Vacation! ~ says :I Love Santy[/BANANA][/CENTER]

    [CENTER][BANANA]Raymond - Oh rilie? says :Your smart[/BANANA][/CENTER]

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
  •