SRL Archive - OSR Help

My script so far


Stevee

2010-03-16 19:45:48

Yeh, I've been working on my autoalcher. this is about 4-5 hours into it, and it's my first script.

AFAIK, the only thing left is antiban. That and failsafes (it just terminatesscript and logsout atm).
Code:

[LEFT][COLOR=#000000][B]program[/B][/COLOR] SteveAutoAlcher;
[COLOR=#008000]{.include srl/srl.scar}[/COLOR]
[COLOR=#008000]{[/COLOR]
[COLOR=#008000]-Consts[/COLOR]
[COLOR=#008000]-*Player username[/COLOR]
[COLOR=#008000]-*Player password[/COLOR]
[COLOR=#008000]-*Breaks[/COLOR]
[COLOR=#008000]-*Do you want the script to auto-bank when done?[/COLOR]
[COLOR=#008000]-**Bank pin[/COLOR]
[COLOR=#008000]-*Make DTM (DONE)[/COLOR]
[COLOR=#008000]-[/COLOR]
[COLOR=#008000]}[/COLOR]
[COLOR=#000000][B]var[/B][/COLOR]
i, x, y: Integer;[/LEFT]

[LEFT][COLOR=#000000][B]const[/B][/COLOR]
[COLOR=#008000]/////////////////////////////Setup Starts Here//////////////////////////////////[/COLOR]
HowManyAlchs = [COLOR=#000080]500[/COLOR]; [COLOR=#008000]//How much are we alchemizing?[/COLOR]
TakeBreaks = True; [COLOR=#008000]//Do You Want to take breaks[/COLOR]
BreakAfter = [COLOR=#000080]60[/COLOR]; [COLOR=#008000]//How Long you want to work for before you take a 15 min break (In Minutes (0 = Do not break))[/COLOR]
BreakFor = [COLOR=#000080]10[/COLOR]; [COLOR=#008000]//How long would you like to break for? (0 = Do not break)[/COLOR]
BreakForRandom = [COLOR=#000080]5[/COLOR]; [COLOR=#008000]//Add this many random minutes into BreakFor[/COLOR]
ChanceOfNotBreaking = [COLOR=#000080]60[/COLOR]; [COLOR=#008000]//Out of 100, chance of not breaking at all[/COLOR][/LEFT]

[LEFT][COLOR=#000000][B]Procedure[/B][/COLOR] DeclarePlayers;
[COLOR=#000000][B]begin[/B][/COLOR]
HowManyPlayers := [COLOR=#000080]1[/COLOR] ;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := [COLOR=#000080]0[/COLOR];[/LEFT]

[LEFT] [COLOR=#000000][B]with[/B][/COLOR] players[[COLOR=#000080]0[/COLOR]] [COLOR=#000000][B]do[/B][/COLOR]
[COLOR=#000000][B]begin[/B][/COLOR]
Name := [COLOR=#ff00ff]''[/COLOR];
Pass := [COLOR=#ff00ff]''[/COLOR];
Nick := [COLOR=#ff00ff]''[/COLOR];
Active := True;
Pin := [COLOR=#ff00ff]''[/COLOR];
[COLOR=#000000][B]end;[/B][/COLOR]
[COLOR=#000000][B]end[/B][/COLOR];
[COLOR=#008000]//////////////////////////////Setup Ends Here\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[/COLOR][/LEFT]

[LEFT][COLOR=#000000][B]Procedure[/B][/COLOR] ClickNote;
[COLOR=#000000][B]var[/B][/COLOR]
BankNote :Integer;
[COLOR=#000000][B]begin[/B][/COLOR]
BankNote := DTMFromString([COLOR=#ff00ff]'78DA6354666060106340034C0C2640921188F'[/COLOR] +
[COLOR=#ff00ff]'F0301A31A90C189A98601AA064C0B030909026AF480840C01358A'[/COLOR] +
[COLOR=#ff00ff]'404299087384F0AB0100AA7605AA'[/COLOR]);
[COLOR=#000000][B]if[/B][/COLOR] (GameTab([COLOR=#000080]25[/COLOR])) [COLOR=#000000][B]then[/B][/COLOR]
[COLOR=#000000][B]begin[/B][/COLOR]
[COLOR=#000000][B]if[/B][/COLOR] FindDTM(BankNote, x, y, MIX1, MIY1, MIX2, MIY2) [COLOR=#000000][B]then[/B][/COLOR]
[COLOR=#000000][B]begin[/B][/COLOR]
Mouse(x, y, [COLOR=#000080]2[/COLOR], [COLOR=#000080]2[/COLOR], true);
[COLOR=#000000][B]end[/B][/COLOR] [COLOR=#000000][B]else[/B][/COLOR]
[COLOR=#000000][B]begin[/B][/COLOR]
Logout;
TerminateScript;
[COLOR=#000000][B]end;[/B][/COLOR]
[COLOR=#000000][B]end;[/B][/COLOR]
FreeDTM(BankNote);
[COLOR=#000000][B]end;[/B][/COLOR]
[COLOR=#000000][B]Procedure[/B][/COLOR] ClickAlch;
[COLOR=#000000][B]var[/B][/COLOR]
HighAlch :Integer;
[COLOR=#000000][B]begin[/B][/COLOR]
HighAlch := DTMFromString([COLOR=#ff00ff]'78DA6314676060106340016A0AE20C46409A1'[/COLOR] +
[COLOR=#ff00ff]'188FF0301231B902181AA86094A33C2682E20214C408D28909026'[/COLOR] +
[COLOR=#ff00ff]'A046164888125023052438F1AB0100BD08058F'[/COLOR]);
[COLOR=#000000][B]if[/B][/COLOR] ([COLOR=#000000][B]not[/B][/COLOR](GameTab([COLOR=#000080]28[/COLOR]))) [COLOR=#000000][B]then[/B][/COLOR] GameTab([COLOR=#000080]28[/COLOR]);
GameTab([COLOR=#000080]28[/COLOR]);
[COLOR=#000000][B]if[/B][/COLOR] FindDTM(HighAlch, x, y, MIX1, MIY1, MIX2, MIY2) [COLOR=#000000][B]then[/B][/COLOR]
[COLOR=#000000][B]begin[/B][/COLOR]
Mouse(x, y, [COLOR=#000080]2[/COLOR], [COLOR=#000080]2[/COLOR], true)
FreeDTM(HighAlch);
[COLOR=#000000][B]end[/B][/COLOR] [COLOR=#000000][B]else[/B][/COLOR]
LogOut;
TerminateScript;
FreeDTM(HighAlch);
[COLOR=#000000][B]end;[/B][/COLOR][/LEFT]

[LEFT][COLOR=#000000][B]Procedure[/B][/COLOR] DoBreak;
[COLOR=#000000][B]var[/B][/COLOR]
Breaktime, LastBreak, SinceBreak, BreakForRandom2, BreakFor2:Integer;
[COLOR=#000000][B]Begin[/B][/COLOR]
BreakTime := BreakAfter * [COLOR=#000080]60[/COLOR] * [COLOR=#000080]1000[/COLOR];
LastBreak := TimeFromMark(SinceBreak);
[COLOR=#000000][B]If[/B][/COLOR](BreakTime <= LastBreak) [COLOR=#000000][B]then[/B][/COLOR]
[COLOR=#000000][B]begin[/B][/COLOR]
Logout;
[COLOR=#000000][B]if[/B][/COLOR](BreakForRandom = [COLOR=#000080]0[/COLOR]) [COLOR=#000000][B]then[/B][/COLOR]
[COLOR=#000000][B]begin[/B][/COLOR]
Wait(BreakFor * ([COLOR=#000080]1000[/COLOR] * [COLOR=#000080]60[/COLOR]));
LoginPlayer;
SetAngle(True);
MarkTime(SinceBreak);
[COLOR=#000000][B]end[/B][/COLOR] [COLOR=#000000][B]else[/B][/COLOR]
[COLOR=#000000][B]begin[/B][/COLOR]
BreakForRandom2 := BreakForRandom * [COLOR=#000080]1000[/COLOR] * [COLOR=#000080]60[/COLOR] ;
BreakFor2 := BreakFor * ([COLOR=#000080]1000[/COLOR] * [COLOR=#000080]60[/COLOR])+(RandomRange([COLOR=#000080]0[/COLOR], BreakForRandom2));
Wait(BreakFor2);
LoginPlayer;
SetAngle(True);
MarkTime(SinceBreak);
[COLOR=#000000][B]end[/B][/COLOR]
[COLOR=#000000][B]end;[/B][/COLOR]
[COLOR=#000000][B]end[/B][/COLOR];[/LEFT]

[LEFT][COLOR=#000000][B]begin[/B][/COLOR]
[COLOR=#000000][B]For[/B][/COLOR] I := [COLOR=#000080]0[/COLOR] [COLOR=#000000][B]to[/B][/COLOR] HowManyAlchs [COLOR=#000000][B]do[/B][/COLOR]
[COLOR=#000000][B]begin[/B][/COLOR]
ClickAlch;
ClickNote;
[COLOR=#000000][B]If[/B][/COLOR](TakeBreaks) [COLOR=#000000][B]then[/B][/COLOR]
DoBreak;
[COLOR=#000000][B]end;[/B][/COLOR]

[COLOR=#000000][B]end.[/B][/COLOR][/LEFT]

**Updated 3/17/10 @10am**
http://pastebin.com/dqkL9n2m

Blumblebee

2010-03-16 20:00:01

did a quick overview, commented on things. Read through as I just gave pointers on how to improve current code. If you wish for me to help you with developing future code, I can help you do that as well.

Looks really good for a first script, a few adjustments to it and you'll have a very good alcher on your hands :)

program SteveAutoAlcher;
{.include srl/srl.scar}
{
-Consts
-*Player username
-*Player password
-*Breaks
-*Do you want the script to auto-bank when done?
-**Bank pin
-*Make DTM (DONE)
-
}
var
i, x, y: Integer;

const // Have these constants variables in declare players for more user customization
/////////////////////////////Setup Starts Here//////////////////////////////////
HowManyAlchs = 500; //How much are we alchemizing?
TakeBreaks = True; //Do You Want to take breaks
BreakAfter = 60; //How Long you want to work for before you take a 15 min break (In Minutes (0 = Do not break))
BreakFor = 10; //How long would you like to break for? (0 = Do not break)
BreakForRandom = 5; //Add this many random minutes into BreakFor
ChanceOfNotBreaking = 60; //Out of 100, chance of not breaking at all

// I would do something like...

const
Alchs = 0;
Take_Breaks = 1;
Break_For = 2;

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

with players[0] do
begin
Name := '';
Pass := '';
Nick := '';
Active := True;
Pin := '';

// I would do something like...

Integers[Alchs] := 500; // number of alchs
Booleans[Take_Breaks] := True; // Do you want to take Breaks
Integers[Break_For] := 10; // How long would you like to break for? (0 = Do not break)
end;
end;
//////////////////////////////Setup Ends Here\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

Procedure ClickNote;
var
BankNote :Integer;
begin
BankNote := DTMFromString('78DA6354666060106340034C0C2640921188F' +
'F0301A31A90C189A98601AA064C0B030909026AF480840C01358A' +
'404299087384F0AB0100AA7605AA');
if (GameTab(25)) then // Use GameTab(tab_Inv) ! Helps with readability
begin
if FindDTM(BankNote, x, y, MIX1, MIY1, MIX2, MIY2) then
begin // no need for the begin..end nest here. just if(condition)then this; else begin that; this; end;
Mouse(x, y, 2, 2, true); // I think you should have more randomness than just 2, 2. Seems kind of bannable.
end else
begin
Logout; // NextPlayer(False) makes this multiplayer
TerminateScript; // you also forgot to free your DTM. Memory leaks are bad.
end;
end;
FreeDTM(BankNote);
end;

Procedure ClickAlch;
var
HighAlch :Integer;
begin
HighAlch := DTMFromString('78DA6314676060106340016A0AE20C46409A1' +
'188FF0301231B902181AA86094A33C2682E20214C408D28909026' +
'A046164888125023052438F1AB0100BD08058F');
if (not(GameTab(28))) then GameTab(28); // use the constants for readability like stated above
GameTab(28); // wtf is this doing here?
if FindDTM(HighAlch, x, y, MIX1, MIY1, MIX2, MIY2) then
begin
Mouse(x, y, 2, 2, true); // I would advise more randomness to this.
FreeDTM(HighAlch);
end else // your missing a begin..end nest here.
//begin should be here
LogOut;
TerminateScript;
FreeDTM(HighAlch); // you can do a more efficient job of freeing this. Instead of repeating code.
//end; and here
end;

Procedure DoBreak; // Looks good, Can't complain about it.
var
Breaktime, LastBreak, SinceBreak, BreakForRandom2, BreakFor2:Integer;
Begin
BreakTime := BreakAfter * 60 * 1000;
LastBreak := TimeFromMark(SinceBreak);
If(BreakTime <= LastBreak) then
begin
Logout;
if(BreakForRandom = 0) then
begin
Wait(BreakFor * (1000 * 60));
LoginPlayer;
SetAngle(True);
MarkTime(SinceBreak);
end else
begin
BreakForRandom2 := BreakForRandom * 1000 * 60 ;
BreakFor2 := BreakFor * (1000 * 60)+(RandomRange(0, BreakForRandom2));
Wait(BreakFor2);
LoginPlayer;
SetAngle(True);
MarkTime(SinceBreak);
end
end;
end;

begin // your mainloop should be set up for multiplayer

// your missing declare players. LogInPlayer, etc.
// I would have...
//----------------------------------------\\
SetUpSRL();
DeclarePlayers();
while not LoggedIn() do LogInPlayer();
SetAngle(true);
//----------------------------------------\\

For I := 0 to HowManyAlchs do
begin
ClickAlch;
ClickNote;
If(TakeBreaks) then
DoBreak;
end;
end.

Stevee

2010-03-17 09:50:17

Updated with Failsafes. Only thing left is antiban, and I'm going to do a function to find when the player is alching. I believe I can do that by taking the color of the alching effect (or a bitmap, which should I do?), and a function like..

function StillAlching(IsAlching :boolean)boolean;
[LEFT]var
Alch :integer
begin
Alching := BitmapFromString([COLOR=#ff00ff]'XXXXXXXXX'[/COLOR]);
if(FindBitmapToleranceIn(Alching, x, y, MSX1, MSY1, MSX2, MSY2, [COLOR=#000080]40[/COLOR]) then
result := True;
end;[/LEFT]


Then in the main loop…



begin [COLOR=#008000]{This main loop will work?}[/COLOR]
For I := [COLOR=#000080]0[/COLOR] [COLOR=#000000][B]to[/B][/COLOR] HowManyAlchs do
begin</p>

[LEFT]ClickAlch;
[LEFT]ClickNote;
while StillAlching do
wait([COLOR=#000080]200[/COLOR]);
If(TakeBreaks) then
DoBreak;
end;
end.[/LEFT]
[/LEFT]


[LEFT]Now my question; how should one include AntiBan with an alcher? Your mouse is constantly moving as it is….[/LEFT]

Bionicle

2010-03-17 10:04:11

From: Stevee
[LEFT]Now my question; how should one include AntiBan with an alcher? Your mouse is constantly moving as it is….[/LEFT]


- Well is this script a banking/alching script or an alching notes script? If it is a banking one, you could make it a 1 in 50 chance of the script going for a little jaunt
- Miss clicking
- HoverSkill would still work fine

Awkwardsaw

2010-03-17 11:59:47

moving the screen around, bored human, random waits(like 1-3 min long) + pickup mouse would suffice

also make your own waiting while waiting to alch

like


procedure waitanti(r : integer); //i would make a different antiban, that is used just in general, and just use this for the waiting
begin
case random(r) of
0 : wait(1000 + random(1000);
1 : pickupmouse;
2 : makecompass(randomrange(-360, 360));
3 : makeangle(rbool());
end;
end;

procedure awkwardwait(time, r : integer);
var
t : integer;
begin
marktime(t);
while timefrommark(t) > time do
begin
waitanti(r);
findnormalrandoms;
wait(5);
end;
end;

and then replace that wait with the normal one, :) i hope it makes sence, i didnt really explain much :)

Stevee

2010-03-17 12:50:12

Thanks bionicle.

AwkwardSaw, I'll redo your antiban to do more stuff, but to include it, this is what I would do, right?
begin [COLOR=#008000]{This main loop will work?}[/COLOR]
For I := [COLOR=#000080]0[/COLOR] [COLOR=#000000][B]to[/B][/COLOR] HowManyAlchs do
begin

[LEFT]ClickAlch; [/LEFT]

[LEFT]ClickNote;

while StillAlching do
[LEFT]AwkwardWait;
If(TakeBreaks) then
DoBreak;
end;
end.[/LEFT]
[/LEFT]

[LEFT]


[LEFT]And then I have to measure out an approximation of the time it takes to alch (t in your procedure), and probably like..
[LEFT]
d := RandomRange(0, 100);
[/LEFT]
[/LEFT]


[LEFT]if((not)d > 88)) then
[LEFT]begin
t := 2000 + RandomRange(0, 650);
Wait(t);
end else
begin
t := 2000 + RandomRange(650, 3000);
Wait(t);
end;
end;[/LEFT]
[/LEFT]

[LEFT]This would make it so there's a 12% chance to wait more than 2.65 seconds, because humands probably wouldn't always get to click within a certain zone of 650milliseconds.

[LEFT]Actually, I'm probably going to make about 60 lines dedicated to randomness in waiting (1% chance to wait for a minute, etc).[/LEFT]
[/LEFT]


[/LEFT]

Awkwardsaw

2010-03-17 12:54:48

my old alcher just did a wait(1900 + random(400)), but your random waiting is fine too :)

Stevee

2010-03-19 21:43:45

*bump*

More advice appreciated