SRL Archive - First Scripts

Soulsplit AutoMiner.


Failure

2011-11-21 11:20:49

Hello guys, I'm not sure where to place this, so just move if this is the wrong section, I couldn't anything better since it's my first Script.

I made today a AutoMiner and I'm quite proud, cause I learned some methods which are usefull, I learned about const, functions, and if then statements. I put them together, and I came with this.

http://www.youtube.com/watch?v=FRw_8Ueh2TY

Yes, it's very basic, but it gaved me some valueable knowledge, however I really wanna optimize the speed, like when it's mining, and it doesn't get a Ore within 5 seconds, it will wait longer until it gets one. But I don't know how, so I set a basic timer of 5 seconds to repeat to mine everytime.

Feedback, suggestions are welcome! :)

program New;

{$i SRL/SRL.scar}



var x,y:Integer;

const

LoginScreen = 1810659;


HomeBank = 1556970;
HomeBank1 = 212833;
HomeBank2 = 11973051;

AdamantineRock = 5268559;
AdamantineRock1 = 5992793;

AddyOre = 4939339;

BankBooth = 9214628;
BankBooth1 = 6323598;
BankBooth2 = 9478314;

UseBank = 16776960;




function Login : boolean; //Boolean because it results true or false;
begin
result := false;
If FindColor(x, y, LoginScreen, 677, 464, 677, 464)
then result := true
end;

function HomeBanking : boolean; //Boolean because it results true or false;
begin
result := false;
If FindColorTolerance(x, y, HomeBank, 626, 75, 674, 101, 2) or
FindColorTolerance(x, y, HomeBank1, 626, 75, 674, 101, 2) or
FindColorTolerance(x, y, HomeBank2, 626, 75, 674, 101, 2)
then result := true
end;

function AddyRock : boolean; //Boolean because it results true or false;
begin
result := false;
If FindColorTolerance(x, y, AdamantineRock, 161, 231, 275, 331, 2) or
FindColorTolerance(x, y, AdamantineRock, 230, 223, 281, 272, 2)
then result := true
end;

function FullInventory : boolean; //Boolean because it results true or false;
begin
result := false;
If FindColor(x, y, AddyOre, 714, 476, 714, 476)
then result := true
end;

function Banking : boolean; //Boolean because it results true or false;
begin
result := false;
If FindColorTolerance(x, y, BankBooth, 157, 100, 257, 168, 2) or
FindColorTolerance(x, y, BankBooth1, 157, 100, 257, 168, 2) or
FindColorTolerance(x, y, BankBooth2, 157, 100, 257, 168, 2)
then result := true
end;







begin

SetupSRL;

Repeat

If (Login = True) then
begin
Writeln('We logged out some, we are going to log back in!')
KeyDown(13);
Wait(1);
KeyUp(13);
Wait(10000);
end;

/////////////////////////////////////////////////////////////////////////////
//Teleporting to Skilling Area
Begin
Keydown(115);
Wait(100);
KeyUp(115);
MMouse(576, 387, 2, 2);
Wait(100);
GetMousePos(x, y);
Mouse(x, y, 0, 0, True);
MMouse(270, 461, 10, 2);
Wait(2000);
GetMousePos(x, y);
Mouse(x, y, 0, 0, True);
Wait(5000);
KeyDown(112);
Wait(100);
KeyUp(112);
end;

If(AddyRock = True) then


Begin
MMouse(x, y, 0, -30);
Wait(100);
GetMousePos(x, y);
Mouse(x, y, 0, 0, True);
Wait(5000);
end;

If FindColorTolerance(x, y, AdamantineRock, 155, 188, 272, 311, 2) or
FindColorTolerance(x, y, AdamantineRock1, 155, 188, 272, 311, 2)then
Begin
Repeat
MMouse(x, y, 0, 0);
Wait(100);
Mouse(x, y, 0, 0, True);
Wait(5000);
Until FindColorTolerance(x, y, 4939339, 714, 476, 714, 476, 2);
end;

If(FullInventory = True) then
Begin
Keydown(115);
Wait(100);
KeyUp(115);
MMouse(577, 268, 0, 0);
Wait(100);
Mouse(577, 268, 0, 0, True);
Wait(5000);
end;

If (HomeBanking = True) then
Begin
KeyDown(112);
Wait(100);
KeyUp(112);
MMouse(x, y, 0, 0);
Wait(100);
Mouse(x, y, 0, 0, True);
Wait(5000);
end;

If(Banking = True) then
Begin
MMouse(x, y, 0, 0);
Wait(100);
Mouse(x, y, 0, 0, False);
Wait(300);
If FindColorTolerance(x, y, 16776960, 105, 79, 369, 281, 2) then
Wait(300);
MMouse(x, y, 0, 0);
Wait(300);
Mouse(x, y, 0, 0, True);
Wait(3000);
MMouse(712, 473, 0, 0);
Wait(100);
Mouse(712, 473, 0, 0, False);
Wait(100);
MMouse(649, 444, 0, 0);
Wait(100);
Mouse(649, 444, 0, 0, True);
Wait(400);
MMouse(464, 70, 0, 0);
Wait(100);
Mouse(464, 70, 0, 0, True);
Wait(500);
end;

Until False;
end.

Mark

2011-11-21 11:52:44

Hey grats on your first script.
a few pointers try to use more randomness in your waiting
Example you got Wait(500); instead use Wait(RandomRange(500,750));
also there is plenty of functions and procedures already made which would greatly shorten and improve your script have a look though this http://docs.villavu.com/srl-5/srlref.html
good work and keep on scripting

Failure

2011-11-21 11:54:51

From: CRU1Z1N
Hey grats on your first script.
a few pointers try to use more randomness in your waiting
Example you got Wait(500); instead use Wait(RandomRange(500,750));
also there is plenty of functions and procedures already made which would greatly shorten and improve your script have a look though this http://docs.villavu.com/srl-5/srlref.html
good work and keep on scripting


Heey thanks, well I don't use randomness due the fact it's a Private Server but I will soon I have the base of the Script. Finally the SRL Link, I was looking for it for ages thanks will definitly help! :D

Mark

2011-11-21 12:11:01

no problem if u explain what lines do what i can help you improve stability and speed

Failure

2011-11-21 12:16:49

If FindColorTolerance(x, y, AdamantineRock, 155, 188, 272, 311, 2) or
FindColorTolerance(x, y, AdamantineRock1, 155, 188, 272, 311, 2)then
Begin
Repeat
MMouse(x, y, 0, 0); //Moving to Addy rock
Wait(100);
Mouse(x, y, 0, 0, True); //Clicking Addy rock
Wait(5000);
Until FindColorTolerance(x, y, 4939339, 714, 476, 714, 476, 2); //Until find Adamantite ore on the 28th inventory slot.
end;

This one searches for the Adamantite rock, clicks it, mines the ore waits 5 seconds before attempting to click again, and it repeats until it finds the Adamantite ore color on the 28th inventory spot.

I want it, to mine and keep mining (Not for 5 seconds) until it gets a Adamantite ore, if it gets it will click it again until it has 28 Adamantite ores in inventory, and then when it has 28, not to wait 5 seconds, but do this right after it found the Adamantite ore on the 28th spot.

 If(FullInventory = True) then
Begin
Keydown(115);
Wait(100);
KeyUp(115); //Making sure F4 is pressed magic Tab.
MMouse(577, 268, 0, 0);
Wait(100);
Mouse(577, 268, 0, 0, True); //Clicking home teleport
Wait(5000);
end;

Thanks in advance! :D

RISK

2011-11-21 16:55:50

Nice first script. Here's some things that I saw by looking over it quickly:
1. Work on your standards: http://villavu.com/forum/showthread.php?t=60288 This should be the first thing you learn and practice until it becomes natural to you.
2. Check out the SRL include. There are a lot of functions for the things you want to do and have done.
3. Try to never use global variables (The "X" and "Y" variables you have at the very top are global variables). You should use local variables like this:
procedure ProcedureName;
var X, Y : Integer;
begin
end;

It will avoid any possible errors you may have and it's just good to have in practice.
4.
function FullInventory : boolean; //Boolean because it results true or false;
begin
result := false;
If FindColor(x, y, AddyOre, 714, 476, 714, 476)
then result := true
end;

This type of function is already in the SRL include, "InvFull". But it's good to see you implementing your own functions.

Great first script and I really look forward to your future scripts!

mika

2011-11-21 17:01:12

cant vie video its set to private

Mark

2011-11-21 19:42:03

From: Failure
If FindColorTolerance(x, y, AdamantineRock, 155, 188, 272, 311, 2) or
FindColorTolerance(x, y, AdamantineRock1, 155, 188, 272, 311, 2)then
Begin
Repeat
MMouse(x, y, 0, 0); //Moving to Addy rock
Wait(100);
Mouse(x, y, 0, 0, True); //Clicking Addy rock
Wait(5000);
Until FindColorTolerance(x, y, 4939339, 714, 476, 714, 476, 2); //Until find Adamantite ore on the 28th inventory slot.

I would do something like this instead

procedure MineRock;
var
AddyRockCol:Array [1..2] of integer;//i added an array for the colors
Tam,TimeAtMine,i:integer;
begin
AddyRockCol[1]:= AdamantineRock; AddyRockCol[2]:= AdamantineRock1; //these are your rock colors set the values in your const
MarkTime(TimeAtMine); //this marks the time you get to mining place
Tam:=TimeFromMark(TimeAtMine); // this counts how long its been since you started miing
repeat
If FindColorTolerance(x, y, AddyRockCol[RandomRange(1,2)], 155, 188, 272, 311, 2)then
begin
Case RandomRange(1,2) of //this makes it randomly choose to left or right click the rock
1:begin
Mouse(x,y,5,5,false);
ChooseOption('ine'); //this might need changing to wateva the right click option might be
end;
2: Mouse(x,y,5,5,true); // left clicks the rock
end;
end else
writeln('Failed to mine rock make sure colors are correct');
TerminateScript;
until (invFull) or (Tam>=10*60000); // will repeat untilfull invo or not filled within 10 mins
if Tam>=10*60000 then
begin
if InvCount<=1 then
writeln('Failed to Find Rock');
TerminateScript;
end;
end;

Failure

2011-11-22 01:12:23

From: RISK
Nice first script. Here's some things that I saw by looking over it quickly:
1. Work on your standards: http://villavu.com/forum/showthread.php?t=60288 This should be the first thing you learn and practice until it becomes natural to you.
2. Check out the SRL include. There are a lot of functions for the things you want to do and have done.
3. Try to never use global variables (The "X" and "Y" variables you have at the very top are global variables). You should use local variables like this:
procedure ProcedureName;
var X, Y : Integer;
begin
end;

It will avoid any possible errors you may have and it's just good to have in practice.
4.
function FullInventory : boolean; //Boolean because it results true or false;
begin
result := false;
If FindColor(x, y, AddyOre, 714, 476, 714, 476)
then result := true
end;

This type of function is already in the SRL include, "InvFull". But it's good to see you implementing your own functions.

Great first script and I really look forward to your future scripts!


Thanks, well I aint sure if all SRL functions work on a Private Server ofcourse, I can try haha, and that use the variable local, I am now thinking, you might saved my ass since whenever it's mining, it finds the rock color once, and just repeats to click on it even if it's not found. But I'll definitly check it out thanks! :D

From: mika
cant vie video its set to private


Sorry, messed something up, should be fine now!

From: CRU1Z1N
I would do something like this instead

procedure MineRock;
var
AddyRockCol:Array [1..2] of integer;//i added an array for the colors
Tam,TimeAtMine,i:integer;
begin
AddyRockCol[1]:= AdamantineRock; AddyRockCol[2]:= AdamantineRock1; //these are your rock colors set the values in your const
MarkTime(TimeAtMine); //this marks the time you get to mining place
Tam:=TimeFromMark(TimeAtMine); // this counts how long its been since you started miing
repeat
If FindColorTolerance(x, y, AddyRockCol[RandomRange(1,2)], 155, 188, 272, 311, 2)then
begin
Case RandomRange(1,2) of //this makes it randomly choose to left or right click the rock
1:begin
Mouse(x,y,5,5,false);
ChooseOption('ine'); //this might need changing to wateva the right click option might be
end;
2: Mouse(x,y,5,5,true); // left clicks the rock
end;
end else
writeln('Failed to mine rock make sure colors are correct');
TerminateScript;
until (invFull) or (Tam>=10*60000); // will repeat untilfull invo or not filled within 10 mins
if Tam>=10*60000 then
begin
if InvCount<=1 then
writeln('Failed to Find Rock');
TerminateScript;
end;
end;


That looks quite complicated for now, not used to it thanks for the time to make it, I will study that code, and eventually re-write my Script and trying to do it kinda that like to train my Script knowledge also with Risk his suggestion. Cause if I'm able to do that, like perfectly I will make and maybe that's a big thing, since Soulsplit has Dungeoneering, to make a bot for it. I did that, but ehh, messed up some parts due poorly Scripting.

EvilTwin

2011-11-26 08:17:08

Looks good ;) Will test now!

kyocera

2011-12-16 08:08:34

Nice first RSPS script released publicly I think LOL?
Look's good for your first though:)