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.