Results 1 to 7 of 7

Thread: How to detect if fishing? / Drop problem.

  1. #1
    Join Date
    Feb 2013
    Location
    Nova Scotia
    Posts
    10
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default How to detect if fishing? / Drop problem.

    Hey everyone. I've spent a few days reading various tutorials on the forums and taking in bits of information in hopes of being able to write a basic script. I've come up with this, extremely basic, fishing script (I call it the shitty fisher). Problem is, it drops all of the fish after catching about only 4 or 5 (When the inventory isn't full) and while it's fishing it will switch to a different fishing spot.

    I'm completely new to scripting for Runescape, so excuse my noobness, but any help would be appreciated so I could make this functional. (It works, it's just not efficient ) It's for EOC by the way. Thanks

    Simba Code:
    procedure Fish;
    var
    x, y:Integer;
    begin
      writeln('Find Fishing Spot..');
      if FindObj(x, y, 'Net', 11576734, 35) then
      begin
      writeln('Found!');
      writeln('Netting!..');
      Mouse(x, y, 2, 2, false);
      ChooseOption('Net');
      repeat
       Wait(30000+random(2000));
       Antiban;
       Until not  IsUpText('Net') or (InvFull);
     end;

    end;

    procedure dropfish;
    begin
      if InvFull Then
      writeln('Inv full!');
      writeln('Dropping Inventory...');
       DropAllExcept([1]);
      wait(100+random(125));
      end;

  2. #2
    Join Date
    Feb 2012
    Location
    Discord
    Posts
    3,114
    Mentioned
    37 Post(s)
    Quoted
    538 Post(s)

  3. #3
    Join Date
    Feb 2013
    Location
    Nova Scotia
    Posts
    10
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by The Killer View Post
    Thankyou so much! Not really sure where to start with this, or how to use it? Would anyone mind helping me out? Completely new to this. Thanks.
    Last edited by torinx; 03-02-2013 at 11:50 PM.

  4. #4
    Join Date
    Mar 2007
    Location
    Mars, I thought all men were from Mars.
    Posts
    513
    Mentioned
    7 Post(s)
    Quoted
    124 Post(s)

    Default

    you can use mine if you like...
    Simba Code:
    Procedure IsFishing;
    var
      OutTime, ETime, STime: Integer;
      Mov: Boolean;
      Box: TBox;
    begin
      if InvFull then
      begin
        Writeln('Can''t fit anymore, going to bank or dropping');
        Exit;
      end;
      Box := IntToBox(MSCX - 2, MSCY - 4, MSCX + 4, MSCY + 6);
      repeat
        Mov := False;
        STime := GetSystemTime;

        repeat
          if Animating(Box, 100, 9) then Mov := True;
          ETime := GetSystemTime - STime;
        until (ETime > 3000) or (Mov = True) or InvFull

        if InvFull then
        begin
          WriteDebug('Can''t fit anymore, going to bank or dropping');
          Exit;
        end;


        OutTime := (GetSystemTime - InTime);
      until (Mov = False) or (OutTime > 240000) or InvFull

    end;
    Not scripting for RS anymore, sorry. Banned too many times.
    MY SCRIPTS

  5. #5
    Join Date
    Feb 2013
    Location
    Nova Scotia
    Posts
    10
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by bud_wis_er_420 View Post
    you can use mine if you like...
    Simba Code:
    Procedure IsFishing;
    var
      OutTime, ETime, STime: Integer;
      Mov: Boolean;
      Box: TBox;
    begin
      if InvFull then
      begin
        Writeln('Can''t fit anymore, going to bank or dropping');
        Exit;
      end;
      Box := IntToBox(MSCX - 2, MSCY - 4, MSCX + 4, MSCY + 6);
      repeat
        Mov := False;
        STime := GetSystemTime;

        repeat
          if Animating(Box, 100, 9) then Mov := True;
          ETime := GetSystemTime - STime;
        until (ETime > 3000) or (Mov = True) or InvFull

        if InvFull then
        begin
          WriteDebug('Can''t fit anymore, going to bank or dropping');
          Exit;
        end;


        OutTime := (GetSystemTime - InTime);
      until (Mov = False) or (OutTime > 240000) or InvFull

    end;
    I've spent the last few hours playing around with that and trying different things to get it to function properly and I haven't had any luck. How should I go about using that in my script and actually getting it to function? I'm very confused at the moment.

  6. #6
    Join Date
    Mar 2007
    Location
    Mars, I thought all men were from Mars.
    Posts
    513
    Mentioned
    7 Post(s)
    Quoted
    124 Post(s)

    Default

    Quote Originally Posted by torinx View Post
    I've spent the last few hours playing around with that and trying different things to get it to function properly and I haven't had any luck. How should I go about using that in my script and actually getting it to function? I'm very confused at the moment.
    Maybe commenting it better will help you understand it.

    Simba Code:
    Procedure IsFishing;
    var
      OutTime, ETime, STime: Integer;
      Mov: Boolean;
      Box: TBox;
    begin
      //This checks if inv is full. Because you don't want to continue looking
      //if we are fishing, if you inv is full
      if InvFull then
      begin
        Writeln('Can''t fit anymore, going to bank or dropping');
        Exit;// This exits the procedure without doing anything else
      end;
      //Sets a Tbox into a small square at the center of the rs main screen
      Box := IntToBox(MSCX - 2, MSCY - 4, MSCX + 4, MSCY + 6);
      //This is the out side loop. It times out after 4 mins
      repeat
        Mov := False;// False because if the below loop don't find movement,
                     // this false reading will kick it out of loop
        STime := GetSystemTime;//Gets the start time

        //Inside loop. This loop looks for movement for 3000 ms(3sec)
        repeat
          // Below baicly takes a picture of the box specified and 100ms later
          // takes another picture to compare to. If at least 9 pixels change in
          // the second pic, then it returns true as it found movement
          if Animating(Box, 100, 9) then Mov := True; //mov is true if found
          ETime := GetSystemTime - STime;// this gets the time the inner loop has been repeated for
        until (ETime > 3000) or (Mov = True) or InvFull
        // If the above loop finds movement then the outside loop is repeated
        // until it doesn't find movement for at least 3 sec or 4 mins has passed.

        // Once again check for full inv to kick out of loop if needed
        if InvFull then
        begin
          WriteLn('Can''t fit anymore, going to bank or dropping');
          Exit;
        end;

        // Gets the time the outer loop has been repeated for
        OutTime := (GetSystemTime - InTime);
      until (Mov = False) or (OutTime > 240000) or InvFull
      // If 4 mins has passed or the inner loop didn't find movement for 3 sec then
      // the outer loop ends and we are not fishing or not fishing anymore.
    end;

    So if you call this procedure after you click on a fishing spot it will look for movement for 3 sec and if not found will end. If it does find movement it continues loop till it no longer finds movement or 4 mins has passed. BTW this procedure was just an example, not a working one. You would have to edit it to get it working. I added a working one below

    This is the main part your looking for
    Simba Code:
    repeat
          if Animating(Box, 100, 9) then Mov := True;
          ETime := GetSystemTime - STime;
        until (ETime > 3000) or (Mov = True) or InvFull
    You want to repeat the Animating function several times because while fishing you dip down pause for a sec and rise back up. This process takes about just under 3 sec to complet. So by repeating this loop for 3 sec you are bound to catch the movement if you are fishing. This is to most accurate way I found to detect fishing. And I'd say still only about 95% accurate. It's harder than some movements to detect because of the pauses in the animation of fishing.

    You can use this to test how often if finds movement. To better gauge your movement wait time.
    Simba Code:
    program new;
    {$DEFINE SMART}
    {$I SRL/SRL.Simba}

    var
      STime, LoopTime: integer;
      box: TBox;
      Mov: Boolean;

    begin
      SetUpSRL;
      Box := IntToBox(MSCX - 2, MSCY - 4, MSCX + 4, MSCY + 6);

      repeat
        STime := GetSystemTime;
        Mov := False;
        repeat
          if Animating(Box, 100, 9) then Mov := True;
        until (Mov = True)
        LoopTime := GetSystemTime - STime;
        writeln('Took ' + IntToStr(LoopTime) + ' ms to find Movement');
      until(false)
    End.

    example of calling it from my own fishing script.

    Simba Code:
    //because my script looks for next spot before it's finished
        //fishing it first checks if mouse is already hovering over fishing spot
        if FindTextAdv(FishText) then
        begin
          // If correct fishing spot is found then it clicks on it.
          if ClickFishingSpot then
          begin
            TryCount := 0;
            FoundSpot := True;
          end;
        end else
        begin
          // If mouse not already hovering over fishing spot then it looks for fishing spot and clicks it
          if StartFishing then
          begin
            TryCount := 0;
            FoundSpot := True;
          end else inc(TryCount);
        end;
       
        // So if the above was successful then FoundSpot will equal true and below will happen next
        if (FoundSpot = True) then
        begin
          WaitNotMoving(True);// this waits till we finihed running to fishing spot after clicking on it
          WriteDebug('Checking if we are fishing'); // a comment
          IsFishing;  // <---- IsFishing
        end;

    This is my actual IsFishing procedure in my script. This will compile on its own. Just add the below to a new Simba tab and press run while fishing or not. It will detect if fishing or not. If you are fishing it will continue to loop though until you are no longer fishing then the script will stop. Also includes all my debug stuff for your convenience. Will paint a yellow cross every time it detects movement. Also displays the search area box. Hope all this helps and Good Luck.

    Simba Code:
    program new;
    {$DEFINE SMART}
    {$I SRL/SRL.Simba}
    {$IFDEF SIMBAMAJOR980}
      {$I SRL/SRL/Misc/PaintSmart.Simba}
    {$ELSE}
      {$I SRL/SRL/Misc/SmartGraphics.Simba}
    {$ENDIF}

    var
      FishText: TStringArray;

    const

    Debug = true;

    procedure LoadText;
    begin
      FishText := ['Cage', 'age']; // the uptext for the fishing spot you are looking for
    end;

    Procedure PaintCross(x,y,col: Integer);
    var
      CTPA ,HighTPA, i, c: Integer;
      TP: Tpoint;
      TPA, NewTPA: TPointArray;
    begin
      SetLength(TPA, 104);
      SetLength(NewTPA, Length(TPA));
      //Draw right
      TP := Point(x, y);
      for CTPA:= 0 to 9 do
      begin
       TPA[CTPA] := TP;
       TP := point(TP.x + 1, TP.y);
      end;
      TP := Point(x, y - 1);
      for CTPA := 10 to 17 do
      begin
       TPA[CTPA] := TP;
       TP := point(TP.x + 1, TP.y);
      end;
      TP := Point(x,y+1);
      for CTPA:= 18 to 25 do
      begin
       TPA[CTPA] := TP;
       TP := point(TP.x + 1, TP.y);
      end;
      //Draw down
      TP := Point(x, y);
      for CTPA := 26 to 35 do
      begin
       TPA[CTPA] := TP;
       TP := point(TP.x, TP.y + 1);
      end;
      TP := Point(x + 1, y);
      for CTPA := 36 to 43 do
      begin
       TPA[CTPA] := TP;
       TP := point(TP.x, TP.y + 1);
      end;
      TP := Point(x - 1, y);
      for CTPA := 44 to 51 do
      begin
       TPA[CTPA] := TP;
       TP := point(TP.x, TP.y + 1);
      end;
      //Draw left
      TP := Point(x, y);
      for CTPA := 52 to 61 do
      begin
       TPA[CTPA] := TP;
       TP := point(TP.x - 1, TP.y);
      end;
      TP := Point(x, y + 1);
      for CTPA := 62 to 69 do
      begin
       TPA[CTPA] := TP;
       TP := point(TP.x - 1, TP.y);
      end;
      TP := Point(x, y - 1);
      for CTPA := 70 to 77 do
      begin
       TPA[CTPA] := TP;
       TP := point(TP.x - 1, TP.y);
      end;
      //Draw up
      TP := Point(x, y);
      for CTPA:= 78 to 87 do
      begin
       TPA[CTPA] := TP;
       TP := point(TP.x, TP.y - 1);
      end;
      TP := Point(x + 1, y);
      for CTPA := 88 to 95 do
      begin
       TPA[CTPA] := TP;
       TP := point(TP.x, TP.y - 1);
      end;
      TP := Point(x - 1, y);
      for CTPA:= 96 to 103 do
      begin
       TPA[CTPA] := TP;
       TP := point(TP.x, TP.y - 1);
      end;
      c := 0;
      HighTPA := High(TPA)
      for i := 0 to HighTPA do
      begin
        if not (TPA[i].x < MSX1 + 1) and
           not (TPA[i].x > MSX2 - 1) and
           not (TPA[i].y < MSY1 + 1) and
           not (TPA[i].y > MSY2 - 1) then
        begin
          NewTPA[c] := TPA[i];
          inc(c);
        end;
      end;

      SetLength(NewTPA, c)
      SMART_DrawDotsEx(False, NewTPA, col);
    end;

    Procedure WriteDebug(txt: string);
    begin
      if(Debug)then
        WriteLn(txt);
    end;

    Function CheckLogin: Boolean;
    begin
      Result := False;
      if not loggedin then
      begin
        if not loginplayer then
        begin
          //restart := True;
          Result := True;
        end;
      end;
    end;

    Function IsUpTextAdv(Text: TStringArray): Boolean;
    var
    TP : TPoint;
    begin
      Result := FindTextEx(TP.x,TP.y,Text,['UpChars'],MSX1,MSY1,MSX1+300,MSY1+30) or
                FindTextEx(TP.x,TP.y,Text,['UpChars_s'],MSX1,MSY1,MSX1+300,MSY1+30) or
                FindTextEx(TP.x,TP.y,Text,['UpCharsEx'],MSX1,MSY1,MSX1+300,MSY1+30) or
                IsUpTextMultiCustom(Text);
    end;

    Function FindTextAdv(Text: TStringArray): Boolean;
    var
      x, y: Integer;
    begin
      Result := False;
      if IsUpTextAdv(Text) then
      begin
        Result := True;
      end else
      begin
        if FindTextEx(x, y, Text, ['UpCharsEx'], MSX1, MSY1, MIX2, MIY2) then
        begin
          Result := True;
        end else
        begin
          WriteDebug('Did not Find ' + Text[0] + ' UpText');
        end;
      end;
    end;


    Procedure IsFishing;
    var
      InTime, OutTime, ETime, STime: Integer;
      Mov: Boolean;
      Box, Box2 : TBox;
    begin
      if CheckLogin then Exit;
      if (debug = True) then SMART_ClearCanvas;
      if InvFull then
      begin
        WriteDebug('Can''t fit anymore, going to bank or dropping');
        Exit;
      end;

      Box := IntToBox(MSCX - 2, MSCY - 4, MSCX + 4, MSCY + 6);
      Box2 := IntToBox(MSCX - 13, MSCY, MSCX + 13, MSCY + 24);
      InTime := (GetSystemTime);
      Mov := False;
      STime := GetSystemTime;
      repeat
        if Animating(Box, 100, 9) then Mov := True;
        ETime := GetSystemTime - STime;
      until (ETime > 3500) or (Mov = True)

      if (Mov = True) then
      begin
        WriteDebug('We are fishing');
        repeat

          if CheckLogin then Exit;
          if (debug = True) then SMART_DrawBox(Box);
          //if (debug = True) then SMART_DrawBoxEX(False, False, Box2, clGreen);

          Mov := False;
          STime := GetSystemTime;

          repeat
            if Animating(Box, 100, 9) then Mov := True;
            ETime := GetSystemTime - STime;
          until (ETime > 3000) or (Mov = True) or InvFull

          if InvFull then
          begin
            WriteDebug('Can''t fit anymore, going to bank or dropping');
            Exit;
          end;

          if (Mov = True) then
          begin
            if (debug = True) then PaintCross(MSCX, MSCY, clYellow);
            wait(RandomRange(10,11));
            status('We are fishing');
            //WriteDebug('Still Fishing');
            //AntiBan;
            if not FindTextAdv(FishText) then
            begin
              WriteDebug('Add you fishing spot finder here to look for next fishing spot');
              // Here you can add you fishing spot finding method to
              // look for next fishing spot b4 finished fishing
              {if FindFishingSpot(False, 30) then
                WriteDebug('Nexted Fishing Spot Found'); }

            end;
          end else WriteDebug('Stopped Fishing');

          if (debug = True) then SMART_ClearCanvas;

          //LookForFullChatTxt;
          OutTime := (GetSystemTime - InTime);
        until (Mov = False) or (OutTime > 240000) or InvFull
        if (OutTime > 120000) then
        begin
          WriteDebug('''Is Fishing'' timed out');
          writeln('Timed out after ' + ToStr(OutTime));
        end;

      end else
      begin
        WriteDebug('Didn''t detect that we are fishing');
        Exit;
      end;
      if (debug = True) then SMART_ClearCanvas;
    end;

    begin
    SetupSRL;
    LoadText;

    IsFishing

    end.
    Last edited by bud_wis_er_420; 03-04-2013 at 09:41 AM.
    Not scripting for RS anymore, sorry. Banned too many times.
    MY SCRIPTS

  7. #7
    Join Date
    Feb 2013
    Location
    Nova Scotia
    Posts
    10
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    I can't thank you enough for your post. It explains just about everything I was wondering and I'm fairly confident I understand what's going on now! I'll try it out when I get home. Thankyou!

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
  •