SRL Archive - OSR Help

Rock finding


blother

2012-06-02 14:45:48

I am working on a clay mining script and it has progressed pretty far. I have gotten it to where it can mine a load bank and repeat with really no more problems. Besides adding things like antiban and more failsafes, I am looking to to make the script work better in general. Currently, I am looking to make the mining process smoother and quicker.

function ClayColor: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.03, 3.63);

FindColorsSpiralTolerance(MSCX, MSCY, arP, 8239579, MSX1, MSY1, MSX2, MSY2, 11);
if (Length(arP) = 0) 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
ColorToXYZ(arC[i], X, Y, Z);

if (X >= 30.46) and (X <= 69.28) and (Y >= 31.67) and (Y <= 70.48) and (Z >= 19.91) and (Z <= 35.95) 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;

Procedure FindClay;
var
x, y: Integer;

begin
if not LoggedIn then Exit;
Randoms;
if FindObjTPA(x, y, ClayColor, 5, 1, 25, 25, 5, ['lay rocks', 'y r', 'ine clay']) then
begin
Mouse(x, y, 7, 7, True);
Writeln('Found clay.');
end else
Writeln('Clay not found.')
end;


Procedure MineClay;
var
PlayerBox: TBox;

begin
if not LoggedIn then Exit;
Randoms;
PlayerBox := IntToBox(245, 130, 285, 195);
if AveragePixelShift(PlayerBox, 300, 1000) < 250 then
FindClay;
end;

That is everything I am using for mining so far. I just added ACA today and it is finding the color almost every time, but it finds it a bit slower. What could I change that would help speed up the mining process without sacrificing any accuracy (possibly increasing accuracy)?

Another thing I am looking to do is instead of checking the player for pixel shifting to determine when to try to mine again how can I use the color in the rock to determine that? For example, my idea of what would happen is the scripts would find a rock then draw a box around that, and once the clay color is no longer in the box it would find another. Is that something along the lines of what I could possibly do?

I would appreciate if people don't post the exact code of how to do things, unless it is just a better function/procedure in SRL. I would rather be pointed to a tutorial or another source that could help me learn to develop the code on my own. Thanks.

Runaway

2012-06-02 14:53:20

Hi there,

I had this exact struggle when I was creating my mining script. I started with a Pixelshift check, but that just didn't cut it. I ended up setting my public chat to hide and looking at the game text changes to determine when a rock was mined.

The problem with using color is that you find it and click it; but if you have to walk to the rock then you cannot use the TPA bounds to keep track of the rock colors anymore. You're forced to then re-find it after you've stopped moving which could result in finding the wrong rock. And I don't think I need to explain what kind of issues that could cause :p

Good luck with whatever you end up doing.

litoris

2012-06-02 14:58:31

From: blother
Currently, I am looking to make the mining process smoother and quicker.

I think runaway(might be someone else) recently released a crafting script at the crafting guild, and it mines clay. You can check the way he created his procedure, ad try to understand how to make it faster.

From: blother

Another thing I am looking to do is instead of checking the player for pixel shifting to determine when to try to mine again how can I use the color in the rock to determine that? For example, my idea of what would happen is the scripts would find a rock then draw a box around that, and once the clay color is no longer in the box it would find another. Is that something along the lines of what I could possibly do?

I'm pretty sure MSI does that, after clicking the rock, when your screen becomes still(ie. you are next to the rock) it searches for the ore color around you, creates a box where the ore color is concentrated and waits until the color is gone AND uses pixelshift just in case. (at least that's how I see it does it :P)You could try to check the mining file of MSI, though it might be hard to figure out since MSI is scripted very differently.

Sin

2012-06-02 14:59:25

Just do what I did, wait for the xp to increase.

Based Lord

2012-06-02 15:19:19

What do you do when someone else gets the rock? :/

Runaway

2012-06-02 15:22:03

From: Based Lord
What do you do when someone else gets the rock? :/


Hop worlds :p

blother

2012-06-02 19:10:41

From: Shay
Just do what I did, wait for the xp to increase.


That is probably a good idea except for what others have said about not getting the ore. ACA seems to have slowed it down, but the script is more consistent with it. Could the box be drawn after walking to the rock? Also, would this process make the script slower?

Runaway

2012-06-02 19:18:57

From: blother
That is probably a good idea except for what others have said about not getting the ore. ACA seems to have slowed it down, but the script is more consistent with it. Could the box be drawn after walking to the rock? Also, would this process make the script slower?


It wouldn't make it slower since waiting to mine the ore is simply that; waiting. Make sure you factor in the chance that the color you're monitoring is not the color of the rock you just clicked. You should use a chat message/xp check failsafe (or another) to make sure you're not waiting for the wrong rock.