SRL Archive - Help and Support

Detecting when rock is mined...


Negaal

2007-11-24 08:47:56

Hello, I need a good idea how detect is rock mined or not…

I'm still too newbie to understand wizzup's followrock and TPointArray stuff…

So, i'm waiting for an idea or example what i can use…


My mining procedure looks like that:


//=== Idea by Sumilion ===//

function Getfreeinvspot : integer;
begin
for InvSpot := 1 to 28 do
if not(ExistsItem(InvSpot))then
begin
result := invspot;
exit;
end;
end;

//========================//





procedure Mining;
var minestart, i, slot : integer;
breakout : boolean;
begin
repeat

if (orenotfound = 20) then begin logout; exit; end;
if welostpick then exit;
if not loggedin then exit;
if random(10) = 5 then Antiban;
slot := getfreeinvspot;
breakout:= false;

if (findobjcustom(a, b,['ine'], [orecolor1,orecolor2,orecolor3], 3)) and (not(GasFound(a, b))) then
begin
mouse(a, b, 0, 0, true);
marktime(minestart);
orenotfound := 0;
wait(350);
findtherandoms;
wait(500);
repeat
while (LoggedIn) and (not breakout) do
begin
for i := 0 to 7 do
begin
case i of
0 : if FindTheRandoms then
begin
writeln('0');
breakout:= true;
Break;
end;
1 : flag;
2 : if Gas then
begin
breakout:= true;
Break;
end;
3 : if(ExistsItem(slot))then
begin
writeln('3');
breakout:= true;
Break;
end;
4 : FindPick;
5 : if(TimeFromMark(MineStart) > Rockwait) then
begin
writeln('5');
breakout:= true;
Break;
end;
6 : if (FindBlackChatMessage('manage')) or (FindBlackChatMessage('no ore')) then
begin
writeln('6');
breakout:= true;
Break;
end;
7 : Talk;
end;
Wait(1);
end;
end;
if breakout then break;
until(false);
end else
orenotfound:= orenotfound + 1;
until (InvFull);
drop;
loads:= loads + 1;
loadsdone := loadsdone + 1;
end;


EDIT: From debug box:
(here you can understand why did it break out of "WorkUntilMined" loop


5
3
3
5
3
6
5
5
5
3
5
3
5
3
5
5
3
5
5
5
3
5
5
3
6
3
6
5
3
6
3
3
6
3
3
6
3
3
6
5
5
3
6
5
5
3
5
3
6
3
3
6
3
6
3
6
5
3
3

JuKKa

2007-11-24 08:51:34

InvAmount := InvCount;
Repeat
Wait(100);
//antiban
//antirandom
Until(ExistsItem(InvAmount+1))Or(Not Loggedin);

For a start add more fail safes etc.


Edit:

In my guild miner this is how i do it:


Repeat
Wait(50);

If(Not RockColorExists(Dx, Dy, MiningColor, MiningTol))Then
Break; //This will check if the current ore exists..

//Gas finding deleted...

//Antirandom stuff deleted..

Until( TimeFromMark(MineTimer)>10000) Or (Not Loggedin);

you will also need:

If(FollowColor(Dx, Dy, MiningColor, MiningTol))Then
Begin
Result:= True;
Wait(500+Random(500));
End;

Which is this:


Function FollowColor(Var X, Y: Integer; Color, Tol: Integer): Boolean;
Var
NoFlag, Fail: Integer;
Begin
MarkTime ( Fail );
If(FlagPresent)Then
Begin
Repeat
If(TimeFromMark( Fail ) > 5000 )Then
Begin
Result:= False;
Break;
End;
Wait(20);
Result:= FindColorSpiralTolerance(X, Y, Color, X-30, Y-30, X+30, Y+30, Tol);
Until(Not FlagPresent) Or (Not Loggedin) Or (Not Result);

If(Result)Then
Begin
MarkTime( NoFlag );
Repeat
Wait(20);
Result:= FindColorSpiralTolerance(X, Y, Color, X-30, Y-30, X+30, Y+30, Tol);
Until(TimeFromMark(NoFlag)>500) Or (Not Loggedin) Or (Not Result);
End;

End Else Result:= True;
End;

this is my simple RockColorExists

Function RockColorExists(Var Dx, Dy, Color, Tolerance: Integer): Boolean;
Begin
Result:= FindColorSpiralTolerance(DX, DY, Color, Dx-10, Dy-10, Dx+10, Dy+10, Tolerance);
End;

Edit2:

This might be a little messy just pm it and ill plant it to ur script ;)

Pentti

2007-11-24 08:55:02

…Chat text that appears when you have mined ore.

Wizzup?

2007-11-24 08:55:25

First thing you should use is the text.
You manage to mine …

Second, if you keep track of the rock, with a simple findspiralcolortolerance in a loop or in a different way, add a if not findcolorspiraltolerance then rockgone := true;

If you don't track a rock, you can't check for gas really.
I'll try and see if I can speed up my GasFinder for MS. ;)

Negaal

2007-11-24 09:15:59

…Chat text that appears when you have mined ore.

First thing you should use is the text.
You manage to mine …


It was in script if you didn't noticed

Second, if you keep track of the rock, with a simple findspiralcolortolerance in a loop or in a different way, add a if not findcolorspiraltolerance then rockgone := true;


That was my 1st idea:

function RockGone(rx, ry: Integer): Boolean;
begin
Result := not FindColorSpiralTolerance(rx, ry, OreColor, rx - 10, ry - 10, rx + 10, ry + 10, 10);
end;

But when i click on rock, then character will move and there will not be same rock near x,y…I need to make some simple follow rock procedure, of course with your help guys…:p

Rikje

2007-11-24 09:45:31

JuKKa already posted a example ;)
follow rock from sb100, maby you can get some tips out of it:
(hes easy to understand imo, better then all the tpa shit :p)

{ ---------------------------------------------------------------------------- ]
[ >> Function UpdateCoords(Var ax, ay: Integer; TheColor: Integer): Boolean; ]
[ >> Updates Color Coords When you are Moving after a Click ]
[ >> Huge Thanks to Sumillion and Lorax for the Function - modified by Star ]
[ ---------------------------------------------------------------------------- }

Function UpdateCoords(Var cx, cy: Integer; ax, ay, TheColor, Tol: Integer): Boolean;
var
//ax, ay,
Counter: Integer;
Begin
//GetMousePos(ax, ay);
If (ax < 20) then ax := 20; If (ay < 20) then ay := 20;
While (FlagPresent) and (FindColorSpiralTolerance(cx, cy, TheColor, ax-20, ay-20, ax+20, ay+20, Tol)) do
begin
ax := cx; ay := cy;
Wait(10);
end;
If (ax < 10) then ax := 10; If (ay < 10) then ay := 10;
While (FindColorSpiralTolerance(cx, cy, TheColor, ax-10, ay-10, ax+10, ay+10, Tol)) and (Counter < 100) do
begin
ax := cx; ay := cy;
Counter := Counter + 1;
Wait(10);
end;
Result := FindColorSpiralTolerance(cx, cy, TheColor, ax-10, ay-10, ax+10, ay+10, Tol);
end;

Negaal

2007-11-24 10:30:40

From: rikjess
JuKKa already posted a example ;)
follow rock from sb100, maby you can get some tips out of it:
(hes easy to understand imo, better then all the tpa shit :p)

{ ---------------------------------------------------------------------------- ]
[ >> Function UpdateCoords(Var ax, ay: Integer; TheColor: Integer): Boolean; ]
[ >> Updates Color Coords When you are Moving after a Click ]
[ >> Huge Thanks to Sumillion and Lorax for the Function - modified by Star ]
[ ---------------------------------------------------------------------------- }

Function UpdateCoords(Var cx, cy: Integer; ax, ay, TheColor, Tol: Integer): Boolean;
var
//ax, ay,
Counter: Integer;
Begin
//GetMousePos(ax, ay);
If (ax < 20) then ax := 20; If (ay < 20) then ay := 20;
While (FlagPresent) and (FindColorSpiralTolerance(cx, cy, TheColor, ax-20, ay-20, ax+20, ay+20, Tol)) do
begin
ax := cx; ay := cy;
Wait(10);
end;
If (ax < 10) then ax := 10; If (ay < 10) then ay := 10;
While (FindColorSpiralTolerance(cx, cy, TheColor, ax-10, ay-10, ax+10, ay+10, Tol)) and (Counter < 100) do
begin
ax := cx; ay := cy;
Counter := Counter + 1;
Wait(10);
end;
Result := FindColorSpiralTolerance(cx, cy, TheColor, ax-10, ay-10, ax+10, ay+10, Tol);
end;



hmmm…
[Runtime Error] : Exception: Canvas does not allow drawing in line 127 in script C:\Program Files\SCAR 3.12\includes\SRL\srl/Skill\Mining.scar

<-It pops out mining.scar…

No idea, i remember Tara's chickenkiller 2.37 had same problem, and btw im on 3.12c…


And my mining looks now like that…

procedure Mining;
var minestart, i, slot : integer;
breakout, coordsupdated : boolean;
begin
repeat

if (orenotfound = 20) then begin logout; exit; end;
if welostpick then exit;
if not loggedin then exit;
if random(10) = 5 then Antiban;
slot := getfreeinvspot;
breakout:= false;

if (findobjcustom(a, b,['ine'], [orecolor1,orecolor2,orecolor3], 3)) and (not(GasFound(a, b))) then
begin
mouse(a, b, 0, 0, true);
marktime(minestart);
orenotfound := 0;
wait(200);
findtherandoms;
repeat
while (LoggedIn) and (not breakout) do
begin
for i := 0 to 9 do
begin
case i of
0 : if FindTheRandoms then
begin
writeln('0');
breakout:= true;
Break;
end;
1 : wait(50);////////
2 : if UpdateCoords(a, b, 22, 20, orecolor1, 3) then
begin
coordsupdated:= true;
status('Rock followed - True')
end else
begin
coordsupdated:= false;
status('Rock followed - True')
end;

3 : if Gas then
begin
breakout:= true;
Break;
end;
4 : if(ExistsItem(slot))then
begin
writeln('4');
breakout:= true;
Break;
end;
5 : FindPick;
6 : if(TimeFromMark(MineStart) > Rockwait) then
begin
writeln('6');
breakout:= true;
Break;
end;
7 : if (FindBlackChatMessage('manage')) or (FindBlackChatMessage('no ore')) then
begin
writeln('7');
breakout:= true;
Break;
end;
8 : Talk;
9 : if CoordsUpdated then
begin
if RockGone(a, b) then
begin
writeln('9');
breakout:= true;
Break;
end;
end;
end;
Wait(1);
end;
end;
if breakout then break;
until(false);
end else
orenotfound:= orenotfound + 1;
until (InvFull);
drop;
loads:= loads + 1;
loadsdone := loadsdone + 1;
end;
So whats wrong now…

R0b0t1

2007-11-24 12:04:25

I think 3.12c had some problems with it that were fixed in 3.13.


Anywho, all of those ideas should work. I really don't understand how they aren't unless your doing something really wrong. Try asking someone to make a mask or something for you (for finding the text, etc.)

mat_de_b

2007-11-24 13:57:13

Aslong as you follow the rock you can do a GetColor and store it to an int and then keep looking for that colour… or keep following and do a check to see if you've stopped moving and once you have keep doing a get color until it doesnt equal the iron color…

Negaal

2007-11-24 15:30:35

From: mat_de_b
Aslong as you follow the rock you can do a GetColor and store it to an int and then keep looking for that colour… or keep following and do a check to see if you've stopped moving and once you have keep doing a get color until it doesnt equal the iron color…


if i'll use getcolor then it will find other rocks too…right…?
And btw i got jukka's followcolor half working, sometimes it will follow, sometimes not…i'll be thankful if anyone posts examples like rikjess or jukka.

Thx