SRL Archive - First Scripts

My First Script is JugOfWaterBuyer.scar


graffy

2008-12-08 10:11:45

Here is my first attempt at scripting. As the name suggest's it will buy jug's of water when started in or around the Gnome Copter area. All you have to do is make your way to the Gnome Copter, Fill in lines 12,
  ToBuy = 10000;                 //How Many Jug's of water would like to Purchase
and 22, 23, 24,
    Players[0].Name := 'Name';           //Your Name
Players[0].Pass := 'Password'; //Your Password
Players[0].Nick := 'Nick'; //3-4 Characters from your name
Select the client target and then hit start.

If script wont Trade or Open the Deposit Box try to change the colors in Lines 5, 6, 7, 8, 9, 10 and 11
  NPCcolor1 =  5526618;          //Hieronymus Avlafrim Light Grey
NPCcolor2 = 2500137; //Hieronymus Avlafrim Dark Grey
NPCcolor3 = 1008396; //Hieronymus Avlafrim Green
MainStock = 1930687; //The color of "Main Stock" Text when "Player Stock" IS selected.
DepositBox1 = 6053207; //Deposit Box Light Grey
DepositBox2 = 5263435; //Deposit Box Dark Grey
DepositBox3 = 3161928; //Deposit Box Brown


The first proggie i think looks promising.

[LEFT]Graffys Jug Buyer
_____________________________________________________

Ran For 16 Minutes and 29 Seconds
Bought A Total Of 702 Jugs
With 26 Completed Loads
And 1 Failed Loads
_____________________________________________________
[/LEFT]


Just a little word of warning, If when you log in the bank symbol is hanging over the fence line, you may want to log out and then back in again as sometimes when it tries to walk to the deposit box the flag will end up on the other side of the fence.

All feedback is accepted so if there is anything you can think of that i may have left out please feel free to let me know, and if you try the script please post proggies.

Graffy

JugOfWaterBuyerV2.scar
Has better AntiBan thanks to R1ch
Better finding of NPC and Deposit box.

JugOfWaterBuyerV3.scar
Put in some Fail Safes
Fixed a little bug that i found.
Now Select's "Main Stock" in store
Put in some little descriptions of what the Procedures actually do.

JugOfWaterBuyerV3-1.scar
Ungraded Fail Safes

Rich

2008-12-08 11:50:39

For your first script, I am very impressed. I mean, VERY impressed. A thing that you could work is a bit more antiban. Here's the anti ban that I'm using in my VWB Smither that I'm still testing. Have a read through it and tell me if there's anything you don't understand.
procedure AntiBan;
begin
AntiRandoms;
case Random(150) of
0: RandomRClick;
2, 27, 51, 73, 99: HoverSkill('Random', False);
3, 26, 52, 74, 98 : HoverSkill('smithing', False);
4: MouseBox(MSX1, MSY1, MSX2, MSY2, 3);
5: PickUpMouse;
6: BoredHuman;
7: begin
Mouse(Random(x), Random(y), 150, 150, False);
Wait(1337 + Random(1000));
ChooseOption('xamine');
end;
8: begin
GameTab(1 + Random(12));
Wait(2000 + Random(1337));
GameTab(4);
end;
9: RandomMovement;
11: begin
case Random(4) of
0: begin
MakeCompass('N');
Wait(100 + Random(50));
end;
1: begin
MakeCompass('S');
Wait(100 + Random(50));
end;
2: begin
MakeCompass('E');
Wait(100 + Random(50));
end;
3: begin
MakeCompass('W');
Wait(100 + Random(50));
end;
end;
MakeCompass('N');
end;
12: begin
case Random(4) of
0: MouseBox(MSX1, MSY1, MSX2, MSY2, 3);
1: MouseBox(MMX1, MMY1, MMX2, MMY2, 3);
2: MouseBox(MIX1, MIY1, MIX2, MIY2, 3);
3: MouseBox(MCX1, MCY1, MCX2, MCY2, 3);
end;
end;
end;
AntiRandoms;
end;

As you've probably guessed, I've got another procedure called AntiRandoms…

benjaa

2008-12-08 16:48:12

procedure Trade;
begin
if FindObj(x,y,'frim',NPCcolor,5) then
begin
Wait(100+random(400));
Mouse(x, y, 2, 2, False);
Wait(800+random(400));
ChooseOption('rade');
end;
end;
begin and end were in wrong places ;)

procedure BuyJugOfWater;
begin
JugOfWater := DTMFromString('78DA63E4676060106640016DB5350CBF80342' +
'310FF0702463E20439E010D302291409A15488812500332878580' +
'1A3120C14D408D2C901020A0461C48481350C30924F808A861071' +
'252F8D5000054E207C3');
if(not ShopScreen)then exit; //failsafe
ShopSwitchTab('main'); //just in case
Wait(1500+random(1000));
if (FindDTM(JugOfWater, x, y, MSx1, MSy1, MSx2, MSy2)) then
begin
Wait(800+random(150));
Mouse(x, y, 3, 3, False);
Wait(800+random(150));
if ChooseOption('X') then
begin
Wait(800+random(150));
TypeSend('27');
Wait(800+random(150))
end;
end;
end;

And DepositJugOfWater could also use;
if(not Bankscreen)then exit;


Main loop looks a little messy too, try calling the antiban and antirandom within the procedure, instead of before it

Other than that, I am also very impressed. Keep it up!

Edit: You should use FindObjCustom for "frim". It allows you to input an array of colors, instead of just one

graffy

2008-12-08 18:36:08

From: R1ch
For your first script, I am very impressed. I mean, VERY impressed. A thing that you could work is a bit more antiban. Here's the anti ban that I'm using in my VWB Smither that I'm still testing. Have a read through it and tell me if there's anything you don't understand.
procedure AntiBan;
Blah blah blah was too long so didnt want to put it in again.

As you've probably guessed, I've got another procedure called AntiRandoms…


Hey there mate thanks for the feedback. Just had a read through and pretty much understood them all. I didnt even think about calling for my AntiRandom inside of AntiBan, which would take a fair bit out of the MainLoop too. Would you mind if i was to copy that and put it into my script with credit to you? (Although i would take out the hover skill smithing, Just leave the random, and i would take out and the random make compass north.)

graffy

2008-12-08 19:05:34

Sorry about double posting but if i didnt the last post would have been massive

From: benjaa
procedure Trade;
begin
if FindObj(x,y,'frim',NPCcolor,5) then
begin

end;
end;
begin and end were in wrong places ;)
If this is first because its the worst thing you found with the script then man am i a happy little vegemite. :) And fixed for next release (Probably get it up around 1am tonight.)

procedure BuyJugOfWater;
begin
Blah blah
if(not ShopScreen)then exit; //failsafe
ShopSwitchTab('main'); //just in case
Blah Blah
end;
Before adding these can you please explain to me what "ShopSwitchTab('main'); //just in case" is for and whats it do?

And DepositJugOfWater could also use;
if(not Bankscreen)then exit;

I will probably get around to putting this in soon. If i was to make it

if(not Bankscreen)then
begin
Fails := Fails+1;
Wait(800+random(150));
exit;
end;
would that work and still? It does compile but i havent tested it and wont get time to until tonight.


Main loop looks a little messy too, try calling the antiban and antirandom within the procedure, instead of before it
Will be fixed for next release

Other than that, I am also very impressed. Keep it up!

Edit: You should use FindObjCustom for "frim". It allows you to input an array of colors, instead of just one
noted and shall see what i can do.



P.S. Thank you VERY much for you feedback. Its all a great help to me. :)

benjaa

2008-12-08 20:02:13

ShopSwitchTab –> Go to any bank in Rs, and you'll see two little tabs in the top right corner, one called "Main" and one called "Player". This procedure Simply selects the "Main" tab, where the buckets are. It usually takes a while, so it needs a 2 sec+ wait afterwards.

If(notBankscreen)then +1 fails –> yes this would work. you could go;
if(not Bankscreen)then
begin
Fails := Fails + 1;
Wait(800 + Random(150));
exit;
end else
begin
*Do the banking thing*
end;

If this is first because its the worst thing you found with the script then man am i a happy little vegemite. And fixed for next release (Probably get it up around 1am tonight.)


yes, as i said i was VERY impressed :)

Edit: Once you edit the update, I'll have a closer look through it and give you some more tips to improve it.

graffy

2008-12-09 10:53:27

OK to start off with Version 2 is now up and available.
I have done the following.
Added more AntiBan,
Fixed the end tags in Trade (Just noticed there is still the extra line, Will fix in version 3)
Changed it to FindObjCustom with 3 colours each for both NPC and DepositBox


From: benjaa
ShopSwitchTab –> Go to any bank in Rs, and you'll see two little tabs in the top right corner, one called "Main" and one called "Player". This procedure Simply selects the "Main" tab, where the buckets are. It usually takes a while, so it needs a 2 sec+ wait afterwards.

Mate i was just about to say that i put it in and it didnt work. Then i thought i better read it again before commenting on it. Just realised that i didnt have the 2sec+ wait afterwards. Will put it into version 3

If(notBankscreen)then +1 fails –> yes this would work. you could go;
if(not Bankscreen)then
begin
Fails := Fails + 1;
Wait(800 + Random(150));
exit;
end else
begin
*Do the banking thing*
end;

I also tried that but it didnt work so i changed it to
if(not Bankscreen)then
begin
Fails := Fails + 1;
Wait(800 + Random(150));
LogOut; // this line
end else
begin
*Do the banking thing*
end;
and it would run buy the jugs of water go to deposit box and open it but then logout. So im guessing that it doesnt count as a Bankscreen? You know any different?




yes, as i said i was VERY impressed :)
Once again thank you.

Edit: Once you edit the update, I'll have a closer look through it and give you some more tips to improve it.


I also Added
procedure PreparePlayer;
begin
if not LoggedIn then LoginPlayer;
end;
and changed
begin
SetupSRL;
ActivateClient;
DeclarePlayers;
PreparePlayer; // Used to be LogIn
ClearDebug;
MainLoop;
Logout;
end.

I thought it might look a bit suss if when it was logged on while i was testing, (and i was testing alot) that it kept on Checking the video settings before walking to the bank. Plus it really cant hurt it in the long run can it?

Well i think that just about covers all the changes i made to it so if you can think of any more that i could use please feel free to let me know.


EDIT: Oh yeah and i fixed up the main loop by calling for AntiRandom inside of AntiBan and then calling for AntiBan inside the other procedure's. Thanks for telling me about it makes a big difference and its something that i dont think i would have thought about it on my own for a while lol

benjaa

2008-12-09 20:23:51

@ BankScreen: oh woops, forgot it was depositbox, yes it wont render as bankscreen

and PreparePlayers - i usually just put;
if(not LoggedIn)then Loginplayer;
In main loop, but making a procedure will work exactly the same :)

I think it's stupid changing the settings for EVERY log in… its so detectable.

graffy

2008-12-10 00:33:53

JugOfWaterBuyerV3.scar is now available.

From: benjaa
@ BankScreen: oh woops, forgot it was depositbox, yes it wont render as bankscreen


When messing around with opening the bank at the GE i came up with an idea about how to have a fail safe way to open the DepositBox and i also used it for Trade. It should never have another failed attempt unless it is from Human Interaction or mabey a random event.

Also i couldnt get
  ShopSwitchTab('main'); //just in case
to work so i wrote my own one that seems to work well.

Finally benjaa would you be willing to take a look at my clay softener that i have made? Its the reason i wrote this one.
Im going to wait till i hit the 10 post's before i release it but i would really like to know what you think of it.


EDIT:Oh yeah and this is the Proggie i got from the clay softener during testing. :)
[LEFT]Graffys Clay Softener
_____________________________________________________

Ran For 46 Minutes and 49 Seconds
Softened A Total Of 616 Clay
With 44 Completed Loads
And 0 Failed Loads
_____________________________________________________[/LEFT]

benjaa

2008-12-10 00:49:32

yeah sure, pm the softener to me, i'll take a look

Edit:
procedure Trade;                //Opens the store window. Loops until its open.
var
t : integer;
begin
ShopIcon := DTMFromString('78DA6394656060506540015B92E5187E01694' +
'620FE0F048C0A408624031A6044228134485E9A801A90BC3A0135' +
'E2404289801A2D4C3763A89107127A04D4A801095D026A40EE952' +
'2A04613486812E16679026A048970333F905023A0469688F81225' +
'1CCE00CACD0A2E');
MarkTime(t);
repeat
begin
AntiBan;
if FindObjCustom(x,y,['frim'],[NPCcolor1,NPCcolor2,NPCcolor3],10) then
Wait(100+random(400));
Mouse(x, y, 2, 2, False);
Wait(800+random(400));
ChooseOption('rade');
FFlag(1+random(2));
Wait(800+random(150));
if (FindDTM(ShopIcon, x, y, MSx1, MSy1, MSx2, MSy2)) then break;
AntiBan;
end;
until(FindDTM(ShopIcon, x, y, MSx1, MSy1, MSx2, MSy2)) or (TimeFromMark(t) >= 60 *1000); //it repeats until finding the DTM OR taking longer than 1 minute
Wait(100+random(400));
FreeDTM(ShopIcon);
end;

graffy

2008-12-10 01:40:49

JugOfWaterBuyerV3-1.scar is now available.
From: benjaa
yeah sure, pm the softener to me, i'll take a look

Edit:
procedure Trade;                //Opens the store window. Loops until its open.
var
t : integer;
begin
ShopIcon := DTMFromString('78DA6394656060506540015B92E5187E01694' +
'620FE0F048C0A408624031A6044228134485E9A801A90BC3A0135' +
'E2404289801A2D4C3763A89107127A04D4A801095D026A40EE952' +
'2A04613486812E16679026A048970333F905023A0469688F81225' +
'1CCE00CACD0A2E');
MarkTime(t);
repeat
begin
AntiBan;
if FindObjCustom(x,y,['frim'],[NPCcolor1,NPCcolor2,NPCcolor3],10) then
Wait(100+random(400));
Mouse(x, y, 2, 2, False);
Wait(800+random(400));
ChooseOption('rade');
FFlag(1+random(2));
Wait(800+random(150));
if (FindDTM(ShopIcon, x, y, MSx1, MSy1, MSx2, MSy2)) then break;
AntiBan;
end;
until(FindDTM(ShopIcon, x, y, MSx1, MSy1, MSx2, MSy2)) or (TimeFromMark(t) >= 60 *1000); //it repeats until finding the DTM OR taking longer than 1 minute
Wait(100+random(400));
FreeDTM(ShopIcon);
end;


Funny you should say that because i just updated it again so that it will loop 5 times and then TerminateScript. Will add this Fail safe to the ClaySoftener and then send it your way.

EDIT: Just sent it over. Let me know what you think of it.

benjaa

2008-12-10 08:20:00

i edited softener, it's in inbox!

graffy

2008-12-10 19:55:48

From: benjaa
i edited softener, it's in inbox!


Cool ill have a look at it now.

benjaa

2008-12-10 23:05:36

Graffys Jug Buyer
_____________________________________________________

Ran For 4 Minutes and 29 Seconds
Bought A Total Of 162 Jugs
With 6 Completed Loads
And 1 Failed Loads
_____________________________________________________

Failed to find and solve "Miles" random

Graffys Jug Buyer
_____________________________________________________

Ran For 9 Minutes and 32 Seconds
Bought A Total Of 297 Jugs
With 11 Completed Loads
And 0 Failed Loads
_____________________________________________________
Failed to open Deposit Box 5 Times. Terminating script..

Bank symbol was outside fence, started walking all the way around, then couldn't locate box.

graffy

2008-12-13 05:49:55

From: benjaa
Graffys Jug Buyer
_____________________________________________________

Ran For 4 Minutes and 29 Seconds
Bought A Total Of 162 Jugs
With 6 Completed Loads
And 1 Failed Loads
_____________________________________________________

Failed to find and solve "Miles" random

Graffys Jug Buyer
_____________________________________________________

Ran For 9 Minutes and 32 Seconds
Bought A Total Of 297 Jugs
With 11 Completed Loads
And 0 Failed Loads
_____________________________________________________
Failed to open Deposit Box 5 Times. Terminating script..

Bank symbol was outside fence, started walking all the way around, then couldn't locate box.


OK mate thanks for the proggies. Im in the middle of rewriting allot of the script so i will try to address those both for next release.