Results 1 to 13 of 13

Thread: Spaceblow's redberries gatherer (my first script)

  1. #1
    Join Date
    Jul 2014
    Location
    Europe
    Posts
    182
    Mentioned
    7 Post(s)
    Quoted
    103 Post(s)

    Exclamation Spaceblow's redberries gatherer (my first script)

    EDIT: I released a better version of this script with more features: Spaceblow's Redberries Gatherer



    Hello everyone, I'm really new to this kind of stuff. I made a simple script that gathers redberries at Varrock East and banks them. I did this so I could get a little bit of experience because this is my first scripting language that I've ever learned. I have no idea how I could put an antiban in the 'getRedberries()' procedure (look below), I tried it for hours but I just don't have any clue. Learning how to make an antiban will probably be for my next script or maybe for an update on this one, but I don't think so because I think I've had it with the redberries.

    Sooner or later you'll probably going to experience a bug when running my script, it would be nice if you would let me know so I could learn from my mistakes. If you try it out, start in the bank of Varrock East, next to the bushes or on the way from the bank to the redberries. A huge thank you for @The Mayor. I would never have even learned to type 'writeLn()' without him. And of course a very big thank you for everyone who helped me and for the people who have made guides and tutorials!

    It actually took me way too long to make this but this was because of a lot trial and error. I guess it isn't flawless but I just couldn't hold it anymore to start this thread. I included the map with this thread. Just place it in Simba\Includes\SPS\img\runescape_other. Delete the Direct-X line at the end of the script if you don't use that plugin. I hope experienced and unexperienced scripters will reply on this thread to tell me whether I did good or bad.

    BERRY_MAP.png

    Simba Code:
    program Spaceblows_redberries_gatherer;

    {$DEFINE SMART}
    {$I SRL-6/SRL.simba}
    {$I SPS/lib/SPS-RS3.Simba}

    var
      loadsDone: integer;

    procedure declarePlayers();
    begin
      setLength(players, 1);
      with players[0] do
      begin
        loginName := 'username'; // Enter your username
        password := 'password';  // Enter your password
        isActive := true;
        isMember := false;       // Set it to true if you're a member
      end
      currentPlayer := 0;
    end;

    // STUFF //
    procedure runToBank();
    var
      pathToBank: TPointArray;

    begin
      if not isLoggedIn() then
        exit;

      if not tabBackpack.isFull() then
        exit;

      writeLn('--------------------------------------------------------------------------- Running to bank.');
      wait(randomRange(500, 750));
      pathToBank:= [Point(274, 294), Point(273, 280), Point(274, 264), Point(274, 247), Point(271, 230), Point(266, 216), Point(258, 199), Point(253, 185), Point(248, 169), Point(245, 153), Point(240, 137), Point(224, 133), Point(211, 133), Point(187, 131), Point(173, 132), Point(157, 132), Point(137, 130), Point(120, 136), Point(118, 151), Point(117, 169)];
      if SPS.walkPath(pathToBank) then
        minimap.waitPlayerMoving()
      else
        writeLn('--------------------------------------------------------------------------- We failed to walk to the bank.');
    end;


    procedure bankRedberries();
    var
      bankTimer: TTimeMarker;
      pathFail: TPointArray;

    begin
      if not isLoggedIn() then
        exit;

      if not tabBackpack.isFull() then
        exit;

      minimap.setAngle(MM_DIRECTION_SOUTH);
      mainScreen.setAngle(MS_ANGLE_HIGH);

      bankScreen.open(BANK_NPC_BLUE);
      _waitBankOrPinscreen(5000);
      wait(randomRange(750, 1250));

      if bankScreen.isOpen() then
      begin
        bankTimer.start();
        writeLn('--------------------------------------------------------------------------- Succesfully opened the bank');
        repeat
          begin
            wait(randomRange(600, 900));
            bankScreen.quickDeposit(QUICK_DEPOSIT_INVENTORY);
            wait(randomRange(600, 900));
            bankScreen.close();
            writeLn('--------------------------------------------------------------------------- Succesfully closed the bank.');
          end;
        until(tabBackpack.isEmpty()) or (not isLoggedIn()) or (bankTimer.getTime() > 7000);
           if tabBackpack.isEmpty() then
              begin
                writeLn('--------------------------------------------------------------------------- Succesfully banked Redberries.');
                inc(loadsDone);
                wait(randomRange(750, 1250));
                writeLn('--------------------------------------------------------------------------- Running to redberries.');
              end;
      end else
        begin
          writeLn('--------------------------------------------------------------------------- Could not open bank, trying to find it.');
          wait(randomRange(750, 1000));

          pathFail:= [Point(118, 133), Point(118, 169)]; //in case the player somehow didn't got in the bank, but outside of it
          if SPS.walkPath(pathFail) then
            minimap.waitPlayerMoving();

          wait(randomRange(750, 1000));
          bankRedberries();
        end;

      if tabBackpack.isEmpty() then
      begin
        exit;
      end else
        bankRedberries();
    end;

    procedure runToDoor();
    var
      pathToDoor, pathFurther: TPointArray;
      goToBankTimer: TTimeMarker;
      dummySymbol, clothesSymbol: TPoint;

    begin
      if not isLoggedIn() then
        exit;

      if tabBackpack.isFull() then
        begin
          goToBankTimer.start();
        repeat
          bankRedberries();
          if (goToBankTimer.getTime() > 15000) then
            WriteLn('--------------------------------------------------------------------------- Could not bank, terminating the script.');
            terminateScript();
        until (tabBackpack.isEmpty());
        end;

      if not minimap.findSymbol(dummySymbol, MM_SYMBOL_TRAINING_DUMMY, minimap.getBounds()) then
        exit;

      writeLn('--------------------------------------------------------------------------- Running to door.');

      minimap.setAngle(MM_DIRECTION_NORTH);

      pathToDoor:= [Point(117, 162), Point(118, 145), Point(120, 136), Point(137, 128), Point(157, 132), Point(180, 132), Point(192, 132), Point(208, 131)];
      if SPS.walkPath(pathToDoor) then
        minimap.waitPlayerMoving()
      else
        writeLn('--------------------------------------------------------------------------- We failed to walk to the redberries.');

      if conversationBox.isOpen() then
        repeat
          wait(randomRange(350, 750));
          conversationBox.continue(true, true);
          wait(randomRange(350, 750));
          conversationBox.selectOption(1);
          wait(1000);
        until not conversationBox.isOpen();

      wait(randomRange(2000, 2250)); //in case the player somehow didn't go through the door (I experienced it)

      if conversationBox.isOpen() then
        repeat
          wait(randomRange(350, 750));
          conversationBox.continue(true, true);
          wait(randomRange(350, 750));
          conversationBox.selectOption(1);
          wait(1000);
        until not conversationBox.isOpen();
          writeLn('--------------------------------------------------------------------------- We continued our journey.');

      // after door //
      pathFurther := [Point(217, 131), Point(233, 147), Point(254, 178), Point(257, 190)];
      if SPS.walkPath(pathFurther) then
        minimap.waitPlayerMoving();

      if not minimap.findSymbol(clothesSymbol, MM_SYMBOL_SHOP_CLOTHES, minimap.getBounds()) then
        begin
          writeLn('---------------------------------------------------------------------------  Not at the right location, terminating script.');
          terminateScript;
        end;

    end;


    procedure runToRedberries();
    var
      pathToRedberries: TPointArray;
      altarSymbol, treeSymbol: TPoint;

    begin
      if not isLoggedIn() then
        exit;

        writeLn('--------------------------------------------------------------------------- Running to redberries.');
        wait(randomRange(500, 750));
        pathToRedberries:= [Point(215, 132), Point(222, 135), Point(241, 143), Point(250, 156), Point(259, 167), Point(260, 181), Point(262, 198), Point(265, 212), Point(268, 229), Point(272, 244), Point(274, 259), Point(273, 275), Point(274, 292), Point(280, 314), Point(281, 325), Point(280, 339), Point(271, 350), Point(256, 360), Point(239, 362), Point(222, 361), Point(208, 361)];
      if SPS.walkPath(pathToRedberries) then
        minimap.waitPlayerMoving()
      else
        writeLn('--------------------------------------------------------------------------- We failed to run to the redberries.');

      if (minimap.findSymbol(altarSymbol, MM_SYMBOL_ALTAR, minimap.getBounds()) and minimap.findSymbol(treeSymbol, MM_SYMBOL_TREE, minimap.getBounds())) then
        begin
          writeLn('--------------------------------------------------------------------------- We found the redberry bushes.');
        end else
          begin
            writeLn('--------------------------------------------------------------------------- We somehow didn''t find the redberry bushes, maybe you''re at the wrong location, terminating script.');
            terminateScript;
          end;
    end;


    procedure getRedberries();
    var
      x, y, i: integer;
      bushTPA: TPointArray;
      berryTPA: TPointArray;
      ATPA: T2DPointArray;
      redberriesTimer: TTimeMarker;

    begin
      if not isLoggedIn() then
        exit;

      redberriesTimer.start();
      minimap.setAngle(320);
      mainScreen.setAngle(MS_ANGLE_HIGH);

      repeat

        findColorsSpiralTolerance(x, y, bushTPA, 1714858, mainScreen.getBounds(), 5, colorSetting(2, 0.11, 0.31));
        ATPA:= bushTPA.toATPA(30, 30);
        ATPA.sortFromMidPoint(mainscreen.playerPoint);
        smartImage.debugATPA(ATPA);

        for i:= 0 to high(ATPA) do
          if findColorsSpiralTolerance(x, y, berryTPA, 1714858, ATPA[i].getBounds(), 5, colorSetting(2, 0.11, 0.31)) then
          begin
            mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
            if isMouseOverText(['Redberry bush'], 2000) then
            begin
              fastClick(MOUSE_LEFT);
              tabBackpack.waitForShift(1500 + random(1000));
              writeLn('--------------------------------------------------------------------------- Succesfully got some redberries');
              wait(randomRange(1250, 1500)); //waiting to refresh smartImage
              smartImage.clear;
              break;
            end;
          end;

      until tabBackpack.isFull() or (redberriesTimer.getTime() > 900000);
    end;

    procedure runToBorderGuard();
    var
      pathToBG: TPointArray;
      questSymbol: TPoint;

    begin
      if not isLoggedIn() then
        exit;

      if not tabBackpack.isFull() then
        exit;

      if minimap.findSymbol(questSymbol, MM_SYMBOL_QUEST, minimap.getBounds()) then
        exit;

      writeLn('--------------------------------------------------------------------------- Running to border guard.');

        minimap.setAngle(MM_DIRECTION_NORTH);
        pathToBG:= [Point(222, 362), Point(234, 362), Point(247, 360), Point(260, 356), Point(273, 347), Point(281, 334), Point(280, 320), Point(278, 296)];
      if SPS.walkPath(pathToBG) then
        minimap.waitPlayerMoving()
      else
        writeLn('--------------------------------------------------------------------------- We failed to walk to the border guard.');

      if conversationBox.isOpen() then
        repeat
          wait(randomRange(350, 750));
          conversationBox.continue(true, true);
          wait(randomRange(350, 750));
          conversationBox.selectOption(1);
          wait(1000);
        until not conversationBox.isOpen();

      wait(randomRange(2000, 2250)); //in case the player somehow didn't go through the door (I experienced it)

      if conversationBox.isOpen() then
        repeat
          wait(randomRange(350, 750));
          conversationBox.continue(true, true);
          wait(randomRange(350, 750));
          conversationBox.selectOption(1);
          wait(1000);
        until not conversationBox.isOpen();
          writeLn('--------------------------------------------------------------------------- We continued our journey.');
    end;

    procedure progressReport();
    var
      redberriesGot, profit, profitPerHour: integer;

    begin
      redberriesGot:= loadsDone * 28;
      profit:= (redberriesGot * 870);
      profitPerHour:= round((profit * 60) / (getTimeRunning() / 60000));

      writeLn('#################################################');
      writeLn('######## Spaceblow''s redberries gatherer ########');
      writeLn('#################################################');
      writeLn('Time run: ' + timeRunning);
      writeLn('Redberries gathered: ' + intToStr(redberriesGot));
      writeLn('Loads done: ' + intToStr(loadsDone));
      writeLn('Profit made: ' + intToStr(profit));
      writeLn('Profit per hour: ' + intToStr(profitPerHour));
      writeLn('#################################################');
    end;


    // MAIN LOOP //
    begin
      clearDebug();
      smartShowConsole := false;
      smartEnableDrawing := true;
      smartPlugins := ['d3d9.dll']; // DIRECT-X PLUGIN, DELETE THIS IF YOU DON'T HAVE THE PLUGIN
      setupSRL();
      declarePlayers();

      SPS.setup ('BERRY_MAP', RUNESCAPE_OTHER);

      repeat
        if not isLoggedIn() then
        begin
          players[currentPlayer].login();
          exitTreasure();
          minimap.setAngle(MM_DIRECTION_NORTH);
          minimap.toggleRun(true);
          mainScreen.setZoom(true);
          mainScreen.setAngle(MS_ANGLE_HIGH);
        end;

        runToBorderGuard();
        runToBank();
        bankRedberries();
        progressReport();
        runToDoor();
        runToRedberries();
        getRedberries();
      until(false);
    end.
    Last edited by Spaceblow; 08-27-2014 at 08:52 AM. Reason: adjusted the script

  2. #2
    Join Date
    Dec 2011
    Location
    Toronto, Ontario
    Posts
    6,424
    Mentioned
    84 Post(s)
    Quoted
    863 Post(s)

    Default

    Very well written for a first script. Keep it up man.

  3. #3
    Join Date
    Jul 2014
    Location
    Europe
    Posts
    182
    Mentioned
    7 Post(s)
    Quoted
    103 Post(s)

    Default

    Quote Originally Posted by Sin View Post
    Very well written for a first script. Keep it up man.
    Thank you very much! I will try to keep it up but I don't know if that's possible because I don't have very much time, we'll see what the future brings.

    For the declarePlayers() procedure, I actually copied it from The Mayor's AIO guide, all the credits go to him.

  4. #4
    Join Date
    Dec 2011
    Location
    Hyrule
    Posts
    8,662
    Mentioned
    179 Post(s)
    Quoted
    1870 Post(s)

    Default

    Quote Originally Posted by Spaceblow View Post
    Thank you very much! I will try to keep it up but I don't know if that's possible because I don't have very much time, we'll see what the future brings.

    For the declarePlayers() procedure, I actually copied it from The Mayor's AIO guide, all the credits go to him.
    Well @The Mayor; copied it from me.. and I copied it from someone else, who copied it from someone else, etc etc. The true question is who was the first???

  5. #5
    Join Date
    Jun 2007
    Location
    The land of the long white cloud.
    Posts
    3,702
    Mentioned
    261 Post(s)
    Quoted
    2006 Post(s)

    Default

    Quote Originally Posted by Ashaman88 View Post
    Well @The Mayor; copied it from me.. and I copied it from someone else, who copied it from someone else, etc etc. The true question is who was the first???
    The earliest declare players I could find was 15 Feb 2006, which was a few days after SRL went public. Mems link

  6. #6
    Join Date
    Aug 2014
    Posts
    34
    Mentioned
    5 Post(s)
    Quoted
    17 Post(s)

    Post

    Great first script, look forward to seeing more. :P

  7. #7
    Join Date
    Jul 2014
    Location
    Europe
    Posts
    182
    Mentioned
    7 Post(s)
    Quoted
    103 Post(s)

    Default

    Quote Originally Posted by Dr Clemsip View Post
    Great first script, look forward to seeing more. :P
    Thank you for your reply, it was nice to meet you by the way.

    I met him when I was working on my script, he was a random player who said it was noticable that I was botting and he recommended me to use Simba, what a small world haha.

  8. #8
    Join Date
    Aug 2014
    Posts
    58
    Mentioned
    0 Post(s)
    Quoted
    30 Post(s)

    Default

    Doesn't work for me...Keeps saying waiting for RS to load but I have tried both OpenGL and DirectX...The other scripts are working for me..I have it setup properly too..

  9. #9
    Join Date
    Jul 2014
    Location
    Europe
    Posts
    182
    Mentioned
    7 Post(s)
    Quoted
    103 Post(s)

    Default

    Quote Originally Posted by twirap View Post
    Doesn't work for me...Keeps saying waiting for RS to load but I have tried both OpenGL and DirectX...The other scripts are working for me..I have it setup properly too..
    It's working fine for me. Maybe it's because of your graphics settings? If you're using the Direct-X plugin, don't forget to change your graphics settings too... I adjusted the script a little bit so update your .simba file if you want to try out my script again. Don't expect it to be flawless but most of the time it's working fine. I would really appreciate it if you tell me how the script is after you've tried it out.

  10. #10
    Join Date
    Aug 2014
    Posts
    58
    Mentioned
    0 Post(s)
    Quoted
    30 Post(s)

    Default

    The settings for direct x are different? I thought the only change for Directx was changing the graphics from Opengl to directx..

  11. #11
    Join Date
    Jul 2014
    Location
    Europe
    Posts
    182
    Mentioned
    7 Post(s)
    Quoted
    103 Post(s)

    Default

    Quote Originally Posted by twirap View Post
    The settings for direct x are different? I thought the only change for Directx was changing the graphics from Opengl to directx..
    You do have the Direct-X plugin, right?

  12. #12
    Join Date
    Aug 2014
    Posts
    58
    Mentioned
    0 Post(s)
    Quoted
    30 Post(s)

    Default

    Ah no. I was using the noral Directx on my settings in game.

  13. #13
    Join Date
    Jul 2014
    Location
    Europe
    Posts
    182
    Mentioned
    7 Post(s)
    Quoted
    103 Post(s)

    Default

    Quote Originally Posted by twirap View Post
    Ah no. I was using the noral Directx on my settings in game.
    You have to set your graphics settings to Direct-X and download the plugin. Just place the plugin in C:\Simba\Plugins and run the script. If you prefer not to use the plugin set your graphics settings to OpenGL and manually delete that line in the script and start it. It should run without problems, I don't see why it wouldn't.

    As I already said, don't expect the script to run flawless as it's my first try for anything related to scripting. I'll probably re-release the script in the near future with antiban and those stuff, so keep an eye out on the RS3 scripts section.

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
  •