SRL Archive - SRL Bugs

DepositAll


legoace

2012-01-04 11:17:38

Coords were changed with today's update and the addition of a deposit-from-coin-pouch button.

Here is the fixed DepositAll:

function DepositAll: Boolean;
var
T, X, Y: Integer;
BScreen, DScreen: Boolean;
begin
Result := false;
BScreen := BankScreen;
if (not(BScreen)) then
DScreen := DepositScreen;
if (BScreen) or (DScreen) then
if (InvCount > 0) or (FindColor(X, Y, srl_outline_black, 98, 68, 436, 257) and (DSCreen)) then
begin
Mouse(369 - 59 * Integer(DScreen), 307 - 29 * Integer(DScreen), 15, 10, True); // This is what I changed
Wait(200 + Random(300));
T := GetSystemTime;
while (InvCount > 0) or (FindColor(X, Y, srl_outline_black, 98, 68, 436, 257) and (DSCreen)) and (GetSystemTime - T < 2000) do
Wait(100);
Result := (InvEmpty) or (not(FindColor(X, Y, srl_outline_black, 98, 68, 436, 257)) and (DScreen));
end else begin
srl_Warn('DepositAll', 'No items to deposit ', warn_AllVersions);
result := true;
end;
end;

and a proposed DepositCoins

function DepositCoins: Boolean;
var
T, X, Y: Integer;
BScreen, DScreen: Boolean;
begin
Result := false;
BScreen := BankScreen;
if (not(BScreen)) then
DScreen := DepositScreen;
if (BScreen) or (DScreen) then
if (true) or (FindColor(X, Y, srl_outline_black, 98, 68, 436, 257) and (DSCreen)) then
begin
Mouse(405 - 58 * Integer(DScreen), 307 - 29 * Integer(DScreen), 15, 10, True); // This is what I changed
Wait(200 + Random(300));
T := GetSystemTime;
while (not(FindChatBoxText('You deposit', 8, clBlack))) or (FindColor(X, Y, srl_outline_black, 98, 68, 436, 257) and (DSCreen)) and (GetSystemTime - T < 2000) do
Wait(100);
Result := (FindChatBoxText('You deposit', 8, clBlack)) or (not(FindColor(X, Y, srl_outline_black, 98, 68, 436, 257)) and (DScreen));
end;
end;

Coh3n

2012-01-04 14:26:45

Your DepositAll fix was committed, though I don't like the DepositCoins. I think we should have it, but it's the exact same as DepositAll with one line changed. It's just unnecessary repeated code.

I'm thinking something like QuickDeposit that will handle all the "quick buttons" in the bank (All, Coins, Equipment, Summoning), then we can have DepositAll, DepositCoins, etc. call QuickDeposit so scripts won't break. Someone want to do it? :rolleyes:

Shuttleu

2012-01-04 14:28:52

sure, now working on it

~shut

Shuttleu

2012-01-04 14:34:48

const
SRL_DEPOSIT_ALL = 0;
SRL_DEPOSIT_COINS = 1;
SRL_DEPOSIT_EQUIPMENT = 2;
SRL_DEPOSIT_FOLLOWER = 3;

function QuickDeposit(Which: Integer): Boolean;
var
T, X, Y: Integer;
BScreen, DScreen: Boolean;
begin
Result := false;
BScreen := BankScreen;
if (not(BScreen)) then
DScreen := DepositScreen;
if (BScreen) or (DScreen) then
if (true) or (FindColor(X, Y, srl_outline_black, 98, 68, 436, 257) and (DSCreen)) then
begin
case Lowercase(Which) of
SRL_DEPOSIT_ALL: Mouse(369 - 58 * Integer(DScreen), 307 - 29 * Integer(DScreen), 15, 10, True);
SRL_DEPOSIT_COINS: Mouse(405 - 58 * Integer(DScreen), 307 - 29 * Integer(DScreen), 15, 10, True);
SRL_DEPOSIT_EQUIPMENT: Mouse(441 - 58 * Integer(DScreen), 307 - 29 * Integer(DScreen), 15, 10, True);
SRL_DEPOSIT_FOLLOWER: Mouse(477 - 58 * Integer(DScreen), 307 - 29 * Integer(DScreen), 15, 10, True);
end;
Wait(200 + Random(300));
T := GetSystemTime;
while (not(FindChatBoxText('You deposit', 8, clBlack))) or (FindColor(X, Y, srl_outline_black, 98, 68, 436, 257) and (DSCreen)) and (GetSystemTime - T < 2000) do
Wait(100);
Result := (FindChatBoxText('You deposit', 8, clBlack)) or (not(FindColor(X, Y, srl_outline_black, 98, 68, 436, 257)) and (DScreen));
end;
end;

function DepositAll: Boolean;
begin
Result:= QuickDeposit(SRL_DEPOSIT_ALL);
end;

function DepositCoins: Boolean;
begin
Result:= QuickDeposit(SRL_DEPOSIT_COINS);
end;

function DepositEquipment: Boolean;
begin
Result:= QuickDeposit(SRL_DEPOSIT_EQUIPMENT);
end;

function DepositFollower: Boolean;
begin
Result:= QuickDeposit(SRL_DEPOSIT_FOLLOWER);
end;

~shut

Coh3n

2012-01-04 14:37:56

Should probably change to use constants as that's going to be the standard for future SRL versions.

SRL_DEPOSIT_ALL = 0;
SRL_DEPOSIT_COINS = 1;
// etc.
Nice job, though. :) I'll add it later.

Marwan96

2012-01-04 14:40:09

where to make this change !?

Shuttleu

2012-01-04 14:43:01

edited

~shut

Marwan96

2012-01-04 14:45:42

shuttleu where to edit this lines , or how to make this change i cant run the bot it keeps clicking on deposit money :S !

Shuttleu

2012-01-04 14:46:57

C:/Simba/Includes/srl/srl/core/bank.scar

replace DepositAll with what i posted

~shut

Coh3n

2012-01-04 14:50:06

Or update to SRL5.

legoace

2012-01-04 17:00:45

Shut, you can't just use if(FindChatBoxText('You deposit', 8, clBlack)) to check for success for ALL of those, as far as I know that text only appears when depositing all coins, maybe equipment. It does NOT appear for the normal Deposit All button.

TwoClover

2012-01-04 17:11:19

where can I find the SRL5 update?

Coh3n

2012-01-05 01:37:10

From: legoace
Shut, you can't just use if(FindChatBoxText('You deposit', 8, clBlack)) to check for success for ALL of those, as far as I know that text only appears when depositing all coins, maybe equipment. It does NOT appear for the normal Deposit All button.
Probably don't need it at all. If the button is clicked, it'll deposit everything (unless the bank is full I suppose).

From: TwoClover
where can I find the SRL5 update?
It's in the updater so just make sure your SRL is updated and you'll have it.

Coh3n

2012-01-08 19:46:19

How's this look? I made it into a procedure because the result didn't work for every deposit method, plus it's always going to click the right spot. DepositAll() now results true if the inventory is full, and I'm not going to add the other deposit methods because scripters should just use QuickDeposit and can come up with their own result if they want to. The only reason I'm keeping DepositAll is so it doesn't break scripts.

(*
QuickDeposit
~~~~~~~~~~~~

.. code-block:: pascal

function QuickDeposit(Which: Integer): Boolean;

Uses the quick deposit buttons in the bottom right of the bank. Valid
arguments for 'Which' are:
* SRL_DEPOSIT_ALL
* SRL_DEPOSIT_COINS
* SRL_DEPOSIT_EQUIPMENT
* SRL_DEPOSIT_FOLLOWER

.. note::

Author: ZephyrsFury & Quickmarch & Shuttleu
Last Modified: January 08, 2012 by Coh3n

Example:

.. code-block:: pascal

QuickDeposit(SRL_DEPOSIT_COINS);
*)
const
SRL_DEPOSIT_ALL = 0;
SRL_DEPOSIT_COINS = 1;
SRL_DEPOSIT_EQUIPMENT = 2;
SRL_DEPOSIT_FOLLOWER = 3;

procedure QuickDeposit(Which: Integer);
var
StartX: Integer;
begin
if (BankScreen) or (DepositScreen) then
begin
case Which of
SRL_DEPOSIT_ALL: StartX := 365;
SRL_DEPOSIT_COINS: StartX := 400;
SRL_DEPOSIT_EQUIPMENT: StartX := 435;
SRL_DEPOSIT_FOLLOWER: StartX := 475;

else
SRL_Warn('QuickDeposit', 'Invalid deposit method ', WARN_ALLVERSIONS);
end;

Mouse(StartX - 58 * Integer(DepositScreen), 307 - 29 * Integer(DepositScreen), 15, 10, True);
Wait(200 + Random(300));
end;
end;

(*
DepositAll
~~~~~~~~~~

.. code-block:: pascal

function DepositAll: Boolean;

Deposits all items in your inventory.

.. note::

Author: Shuttleu
Last Modified: January 08, 2012 by Coh3n

Example:

.. code-block:: pascal

DepositAll();
*)
function DepositAll: Boolean;
begin
QuickDeposit(SRL_DEPOSIT_ALL);
Result := WaitFunc(@InvEmpty, 50, 3000);
end;
Does anything seem wrong with that?

Shuttleu

2012-01-08 19:49:21

how about adding a inv item count?

that way it wont click the button if the inv is already empty

~

EDIT: so change this
if (BankScreen) or (DepositScreen) then
to this
if (((BankScreen) or (DepositScreen)) and (not InvEmpty)) then

Coh3n

2012-01-08 19:55:33

Because you can still deposit coins/equipment/follower if the inventory is empty.

Shuttleu

2012-01-08 19:59:21

From: Coh3n
Because you can still deposit coins/equipment/follower if the inventory is empty.


hmmm… good point

so how about this?

procedure QuickDeposit(Which: Integer);
var
StartX: Integer;
begin
if (BankScreen) or (DepositScreen) then
begin
case Which of
SRL_DEPOSIT_ALL: StartX := 365;
SRL_DEPOSIT_COINS: StartX := 400;
SRL_DEPOSIT_EQUIPMENT: StartX := 435;
SRL_DEPOSIT_FOLLOWER: StartX := 475;

else
SRL_Warn('QuickDeposit', 'Invalid deposit method ', WARN_ALLVERSIONS);
end;

if (Which = SRL_DEPOSIT_ALL) and (InvEmpty) then
Exit;

Mouse(StartX - 58 * Integer(DepositScreen), 307 - 29 * Integer(DepositScreen), 15, 10, True);
Wait(200 + Random(300));
end;
end;

~shut

EDIT: i think this would be better actually
procedure QuickDeposit(Which: Integer);
var
StartX: Integer;
begin
if (BankScreen) or (DepositScreen) then
begin
case Which of
SRL_DEPOSIT_ALL: if InvEmpty then Exit else StartX := 365;
SRL_DEPOSIT_COINS: StartX := 400;
SRL_DEPOSIT_EQUIPMENT: StartX := 435;
SRL_DEPOSIT_FOLLOWER: StartX := 475;

else
SRL_Warn('QuickDeposit', 'Invalid deposit method ', WARN_ALLVERSIONS);
end;

Mouse(StartX - 58 * Integer(DepositScreen), 307 - 29 * Integer(DepositScreen), 15, 10, True);
Wait(200 + Random(300));
end;
end;

Coh3n

2012-01-08 20:06:16

Or the scripter can just do:

if (not InvEmpty) then
DepositAll();
Or I can just change DepositAll to:

function DepositAll: Boolean;
begin
if (InvEmpty) then
begin
Result := True;
Exit;
end;

QuickDeposit(SRL_DEPOSIT_ALL);
Result := WaitFunc(@InvEmpty, 50, 3000);
end;
^ I think I'll do that.

Shuttleu

2012-01-08 20:08:47

the latter one seems good

~shut

Coh3n

2012-01-08 21:21:08

Committed in the newest version. :)

Grihmm

2012-01-09 00:15:26

I have the latest version of SRL5, and yet when I run a script the cursor still clicks the Deposit Coins button. I am using the herb cleaner script here:
http://villavu.com/forum/showthread.php?t=71073

Could someone help please?

Narcle

2012-01-09 00:53:04

From: Grihmm
I have the latest version of SRL5, and yet when I run a script the cursor still clicks the Deposit Coins button. I am using the herb cleaner script here:
http://villavu.com/forum/showthread.php?t=71073

Could someone help please?


Near the top of the script if the includes are .scar files then it is out dated and use SRL4 still.

m3gaman3g3nd

2012-01-09 01:13:16

Hello Just now My DepositAll Does not work I dont think.. i made sure by manually entering the coords and mouse true and that worked so it must have been depositall.. it is 10:12 pm Pacific time, good day.


strangely enough it was working a few hours ago when i was testing.?>?>?>?>/.

Grihmm

2012-01-10 02:32:03

I forgot to mention, I changed the .scar's to .simba's. So it should be working right? :S

Coh3n

2012-01-10 02:55:34

It does work. I've tested myself multiple times.