SRL Archive - SRL Suggestions

Withdraw


Shuttleu

2012-01-03 14:07:05

(*
WithdrawEx
~~~~~~~~~~

.. code-block:: pascal

function WithdrawEx(Col, Row, Amount: Integer; Uptexts: TStringArray): Boolean;

Withdraws Amount at Column/Row.

.. note::

Author: Starblaster100, Town, Wizzup? and Narcle, small fixes by r!ch!e & EvilChicken!
Last Modified: Unknown

Example:

.. code-block:: pascal

WithdrawEx(1, 3, 28, ['ron ore', 'ore', 'on or']);
*)
function WithdrawEx(Col, Row, Amount: Integer; Uptexts: TStringArray): Boolean;
var
BBox: TBox;
X, Y: Integer;
begin
Result := False;
FixBank;

BBox := BankIndexToMSBox(BankPointToBankIndex(Point(Col, Row)));
GetMousePos(X, Y);
if (not PointInBox(Point(X, Y), BBox)) then
MouseBox(BBox.X1 + 5, BBox.Y1 + 5, BBox.X2 - 5, BBox.Y2 - 5, mouse_move);

if (Length(Uptexts) > 0) then
if (not WaitUptextMulti(Uptexts, 500)) then
Exit;

if (Amount = 1) then
ClickMouse2(mouse_left)
else
ClickMouse2(mouse_right);
if (Amount = 1) then
begin
Result := True;
Wait(RandomRange(250, 550));
Exit;
end;

if (Amount = -1) then
Result := WaitOptionMulti(['Withdraw-All but', 'l b'], 300)
if (Amount = 0) then
Result := WaitOptionMulti(['Withdraw-All', 'w-A'], 300)
else
Result := WaitOptionMulti(['Withdraw-' + IntToStr(Amount), 'w-' + IntToStr(Amount)] , 300);

if (not (Result)) and (Amount > 0) then
begin
MouseBox(BBox.X1 + 5, BBox.Y1 + 5, BBox.X2 - 5, BBox.Y2 - 5, mouse_right);
if WaitOptionMulti(['Withdraw-X', 'w-X'], 500) then
begin
X := GetSystemTime + 10000;
while (X >= GetSystemTime) and (not (InRange(CountColor(0, 250, 396, 307, 410), 155, 165))) do
Wait(50);
Wait(RandomRange(75, 400));
TypeSend(IntToStr(Amount));
Result := True;
end;
end;
end;
but putting -1 the script would choose "Withdraw-All but one"

~shut

Coh3n

2012-01-04 01:31:11

Committed to SRL5.

Press Play

2012-01-04 05:12:22

while not FindColorBox(x, y, srl_outline_black, BankIndexToMSBox(Players[CurrentPlayer].Integers[P_BANK_SLOT])) do
begin
Wait(200+Random(150*LaggFactor));
end;
This is an excerpt of a fix from my Fletching script, which is called just before I withdraw my items. Could this be used somewhere in the beginning of this function perhaps? It's similar to the function ExistsItem(I: Integer): Boolean; function, except for the bank. I know it's the scripter's job to take care of such things, but since it checks for UpText, why not also check for the black outline? So maybe it could look like:

(*
WithdrawEx
~~~~~~~~~~

.. code-block:: pascal

function WithdrawEx(Col, Row, Amount: Integer; Uptexts: TStringArray): Boolean;

Withdraws Amount at Column/Row.

.. note::

Author: Starblaster100, Town, Wizzup? and Narcle, small fixes by r!ch!e & EvilChicken!
Last Modified: Unknown

Example:

.. code-block:: pascal

WithdrawEx(1, 3, 28, ['ron ore', 'ore', 'on or']);
*)
function WithdrawEx(Col, Row, Amount: Integer; Uptexts: TStringArray): Boolean;
var
BBox: TBox;
X, Y, T: Integer;
begin
Result := False;
FixBank;

BBox := BankIndexToMSBox(BankPointToBankIndex(Point(Col, Row)));
T := GetSystemTime + 500;
while not FindColor(x, y, srl_outline_black, BBox.X1, BBox.Y1, BBox.X2, BBox.Y2) and (GetSystemTime < T) do
Wait(20 + Random(10));

if not FindColor(x, y, srl_outline_black, BBox.X1, BBox.Y1, BBox.X2, BBox.Y2) then Exit;

GetMousePos(X, Y);
if (not PointInBox(Point(X, Y), BBox)) then
MouseBox(BBox.X1 + 5, BBox.Y1 + 5, BBox.X2 - 5, BBox.Y2 - 5, mouse_move);

if (Length(Uptexts) > 0) then
if (not WaitUptextMulti(Uptexts, 500)) then
Exit;

if (Amount = 1) then
ClickMouse2(mouse_left)
else
ClickMouse2(mouse_right);
if (Amount = 1) then
begin
Result := True;
Wait(RandomRange(250, 550));
Exit;
end;

if (Amount = -1) then
Result := WaitOptionMulti(['Withdraw-All but', 'l b'], 300)
if (Amount = 0) then
Result := WaitOptionMulti(['Withdraw-All', 'w-A'], 300)
else
Result := WaitOptionMulti(['Withdraw-' + IntToStr(Amount), 'w-' + IntToStr(Amount)] , 300);

if (not (Result)) and (Amount > 0) then
begin
MouseBox(BBox.X1 + 5, BBox.Y1 + 5, BBox.X2 - 5, BBox.Y2 - 5, mouse_right);
if WaitOptionMulti(['Withdraw-X', 'w-X'], 500) then
begin
X := GetSystemTime + 10000;
while (X >= GetSystemTime) and (not (InRange(CountColor(0, 250, 396, 307, 410), 155, 165))) do
Wait(50);
Wait(RandomRange(75, 400));
TypeSend(IntToStr(Amount));
Result := True;
end;
end;
end;
It's really messy, but you get my idea? :)

Narcle

2012-01-04 05:32:04

From: -daazndagger-
while not FindColorBox(x, y, srl_outline_black, BankIndexToMSBox(Players[CurrentPlayer].Integers[P_BANK_SLOT])) do
begin
Wait(200+Random(150*LaggFactor));
end;
This is an excerpt of a fix from my Fletching script, which is called just before I withdraw my items. Could this be used somewhere in the beginning of this function perhaps? It's similar to the function ExistsItem(I: Integer): Boolean; function, except for the bank. I know it's the scripter's job to take care of such things, but since it checks for UpText, why not also check for the black outline? So maybe it could look like:

(*
WithdrawEx
~~~~~~~~~~

.. code-block:: pascal

function WithdrawEx(Col, Row, Amount: Integer; Uptexts: TStringArray): Boolean;

Withdraws Amount at Column/Row.

.. note::

Author: Starblaster100, Town, Wizzup? and Narcle, small fixes by r!ch!e & EvilChicken!
Last Modified: Unknown

Example:

.. code-block:: pascal

WithdrawEx(1, 3, 28, ['ron ore', 'ore', 'on or']);
*)
function WithdrawEx(Col, Row, Amount: Integer; Uptexts: TStringArray): Boolean;
var
BBox: TBox;
X, Y, T: Integer;
begin
Result := False;
FixBank;

BBox := BankIndexToMSBox(BankPointToBankIndex(Point(Col, Row)));
T := GetSystemTime + 500;
while not FindColor(x, y, srl_outline_black, BBox.X1, BBox.Y1, BBox.X2, BBox.Y2) and (GetSystemTime < T) do
Wait(20 + Random(10));

if not FindColor(x, y, srl_outline_black, BBox.X1, BBox.Y1, BBox.X2, BBox.Y2) then Exit;

GetMousePos(X, Y);
if (not PointInBox(Point(X, Y), BBox)) then
MouseBox(BBox.X1 + 5, BBox.Y1 + 5, BBox.X2 - 5, BBox.Y2 - 5, mouse_move);

if (Length(Uptexts) > 0) then
if (not WaitUptextMulti(Uptexts, 500)) then
Exit;

if (Amount = 1) then
ClickMouse2(mouse_left)
else
ClickMouse2(mouse_right);
if (Amount = 1) then
begin
Result := True;
Wait(RandomRange(250, 550));
Exit;
end;

if (Amount = -1) then
Result := WaitOptionMulti(['Withdraw-All but', 'l b'], 300)
if (Amount = 0) then
Result := WaitOptionMulti(['Withdraw-All', 'w-A'], 300)
else
Result := WaitOptionMulti(['Withdraw-' + IntToStr(Amount), 'w-' + IntToStr(Amount)] , 300);

if (not (Result)) and (Amount > 0) then
begin
MouseBox(BBox.X1 + 5, BBox.Y1 + 5, BBox.X2 - 5, BBox.Y2 - 5, mouse_right);
if WaitOptionMulti(['Withdraw-X', 'w-X'], 500) then
begin
X := GetSystemTime + 10000;
while (X >= GetSystemTime) and (not (InRange(CountColor(0, 250, 396, 307, 410), 155, 165))) do
Wait(50);
Wait(RandomRange(75, 400));
TypeSend(IntToStr(Amount));
Result := True;
end;
end;
end;
It's really messy, but you get my idea? :)


If we do that I rather just add a GetAmount check on it. So basically it waits for the GetAmount to come up (which includes black outline check). If its false then result := false; would make it way more useful.

(with draw all would have to be excluded from amount check)

Press Play

2012-01-04 06:42:40

From: Narcle
If we do that I rather just add a GetAmount check on it. So basically it waits for the GetAmount to come up (which includes black outline check). If its false then result := false; would make it way more useful.

(with draw all would have to be excluded from amount check)

Yes, I like this idea - might as well implement the whole lot of checks right. Yeah, I didn't know where to add in the Result:= false, so instead I just made it exit the function. It's messy as I said :p

Coh3n

2012-01-04 11:50:49

From: Narcle
If we do that I rather just add a GetAmount check on it. So basically it waits for the GetAmount to come up (which includes black outline check). If its false then result := false; would make it way more useful.

(with draw all would have to be excluded from amount check)
Why would that make it more useful? I can't really think of why WithdrawEx would need the amount of the item. =\

Narcle

2012-01-04 12:04:33

From: Coh3n
Why would that make it more useful? I can't really think of why WithdrawEx would need the amount of the item. =\


No, like if you put an exact amount like 1, 5, 10, 14 etc. it'll check to make sure there's at least that much in the spot. If its set to 0 or -1 it'll ignore this check.

Coh3n

2012-01-04 14:07:08

From: Narcle
No, like if you put an exact amount like 1, 5, 10, 14 etc. it'll check to make sure there's at least that much in the spot. If its set to 0 or -1 it'll ignore this check.
Ah yes, good point. :)