SRL Archive - Research & Development Lounge

WithdrawDesignatedItemAndQuantity


Kevin

2013-07-15 14:13:09

This will accept a name and a quantity to search the bank for to withdraw. It also creates a temporary bitmap of the first item in the bank and waits for the search to load to completion prior to grabbing the new item. As a side-warning, because of that, it will fail to withdraw an item if it happens to be in the first bank slot.


procedure WithdrawDesignatedItemAndQuantity(name: String; quantity: integer);
var
tries, time, i, x, y, bmp: integer;
Acc: Extended;
found: boolean;
BankSlot: TBox;
Colors: TIntegerArray;
TPA: TPointArray;
begin
if(BankScreen)then
begin
BankSlot:= BankIndexToMSBox(1);
TPAFromBoxWrap(IntToBox(BankSlot.x1, BankSlot.y1, BankSlot.x1+29, BankSlot.y1+29), TPA);
GetColorsWrap(TPA, Colors);
OffsetTPA(TPA, IntToPoint(- (BankSlot.x1), - (BankSlot.y1)));
Bmp := BitmapFromString(30, 30, '');
FastSetPixels(bmp, TPA, Colors);
//Done creating bitmap of bankslot 1
SearchBank(name);
time:= GetSystemTime + 2500;
repeat
found:= FindDeformedBitmapToleranceIn(Bmp, X, Y, BankSlot.x1, BankSlot.y1, BankSlot.x1+29, BankSlot.y1+29, 0, 0, False, Acc);
wait(RandomRange(50,65));
until((GetSystemTime > time) or (not found));
FreeBitmap(Bmp);
if(found)then
Writeln('Did not find ' + name);
MouseBankSlot(1, mouse_right);
WaitOptionMulti(['w-'+inttostr(quantity), 'Withdraw-X', 'w-X', 'X'], 1500);
for x:=0 to 200 do
begin
wait(RandomRange(50,65));
if(InRange(CountColorTolerance(0, 250, 396, 307, 410, 1), 155, 165))then
Break;
end;
Wait(randomRange(50,100));
TypeSend(IntToStr(quantity));
end;
end;

Le Jingle

2013-07-15 17:02:54

Have you made this for oldschool runescape?

Also, perhaps fixing/editing the warning in the original post might make for a better function :)

Nice

Kevin

2013-07-15 17:21:44

From: Le Jingle
Have you made this for oldschool runescape?

Also, perhaps fixing/editing the warning in the original post might make for a better function :)

Nice


I've never actually even loaded oldschool runescape, but I'd imagine most of the code could be directly copy pasted changing just the countcolorTolerance check and everything else being srl based?

What do you mean by fixing/editing it? I was debating a 2 box setup, but if box 1 is 'shark' and box 2 is 'raw shark', then withdrawing 'shark' will still result in the exact same issue. Same applies to some other examples that don't come to mind quite yet, but I do recall trying to work around that. Do you have an alternate suggestion?

And thank you :)