Hi, I have managed making a rather good Find & CutTree function.
I made this thread to show you the function, duh!, but also to thank my good friend, Clay (pwnaz0r), to help and explain me TPAtoATPA and MiddleTPA, thanks buddy!!
I'm making a PowerCutter, that I will release when it's ready (I just started on it). I still have some problem (not with this function).
I want to make a functino that will return true if the tree is gone.
Since trees are positioned in grass (or at least nearby) I can't make a function that will look for the color in a box around the spot we've found the tree, because it can be grass..
Any suggestions? Plz post!
However, here is the function:
SCAR Code:
program new;
{.include srl/srl.scar}
function CutTree(var x, y, color: integer): boolean;
var
TreeColor: integer;
i: integer;
tPoints: TPointArray;
stPoints: TPointArrayArray;
begin
x:= MSCX;
y:= MSCY;
FindColorsSpiralTolerance(x, y, tPoints, 2047287, MSX1, MSY1, MSX2, MSY2, 10);
stPoints:= TPAtoATPAEx(tPoints, 100, 30);
for i:= 0 to GetArrayLength(stPoints) - 1 do
tPoints[i]:= MiddleTPA(stPoints[i])
for i:= 0 to GetArrayLength(tPoints) do
begin
MMouse(tPoints[i].x, tPoints[i].y, 2, 2);
if IsUpTextMulti('Chop', 'own', 'ree') then
begin
result:= true;
GetMousePos(x, y);
Color:= GetColor(x, y);
if random(10) < 7 then
begin
Mouse(x, y, 0, 0, True)
Wait(200+random(100));
end else
begin
Mouse(x, y, 0, 0, False);
ChooseOption('Chop');
Wait(200+random(100));
end;
exit;
end;
end;
end;
procedure Test;
var
Mark: longint;
x, y, UpdatedTreeColor: integer;
begin
MarkTime(Mark);
if CutTree(x, y, UpdatedTreeColor) then
begin
Writeln(inttostr(TimeFromMark(Mark))+'ms.');
Writeln('Tree Found at '+inttostr(x)+'x, '+inttostr(y)+'y.');
Writeln('Updated TreeColor: '+inttostr(UpdatedTreeColor));
end else
begin
Writeln('Tree not found!');
end;
end;
begin
setupsrl;
Test;
end.
Oh, a last note, it finds it aprox 800-1200 ms (including, w 200ms wait, uptextmulti finding, etc..)
-Tsn.