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.