SRL Archive - Test corner

ok, MY mining procs


The Claw

2007-09-30 22:26:16

everyone else is posting so why not me. :p

these are for lumbridge west swamp, although they could easily be changed to use anywhere. BetterRocks is a bit sloppy, admittedly. But its extremely fast, 90% of the time it beats the legits. As soon as a higher level rock than the one you are currently mining appears, it mines it. I mean, if you set Players[0].Strings[0] to addy, and it was mining mith, as soon as the addy appeared it would switch over.

procedure SetOres;
begin
case LowerCase(Players[CurrentPlayer].Strings[0]) of
'addy' : begin
OreColor1 := AddyRock;
OreColor2 := MithRock;
OreColor3 := CoalRock;
OreString1:= 'addy';
OreString2:= 'mith';
OreString3:= 'coal';
end;
'mith' : begin
OreColor1 := MithRock;
OreColor2 := CoalRock;
OreColor3 := CoalRock;
OreString1:= 'mith';
OreString2:= 'coal';
OreString3:= 'coal';
end;
'coal' : begin
OreColor1 := CoalRock;
OreColor2 := CoalRock;
OreColor3 := CoalRock;
OreString1:= 'coal';
OreString2:= 'coal';
OreString3:= 'coal';
end;
end;
end;

procedure ChangeOres;
begin
if OreCounter > 3 then OreCounter := 1;
case OreCounter of
1: begin
OreColor := OreColor1;
OreString:= OreString1;
end;
2: begin
OreColor := OreColor2;
OreString:= OreString2;
end;
3: begin
OreColor := OreColor3;
OreString:= OreString3;
end;
end;
end;

procedure ColorValues;
begin
case LowerCase(OreString) of
'addy': begin
OreTol := 7;
CTS := 2;
ArrayLengthNeeded := 5;
end;
'mith': begin
OreTol := 9;
CTS := 2;
ArrayLengthNeeded := 5;
end;
'coal': begin
OreTol := 8;
CTS := 2;
ArrayLengthNeeded := 5;
end;
end;
end;

function ClickTheRock(var x, y: Integer): Boolean;
begin
if not LoggedIn then Exit;
MMouse(x, y, 5, 5);
if IsUpText('ine') then
begin
Mouse(x, y, 0, 0, true);
Result := True;
end else
begin
Mouse(x, y, 0, 0, False);
if ChooseOption('ine') then
begin
Result := True;
end else
begin
ChooseOption('ance');
Result := False;
end;
end;
end;

function FollowRock(var x, y: Integer): Boolean;
var TempCTS: Integer;
begin
if not LoggedIn then Exit;
if (x - 30) < 0 then x := MSCX - 30;
if (y - 30) < 0 then y := MSCY - 30;
TempCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(CTS);
Result := FindColorSpiralTolerance(x, y, OreColor, x - 15, y - 15, x + 15, y + 15, OreTol);
if not Result then
begin
x:= MSCX;
y:= MSCY;
Status('Rock not followed');
end else Status('Rock followed');
ColorToleranceSpeed(TempCTS);
end;

function FindRockCenter(var x, y: Integer): Boolean;
var
RockCol, I: Integer;
OrePoints, RockPoint, Rocks: TPointArray;
begin
if not LoggedIn then Exit;
RockCol := GetColor(x, y);
ColorToleranceSpeed(CTS);
FindColorsTolerance(OrePoints, OreColor, x - 15, y - 15, x + 15, y + 15, OreTol);
ColorToleranceSpeed(2);
FindColorsTolerance(RockPoint, RockRock, x - 15, y - 15, x + 15, y + 15, 8);
if Length(RockPoint) > 50 then
begin
Rocks := CombineTPA(OrePoints, RockPoint);
if CombineFailed then
begin
Result := False;
CombineFailed := False;
Exit;
end;
x := 0;
y := 0;
for I := 0 to GetArrayLength(Rocks) - 1 do
begin
x := x + Rocks[I].X;
y := y + Rocks[I].Y;
end;
if GetArrayLength(Rocks) <> 0 then
begin
x := Round(x div GetArrayLength(Rocks));
y := Round(y div GetArrayLength(Rocks));
Result := True;
//Writeln(IntToStr(x) + ', ' + IntToStr(y));
end;
end else
Writeln('Normal colour length was too short.');
ColorToleranceSpeed(1);
end;

function FindRock(var x, y: Integer; Color: Integer): Boolean;
var
RockPoints: TPointArray;
TempX, TempY: Integer;
begin
if not LoggedIn then Exit;
Gaz := False;
ColorToleranceSpeed(2);
if FindColorSpiralTolerance(x, y, Color, MSX1, MSY1, MSX2, MSY2, OreTol) then
begin
if FindColorSpiralTolerance(x, y, RockRock, x - 10, y - 10, x + 10, y + 10, 8) then
begin
FindColorsSpiralTolerance(x, y, RockPoints, Color, x - 20, y - 20, x + 20, y + 20, OreTol);
Writeln(IntToStr(GetArrayLength(RockPoints)));
if GetArrayLength(RockPoints) > ArrayLengthNeeded then
begin
if FindRockCenter(x, y) then
begin
if GasFound(x, y - 30) then
begin
Result := False;
SaveScreenshot(ScriptPath + 'Found gasA ' + TimeRunning + '.bmp');
HandleGas;
Gaz := True;
Exit;
end;
Result := True;
ColorToleranceSpeed(1);
Exit;
end;
end;
end;
end;
x := MSCX;
y := MSCY;
Result := False;
ColorToleranceSpeed(1);
//Writeln('Took ' + IntToStr(TimeFromMark(RockFinding)) + ' ms to fail finding the rock.');
end;

procedure WaitForRock(var x, y: Integer);
var
FirstTime, LastTime, SingleRock: Integer;
begin
if not LoggedIn then Exit;
MarkTime(SingleRock);
MarkTime(Idling);
MarkTime(Idling2);
Writeln('Mining rock...');
FirstTime := GetSystemTime;
repeat
if not LoggedIn then Break;
if InvFull then Break;
if TimeFromMark(SingleRock) > Players[CurrentPlayer].Integers[0] * 1000 then Break;
FindRandoms;
if My - 30 < 0 then Gy := MSCY - 30 else Gy := My;
Gx := Mx;
if GasFound(Gx, Gy - 30) then Break;
FindPick;
Idle(Idling, Idling2);
Wait(250);
until not FollowRock(x, y);
LastTime := GetSystemTime;
Writeln('Mining took ' + IntToStr(LastTime - FirstTime) + ' ms.');
MarkTime(StandingStill);
end;

function BetterRocks(var x, y: Integer): Boolean;
begin
case LowerCase(Players[CurrentPlayer].Strings[0]) of
'addy': begin
OreTol := 8;
if FindRock(x, y, AddyRock) then
begin
Result := True;
OreCounter := 1;
Exit;
end;
if FindRock(x, y, MithRock) then
begin
Result := True;
OreCounter := 2;
Exit;
end;
if FindRock(x, y, CoalRock) then
begin
Result := True;
OreCounter := 3;
Exit;
end;
Result := False;
end;
'mith': begin
OreTol := 8;
if FindRock(x, y, MithRock) then
begin
Result := True;
OreCounter := 1;
Exit;
end;
if FindRock(x, y, CoalRock) then
begin
Result := True;
OreCounter := 2;
Exit;
end;
Result := False;
end;
'coal': begin
OreTol := 8;
if FindRock(x, y, CoalRock) then
begin
Result := True;
OreCounter := 1;
Exit;
end;
Result := False;
end;
end;
end;

procedure MineRocks;
var SingleRock, Following, RockFinding, FlagGone, x, y: Integer;
begin
if not LoggedIn then Exit;
if InvFull then Exit;
MarkTime(RockFinding);
FindRandoms;
BetterRocks(Mx, My);
ChangeOres;
ColorValues;
Writeln('Currently mining ' + OreString + '.');
MarkTime(SingleRock);
repeat
if not LoggedIn then Exit;
FindRandoms;
if (FindRock(Mx, My, OreColor)) and (Gaz = False) then
begin
Writeln('Took ' + IntToStr(TimeFromMark(RockFinding)) + ' ms to find rock successfully.');
FindRandoms;
if My - 30 < 0 then Gy := MSCY - 30 else Gy := My;
Gx := Mx;
if GasFound(Gx, Gy - 30) then Break;
if ClickTheRock(Mx, My) then
begin
MarkTime(Following);
while TimeFromMark(Following) < 7000 do
begin
if not LoggedIn then Break;
FollowRock(Mx, My);
Wait(50);
if not FlagPresent then
begin
MarkTime(FlagGone);
while TimeFromMark(FlagGone) < 1000 do
begin
if not LoggedIn then Break;
FollowRock(Mx, My);
if My - 30 < 0 then Gy := MSCY - 30 else Gy := My;
Gx := Mx;
if GasFound(Gx, Gy - 30) then HandleGas;
FindRandoms;
Wait(50);
end;
FindRockCenter(Mx, My);
Break;
end;
end;
WaitForRock(Mx, My);
end;
end else
begin
Inc(OreCounter);
Break;
end;
until TimeFromMark(SingleRock) > 1000;
if TimeFromMark(StandingStill) > 40000 then
begin
MarkTime(StandingStill);
case Random(4) of
0: Hoverskill('Random', False);
1: PickupMouse;
2: RandomGameTab;
3: if FindSymbol(x, y, 'Mining spot') then Mouse(x, y, 10, 10, true);
end;
end;
Writeln('Moving on to next rock..');
Wait(1);
end;

Any questions, please ask. It doesnt "look" as flashy as other peoples, who fill up their scripts with 100's of arrays of colours, but i bet it works faster. 100% accuracy btw, it never clicks on anything thats not a rock. and it usually completes the search in 200-400 ms, which is quicker than the time it takes humans to recognise that theres a new rock, i bet ;)

IronTeapot

2007-09-30 22:37:28

Wow, thats a very good idea. No time wasted waiting for rocks to respawn, just lvl up mining lower lvl rocks. Genious! Wish i could test it :(

The Claw

2007-09-30 23:15:45

You can, click on the lumbridge miner pic in my sig ;)

IronTeapot

2007-09-30 23:32:46

If only i had some coal miners in my army :( They're still chickening it up at the moment. Almost at 100 hour report. but then im stopping it cause the false players are getting too far behind in their stats :P But ive book marked the script for when theyre ready ;)

Santa_Clause

2007-10-01 05:00:30

I still don't understand what ColorToleranceSpeed is…

Wizzup?

2007-10-01 07:32:05

From: Santa_Clause
I still don't understand what ColorToleranceSpeed is…


ColorToleranceSpeed is a setting that changes the way SimilarColors works.

The Claw

2007-10-01 07:32:55

From: Santa_Clause
I still don't understand what ColorToleranceSpeed is…


Each different speed uses different ways to search for tolerance. 2 uses hue, saturation and luminance, 1 uses something else and 0 uses something else again. Have a mess around with selecting the different speeds and trying different colours and tols, using nielsies ACA.

n3ss3s

2007-10-01 08:27:22

2: HSL
1: RGB
0: TColor

Uhh tbh if only members parcipate to the Pwnaz0r's competition, Claw has pretty nice chance of robbing pwnaz0r..

~alex~

2007-10-01 08:27:44

Thats perhaps the[/] most comprehensive mining procedure ever? Good job lol.

the scar noob

2007-10-07 16:41:52

Some cool stuff in there;)

I saw a some kind of "bug" in it:)

    if CombineFailed then
begin
Result := False;
CombineFailed := False;
Exit;

Shouldn't that be:
    if CombineFailed then
begin
Result := False;
CombineFailed := True;
Exit;
;)

However, it all looks pretty sexy:p

-Tsn.:bart: