SRL Archive - First Scripts

Simple Coal Powerminer


samuri51

2012-05-28 04:04:26

It does exactly what the title says it does, power mines coal :D. Try it out and let me know what you think when you get the chance.

how to use:
1. Set your character up in front of a bunch of coal rocks (tested working at mining guild).

note: if using at the mining guild set your camera to the highest angle facing south otherwise you will eventually mine your way to the gate and the screen won't be able to find anymore rocks.

2. Copy and paste the script into simba

3. Hit run :D

Bug report: please post all your bugs so that I can work on them, although I'll probably need some help ;)

todo list:
1. add multi path walking
2. add banking

program simplecoalpowerminer;
{$DEFINE SMART}
{$i srl/srl.simba}

// If using this in the miners guild a high angle looking South is recommended.

var
StartingXp, OriginalXp, CoalMined, TimeOut: Integer;


const
(********************Begin Setup*********************************)

SRLStats_Username = ''; // your SRL stats username
SRLStats_password = ''; // your srl stats password
Version = '1.0';
CustomMouseSpeed = 15;

procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
Players[0].Name := ''; // Username?
Players[0].Pass := ''; // Password?
Players[0].Nick := ''; // 3 letters of your username (not the first letter)
Players[0].Active := True;
end;
(***************************End Setup******************************)

{Begin: Modified from MKHerbCleaner2.7 by GetDropped69}
procedure Antiban;
begin
case Random(1500) of
0..25:
begin
HoverSkill('Mining',false);
MouseBox(645,169,670,203,1);
end;
100..150:
begin
Sleep(1500+Random(1500));
end;
350..400:
begin
GameTab(tab_Friends);
Sleep(80+Random(225));
MouseBox(644,168,669,202,1);
end;
600..650:
begin
Mouse(260,160,5,6,false);
Sleep(200+Random(100));
MMouse(190,276,10,30);
Sleep(250+Random(100));
MMouse(495,45,50,50);
end;
800..850:
begin
ToggleMoneyPouch(true);
Sleep(200+Random(250));
Mouse(532,98,10,10,false);
WaitOptionMulti(['Examine money','money pouch'],200);
Sleep(500+Random(200));
ToggleMoneyPouch(false);
end;
900..950:
begin
SleepAndMoveMouse(2000+Random(2000));
end;
end;
end;
{End: Modified from MKHerbCleaner2.7 by GetDropped69}

function XPPerHour(Runtime,Gained:Extended):Extended;
begin
Result:=((Gained * 3600) / (Runtime / 1000));
end;

Function GainedXP:Extended;
begin
Result:= GetXPBarTotal - StartingXp;
end;

procedure ProgressReport;
var
TimeGone, CurrentXp, XpGain, CoalInInv: Integer;
begin
ClearDebug;
TimeGone := (GetTimeRunning/1000);
if(TimeGone = 0) then
exit;
CoalInInv := InvCount
CurrentXp := GetXPBar(1);
originalxp := GetXPBarTotal;
XpGain := (currentxp-originalxp);
begin
writeln('****************************************************************************');
writeln('****************************************************************************');
writeln('****************************************************************************');
writeln('****************************************************************************');
writeln('*Simple Coal Powerminer Version One*');
writeln('*We have mined: ' +IntToStr(CoalMined) + 'coal*');
writeln('*We have gained: ' + floattostr(GainedXp) + ' xp');
Writeln('Thats ' + FloatToStr(XpPerHour(GetTimeRunning,GainedXp))+ ' Xp Per Hour*');
writeln('*Total Running Time: ' + IntToStr(GetTimeRunning/60000) + ' Minutes*');
writeln('*****************************************************************************');
writeln('*****************************************************************************');
writeln('*****************************************************************************');
writeln('*****************************************************************************');
end;
end;

function AutoCoalColor: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL, R, G, B: Integer;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(1.20, 0.19);

if not (FindColorsTolerance(arP, 2237475, MSX1, MSY1, MSX2, MSY2, 7)) then
begin
Writeln('Failed to find the color, no result.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

arC := GetColors(arP);
ClearSameIntegers(arC);
arL := High(arC);

for i := 0 to arL do
begin
ColorToRGB(arC[i], R, G, B);

if (R >= 17) and (R <= 52) and (G >= 17) and (G <= 54) and (B >= 16) and (B <= 52) then
begin
Result := arC[i];
Writeln('AutoColor = ' + IntToStr(arC[i]));
Break;
end;
end;

ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);

if (i = arL + 1) then
Writeln('AutoColor failed in finding the color.');
end;

Function MineCoal :Boolean;
var
a: Integer;
TPA : TPointArray;
ATPA : T2DPointArray;
MP : TPoint;
tmpCTS : Integer;
PlusOne: Integer;
counter: Integer;
begin
FindNormalRandoms;
PlusOne := InvCount+1;
if(not(LoggedIn))then Exit;
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(1.39, 0.10); //Hue and Sat here

FindColorsTolerance(TPA, AutoCoalColor, MSX1, MSY1, MSX2, MSY2, 7); //Color and tolerance here
SortTPAFrom(TPA, Point(MSCX, MSCY));
ATPA := TPAtoATPAEx(TPA, 25, 25);
SortATPAFromSize(ATPA, 500, true);

for a := 0 to High(ATPA) do
begin
MP := MiddleTPA(ATPA[a]);
MMouse(MP.X, MP.Y, 4, 4);
if WaitUptext('Mine Coal', 2000) then //Uptext of mining the rock
begin
FindNormalRandoms;
ClickMouse2(mouse_left);
Result := True;
flag;
marktime(counter);
repeat
FindNormalRandoms;
antiban;
wait(1000);
if invcount = plusone then
writeln('you add an ore of coal to your inventory');
until (invcount=PlusOne) or (TimeFromMark(counter) > 8000);
Break;
end;
end;
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
end;

procedure FailSafe;
var
Time, MaxTime: Integer;
begin
Time := 0;
maxTime := (RandomRange(10000, 20000));

MarkTime(Time)

repeat
if (TimeFromMark(Time) >= MaxTime) then
logout;
TerminateScript;
until(False);
end;

procedure Dropcoal;
Var
I : Integer;
B : TBox;
begin
FindNormalRandoms;
for i := 1 to 28 do
begin
If(ExistsItem(I))then
Begin
FindNormalRandoms;
B := InvBox(I);
If(CountColorTolerance(autocoalcolor, B.x1, B.y1, B.x2, B.y2, 20) > 50)then
Begin
MouseItem(I, mouse_Right);
WaitOption('rop', 100+Random(500));
FindNormalRandoms;
End;
End;
End;
End;

//credits: A big thanks to all the guys in the help section that helped
//me get this script into a working order.

begin
SetupSRL;
DeclarePlayers;
ActivateClient;
if not (LoggedIn) then
LogInPlayer;
if not(IsXPBarOpen) then
ToggleXPBar(True);
StartingXp := GetXPBarTotal;
MarkTime(TimeOut);
MouseSpeed := CustomMouseSpeed;
repeat
FindNormalRandoms;
marktime(TimeOut);
if (TimeFromMark(TimeOut) >30000) then
begin
FailSafe;
end;
MineCoal;
CoalMined := CoalMined + 1;
Dropcoal;
progressreport;
until(false);
end.

credits: A big thanks to all the guys in the help section :D, couldn't have finished this without you guys.

YoHoJo

2012-05-28 04:07:07

Nice nice :D not a bad first script at all congratulations!
I see some YoHoJo-esque stuff in there :D!

if invcount = plusone then

Aww yeah, PLUSONE!

samuri51

2012-05-28 04:11:38

yeah haha the first thing I did to teach myself was look over your tutorials :)

CephaXz

2012-05-28 04:19:46

Oh yeah! Part of my function is inside :p

Scripts looks nice. Keep it up :D

Abusch2013

2012-05-28 14:04:16

I should be making WC by Friday I'll give this a go.

Yet to find any working power miners for mining guild :( Hope this will do the trick

samuri51

2012-05-28 19:24:10

if you run into any problems please lemme know and i'll do my best to fix them C:

samuri51

2012-06-02 09:46:22

gonna add walking/ banking to this, stay tuned c:.

Twisterz

2012-06-03 11:45:01

I mean this in the nicest way, but who in their right mind would powermine coal???

samuri51

2012-06-03 22:27:52

lol it was meant more as a test script then for practical usage, there's already a million iron powerminers on here, i'll be adding banking to it though

putonajonny

2012-06-04 12:20:57

I think checking for randoms twice per ore dropped is a bit excessive but good script :)