SRL Archive - First Scripts

Seren stone script


arclight

2014-10-09 03:09:15

Sup, I've been messing around with simba for a bit, so I figured I might as well try to make my own script. Nothing particularly fancy, it mines the seren stones in the elf city. You just need a free inventory slot for the corrupted ore really. Let me know if you have any questions or possible improvements I could do. I was more focusing on a working script rather than adding the bells and whistles though. If it can't find a rock, the script terminates. I think the anti-ban needs a bit of work to stop causing the game from quitting or being too active for afk mining, but I did not really have any ideas for that.


program SerenStone;
{$DEFINE SMART}
{$I SRL-6/SRL.Simba}
{$i srl-6/lib/misc/srlplayerform.simba}

var
Timer : TTimeMarker;

// From thread on topic of SRL forms
// initiates the SRL player form (you aren't restricted to the procedure name; it can be whatever you want)
procedure initPlayerForm();
begin
with playerForm do
begin
name := 'Seren Stone Miner'; // the title of the SPF, usually the name of your script
scriptHelpThread := ''; // a link to a help thread, if set to '' will link to my setup guide

editBoxLabels := ['Minutes to run', 'Minutes before breaking', 'Minutes of break', 'Number of loops until not active']; // edit boxes are created for each array element
editBoxDefaults := ['0', '0', '0', '4']; // optional default values for each edit box; array length must equal editBoxLabel length

// optional hints for each edit box; hints are shown when the user holds the mouse over the component
editBoxHints := ['How long to run (in minutes), 0 disables timer?', 'Run for this amount of time (in minutes) before breaking.', 'How long you want that break?', 'When should we try to click again?'];
end;
end;

// again, not restricted to the procedure name, although it's recommended
procedure declarePlayers();
var
i: integer;
begin
players.setup(playerForm.players); // load the SPF players from the SRL Player Manager
currentPlayer := 0; // player to use first

// set player attributes based on the settings from the form
for i := 0 to high(players) do
with players[i] do
begin
// convert the integers
integers[0] := strToInt(playerForm.players[i].settings[0]);
integers[1] := strToInt(playerForm.players[i].settings[1]);
integers[2] := strToInt(playerForm.players[i].settings[2]);
integers[3] := strToInt(playerForm.players[i].settings[3]);
end;
end;

procedure debugSPFSettings();
var
i: integer;
begin
writeln('');

for i := 0 to high(players) do
begin
writeln('Minutes to run: ', players[i].integers[0]);
writeln('Break time: ', players[i].integers[1]);
writeln('Break length: ', players[i].integers[2]);
writeln('Inactive: ', players[i].integers[3]);
writeln('');
end;
end;

function clickRock(): Boolean;
var
x, y: integer;
point: TPoint;
begin
Result := false;
case random(100) of
0..70 :
begin
if(mainscreen.findObject(x, y, 16578321, 18, ['Seren stone'], MOUSE_LEFT)) then
Result := true;
end;
71..95 :
begin
if(mainscreen.findObject(x, y, 16578321, 18, ['Seren stone'], MOUSE_RIGHT)) then begin
Wait(GaussRangeInt(100,500));
chooseOption.select(['Mine']);
Result := true;
end;
end;
96..100 :
begin
if(mainscreen.findObject(x, y, 16578321, 18, ['Seren stone'], MOUSE_NONE)) then
begin
point.create(x, y);
if(gaussRangeInt(-10,10) <= mouseSpeed - 20) then
begin
missMouse(point, false);
fastClick(mouse_Left);
end
else
begin
missMouse(point, true);
result := true;
end;
end;
end;
end;
Wait(gaussRangeInt(100,2000));
end;

procedure AntiBan();
begin
case random(10000) of
0..25 :
begin
hoverSkill(Skill_Mining);
Wait(GaussRangeInt(500,1000));
end;
101..105 :
begin
boredHuman(true);
end;
150..160 :
begin
randomGameTab(true);
end;
300..320 :
begin
randomRClickItem();
end;
400..700 :
begin
mouseMovingObject;
end;
900..1200 :
begin
Minimap.setAngle(180 - gaussRangeInt(0,360));
end;
1300..1400 :
begin
//add a bit of AFK
Wait(GaussRangeInt(1000,5000));
end;
1500..1800 :
begin
randomCameraAngle(MS_ANGLE_HIGH);
end;
1900..2200 :
begin
randomCameraAngle(MS_ANGLE_LOW);
end;
2250..2255 :
begin
Wait(gaussRangeInt(10000,120000));
if not Players[currentPlayer].login then
exit;
end;
end;
end;

procedure breakNow(length : integer);
var
breakTimer : TTimeMarker;
begin
if not IsLoggedIn then
Exit;
if(length > 0) then
begin
breakTimer.reset;
length = length + GaussRangeInt(round(length/2),length*2);
writeln('Going to break for ' + intToStr(round(length/60000)) + ' minutes');
players[CurrentPlayer].logout;
breakTimer.start;
while(length > breakTimer.getTime) do
begin
wait(30000);
writeln('Break left: ' + intToStr(round((length - breakTimer.getTime)/60000)));
end;
writeln('Break over, logging in');
Players[CurrentPlayer].Login;
breakTimer.reset;
end;
end;

procedure ReportStats(currentTime, startXp, currentXp: Integer);
var
xp, xph : Integer;
begin
xp := currentXp - startXp;
xph := round(xp * (3600000 / currentTime));
writeln('-------------------------');
writeln('xp gained: ' + intToStr(xp));
writeln('xp per hour: ' + intToStr(xph));
writeln('current run time: ' + intToStr(round(currentTime/1000)));
writeln('-------------------------');
end;


//From Ashaman88's thread about xp
function TRSChatBox.getXP: Integer;
var
b: TBox;
s: String;
tpa : TPointArray;
atpa : T2DPointArray;
i,cts,p: Integer;
begin
b := self.getBounds();
b.edit(+(b.x2-b.x1)-140, +10, -5, -94);

findColorsTolerance(tpa, 14013909, b, 4,colorSetting(2, 0.00, 0.00));

if length(tpa) < 2 then
begin
//print('chatBox.getXP(): No XP found', TDebug.SUB);
Exit;
end;

atpa := tpa.cluster(5);

b:= atpa.getbounds;
b.edit(-2,-2,+2,+3);

s:=Replace(tesseractgettext(b.x1,b.y1,b.x2,b.y2, FILTER_SMALL_CHARS), ' ', '', [rfReplaceAll]);

P := Pos('x', S);
if P > 0 then
Result := StrToIntDef(ExtractFromStr(Copy(s, P, Length(S)), Numbers), 0)
else
Result := StrToIntDef(ExtractFromStr(S, Numbers), 0);

//print('chatBox.getXP(): XP found: ' + tostr(result), TDebug.SUB);
end;

// Goal is to remain consistent, but variable
// Don't favor going too high, but also not too slow
procedure adjustMouse;
var
rateOfChange, distance : Integer;
const
MOUSE_MAX := 25;
MOUSE_MIN := 15;
begin
//mouse speed should not change that often
if(gaussRangeInt(1, 10) < 4) then
begin
if(gaussRangeInt(1,10) < 8) then
rateOfChange := gaussRangeInt(1,4)
else
rateOfChange := gaussRangeInt(5,8);
//okay, goal here is to favor the direction we are furtherest from
distance := 20 - mouseSpeed;
if(gaussRangeInt(1,20) <= 11 + distance) then
mouseSpeed := mouseSpeed + rateOfChange
else
mouseSpeed := mouseSpeed - rateOfChange;
if(mouseSpeed > MOUSE_MAX) then
mouseSpeed := MOUSE_MAX
else if (mouseSpeed < MOUSE_MIN) then
mouseSpeed := MOUSE_MIN;
end;
end;

procedure MainLoop;
var
count, curXp, storedXp, startXp, lastBreak: Integer;
begin
Timer.reset;
Timer.start;
count := 0;
lastBreak := 0;
If Not Players[CurrentPlayer].Login Then
TerminateScript;
Wait(GaussRangeInt(1000,4000));
curXP := chatbox.getXP();
startXp := curXp;
while(Players[CurrentPlayer].Integers[0] = 0 or ((Players[CurrentPlayer].Integers[0] * 60000) > Timer.gettime)) do
begin
storedXp := chatbox.getXP();
if(not (storedXp = curXp)) then
begin
curXp := storedXp;
count := -1 * Players[CurrentPlayer].integers[3];
end
else
count := count + 1;
if(count >= Players[CurrentPlayer].integers[3]) then
begin;
//if we successfully clicked rock, give more time
//before trying again, otherwise we need to correct camera
//on first time at the inactive amount
if(clickRock()) then
begin
count := count - players[CurrentPlayer].integers[3] * 2;
end
else
if(count = players[CurrentPlayer].integers[3]) then
minimap.clickCompass();
end;
if(count >= players[CurrentPlayer].integers[3] * 2) then
terminateScript;
//if count is greater than 1, there is a good chance
//that we are not currently mining
//better not try any antiban to make
//the bot look less stupid
if(count < 1) then
antiban();
ReportStats(Timer.getTime, startXp, curXp);
if((not (players[CurrentPlayer].integers[1] = 0))
and ((players[CurrentPlayer].integers[1] * 60000 + gaussRangeInt(1,5000))
<= Timer.getTime - lastBreak)) then
begin
breakNow(players[CurrentPlayer].integers[2] * 60000);
lastBreak := Timer.getTime;
end;
//Most of the time remove mouse off client
//to show we are doing something else
if(GaussRangeInt(1,100) < 95) then
mouseOffClient(OFF_CLIENT_RANDOM);
adjustMouse;
Wait(GaussRangeInt(1000,4000));
end;
writeln('ending script');
end;

begin
ClearDebug;
smartPlugins := ['OpenGL32.dll'];
initPlayerForm();
runPlayerForm();
if (not playerForm.isScriptReady) then
exit;
declarePlayers();
SetupSRL;
//debugSPFSettings();
MainLoop;
end.

P1nky

2014-10-09 04:10:34

Great start and look, you should keep working on this script and maybe get a bit active on forums and apply for SRL Members! Keep it up.

~P1nky

sipfer3

2014-10-09 05:17:01

hey, looks pretty nice!
for the antiban u could add some random compass movements. or just think of what would YOU do when you semi-afk mine? for example right click on nearby players / objects to check lvls and stuff ;)

arclight

2014-10-09 07:22:08

I edited in a new version of my script in the top post. Ran it for a little while:
————————-
xp gained: 25475
xp per hour: 92761
current run time: 989
————————-
I probably should put in a camera move up and down (it already goes left to right).

sipfer3

2014-10-09 08:04:56

mouseOffClient(OFF_CLIENT_RANDOM); this one is pretty good for afk scripts i guess

Clarity

2014-10-09 08:49:14

Nice first script! For antiban, if you are taking the AFK approach, I would recommend subtly changing mouse speeds after coming back from idling breaks. It is not very humanly realistic to maintain the same mouse speed at all times!

Here is an example of some antiban procedures from my mud runes script to give you some more ideas:


{PROCEDURE -- reCalcAB
Purpose: Recalculates antiban variables, randomizing player mood.
Comments: In the future these numbers will be unique to every user, not random!}
procedure reCalcAB;
begin
lowestAFKTime := random(2000, 8000);
highestAFKTime := random(9000, 57000);
lowestIdleTime := random(500, 3000);
highestIdleTime := random(3750, 12500);
lowestMouseSpeed := random(17, 24);
highestMouseSpeed := random(29, 40);
useMM := random(25, 35);
reflexFactor := gaussRangeInt(350, 550);
forgetfulness := random(5, 15);
inaccuracy := gaussRangeInt(5, 25);
impatience := gaussRangeInt(5, 15);
mouseSpeed := gaussRangeInt(lowestMouseSpeed, highestMouseSpeed);
AFKTime := gaussRangeInt(lowestAFKTime, highestAFKTime);
idleTime := gaussRangeInt(lowestIdleTime, highestIdleTime);
ClarityDebug('Antiban mood and behavior variables recalculated!');
ClarityDebug('(MouseSpeed: ' + ToStr(mouseSpeed) + ') (AFK Time: ' + ToStr(AFKTime) + ') (Idle Time: ' + ToStr(idleTime) + ') (Use MM: ' + ToStr(useMM) + ') (Forgetfulness: ' + ToStr(forgetfulness) + ') (Inaccuracy: ' + ToStr(inaccuracy) + ') (Impatience: ' + ToStr(impatience) + ')');
end;

{PROCEDURE -- humanFlaws
Purpose: Adds human flaws to mouse movement.
Comments: None.}
procedure humanFlaws(pnt: TPoint; button: integer);
var
accuracy, patience: integer;
begin
accuracy := random(100);
patience := random(100);
if (inaccuracy > accuracy) then
begin
missMouse(pnt, true);
ClarityDebug('Missed initial destination mouse point due to human inaccuracy.');
end
else
mouse(pnt, MOUSE_MOVE, MOUSE_HUMAN);
if (impatience > patience) and (button <> MOUSE_RIGHT) then
begin
multiClick(pnt, random(20, 50), random(2, ));
ClarityDebug('Clicked multiple times due to human impatience.');
end
else
fastClick(button);
end;

{PROCEDURE -- antiBan
Purpose: Make us look more like a human and less like a bot.
Comments: None.}
procedure antiBan;
var
i, afk, idle, mSpeed: integer;
begin
if not isLoggedIn then
exit;
i := random(antibanThreshold);
afk := (AFKTime + random(1500));
idle := (idleTime + random(500));
mSpeed := mouseSpeed;
failsafe.pause;
case i of
1..100:
begin
ClarityDebug('Performing antiban. (' + ToStr(i) + ') - Small Random Mouse');
scriptStatus('Performing antiban. (' + ToStr(i) + ') - Small Random Mouse');
smallRandomMouse();
end;
101..200:
begin
ClarityDebug('Performing antiban. (' + ToStr(i) + ') - Pick Up Mouse');
scriptStatus('Performing antiban. (' + ToStr(i) + ') - Pick Up Mouse');
pickUpMouse();
end;
201..300:
begin
ClarityDebug('Performing antiban. (' + ToStr(i) + ') - Sleep and Move Mouse');
scriptStatus('Performing antiban. (' + ToStr(i) + ') - Sleep and Move Mouse');
sleepAndMoveMouse(random(2000) + 500);
end;
301..400:
begin
ClarityDebug('Performing antiban. (' + ToStr(i) + ') - Idling for ' + toStr(idle) + 'ms');
scriptStatus('Performing antiban. (' + ToStr(i) + ') - Idling for ' + toStr(idle) + 'ms');
case i of
301..350:
begin
mouseOffClient(OFF_CLIENT_RANDOM);
wait(idle);
end;
351..400: sleepAndMoveMouse(idle + 500);
end;
end;
401..440:
begin
ClarityDebug('Performing antiban. (' + ToStr(i) + ') - Hover Skill');
scriptStatus('Performing antiban. (' + ToStr(i) + ') - Hover Skill');
if not gameTabs.isTabActive(TAB_BACKPACK) then
exit;
hoverSkill(SKILL_RUNECRAFTING);
sleepAndMoveMouse(random(50, 450));
end;
441..450:
begin
ClarityDebug('Performing antiban. (' + ToStr(i) + ') - AFKing for ' + toStr(afk) + 'ms');
scriptStatus('Performing antiban. (' + ToStr(i) + ') - AFKing for ' + toStr(afk) + 'ms');
mouseOffClient(OFF_CLIENT_RANDOM);
wait(afk);
mouseSpeed := mspeed;
ClarityDebug('New mouse speed - ' + toStr(mspeed));
scriptStatus('New mouse speed - ' + toStr(mspeed));
recalcAB;
end;
451..470:
begin
ClarityDebug('Performing antiban. (' + ToStr(i) + ') - New mouse speed of ' + toStr(mspeed));
scriptStatus('Performing antiban. (' + ToStr(i) + ') - New mouse speed of ' + toStr(mspeed));
mouseSpeed := mspeed;
end;
471..antibanThreshold:
begin
failsafe.start;
exit;
end;
end;
failsafe.start;
end;

@Justin also might like this thread.

Hoodz

2014-10-09 09:07:21

From: Clarity
Nice first script! For antiban, if you are taking the AFK approach, I would recommend subtly changing mouse speeds after coming back from idling breaks. It is not very humanly realistic to maintain the same mouse speed at all times!


i disagree, i would never move the mouse slower myself. BUT your reaction times will be slower

Clarity

2014-10-09 09:14:30

From: hoodz
i disagree, i would never move the mouse slower myself. BUT your reaction times will be slower

I would think that being sleepy vs. energized, or in a different state of mind in general would indeed not only affect your reaction times but also impact your speed on average. From what I can tell the mousespeed variable is an average because it is altered constantly in functions like _humanWindMouse?

But to each their own :)

Hoodz

2014-10-09 09:40:59

From: Clarity
I would think that being sleepy vs. energized, or in a different state of mind in general would indeed not only affect your reaction times but also impact your speed on average. From what I can tell the mousespeed variable is an average because it is altered constantly in functions like _humanWindMouse?

But to each their own :)


i don't think changing the mouse speed will hurt ;)

the bank

2014-10-09 14:17:28

Will check it out tonight and post a report!

Justin

2014-10-09 17:43:35

From: Clarity
…


Thanks Clarity, I'll modify your anti-ban and add it into my personal script :)

arclight

2014-10-09 19:00:11

I messed around a bit with the idea you presented of variable mouse speed. I think it should really vary during the entire gameplay and not just on breaks. I wrote up a function that favors going in the least used side of the max and min for the mouse. I also updated my first post with the script having it integrated. I think it looks a lot more human like with it. Hmm, would be interesting to see if I could make the mouse miss based off the current speed too, so higher mouse speeds make it miss more often than lower mouse speeds. I would need to understand a bit more about the mouse api to do that though. Blah.

Edit: I think I figured out how to implement my idea somewhat, not exactly what I wanted to do, but that can wait until I feel like implementing it in that way.

// Goal is to remain consistent, but variable
// Don't favor going too high, but also not too slow
procedure adjustMouse;
var
rateOfChange, distance : Integer;
const
MOUSE_MAX := 25;
MOUSE_MIN := 15;
begin
//mouse speed should not change that often
if(gaussRangeInt(1, 10) < 4) then
begin
if(gaussRangeInt(1,10) < 8) then
rateOfChange := gaussRangeInt(1,4)
else
rateOfChange := gaussRangeInt(5,8);
//okay, goal here is to favor the direction we are furtherest from
distance := 20 - mouseSpeed;
if(gaussRangeInt(1,20) <= 11 + distance) then
mouseSpeed := mouseSpeed + rateOfChange
else
mouseSpeed := mouseSpeed - rateOfChange;
if(mouseSpeed > MOUSE_MAX) then
mouseSpeed := MOUSE_MAX
else if (mouseSpeed < MOUSE_MIN) then
mouseSpeed := MOUSE_MIN;
end;
end;

The Mayor

2014-10-15 05:33:03

From: arclight
Hmm, would be interesting to see if I could make the mouse miss based off the current speed too, so higher mouse speeds make it miss more often than lower mouse speeds.


missMouse() already exists in SRL6. You should look at mouse.simba in C:\Simba\Includes\srl-6\lib\core


(*
missMouse
~~~~~~~~~

.. code-block:: pascal

procedure missMouse(pnt: TPoint; correct: boolean = true);

Moves the mouse, but initially misses the target point (miss area determined by dist & speed)
then if correct = true will corrects itself.

.. note::

- by Flight

Example:

.. code-block:: pascal

missMouse(point);

*)
procedure missMouse(pnt: TPoint; correct: boolean = true);
var
randSpeed: extended;
x,y,x2,y2,a,dist,mp: integer;
begin
a := mouseSpeed;
getMousePos(x, y);
dist := distance(x, y, pnt.x, pnt.y);
mp := round(dist/150);
if mp < 0 then
mp := 1;

randSpeed := (random(mouseSpeed) / 2.0 + mouseSpeed) / 10.0;
x2 := randomRange(Pnt.x-(a*mp), Pnt.x+(a*mp));
y2 := randomRange(Pnt.y-(a*mp), Pnt.y+(a*mp));
_humanWindMouse(x, y, x2, y2, MOUSE_HUMAN, 5, 10.0/randSpeed, 15.0/randSpeed, 10.0*randSpeed);
getMousePos(x, y);

if (correct) then
mouse(pnt);

mouseSpeed := a;
end;

arclight

2014-10-15 06:18:59

From: The Mayor
missMouse() already exists in SRL6. You should look at mouse.simba in C:\Simba\Includes\srl-6\lib\core


(*
missMouse
~~~~~~~~~

.. code-block:: pascal

procedure missMouse(pnt: TPoint; correct: boolean = true);

Moves the mouse, but initially misses the target point (miss area determined by dist & speed)
then if correct = true will corrects itself.

.. note::

- by Flight

Example:

.. code-block:: pascal

missMouse(point);

*)
procedure missMouse(pnt: TPoint; correct: boolean = true);
var
randSpeed: extended;
x,y,x2,y2,a,dist,mp: integer;
begin
a := mouseSpeed;
getMousePos(x, y);
dist := distance(x, y, pnt.x, pnt.y);
mp := round(dist/150);
if mp < 0 then
mp := 1;

randSpeed := (random(mouseSpeed) / 2.0 + mouseSpeed) / 10.0;
x2 := randomRange(Pnt.x-(a*mp), Pnt.x+(a*mp));
y2 := randomRange(Pnt.y-(a*mp), Pnt.y+(a*mp));
_humanWindMouse(x, y, x2, y2, MOUSE_HUMAN, 5, 10.0/randSpeed, 15.0/randSpeed, 10.0*randSpeed);
getMousePos(x, y);

if (correct) then
mouse(pnt);

mouseSpeed := a;
end;


Ya, I use missMouse in my code. I was talking about using the current mouse speed to influence whether that gets called or not and, if it gets called, to say if it is going to recorrect itself or not. From the idea that the faster you move your mouse, the greater the chance is you are going to miss, I think I only implement the latter part of my idea though.