Results 1 to 7 of 7

Thread: Bagged Plant Buyer

  1. #1
    Join Date
    Dec 2015
    Posts
    35
    Mentioned
    0 Post(s)
    Quoted
    14 Post(s)

    Default Bagged Plant Buyer

    This script buys the daily bagged plants shop in falador park. After it is done buying it will have to refill again for 24 hours. It is a quick daily profit of 550k. It is a rather slow process and I would like some feedback on this script.

    Also it gets hung up at the end of the script because your inventory cant be full, so I dont know how to stop it from doing that, if anyone has any pointers that'd be great thanks!

    Requirements:
    Members
    Empty inventory on Preset 1
    1m Starting Cash or more (Stock replenishes some in the time it takes to buy).



    Code:
    program PlantBuyer;
    
    {$DEFINE SMART}              // Always have this to load smart
    {$I SRL-6/SRL.simba}         // To load the SRL include files
    {$I SPS/lib/SPS-RS3.Simba}   // To load the SPS include files
    
    procedure declarePlayers();
    begin
      setLength(players, 1);
      with players[0] do
      begin
        loginName := 'username';
        password := 'password';
        isActive := true;
        isMember := true;
      end
      currentPlayer := 0;
    end;
    procedure Bank(); //Opens bank and selects preset
    begin
     bankScreen.open(BANK_NPC_GREY);
      wait(RandomRange(1000, 1500));
      bankScreen.clickButton(BANK_BUTTON_PRESET_1);
      wait(RandomRange(200,600))
    
    
    
    end;
    
    procedure RunTo();
    var
       pathToShop: TPointArray;
    begin
      if not isLoggedIn() then
        exit;
    
      pathToShop := [Point(114, 161), Point(148, 137), Point(166, 114)];
    
      if SPS.walkPath(pathToShop) then
        minimap.waitPlayerMoving()
      else
        writeLn('We failed to walk to the shop');
    
    
    end;
    
    procedure Buy(); //Clicks NPC and buys item.
    var
      x, y: integer;
       Plants: TBox;
    begin
      if mainscreen.findObject(x, y, 4144414, 11, ['upplie'], MOUSE_RIGHT) then
      begin
        wait(1200);
        chooseOption.select(['Trade']);
        wait(RandomRange(1500,1920));
        Plants := intToBox(53, 150, 87, 189);
        mousebox(Plants, MOUSE_RIGHT);
        chooseOption.select(['All']);
        tabBackPack.waitForShift(5000);
       end;
    
    
    
    
    end;
    
    procedure Return(); //Returns to bank
    var
       pathToBank: TPointArray;
    begin
      if not isLoggedIn() then
        exit;
    
      pathToBank := [Point(129, 130), Point(145, 172), Point(167, 212)];
    
      if SPS.walkPath(pathToBank) then
        minimap.waitPlayerMoving()
      else
        writeLn('We failed to walk to the bank');
    
    
    end;
    
    procedure compass1(); //Sees Bankers
    var
      compassBox: TBox;
    begin
    compassBox := intToBox(590, 25, 602, 42);
      wait(randomRange(500, 730));
      mouseBox(compassBox, MOUSE_LEFT);
      mainScreen.setAngle(MS_ANGLE_HIGH);
    end;
    procedure compass2(); //Sees Shop
    var
      compassBox: TBox;
    begin
    compassBox := intToBox(590, 25, 602, 42);
      wait(randomRange(500, 730));
      mouseBox(compassBox, MOUSE_LEFT);
      mainScreen.setAngle(45);
    end;
    procedure WaitRandom(MsecToWait: Integer); //procedure that makes random wait time
      begin
        Wait(MsecToWait + Random(Round(MsecToWait / 5.0)));
      end;
    
    
    
    begin
      clearDebug();               // Clear the debug box
      smartEnableDrawing := true; // So we can draw on SMART
      setupSRL();                   // Load the SRL include files
      declarePlayers();             // Set up your username/pass
    
      SPS.setup('FALLYPLANT', RUNESCAPE_OTHER);
    
      if not isLoggedIn() then             // If player isn't logged in then
      begin
        players[currentPlayer].login();   // Log them in
        exitTreasure();            // Exit treasure hunter
        minimap.setAngle(MM_DIRECTION_NORTH);  // Make compass north and angle high
        mainScreen.setAngle(MS_ANGLE_HIGH);
      end;
      repeat
        compass1();
        WaitRandom(500);
        Bank();
        compass2();
        WaitRandom(500);
        RunTo();
      repeat
        Buy();
      until TabBackpack.isFull();
        Return();
        WaitRandom(600);
      until False;
    
    end.



    This map
    FALLYPLANT.PNG

  2. #2
    Join Date
    Sep 2014
    Posts
    447
    Mentioned
    10 Post(s)
    Quoted
    203 Post(s)

    Default

    Not a bad first script! Here's a few pointers:

    1. Wrap your code with [SIMBA] tags. It makes it a lot easier to read.
    2. You have two methods that do almost the same exact thing. One solution could be

    Simba Code:
    procedure compass(angle : integer); //Sees Bankers
    var
      compassBox: TBox;
    begin
      compassBox := intToBox(590, 25, 602, 42);
      wait(randomRange(500, 730));
      mouseBox(compassBox, MOUSE_LEFT);
      mainScreen.setAngle(angle);
    end;

    Therefore, when you call the method, you can say either compass(MS_ANGLE_HIGH) or compass(45). This reduces redundancy.

    3. Also, there's already a procedure that clicks the compass: http://docs.villavu.com/srl-6/minimap.html#clickcompass

    So you don't need all of that code.
    4. Your loops are a bit messy, but I can't really correct them for you atm.

  3. #3
    Join Date
    Jan 2015
    Location
    Hungary
    Posts
    90
    Mentioned
    0 Post(s)
    Quoted
    34 Post(s)

    Default

    Also you could use if statement instead of static waiting time for the bankscreen, that would make your script more reliable

    Simba Code:
    procedure Bank(); //Opens bank and selects preset
    begin
     bankScreen.open(BANK_NPC_GREY);
      wait(RandomRange(1000, 1500));
      bankScreen.clickButton(BANK_BUTTON_PRESET_1);
      wait(RandomRange(200,600));
    end;

    Instead:

    Simba Code:
    procedure Bank(); //Opens bank and selects preset
    begin
     bankScreen.open(BANK_NPC_GREY);
     if bankscreen.isOpen(random(3000,4000)) then bankScreen.clickButton(BANK_BUTTON_PRESET_1);
      wait(RandomRange(200,600));
    end;
    Everything is achievable!

  4. #4
    Join Date
    Dec 2015
    Posts
    35
    Mentioned
    0 Post(s)
    Quoted
    14 Post(s)

    Default

    Quote Originally Posted by yourule97 View Post
    Not a bad first script! Here's a few pointers:
    3. Also, there's already a procedure that clicks the compass: http://docs.villavu.com/srl-6/minimap.html#clickcompass
    Is that click in a tbox or is it always in the same spot?

    Also you could use if statement instead of static waiting time for the bankscreen, that would make your script more reliable
    Thanks for the input I really appreciate it.

  5. #5
    Join Date
    Sep 2014
    Posts
    447
    Mentioned
    10 Post(s)
    Quoted
    203 Post(s)

    Default

    Quote Originally Posted by rickyretardo View Post
    Is that click in a tbox or is it always in the same spot?


    Thanks for the input I really appreciate it.
    It clicks within an circle/oval. You can read the source code for yourself:

    Simba Code:
    procedure TRSMinimap.clickCompass(faceSouth: boolean = false);
    begin
      mouseCircle(self.button[MM_BUTTON_COMPASS].center.x, self.button[MM_BUTTON_COMPASS].center.y,
                  self.button[MM_BUTTON_COMPASS].radius, MOUSE_MOVE);

      if faceSouth or (random(4) = 2) then
      begin
        fastClick(MOUSE_RIGHT);
        wait(random(100, 200));

        case faceSouth of
          true: chooseOption.select(['Face So']);
          false: chooseOption.select(['Face No']);
        end;
      end else
        fastClick(MOUSE_LEFT);

      self.mouseOffCompass();
      wait(150 + random(300));
      print('TRSMinimap.clickCompass(): Clicked compass', TDebug.SUB);
    end;

    mouseCircle points to mouseOval which is

    Simba Code:
    procedure mouseOval(cx, cy, rx, ry, mouseAction: Integer = MOUSE_MOVE);
    var
      a: single;
      p: TPoint;
    begin
      a := randomE() * PI * 2;
      p.x := cx + round(cos(a) * randomRange(-rx, rx));
      p.y := cy + round(sin(a) * randomRange(-ry, ry));
      mouse(p, mouseAction);
    end;

  6. #6
    Join Date
    Dec 2013
    Location
    Pitcairn Island
    Posts
    288
    Mentioned
    20 Post(s)
    Quoted
    166 Post(s)

    Default

    Made some mods:

    Simba Code:
    program PlantBuyer;
    {$DEFINE SMART}              // Always have this to load smart
    {$I SRL-6/SRL.simba}         // To load the SRL include files
    {$I SPS/lib/SPS-RS3.Simba}   // To load the SPS include files

    procedure declarePlayers();
    begin
      setLength(players, 1);
      with players[0] do
      begin
        loginName := 'username';
        password := 'password';
        isActive := true;
        isMember := true;
      end
      currentPlayer := 0;
    end;

    procedure bank();
    begin
      if bankScreen.open(BANK_NPC_GREY) then
        bankScreen.clickButton(BANK_BUTTON_PRESET_1);
    end;

    procedure runTo(Where: String); // Combined both walking procedures together
    var
      path: TPointArray;
    begin
      if not isLoggedIn() then
        exit;

      case lowercase(Where) of
        'bank': path := [Point(129, 130), Point(145, 172), Point(167, 212)];
        'garden': path := [Point(114, 161), Point(148, 137), Point(166, 114)];
      end;

      if not SPS.walkPath(path) then
        writeLn('Failed to walk to the ' + Where);
    end;

    procedure buy();
    var
      x, y: integer;
    begin
      if mainscreen.findObject(x, y, 4144414, 11, ['upplie'], MOUSE_RIGHT) then
      begin
        chooseOption.select(['Trade'], 1000); // You can adjust the wait here instead
        wait(RandomRange(1500,1920));
        mousebox([53, 150, 87, 189], MOUSE_RIGHT);
        if chooseOption.select(['All']) then
          tabBackPack.waitForShift(5000);
      end;
    end;

    procedure compass(Where: String); // Combined both compass procedures together
    begin
      minimap.clickCompass();

      case lowercase(Where) of
        'bank': mainScreen.setAngle(MS_ANGLE_HIGH);
        'garden': mainScreen.setAngle(45);
      end;
    end;

    begin
      clearDebug();                // Clear the debug box
      smartEnableDrawing := true;  // So we can draw on SMART
      setupSRL();                  // Load the SRL include files
      declarePlayers();            // Set up your username/pass

      SPS.setup('FALLYPLANT', RUNESCAPE_OTHER);

      repeat
        if not isLoggedIn() then                // If player isn't logged in then
        begin
          players[currentPlayer].login();       // Log them in
          exitTreasure();                       // Exit treasure hunter
          minimap.setAngle(MM_DIRECTION_NORTH); // Make compass north and angle high
          mainScreen.setAngle(MS_ANGLE_HIGH);
        end;

        runTo('Bank');
        compass('Bank');
        bank();

        runTo('Garden');
        compass('Shop');

        repeat
          buy();
        until tabBackpack.isFull();

      until false;
    end.

  7. #7
    Join Date
    Dec 2015
    Posts
    35
    Mentioned
    0 Post(s)
    Quoted
    14 Post(s)

    Default

    Thanks guys for all of the input. I learned a lot from the additions of my script to. Honestly you guys are the best.

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
  •