Results 1 to 10 of 10

Thread: [OSR] ScrollToItemDTM (Finding bank items)

  1. #1
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default [OSR] ScrollToItemDTM (Finding bank items)

    Hey guys, I updated these couple of functions to work for OSR. Basically you feed this function a DTM of a bank item you want to find and this will search your bank for it via the scroll bar. I put out this function previously for EoC RS but for it to work with OSR it required some modifications here and there. This should be quite useful as there's currently no way (in the SRL-OSR include) to search a bank account for an item.

    Function WindMouseDTM
    -Required for the main function.

    Simba Code:
    Function WindMouseDTM(xs, ys, xe, ye, gravity, wind, minWait, maxWait, targetArea: extended; DTM: Integer): Boolean;
    var
      veloX,veloY,windX,windY,veloMag,dist,randomDist,lastDist,step: extended;
      lastX,lastY,MSP,W,maxStep,X,Y: integer;
      sqrt2,sqrt3,sqrt5: extended;
      fX,fY,mX,mY: Integer;
      B: TBox;
    begin
      Result := False;
      MSP    := MouseSpeed;
      sqrt2  := sqrt(2);
      sqrt3  := sqrt(3);
      sqrt5  := sqrt(5);

      repeat

        dist:= hypot(xs - xe, ys - ye);
        wind:= minE(wind, dist);
        maxStep := (RandomRange(2, 4));

        if dist >= targetArea then
        begin
          windX:= windX / sqrt3 + (random(round(wind) * 2 + 1) - wind) / sqrt5;
          windY:= windY / sqrt3 + (random(round(wind) * 2 + 1) - wind) / sqrt5;
        end else
        begin
          windX:= windX / sqrt2;
          windY:= windY / sqrt2;
        end;

        veloX:= veloX + windX;
        veloY:= veloY + windY;
        veloX:= veloX + gravity * (xe - xs) / dist;
        veloY:= veloY + gravity * (ye - ys) / dist;

        if hypot(veloX, veloY) > maxStep then
        begin
          randomDist:= maxStep / 2.0 + random(round(maxStep) div 2);
          veloMag:= sqrt(veloX * veloX + veloY * veloY);
          veloX:= (veloX / veloMag) * randomDist;
          veloY:= (veloY / veloMag) * randomDist;
        end;

        lastX:= Round(xs);
        lastY:= Round(ys);
        xs:= xs + veloX;
        ys:= ys + veloY;

        if (lastX <> Round(xs)) or (lastY <> Round(ys)) then
          MoveMouse(Round(xs), Round(ys));

        GetMousePos(mX, mY);
        B := IntToBox(mX-5, mY-5, mX+5, mY+5);
      //Search for the scroll bar near the mouse
        if (not FindColorTolerance(fX, fY, 3359309, B.x1, B.y1, B.x2, B.y2, 30)) then
          Exit;

        if FindDTM(DTM, X, Y, MSX1, MSY1, MSX2, MSY2) then
        begin
          Result := True;
          Exit;
        end;

        case Random(50) of
          1..25: W := (MSP + (Random((MSP/4))));
          26..50: W := (MSP - (RandomRange((MSP/2), MSP-1)));
        end;
        if (W < 1) then
          W := 1;

        wait(W);

        step:= hypot(xs - lastX, ys - lastY);
        lastdist:= dist;
      until(hypot(xs - xe, ys - ye) < 1)

      if (Round(xe) <> Round(xs)) or (Round(ye) <> Round(ys)) then
        MoveMouse(Round(xe), Round(ye));

      MouseSpeed := MSP;
    end;

    Function ScrollToItemDTM(DTM: Integer; var Pnt: TPoint): Boolean;
    -2 parameters, the first is the input item DTM you're searching for, the second is the point at which the DTM is found ("if" found). Results true if the DTM is found, false if not.

    Simba Code:
    Function ScrollToItemDTM(DTM: Integer; var Pnt: TPoint): Boolean;
    var
      randSpeed: extended;
      X,Y,A: integer;
    begin
      Result := False;
      if not BankScreen then
        Exit;

      if FindDTM(DTM, X, Y, MSx1, MSy1, MSx2, MSy2) then
      begin
        Result := True;
        Pnt := Point(X, Y);
        Exit;
      end;

      FixBank;

      A := MouseSpeed;
      MMouse(476, 85, 3, 5);
      GetMousePos(X, Y);
      HoldMouse(X, Y, mouse_left);

      MouseSpeed := 30;
      randSpeed:= (random(30) / 30) / 10.0;
      if randSpeed = 0.0 then
        randSpeed := 0.1;

      if windMouseDTM(X, Y, 476+RandomRange(-3,3), 265+RandomRange(-5,5), 9.0,3.0,10.0/randSpeed,15.0/randSpeed,10.0*randSpeed, DTM) then
        Result := FindDTM(DTM, Pnt.X, Pnt.Y, MSx1, MSy1, MSx2, MSy2);

      GetMousePos(X, Y);
      ReleaseMouse(X, Y, mouse_left);

      MouseSpeed := A;
    end;

    Below is a short video of searching my back account for Flax & withdrawing all.

    Last edited by Flight; 08-01-2013 at 02:45 AM.

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


  2. #2
    Join Date
    Mar 2007
    Posts
    5,125
    Mentioned
    275 Post(s)
    Quoted
    901 Post(s)

    Default

    Amazing work Flight, Love how fast it finds it too

    Forum account issues? Please send me a PM

  3. #3
    Join Date
    Dec 2011
    Location
    United States
    Posts
    960
    Mentioned
    21 Post(s)
    Quoted
    504 Post(s)

    Default

    My god Flight. This is genius. I would have never thought of something like this

  4. #4
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    Quote Originally Posted by Wetish View Post
    My god Flight. This is genius. I would have never thought of something like this
    Oh I doubt that Wetish! Thank you both for the kind comments.

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


  5. #5
    Join Date
    Mar 2013
    Posts
    14
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    Thank you so much for this! I can see it being useful for other legitimate tasks too, like spending ages trawling through a bank to find that pesky rope or spade for a clue scroll... I can just save an array of DTMs and and give them names, then I'll never have to search again. In fact, I might make a public script for this soon with common items like spades, flax, logs and what-not. Thanks!

  6. #6
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    I just edited in 1 line that I'd forgotten before. Inside the ScrollToItemDTM function I added in this in the beginning of the function (where the initial DTM check is done):
    Simba Code:
    if FindDTM(DTM, X, Y, MSx1, MSy1, MSx2, MSy2) then
      begin
        Result := True;
        Exit;
      end;
    To this:
    Simba Code:
    if FindDTM(DTM, X, Y, MSx1, MSy1, MSx2, MSy2) then
      begin
        Result := True;
        Pnt := Point(X, Y);
        Exit;
      end;

    Before if the item was initially found (without ever having to scroll) the function would, of course, result true and exit, but it did not return the point at which the item was found. I didn't realize this until real-time running minutes ago. It should work, once again, correctly now.

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


  7. #7
    Join Date
    Jan 2012
    Posts
    1,104
    Mentioned
    18 Post(s)
    Quoted
    211 Post(s)

    Default

    Very nice, gonna try this out tomorrow!

  8. #8
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    There was a slight flaw in this and I've fixed it to work perfectly with OSRS. I've also moved this to the SRL-OSR Snippets section.

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


  9. #9
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by Flight View Post
    There was a slight flaw in this and I've fixed it to work perfectly with OSRS. I've also moved this to the SRL-OSR Snippets section.
    Hey, small suggestion it would be cool it it had the option to wait randomly after it found the dtm. Sometimes when i'm scrolling for an object in my bank I overshoot a little bit

  10. #10
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    Quote Originally Posted by Officer Barbrady View Post
    Hey, small suggestion it would be cool it it had the option to wait randomly after it found the dtm. Sometimes when i'm scrolling for an object in my bank I overshoot a little bit
    Ah yeah that's possible indeed. If you really wanted it just make a function that continues to scroll down a little bit.

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


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
  •