Results 1 to 4 of 4

Thread: [RS3] Doughmaker Lumbridge Moneymaking

  1. #1
    Join Date
    Jul 2015
    Posts
    12
    Mentioned
    2 Post(s)
    Quoted
    1 Post(s)

    Default [RS3] Doughmaker Lumbridge Moneymaking

    Doughmaker
    By: Longfinmako and Nicerman1
    Current version: v1.2
    Current status: No longer supported.

    Hello there! Most of you will probably not know me because this is my first publicly posted script on this forum.
    I've spent a lot of time coding and improving my script until it reached the point that I was satisfied with it. And now here it is! My own doughmaking script.
    I have tested this script extensively and tried to protect it with enough failsafes to make it run smooth. If it does manage to fail too many times it will shut itself down with an error message printed in your Simba client.

    Please post any unresolved problems or errors here, so I can try to fix them.
    Any criticism on the script is welcome, as I am very eager to improve it, but please be polite.


    Features:
    - Makes pastry dough in lumbridge.
    - Makes up to 150K/h profit.
    - Uses SPF for your convenience.
    - SPS map walking from bank to fountain and vice versa.
    - Anti-ban precautions with customizable frequence.
    - Prgress report gets printed on your client to let you track your progress.

    Setting it all up:
    - Download the simba code included in this post.
    - Make sure you also download the SPS map image, named 'DoughMap.png', also included in this post and put it in your 'Simba\Includes\SPS\img\runescape_other' file
    - You will need a cooking level of 10.
    - You will need pots of flour in your bank and preset 1 has to contain 14 pots of flour in the first 14 slots of your inventory.
    - Make sure you start the script while near the Lumbridge bank chest or in the Lumbridge combat academy.
    - Configure your players in the Rafiki player manager.
    - Hit run and enjoy.


    Special thanks:

    -Nicerman1 for helping me develop this script.
    -The Mayor for his awesome AIO beginner tutorial that really helped me to get started: https://villavu.com/forum/showthread.php?t=107757
    -BMWxi for his runescape world map to use with SPS: https://villavu.com/forum/showthread.php?t=111234


    Still to do:

    - Lodestone resets
    - Update with a better progress paint.
    - Automatic downloader for extra needed files.
    - Save progress reports and errors in txt files.


    Changelog:

    v1.3:
    - Removed potentially infinite loop
    - Script terminating failsafes if the script fails to find things on screen.
    - Improved the SPS map 'DoughMap.png' to improve overall performance.
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by longfinmako; 12-19-2016 at 04:01 PM.

  2. #2
    Join Date
    Feb 2015
    Posts
    422
    Mentioned
    41 Post(s)
    Quoted
    226 Post(s)

    Default

    First of all, congratulations on releasing your first script! Hopefully the first of many more to come!

    I will post my comments/suggestions in a few minutes.

    EDIT: @longfinmako

    sorry for the long time it took. I got busy!

    Simba Code:
    program Doughmaker;

    //######################################################################//
    //                                                                      //
    //                  Longfinmako's Doughmaker (pastry)                   //
    //                                                                      //
    //        Makes dough in Lumbridge, please start the script while       //
    //        you are near the bank chest in Lumbridge, or atleast in the   //
    //        combat academy area. You will need Pots of flour in your      //
    //        bank and an inventory filled with 14 pots of flour set to     //
    //        preset 1. Makes a profit of about 152k/h.                     //
    //                                                                      //
    //######################################################################//

    {
    BEFORE RUNNING MAKE SURE:

    -> You have downloaded the DoughMap.png file and put it in the correct folder
        for more info on doing this correct visit:
    -> Your cooking level is at least 10.
    -> You have pots of flour in your bank.
    -> You have 14 pots of flour set to be preset 1!
    -> If the script has issues finding water, or if it tells you te edit color settings, this can be done
       at lines 38 to 50.
    }


    {$DEFINE SMART}
    {$i srl-6/srl.simba}
    {$i srl-6/lib/misc/srlplayerform.simba}
    {$I SPS/lib/SPS-RS3.Simba}

    // User settings: You may edit code in this section but ONLY IF NEEDED
    // if your script runs flawlessly then you don't have to touch this part
    // These seting work for me, if they don't work for you you might want to change
    // them using ACA

    const
      FOUNTAIN_COLOR := 11844782;      //original color: 11844782
      FOUNTAIN_TOL := 4;               //original tol: 4
      FOUNTAIN_HUE := 2.14;            //original hue: 2.14
      FOUNTAIN_SAT := 0.72;            //original sat: 0.72

    // Lower this number to increase anti-ban chance (with a value of 75 you will perform anti-bans 25%of the time)

      ANTI_BAN_FREQUENCE := 80;

    //These aren't really necessary, but I use them for my profit calculator.

      PRICE_POT_OF_FLOUR := 120;
      PRICE_PASTRY_DOUGH := 285;

    //WARNING: editing code under this line may stop your script from working if you don't know what you're doing.
    //################################################################################################################

    var
      loads, goalLoads, breakDuration, lastBreak, breakTime: integer;
      failCounter: integer := 0;
      runTimer: TTimeMarker;
      terminateMsg : String := '';
      terminate: boolean := false;

    procedure initPlayerForm();                    //Setting up the playerform
    begin
      with playerForm do
      begin
        name := 'Doughmaker';
        scriptHelpThread := '';
        scriptSettingsPath := '';

        editBoxLabels := ['Time before taking a break', 'Duration of a break', 'Loads to make'];
        editBoxDefaults := ['0', '0', '0'];
        editBoxHints := ['In minutes', 'In minutes', '14 pots of flour per load'];

      end;
    end;

    procedure declarePlayers();
    var
      i: integer;
    begin
      players.setup(playerForm.players);
      currentPlayer := 0;

      for i := 0 to high(players) do
        with players[i] do
        begin

          integers[0] := strToInt(playerForm.players[i].settings[0]);
          integers[1] := strToInt(playerForm.players[i].settings[1]);
          integers[2] := strToInt(playerForm.players[i].settings[2]);

        end;
    end;

    procedure debugSPFSettings();
    var
      i: integer;
    begin
      writeln('');

      for i := 0 to high(players) do
      begin
        writeln('Minutes to run:           ', players[i].integers[0]);
        writeln('Minutes before breaking:  ', players[i].integers[1]);
        writeln('Dough to make:            ', players[i].integers[2]);
        writeln('');
      end;
    end;

    procedure performAntiBan()                    //Nothing very fancy, just some basic anti ban features.
    begin
      if(random(101) > ANTI_BAN_FREQUENCE) then
      begin
        writeln('Performing Anti-ban.');
        case random(7) of
        0: randomRClickItem();
        1: sleepAndMoveMouse(600 + random(2800));
        2: pickUpMouse();
        3: mouseOffClient(OFF_CLIENT_RANDOM);
        4: randomCameraAngle(MS_ANGLE_HIGH);
        5: boredHuman(true);
        6: mouseMovingObject();
        end;
        writeln('Resuming normal actions');
      end
      else begin
        writeln('Not performing Anti-ban actions');
      end;
    end;

    procedure goToWater();
    var
      p: TPoint;
      pathToFountain: TPointArray;
    begin

      if(not isLoggedIn()) then
         exit();

      if bankscreen.isOpen(100) then
        bankscreen.close();

       pathToFountain := [Point(115, 58), Point(47, 109)];

    {* Good job implementing SPS in your walking. However, What happens if the script fails
       To walk to the fountain? ATM it is going to try to SPS walk then click the symbol until
       Inifinity, and we dont want that. I suggest maybe adding an integer variable that goes up every time
       the repeat loop goes around, and checking if that integer is above lets say 4, then the script
       will either terminate or go to a recovery procedure. *}


      repeat
                                                                // repeats the walking part untill we are close enough to the Fountain.
        if SPS.walkPath(pathToFountain) then
          minimap.waitPlayerMoving()
        else
          writeLn('We failed to walk to the fountain.');
        minimap.findSymbol(p, MM_SYMBOL_WATER, minimap.getBounds());
      //Im assumeing these points are the white dot in the center of the minimap.
      //You can use distance(minimap.getCenterPoint, p); instead.
      until  distance(688, 106, p.X, p.Y) < 25;

      writeln('Arrived at water');

      wait(randomRange(400,1200));
    end;
      {* Same Comments as above *}
    procedure goToBanker();
    var
      p: TPoint;
      pathToBank: TPointArray;
    begin

      if(not isLoggedIn()) then
         exit();

      pathToBank := [Point(47, 102), Point(115, 58)];

      repeat                                                   // repeats the walking part untill we are close enough to the bank.

        if SPS.walkPath(pathToBank) then
          minimap.waitPlayerMoving()
        else
          writeLn('We failed to walk to the Bank.');

        minimap.findSymbol(p, MM_SYMBOL_BANK, minimap.getBounds());

      until  distance(688, 106, p.X, p.Y) < 25;

      wait(randomRange(500,1200));
      writeln('We are now at the bank');

      if(random(4) >= 2) then
        minimap.setAngle(MM_DIRECTION_EAST)
      else
        minimap.setAngle(MM_DIRECTION_WEST);

    end;

    procedure clickBanker()
    var
      x, y, i, counter, limit: integer; //x,y,i are un needed variables
      TPA: TPointArray;       //this too
      ATPA : T2DPointArray;   //this too
    begin

      if(not isLoggedIn()) then
        exit;
     {* Be carful of infinit loops! The only thing that will take us out of this loop,
        is the bank screen opening. What if it never opens? Again we need a failsafe here to Exit the loop, and terminate. *}

      repeat

        writeln('Looking for banker');
        counter := 0;
        limit := randomRange(3,7);

        repeat

          inc(counter);

          if bankscreen.open(BANK_CHEST_LUMBRIDGE) then
            break();

         until counter > limit


         if counter > limit then
         begin
           writeln('Didnt find banker in time, retrying.');
           limit := randomRange(3,7);
           goToWater();      //or a terminate fail safe in both of these would do.
           goToBanker();     //because they are called in the loop.
         end;


      until bankscreen.isOpen(200);

         if bankscreen.isOpen() then
         begin
           bankscreen.clickButton(BANK_BUTTON_PRESET_1);
         end;

    end;
     {* Took me a while to read through this part, the logic here is overly complicated
        for no apparent reason. The many spaces also make it very hard to read. This procedure
        will do what it is supposed to tho. I also can't really see any infinite loops }

    procedure makeDough()
    var
      x, y, i, counter, limit: integer;
      TPA: TPointArray;
      ATPA : T2DPointArray;
    begin

       if(not isLoggedIn()) then                      //Failsafe.
         exit();

       counter := 0;
       limit := randomRange(3,7);                     //looks for water for an amount of times up to this limit


       repeat
                                                             //Use mainscreen.getBounds()
         findColorsSpiralTolerance(x, y, TPA, FOUNTAIN_COLOR, intToBox(0,0,575,400), FOUNTAIN_TOL, colorSetting(2, FOUNTAIN_HUE, FOUNTAIN_SAT));

         if(length(TPA) < 1) then                     //If no correct color is found, don't try to make dough
         begin
           writeln('No color found');
         end;

         ATPA := TPA.toATPA(30,30);
         ATPA.filterBetween(0,20);

         //smartImage.debugATPA(ATPA);

         if(length(ATPA) < 1) then
         begin
           writeln('Not enough colors found!');            //If not enough colors are found, don't try to make dough
           inc(counter);
         end
         else
         begin
                                  //This might give you an error! random(10) is from 0-9 and there is not backpack slot 0
                                  //I suggest using randomRange(1,10);
           tabBackpack.mouseSlot(random(10), MOUSE_LEFT)

           for i:= 0 to high(ATPA) do
           begin

             mouse(middleTPA(ATPA[i]),MOUSE_MOVE);
             if isMouseOverText(['Use Pot of flour -> Mem'], 500) then        //if the fountain is found, make dough!
             begin
               writeln('Found the watersource!');
               failCounter := 0;                               //Reset failCounter if we have found the fountain.
               fastClick(MOUSE_LEFT);
               //smartImage.clear();
               break;
             end
             else
             begin
               writeln('Watersource not found.');
               inc(counter);
             end;
           end;
         end;

       if counter = 0 then                            //Breaks out of the repeat loop when we made dough without encountering a problem.
         break();

       until counter > limit;                            //The repeat makes us look for water a couple times, if we still don't find water,
                                                         //before the counter reaches its limit,we will try to walk back and forth again and try to find water again.


       if failCounter >= 2 then                       //If we fail finding water, even after  completely retrying 2 times, exit the script.
         begin
           terminate := true;
           terminateMsg := 'Failed to find water too many times, terminating script! I suggest editing the color settings.';
           exit();
         end;

       if counter > limit then                          //If we looked 5 times and didn't find a fountain, go to the bank and come back again
       begin
         inc(failCounter);
         writeln('Didnt find water in time, retrying.');
         writeln('Failcounter: ' + intToStr(failCounter));           // FailCounter prevents us from trying again without an end.
       end;


         minimap.waitPlayerMoving(1000);                 //If we did find the fountain, wait untill we have made all of our dough.
         if(productionScreen.isOpen(2000)) then
         begin
           productionScreen.selectBox(2);
           productionScreen.clickStart();
           inc(loads);
         end;

         repeat
           wait(randomRange(1000,2000));
         until not progressScreen.isOpen(1000);

         //smartImage.clear;
    end;

    procedure printProgress()
    var
      profit, doughs: integer;
    begin
      doughs := 14*loads;
      profit := (14*loads)*(PRICE_PASTRY_DOUGH-PRICE_POT_OF_FLOUR);

      smartImage.clear();
      smartImage.drawText('Progress:      ', point(20, 5), 'BigChars', false, clYellow);
      smartImage.drawText('Loads done:    ' + intToStr(loads), point(20, 40), 'UpChars', false, clYellow);
      smartImage.drawText('Dough made:    ' + intToStr(doughs), point(20, 60), 'UpChars', false, clYellow);
      smartImage.drawText('Approx profit: ' + intToStr(profit), point(20, 80), 'UpChars', false, clYellow);
      smartImage.drawText('Exp earned:    ' + intToStr(doughs), point(20, 100), 'UpChars', false, clYellow);
    end;


    begin

      clearDebug();

      initPlayerForm();
      runPlayerForm();

      if (not playerForm.isScriptReady) then     // Does not let the script run if the playerform wasn't filled in properly
        exit;

      declarePlayers();                          // all sorts of setting up
      debugSPFSettings();
      smartEnableDrawing := true;
      setupSRL();
      SPS.setup('DoughMap', RUNESCAPE_OTHER);

      runTimer.start();
                                                                   //storing setings in variables
      loads := 0;
      lastBreak := 0;
      breakTime := players[currentPlayer].integers[0];            //This is in MINUTES not in seconds!
      breakDuration := players[currentPlayer].integers[1];        //This is in MINUTES not in seconds!
      goalLoads := players[currentPlayer].integers[2];

      if isLoggedIn() then
      mainscreen.setAngle(MS_ANGLE_HIGH);

      repeat

      printProgress();

      if not isLoggedIn() then                //failsafe to check your login status, repeated every loop to
      begin                                   // make sure the script doesn't try to make dough when not logged in.
        players[currentPlayer].login();
        wait(randomRange(5000,7000));
        mainscreen.setAngle(MS_ANGLE_HIGH);
      end;

    //##################################################################################

      goToBanker();      //This is the actual 'dough making run'
      clickBanker();     //The other code is either setup stuff or anti-ban stuff
                         //The procedures used are to be found at te top of the program
      performAntiBan();

      if (loads >= goalLoads) then                    //player form functionality: terminating when desired amount of loads is reached
      begin
        write('We have reached the goal amount of ' + intToStr(goalLoads) + ' loads, terminating script');
        players[currentPlayer].logout();
        exit();
      end;

      if terminate then                              //if we failed somwhere or need to terminate the script, check it right after we banked our inventory.
      begin
        writeln(terminateMsg);
        break();
      end;

      goToWater();
      makeDough();

      performAntiBan();                               //Performs random anti-ban actions

    //##################################################################################


      if (runTimer.getTime() > breakTime*60000) then     //Makes us rest every once in a while
      begin
        writeln('Running for ' + intToStr(breakTime) + ', taking a break.');
        players[currentPlayer].logout();
        runTimer.pause();
        writeln('Resting for approximately ' + intToStr(breakDuration) +  ' minutes.');
        wait((breakDuration + randomRange(-3,3))*60000);
        runTimer.reset();   //Dont need the reset, start is enough to restart the timer.
        runTimer.start();
      end;

    until false;

      if isLoggedIn() then
        players[currentPlayer].logout();                      //Failsafe to logs us out after breaking the loop if this didn't happen already

    end.

    I've added comments around in the script. Overall very nice job on your first script! it is much better than my first! I see you've implemented some failsafes, but there are still some infinite loops in there that might get it stuck. Also, the spacing in the script is way too much. No need for an empty line after every begin and repeat. It will make it much easier to read!

    If you ever have any questions, you can always PM me, Ill be glad to help.

  3. #3
    Join Date
    Jul 2015
    Posts
    12
    Mentioned
    2 Post(s)
    Quoted
    1 Post(s)

    Default

    As you might notice, it is merely an adaptation of the script you gave me some feedback on. Although it is changed and improved and tested a lot.

  4. #4
    Join Date
    Jul 2015
    Posts
    6
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    grats on release m8.

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
  •