Results 1 to 21 of 21

Thread: Fishing Spot Finder

  1. #1
    Join Date
    Apr 2007
    Posts
    2,593
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Fishing Spot Finder

    Please post anything that you find that may be wrong, or anything that I can improve on.

    This will be a function that will go into the script I'm posting in my members application.


    SCAR Code:
    program New;
    {.include SRL/SRL.scar}

    var
      FishezTPA     : TPointArray;
      FishezATPA    : T2DPointArray;
      FishezPoint   : TPoint;
      x, y, i, r, z : Integer;
     


    {*******************************************************************************
    function FindFishez(FishyColor, FishyColor1, FishyColor2 : integer) : boolean;
    By: TheVoiceInYourHead(Elkins121)
    Description: Finds a fishing spot using the colors you provide. FishyColor,
    FishyColor1, and FishyColor2 should be the "sparkling" parts of the water.
    *******************************************************************************}

    function FindFishez(FishyColor, FishyColor1, FishyColor2 : integer) : boolean;
    begin
      x := MSCX;
      y := MSCY;
      FindColorsSpiralTolerance(x, y, FishezTPA, FishyColor, MSX1, MSY1, MSX2, MSY2, 5);
      if Length(FishezTPA)=0 then FindColorsSpiralTolerance(x, y, FishezTPA, FishyColor1, MSX1, MSY1, MSX2, MSY2, 5);
      if Length(FishezTPA)=0 then FindColorsSpiralTolerance(x, y, FishezTPA, FishyColor2, MSX1, MSY1, MSX2, MSY2, 5);
      FishezATPA := SplitTPA(FishezTPA, 8);
      for i := 0 to High(FishezATPA) do
      begin
        FishezPoint := MiddleTPA(FishezATPA[i]);
        MMouse(FishezPoint.x, FishezPoint.y, 3, 3);
        if IsUpTextMultiCustom(['et', 'ishing']) then
        begin
          GetMousePos(x, y);
          MarkTime(r);
          z := InvCount;
          case Random(2) of
            1: Mouse(x, y, 1, 1, True);
            2: Mouse(x, y, 3, 3, True);
          end;
          repeat
            Wait(250+Random(750));
            FindNormalRandoms;
          until((InvFull) or (TimeFromMark(r)>=15000));
          if z=InvCount then
          begin
            FindFishez(FishyColor, FishyColor2, FishyColor2);
          end else
            Result := True;
        end;
      end;
    end;


    begin
    SetupSRL;
    FindFishez({FishyColor}, {FishyColor1}, {FishyColor2});
    end.

  2. #2
    Join Date
    Jul 2007
    Location
    Massachusetts
    Posts
    896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    fishycolor could be made into an tintegerarray so the person can choose how many colors they want to have and then you could make a loop instead of the three if statements. (if this isnt clear then i will explain more)

    Umm, why do you use FindFishez IN FindFishez. Is that even possible? You cant use a function in the declaration of that function.

  3. #3
    Join Date
    Apr 2007
    Posts
    2,593
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    No, it just starts the function over again, that I know of.

  4. #4
    Join Date
    Jul 2007
    Location
    Massachusetts
    Posts
    896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    really? i learned something new today

  5. #5
    Join Date
    Apr 2007
    Posts
    2,593
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    It may not, but I'm pretty sure it does.

    If it doesn't then I can just change it to a label.

  6. #6
    Join Date
    Jun 2007
    Location
    La Mirada, CA
    Posts
    2,484
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    there is something weird about the function, but i can't put my finger on it.

    and yes declaring the function inside itself just loops around to start over the function.

    and why not just use findObjTPA?

    "Failure is the opportunity to begin again more intelligently" (Henry Ford)


  7. #7
    Join Date
    Apr 2007
    Posts
    2,593
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Because I wanted to show my knowledge of TPAs.

  8. #8
    Join Date
    Jul 2007
    Location
    Massachusetts
    Posts
    896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    well, if it does loop it back then couldn't it result in a potentially endless loop?

  9. #9
    Join Date
    Jul 2007
    Location
    Norway.
    Posts
    1,938
    Mentioned
    3 Post(s)
    Quoted
    0 Post(s)

    Default

    Hey, sorry for not repying.

    Here's a "fixed" version:
    SCAR Code:
    {*******************************************************************************
    function FindFishez(FishyColor, FishyColor1, FishyColor2 : integer) : boolean;
    By: TheVoiceInYourHead(Elkins121)
    Description: Finds a fishing spot using the colors you provide. FishyColor,
    FishyColor1, and FishyColor2 should be the "sparkling" parts of the water.
    *******************************************************************************}

    function FindFishez(FishColors: TIntegerArray): Boolean;
    var
      TPA: TPointArray;
      ATPA: T2DPointArray;
      I, A, X, Y: Integer;
     
    begin
      Result := False;
      for I := 0 to High(FishColors) do
      begin
        FindColorsSpiralTolerance(MSCX, MSCY, TPA, FishyColor[I], MSX1, MSY1, MSX2, MSY2, 15);
        if Length(TPA) = 0 then
          if I = High(TPA) then exit
        else
          Continue;
      end;
      ATPA := TPAtoATPA(TPA, 8);
      for A := 0 to High(ATPA) do
      begin
        MiddleTPAEx(FishezATPA[A], X, Y);
        MMouse(X, Y, 6, 6);
        if IsUpTextMultiCustom(['et', 'ishing']) then
        begin
          GetMousePos(x, y);
          MarkTime(r);
          z := InvCount;
          if Random(2) = 0 then
            Mouse(x, y, 1, 1, True)
          else
            Mouse(x, y, 3, 3, True);
          repeat
            Wait(250+Random(750));
            FindNormalRandoms;
          until((InvFull) or (TimeFromMark(r)>=15000));
          if z=InvCount then
          begin
            FindFishez([FishColors]);
          end else
            Result := True;
        end;
      end;
    end;


    begin
      SetupSRL;
      FindFishez([FishColors]);
    end.

    Fixed the most serious errors.

    See the differences?

    And also, run this:

    SCAR Code:
    var
      I: Byte;

    begin
      for I := 0 to 255 do
        WriteLn(IntToStr(Random(2)));
    end.

    Random(2) = 0 or 1, Random(5) = 0..4 ect.

    Quote Originally Posted by HyperSecret View Post
    there is something weird about the function, but i can't put my finger on it.

    and yes declaring the function inside itself just loops around to start over the function.

    and why not just use findObjTPA?
    This will be in his app, it is supposed to show his über mad hax0r skillz.

  10. #10
    Join Date
    Apr 2007
    Posts
    2,593
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    It wouldn't be endless if it found the correct colors. That's why I have you set up the Fishing Spot colors.

    E: Thanks, EC! I don't quite understand the TPAtoATPA, etc..ATPA's confuse me. I guess it replaces SplitTPA?

  11. #11
    Join Date
    Jul 2007
    Location
    Massachusetts
    Posts
    896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    but what if there are no fish on the minimap and the colors can not be found. Does this mean you should continue checking or you should log out?

  12. #12
    Join Date
    Apr 2007
    Posts
    2,593
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Mate, this is only 1 function of the script...I'm going to implement into it a counter..In another function it'll be along the lines of:
    SCAR Code:
    begin
    repeat
      FindFishez(blah);
      Inc(Counter);
    until((FindFishez(blah)) or Counter>=5);

  13. #13
    Join Date
    Jul 2007
    Location
    Massachusetts
    Posts
    896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    but you will never get out of the first findfishez if it doesnt find the fish because you will keep redoing findfishes.

    also, look at this

    SCAR Code:
    begin
          GetMousePos(x, y);
          MarkTime(r);
          z := InvCount;
          if Random(2) = 0 then
            Mouse(x, y, 1, 1, True)
          else
            Mouse(x, y, 3, 3, True);
          repeat
            Wait(250+Random(750));
            FindNormalRandoms;
          until((InvFull) or (TimeFromMark(r)>=15000));
          if z=InvCount then
          begin
            FindFishez([FishColors]);
          end else
            Result := True;


    first, r and z are never declared as variables. Also, the function will always repeat no matter what because you never do anything to if after you assign it to the value of invcount.

  14. #14
    Join Date
    Apr 2007
    Posts
    2,593
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    -.-

    r and z are globally declared. If it clicks and the InvCount stays the same then it starts over..It does this because you SHOULD put the right colors in.

  15. #15
    Join Date
    Jul 2007
    Location
    Massachusetts
    Posts
    896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    But you never change invcount so why wouldn't it be the same as z?(this question should lead you to the solution)

    What if the person DID input the right colors but you havent arrived at the fishing spot yet so it wont find the colors?

    SCAR Code:
    if Random(2) = 0 then
            Mouse(x, y, 1, 1, True)
          else
            Mouse(x, y, 3, 3, True);

    what is the point of this?

  16. #16
    Join Date
    Apr 2007
    Posts
    2,593
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Mate. Remember, this is only 1 function.

    And, the InvCount wouldn't be the same because it checks it for the second time after it clicks.

    Alas, that is just a little bit of AntiBan.

  17. #17
    Join Date
    Jul 2007
    Location
    Massachusetts
    Posts
    896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    oh sorry, i didn't know invcount was a function XD

    SCAR Code:
    case Random(2) of
            1: Mouse(x, y, 1, 1, True);
            2: Mouse(x, y, 3, 3, True);
          end;
    ^^This is not needed
    no randomness is needed Mouse(x, y, 0, 0, True) is fine. You have already moved your mouse to the spot+randomness. If you add more randomness then it will have a little jump (think about it).

  18. #18
    Join Date
    Apr 2007
    Posts
    2,593
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    function InvCount : integer;

    ...Duhhh??

  19. #19
    Join Date
    Jul 2007
    Location
    Massachusetts
    Posts
    896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    sorry lol iv been away from srl for a while

    SCAR Code:
    if z=InvCount then
          begin
            FindFishez(FishyColor, FishyColor2, FishyColor2);
          end else
            Result := True;

    should be

    SCAR Code:
    if z=InvCount then
          begin
            A:=A-1;
          end else
          begin
            Result := True;
            Exit;
          end;

    Because otherwise it will continue with the for loop even if you have successfully fished.

    I added A:=A-1 because then it will redo the fish thing with the same color because it found the fish but obviously didn't fish for some reason (probably a lag)

    Also, add a Result:=False at the end because you know if it hasnt exited (it exits when it succeeds) then it has failed.

  20. #20
    Join Date
    Apr 2007
    Posts
    2,593
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    What does the A have to do with anything?

  21. #21
    Join Date
    Jul 2007
    Location
    Massachusetts
    Posts
    896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    its i in yours and a in ec's. It is basicly the var that you are using in the for loop.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. i need help with how to find a fishing spot
    By poolikemax in forum OSR Help
    Replies: 12
    Last Post: 02-07-2008, 09:30 AM

Posting Permissions

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