SRL Archive - First Scripts

Super Glass Maker


flamer

2010-02-27 14:57:19

I just wrote this up today because even though I've known that Superglass make is an awesome way to level up magic, crafting and make money at the same time, it's just too click intensive for me. So heres my first attempt:

program GlassMaker;
{.include SRL/SRL.scar}

const
SciptTime = 30; //In minutes

var
x, y, BeginningTime: integer;

Procedure BankWork;
var
Seaweed, Sand, Glass: integer;
begin
Seaweed := DTMFromString('78DA635CC0C8C07008889100979F01033F908' +
'689324E05B24EA3AA61606082C8C1D4AC00B2CE1050B316C8DA4B' +
'40CD3C20EB1C7E3500466F07C0');
Sand := DTMFromString('78DA639CC6C8C0A004C448A03ED59C4104488' +
'344FF0301630F902585AA868181094CC244197B812C45026AE603' +
'59C204D4CC03B214F0AB01007DF308C4');
Glass := DTMFromString('78DA639CC9C4C0C0CDC8800CEE352530C8016' +
'998286337500D33AA1A060626881CB21A1E026A1661DA85AE0600' +
'C5F3046F');

if(not (LoggedIn)) Then
Exit;
if(not BankScreen) then
OpenBankFast('veb');
MouseSpeed:=11;
if(FindDTM(Glass, x, y, MIX1, MIY1, MIX2, MIY2))then
begin
case random(100) of
0..70:
begin
Mouse(x, y, 7, 7, false);
ChooseOption('All'); //Deposit Molten Glass
end;
71..99:
begin
Mouse(x, (y+36), 7, 7, false);
ChooseOption('All'); //Deposit Molten Glass, one row down for randomess
end;
end;
end;
MouseSpeed:=9;
if(FindDTM(Seaweed, x, y, MSX1, MSY1, MSX2, MSY2)) then //Withdraw Seaweed
begin
Mouse(x, y, 7, 7, false);
ChooseOption('13');
end else
begin
writeln('No Seaweed left, logging out');
LogOut;
TerminateScript;
end;
if(FindDTM(Sand, x, y, MSX1, MSY1, MSX2, MSY2)) then //Withdraw Seaweed
begin
Mouse(x, y, 7, 7, false);
ChooseOption('13');
end else
begin
writeln('No Sand left, logging out');
LogOut;
TerminateScript;
end;

CloseBank;
FreeDTM(Glass);
FreeDTM(Seaweed);
FreeDTM(Sand);
end;


Procedure Cast;
var
Spell: integer;
begin
Spell := BitmapFromString(8, 9, 'beNqzN3ZlY0hnAqEZTNxAdJZZ/' +
'01/NxABxeFSQHTDIwhZHC71qLISiICyQDZQ0AWMIOqBCGhaZUEm3B' +
'Cg+RDB+iOfGRgYgVJAEYg4XNDd3hhI1jcvWbzrwus3byCCTlYGrvZ' +
'GQBLIVsiaDReEiEO1HPkMVA8xwR0AiKhBXg==');
GameTab(Tab_Magic);
FindBitmapToleranceIn(Spell, x, y, MIX1, MIY1, MIX2, MIY2, 5); //Cast Superglass Make
Mouse(x, y, 3, 3, true);
FreeBitmap(Spell);
Wait(2998+Random(500));
end;

begin
SetupSRL;
MarkTime(BeginningTime);
repeat
BankWork;
Cast;
until(TimeFromMark(BeginningTime) > (ScriptTime*60000));
end.

There are a few things I would like to improve, but don't really have the expertise to do so:

  • Having the mouse move "pre-emptively" to the banking booth, right click and hover over the quick-bank option, to model human behavior istead of waiting around for a few seconds, then moving
  • Be able to place the sand and seaweed (near each other, of course) anywhere in the bank, and to be able to find them
  • Be able to read the amount of sand, seaweed and runes left, and stop when supplies run out
  • Be able to check if the magic tab is current active, and switch to the magic tab if its not

Any help would be appreciated :)

Bionicle

2010-02-27 15:28:16

K, I have a lot to say with this :p

Try making DTMs for your items. It is a lot better then blind clicking/withdrawing and you can have it so if the script dosn't find the DTM, it will stop (like you wanted to improve on ;))
Here is a good tutorial on DTMs, well, its on everything, but the DTM section is great :p http://villavu.com/forum/showthread.php?t=49089
Also, your standards need a bit of work, and to make things more readable, you can paste the script in [.SCAR][/.SCAR] tags (without the '.'s :p)
Heres your script with proper standards:
program GlassMaker;
{.include SRL/SRL.scar}

var
x, y: integer;

Procedure BankWork;
begin
MouseSpeed:=11;
if not LoggedIn then
Exit;
if not BankScreen then
OpenBankFast('veb');
if(FindColorSpiral(x, y, 6390494, 547, 206, 734, 464))then
begin
Mouse(x, y, 7, 7, false);
ChooseOption('All'); //Deposit Molten Glass
end;
MouseSpeed:=9;
Withdraw(8 , 3, 13); //Withdraw Seaweed
Withdraw(8, 4, 13); //Withdraw Bucket of Sand
CloseBank;
end;

Procedure Cast;
begin
Mouse(570, 315, 10, 10, True) //Cast Superglass Make
Wait(2998+Random(500));
end;

begin
repeat
BankWork;
Cast;
until(false);
end.
Now if you want to use the DTMs, here is how you should use them:
program GlassMaker;
{.include SRL/SRL.scar}

var
x, y: integer;

Procedure BankWork;
begin
MouseSpeed:=11;
if not (LoggedIn) then
Exit;
if not BankScreen then
OpenBankFast('veb');
if(FindDTM(x, y, Glass, MIX1, MIY1, MIX2, MIY2))then //SEE 1
begin
Mouse(x, y, 7, 7, false);
ChooseOption('All'); //Deposit Molten Glass
end else
begin
Logout;
TerminateScript; //SEE 2
end;
MouseSpeed:=9;
if(FindDTM(x, y, Seaweed, MSX1, MSY1, MSX2, MSY2) then //Withdraw Seaweed
begin
Mouse(x, y, 7, 7, false);
ChooseOption('All');
end else
begin
Logout;
TerminateScript; //SEE 2
end;
if(FindDTM(x, y, Sand, MSX1, MSY1, MSX2, MSY2) then //Withdraw Bucket of sand
begin
Mouse(x, y, 7, 7, false);
ChooseOption('All');
end else
begin
Logout;
TerminateScript; //SEE 2
end;
CloseBank;
end;

Procedure Cast;
begin
Mouse(570, 315, 10, 10, True) //Cast Superglass Make
Wait(2998+Random(500));
end;

begin
repeat
BankWork;
Cast;
until(false);
end.

1: Glass is the name you will save the DTM of the glass under. MIX1, MIY1 ect are global vars, it stands for Main Inventory X1, Y1, X2, Y2, and it makes a box around the main inventory, so the glass can be anywhere in the inventory. MS = Main Screen.
2: This is if the script doesn't find the DTM, it will log out and terminate.

You will still need to make the DTMs though if you do this, don't forget! :)

Now, in your Cast procedure, instead of blind clicking, you can use a bitmap.
Here's that tutorial again, look at the bitmap section :p http://villavu.com/forum/showthread.php?t=49089
Blind clicking is never good ;)

Procedure Cast;
begin
GameTab(Tab_Magic);
FindBitmapTolerance(x, y, Cast, MIX1, MIY1, MIX2, MIY2, 5) //Cast Superglass Make
Mouse(x, y, 3, 3, true);
Wait(2998+Random(500));
end;

That looks better, doesn't it? :)

Now lastly, just for convenience sake, you can have a time limit on your script. Just make a constant at the beginning and an integer at the beginning to keep the time in:

program GlassMaker;
{.include SRL/SRL.scar}

Const
ScriptTime = 1000; //Time in ms on how long to run the script

var
x, y, Beginning: integer;
And at the end in your mainloop do:
begin
MarkTime(BeginningTime);
repeat
BankWork;
Cast;
until(TimeFromMark(BeginningTime) > ScriptTime);
end.

HOLY CRAP that was fun :p
So here is what we have now

program GlassMaker;
{.include SRL/SRL.scar}

Const
ScriptTime = 1000; //Time in ms on how long to run the script

var
x, y, Beginning: integer;

Procedure BankWork;
begin
Glass := DTMFromString('DTM HERE');
Seaweed := DTMFromString('DTM HERE');
Sand := DTMFromString('DTM HERE');
MouseSpeed:=11;
if not (LoggedIn) then
Exit;
if not BankScreen then
OpenBankFast('veb');
if(FindDTM(x, y, Glass, MIX1, MIY1, MIX2, MIY2))then
begin
Mouse(x, y, 7, 7, false);
ChooseOption('All'); //Deposit Molten Glass
end else
begin
Logout;
TerminateScript;
end;
MouseSpeed:=9;
if(FindDTM(x, y, Seaweed, MSX1, MSY1, MSX2, MSY2) then //Withdraw Seaweed
begin
Mouse(x, y, 7, 7, false);
ChooseOption('All');
end else
begin
Logout;
TerminateScript;
end;
if(FindDTM(x, y, Sand, MSX1, MSY1, MSX2, MSY2) then //Withdraw Bucket of sand
begin
Mouse(x, y, 7, 7, false);
ChooseOption('All');
end else
begin
Logout;
TerminateScript;
end;
CloseBank;
end;

Procedure Cast;
begin
Cast := BitmapFromString('BITMAP HERE');
GameTab(Tab_Magic);
FindBitmapTolerance(x, y, Cast, MIX1, MIY1, MIX2, MIY2, 5) //Cast Superglass Make
Mouse(x, y, 3, 3, true);
Wait(2998+Random(500));
end;

begin
MarkTime(BeginningTime);
repeat
BankWork;
Cast;
until(TimeFromMark(BeginningTime) > ScriptTime);
end.

If you don't understand some of the procedures/functions ive used, don't be afraid to inquire on them :p
Over all, it is a great first script! Good luck!

E: Silly me forgot to free the bitmaps/DTMs :p, this will reduce lag in the script:
program GlassMaker;
{.include SRL/SRL.scar}

Const
ScriptTime = 1000; //Time in ms on how long to run the script

var
x, y, Beginning: integer;

Procedure BankWork;
begin
Glass := DTMFromString('DTM HERE');
Seaweed := DTMFromString('DTM HERE');
Sand := DTMFromString('DTM HERE');
MouseSpeed:=11;
if not (LoggedIn) then
Exit;
if not BankScreen then
OpenBankFast('veb');
if(FindDTM(x, y, Glass, MIX1, MIY1, MIX2, MIY2))then
begin
Mouse(x, y, 7, 7, false);
ChooseOption('All'); //Deposit Molten Glass
end else
begin
Logout;
TerminateScript;
end;
MouseSpeed:=9;
if(FindDTM(x, y, Seaweed, MSX1, MSY1, MSX2, MSY2) then //Withdraw Seaweed
begin
Mouse(x, y, 7, 7, false);
ChooseOption('All');
end else
begin
Logout;
TerminateScript;
end;
if(FindDTM(x, y, Sand, MSX1, MSY1, MSX2, MSY2) then //Withdraw Bucket of sand
begin
Mouse(x, y, 7, 7, false);
ChooseOption('All');
end else
begin
Logout;
TerminateScript;
end;
CloseBank;
FreeDTM(Glass);
FreeDTM(Seaweed);
FreeDTM(Sand);
end;

Procedure Cast;
begin
Cast := BitmapFromString('BITMAP HERE');
GameTab(Tab_Magic);
FindBitmapTolerance(x, y, Cast, MIX1, MIY1, MIX2, MIY2, 5) //Cast Superglass Make
Mouse(x, y, 3, 3, true);
Wait(2998+Random(500));
FreeBitmap(Cast);
end;

begin
MarkTime(BeginningTime);
repeat
BankWork;
Cast;
until(TimeFromMark(BeginningTime) > ScriptTime);
end.

flamer

2010-02-27 18:43:05

Thanks for the detailed response =)

Got everything working, except my first point. I'm not sure how to approach this, should I use color? But then there is an issue of picking the same booth as the OpenBank function (I think the OpenBank chooses the booth closest to the player, does finding color work the same way?) Or (the easiest I suppose) if there a function exactly like OpenBank but it doesn't click, only hovers over an object?

btw, I've updated the main post with my new script.

edit:
What is the name for varrock west bank? I've tried 'vwb' without sucess

i luffs yeww

2010-02-27 18:49:53

D: Oh noessss. Don't make good money/exp methods public. :< Haha oh well.

Bionicle

2010-02-27 18:50:20

From: flamer
Thanks for the detailed response =)

Got everything working, except my first point. I'm not sure how to approach this, should I use a bit-map? That would require a specific angle and direction right? So I guess I could color, but then there is an issue of picking the same booth as the OpenBank function (I think the OpenBank chooses the booth closest to the player, does finding color work the same way?)

btw, I've updated the main post with my new script.


Yea, a bitmap defiantly would not do the trick, but i don't quite get what you are saying. Is it not opening the bank? Or is it just really slow about it? Or is it because its always picking the same booth?

weequ

2010-02-27 18:52:09

How much money and exp will this make per hour?

i luffs yeww

2010-02-27 18:55:14

Those are pretty much impossible to calculate exactly. Since you get a range of like.. 1-3 glass per bucket/seaweed.. it averages out to 1.33 per over time, but it can be up to 500k/hr.

flamer

2010-02-27 19:20:24

From: bionicle1800
Yea, a bitmap defiantly would not do the trick, but i don't quite get what you are saying. Is it not opening the bank? Or is it just really slow about it? Or is it because its always picking the same booth?


Haha sorry, I updated that post to make it a bit clearer. Here:

Thanks for the detailed response =)

Got everything working, except my first point. I'm not sure how to approach this, should I use color? But then there is an issue of picking the same booth as the OpenBank function (I think the OpenBank chooses the booth closest to the player, does finding color work the same way?) Or (the easiest I suppose) if there a function exactly like OpenBank but it doesn't click, only hovers over an object?

btw, I've updated the main post with my new script.

edit:
What is the name for varrock west bank? I've tried 'vwb' without sucess


I want to have the mouse move and hover over the bank booth while my spell is completing it's cast animation. No real person playing would wait a few seconds across the screen then move the mouse to the bank booth as the spell finishes. However, because I don't know the method of which OpenBank finds the bank booth, I'm not sure how to go about doing that.

edit:
Yes, it can make a decent profit, but depends on market prices, but as post above said, it can peak at 500k/hr. Although it is pretty tedious, so I don't recommend doing it for a long while or else your hand will hurt. (Unless you bot, rofl) I'll be back later, to check on this thread. It has been pretty helpful so far, thanks!

Bionicle

2010-02-27 19:30:00

From: flamer
Haha sorry, I updated that post to make it a bit clearer. Here:



I want to have the mouse move and hover over the bank booth while my spell is completing it's cast animation. No real person playing would wait a few seconds across the screen then move the mouse to the bank booth as the spell finishes. However, because I don't know the method of which OpenBank finds the bank booth, I'm not sure how to go about doing that.

edit:
Yes, it can make a decent profit, but depends on market prices, but as post above said, it can peak at 500k/hr. Although it is pretty tedious, so I don't recommend doing it for a long while or else your hand will hurt. (Unless you bot, rofl) I'll be back later, to check on this thread. It has been pretty helpful so far, thanks!


FindColorTolerance finds the color and returns the coords in x, y
FindColorSpiralTolerance finds the color in a spiral starting in the center of the specified box and returns the coords in x, y.
Then you could just use a MoveMouse procedure.

flamer

2010-02-28 03:44:09

From: bionicle1800
FindColorTolerance finds the color and returns the coords in x, y
FindColorSpiralTolerance finds the color in a spiral starting in the center of the specified box and returns the coords in x, y.
Then you could just use a MoveMouse procedure.


Ah, thanks! But what happens when there is more than one bank booth? I suppose I could make it so it would find the bank booth in a cross pattern (like a +, using two find color boxes) so that way it will always go to the bank booth closest to me. Seems to work perfectly, as after the initial find bank, I won't be moving :sasmokin:

Dgby714

2010-02-28 03:54:09

You can change
  if not BankScreen then
OpenBankFast('veb');
to
OpenBankFast('veb');
as there is a check for BankScreen in OpenBankFast =)

You could also make it
if not OpenBankFast('veb') then 
Exit;

You should take a look at SRL/SRL/core/Bank.scar

Bionicle

2010-02-28 12:56:14

From: flamer
Ah, thanks! But what happens when there is more than one bank booth? I suppose I could make it so it would find the bank booth in a cross pattern (like a +, using two find color boxes) so that way it will always go to the bank booth closest to me. Seems to work perfectly, as after the initial find bank, I won't be moving :sasmokin:


You could also use ATPAs, but those might be a bit advanced for you :p

To put it simply, it finds all the tpoints (x, y coords) of the color you specify, puts them in an array, then splits the array into multiple arrays (inside its own array) of tpoints that are close together.
[php] Array of arrays
___________________________________________|__________________________________________
| |
| Array of tpoints Array of tpoints |
| __________|__________ __________|__________ |
| _________| |_________ _________| |_________ |
| | | | | |
| | tpoint tpoint | | tpoint tpoint | |
| | _______|_______ _______|_______ | | _______|_______ _______|_______ | |
| | | | | | | | | | | | | |[/php]

That's just the theory behind ATPAs, first you have to learn about TPAs if you haven't already :p there is a lot of procedures and functions behind them, but once you get the hang of them, they become very easy.
http://villavu.com/forum/showthread.php?t=21786 GREAT TPA tutorial, this is the one I learned from in just a day :p
http://villavu.com/forum/showthread.php?t=49067 The wizzy plugin, you DONT need to memorise this, good luck if you want to :p, but these proc and func are essential to TPAs and ATPAs.
http://villavu.com/forum/showthread.php?t=48822 this is the tutorial i learned ATPAs from, its actualy a TPA walking tutorial, but it has enough info on ATPAs to understand it

Good luck if you want to try this :p this is very advanced stuff at your level, but seeing on how easily you understood everything in my first post, and even how you made a few changes, i think you can handle it :)

flamer

2010-03-01 03:01:05

Haha, my brain hurts >_> But I did find that FindObjCustom might be just the thing I need. Apparently you can specify the uptext (Bank-booth in my case) and the two colors of the bank booth (window and the wood) to make it much more accurate.

I think after that I'll work on antibans and antirandoms, I think I've spent enough time on this script. The RS people are probably wondering why I start and stop my glassmaking so much haha =p

Dgby714

2010-03-01 05:20:39

From: flamer
Haha, my brain hurts >_> But I did find that FindObjCustom might be just the thing I need. Apparently you can specify the uptext (Bank-booth in my case) and the two colors of the bank booth (window and the wood) to make it much more accurate.

I think after that I'll work on antibans and antirandoms, I think I've spent enough time on this script. The RS people are probably wondering why I start and stop my glassmaking so much haha =p


Nah, if i seen someone making glass and stop every few seconds id just think there doing something else like watching a movie =)

Awkwardsaw

2010-03-01 17:44:44

From: Dgby714
Nah, if i seen someone making glass and stop every few seconds id just think there doing something else like watching a movie =)


this lol. its what i do