SRL Archive - First Scripts

[Need Help] Herb Cleaner


Xerocide

2012-05-06 21:18:37

Hello all, this is my first attempt at an herb cleaning script and I am having an issue compiling.

program HerbCleaner;
{$DEFINE SMART}
{$i srl/srl.simba}

Procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

Players[0].Name := '';
Players[0].Pass := '';
Players[0].Nick := '';
Players[0].Active := True;
end;

Procedure CleanHerb;
Var
GKWuarm, SWChest, CKwuarm, x, y, c1: integer;


Begin

GKwuarm := DTMFromString('m1gAAAHic42JgYOABYnEgFgNiISDmZIAARiDmAmJ+qDiIzQSlBaGYF4jZoOqZoWw7Q2moSvxYhIE4wEgkRgAA8nsBmQ==');
SWChest := DTMFromString('mggAAAHicY2NgYBACYnkgVgFiZgYI4AJiASibH4gVoOoYgTjYzZzh3NEjDGcOH2YoLchn6G5tZbh+7iyDHAN2wIgDQwAAIbALsw==');
CKwuarm := DTMFromString('mwQAAAHic42RgYOAGYh4gFgNicSAWBGIOBghggbJ5oHxmIOYCYiEo5gNiNqg6A2uQSia8mImBMGAkAsMBALkzAVY=');

If not InvFull Then
Exit;
If InvFull Then
Begin
c1 := 0
Repeat
If FindDTM(GKwuarm, x, y, MIX1, MIY1, MIX2, MIY2) Then
Mouse(x, y, 5, 5, True);
Wait(20+Random(35));
c1 := c1+1;
Until (c1=27);
End;
End;

Procedure Bank;
Begin
MakeCompass('S');
If FindDTM(SWChest, x, y, MSX1, MSY1, MSX2, MSY2) Then
Mouse(x, y, 5, 5, True);
Wait(1500+Random(250));
If FindDTM(CKwuarm, x, y, MIX1, MIY1, MIX2, MIY2) Then
Mouse(x, y, 5, 5, False);
ChooseOption('All');
Wait(250+Random(100));
If FindDTM(GKwuarm, x, y, MIX1, MIY1, MIX2, MIY2) Then
Mouse(x, y, 5, 5, False);
ChooseOption('All');
End;



begin
SetUpSRL;
ActivateClient;
DeclarePlayers;
LoginPlayer;
Repeat
CleanHerb;
Bank;
Until (1=2);
end.

I am getting an error "Unknown identifier 'SWChest' at line 45" and I'm not quite sure why as I defined SWChest as a variable and my other two DTM variables don't seem to have the same issue. Any help would be much appreciated including tips/criticism!

Turpinator

2012-05-06 21:27:36

Its defined in the wrong scope. To fix it, i would suggest moving all your var declarations to global (just after your includes) and then defining SWChest in the bank function to make sure that it is defined before its used.

But mainly as previously stated, it has the wrong scope.
program HerbCleaner;
{$DEFINE SMART}
{$i srl/srl.simba}

Var
GKWuarm, SWChest, CKwuarm, x, y, c1: integer;
Procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

Players[0].Name := '';
Players[0].Pass := '';
Players[0].Nick := '';
Players[0].Active := True;
end;

Procedure CleanHerb;
Begin
GKwuarm := DTMFromString('m1gAAAHic42JgYOABYnEgFgNiISDmZIAARiDmAmJ+qDiIzQSlBaGYF4jZoOqZoWw7Q2moSvxYhIE4wEgkRgAA8nsBmQ==');
CKwuarm := DTMFromString('mwQAAAHic42RgYOAGYh4gFgNicSAWBGIOBghggbJ5oHxmIOYCYiEo5gNiNqg6A2uQSia8mImBMGAkAsMBALkzAVY=');

If not InvFull Then
Exit;
If InvFull Then
Begin
c1 := 0
Repeat
If FindDTM(GKwuarm, x, y, MIX1, MIY1, MIX2, MIY2) Then
Mouse(x, y, 5, 5, True);
Wait(20+Random(35));
c1 := c1+1;
Until (c1=27);
End;
End;

Procedure Bank;
Begin
SWChest := DTMFromString('mggAAAHicY2NgYBACYnkgVgFiZgYI4AJiASibH4gVoOoYgTjYzZzh3NEjDGcOH2YoLchn6G5tZbh+7iyDHAN2wIgDQwAAIbALsw==');
MakeCompass('S');
If FindDTM(SWChest, x, y, MSX1, MSY1, MSX2, MSY2) Then
Mouse(x, y, 5, 5, True);
Wait(1500+Random(250));
If FindDTM(CKwuarm, x, y, MIX1, MIY1, MIX2, MIY2) Then
Mouse(x, y, 5, 5, False);
ChooseOption('All');
Wait(250+Random(100));
If FindDTM(GKwuarm, x, y, MIX1, MIY1, MIX2, MIY2) Then
Mouse(x, y, 5, 5, False);
ChooseOption('All');
End;

begin
SetUpSRL;
ActivateClient;
DeclarePlayers;
LoginPlayer;
Repeat
CleanHerb;
Bank;
Until (1=2);
end.

Turpinator

2012-05-06 21:29:29

Orrr… you could also define your DTMs in the main program so you arent defining it over and over again.

Also, there is a bank function built in for sw and bankers, so i would suggest using that.

(ughh the edit failed. oops on the double post)


And heres the SW bank function.
OpenBankChest(SRL_BANK_SW);
Make sure to SetAngle(SRL_ANGLE_HIGH) before hand though so it can find the chest.

putonajonny

2012-05-06 21:29:38

Have a look at what I changed :) I would do a more detailed response but I am tired and need to go to bed…

program HerbCleaner;
{$DEFINE SMART}
{$i srl/srl.simba}

Procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

Players[0].Name := '';
Players[0].Pass := '';
Players[0].Nick := '';
Players[0].Active := True;
end;

Procedure CleanHerb;
Var
GKWuarm, x, y, c1: integer;


Begin

GKwuarm := DTMFromString('m1gAAAHic42JgYOABYnEgFgNiISDmZIAARiDmAmJ+qDiIzQSlBaGYF4jZoOqZoWw7Q2moSvxYhIE4wEgkRgAA8nsBmQ==');

If not InvFull Then
Exit;
If InvFull Then
Begin
c1 := 0
Repeat
If FindDTM(GKwuarm, x, y, MIX1, MIY1, MIX2, MIY2) Then
Mouse(x, y, 5, 5, True);
Wait(20+Random(35));
c1 := c1+1;
Until (c1=27);
End;
End;

Procedure Bank;
Var
GKwuarm, SWChest, CKwuarm, x, y : integer; //You need to have these in every procedure you use them in :)
Begin
GKwuarm := DTMFromString('m1gAAAHic42JgYOABYnEgFgNiISDmZIAARiDmAmJ+qDiIzQSlBaGYF4jZoOqZoWw7Q2moSvxYhIE4wEgkRgAA8nsBmQ==');
SWChest := DTMFromString('mggAAAHicY2NgYBACYnkgVgFiZgYI4AJiASibH4gVoOoYgTjYzZzh3NEjDGcOH2YoLchn6G5tZbh+7iyDHAN2wIgDQwAAIbALsw==');
CKwuarm := DTMFromString('mwQAAAHic42RgYOAGYh4gFgNicSAWBGIOBghggbJ5oHxmIOYCYiEo5gNiNqg6A2uQSia8mImBMGAkAsMBALkzAVY=');
MakeCompass('S');
If FindDTM(SWChest, x, y, MSX1, MSY1, MSX2, MSY2) Then
Mouse(x, y, 5, 5, True);
Wait(1500+Random(250));
If FindDTM(CKwuarm, x, y, MIX1, MIY1, MIX2, MIY2) Then
Mouse(x, y, 5, 5, False);
ChooseOption('All');
Wait(250+Random(100));
If FindDTM(GKwuarm, x, y, MIX1, MIY1, MIX2, MIY2) Then
Mouse(x, y, 5, 5, False);
ChooseOption('All');
End;



begin
SetUpSRL;
ActivateClient;
DeclarePlayers;
LoginPlayer;
Repeat
CleanHerb;
Bank;
Until (1=2);
end.

Xerocide

2012-05-06 22:08:20

Thanks for the quick replies you guys! I moved the variable declarations to the beginning (as suggested by Turpinator) and it compiled with no errors :) I'll look into the SW bank function though as that seems much more specialized to what I'm trying to do. Does it have functions to click the deposit inventory button and such?

Google

2012-05-06 22:18:02

From: Xerocide
Thanks for the quick replies you guys! I moved the variable declarations to the beginning (as suggested by Turpinator) and it compiled with no errors :) I'll look into the SW bank function though as that seems much more specialized to what I'm trying to do. Does it have functions to click the deposit inventory button and such?


DepositAll;

There ya go:spongebob:

Joepetey

2012-05-06 22:31:51

Like Turpinator said, using the built in bank function for the soul wars chest would make your life a million times easier.

:garfield:

Xerocide

2012-05-06 22:34:32

From: GOOGLE
DepositAll;

There ya go:spongebob:


Thank you. I have a new issue though which is that my script is killing my already-running SMART windows/RS clients and restarting in the case of SMART or just doing nothing in the case of RS client. Trying to find how to prevent it by reading through Narcle's Fast Fighter but I'm not exactly sure what I'm looking for.

Turpinator

2012-05-07 01:44:58

So Ive been playing around with this and well, (1) it cant seem to find the kwaurms in the bank, and (2) when it actually withdraws them, and cleans, it usually double clicks each one and will sometimes click backwards, causing it to only do about half the inventory.

Heres the new bank function with the SW chest and deposit all.
Procedure Bank;
Begin
repeat
SetAngle(SRL_ANGLE_HIGH);
OpenBankChest(SRL_BANK_SW);
until BankScreen or PinScreen;
if PinScreen then
begin
repeat
InPin(Players[0].Pin);
until BankScreen or not (LoggedIn);
end;
if BankScreen then
begin
DepositAll;
Withdraw(0, 0, 28);
CloseBank;
end
End;
(1) is a simple fix, i just put it in slot 1 and and used Withdraw(0, 0, 28);

For (2), Im still not sure as to the best way to approach this and still use the DTMs without adding a long wait in between each DTM search.

Sidenote:
I used
{.include SRL/SRL/Misc/Smart.simba}
{.include SRL/SRL.simba}
for my includes and it works fine after adding
Cleardebug;
Smart_Server := 10;
Smart_Members := false;
Smart_Signed := false;
Smart_SuperDetail := false;
to the main portion.

Xerocide

2012-05-07 10:08:01

Yeah, putting in a long wait would sort of defeat the purpose because I'm going for speed but I know what you're talking about. It's because I had it loop 27 times and since it would likely click the same herb twice or go back to a previously cleaned herb it wouldn't finish the inventory. I never got the withdrawing to work properly though. I'm assuming it had to do with the method of withdrawing I was trying to use (find DTM, right click, findoption containing 'all') as I'm not sure if it would work as I had hoped. Is there a way to just click an inventory slot or should I just use coordinates in lieu of using DTM?

Turpinator

2012-05-07 15:10:05

using
    Withdraw(0, 0, 28);
will withdraw the item on screen at 0,0 and 28 of them. so that would be the first slot. (column, row,amount)
The thing with stackable dtms like in a bank is that when you create them, you need to make sure you stay away from the upper left corner where the numbers show.

I believe the best way to clean would just be to do a double loop with pseudo code similar to
for column = 0 until  > 3
for row = 0 until > 6
click(x+column*(distance between spaces), y+row*(distance between spaces)) //With random pixels ofc.
wait(small adjustable random time)
end
end
So if i wrote that correctly, it would clean vertically row by row with an adjustable speed. this way may not clean every single herb, but play with the speed till it works. you could still even implement your dtm search after the loops to make sure it got the whole inventory.