SRL Archive - SRL Archives

CutTree function


the scar noob

2007-10-15 15:25:12

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..:D

Any suggestions? Plz post! :)

However, here is the function:

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.

pwnaz0r

2007-10-15 15:27:57

thats about the time it should take for a player to click on the tree i guess.

Sumilion

2007-10-15 15:31:37

Seems like you know the wizzuplugin a bit already ;)

About the tree gone part, just try using a color to detect if its gone or not… hehe.

the scar noob

2007-10-15 15:33:49

From: Sumilion
Seems like you know the wizzuplugin a bit already ;)

About the tree gone part, just try using a color to detect if its gone or not… hehe.


Yes I did, thanks to pwnaz0r (and actually a lil bit Markus too).

Btw, color of what?? some unique color, because they are simular to the grass color..:p

-Tsn.

pwnaz0r

2007-10-15 15:38:06


function FollowColor(var x, y: integer; Color: integer; acc: extended): boolean;
var
ColorMark, tries, found: integer;
begin
if not LoggedIn then exit; tries:= 0; found:= 0;
MarkTime(ColorMark);
while FlagPresent do
begin
if (TimeFromMark(ColorMark) >= 20000)then exit;
if not LoggedIn then exit;
Inc(tries);
if FindColorSpiral(x, y, Color, x - 25, y - 25, x + 25, y + 25) then Inc(Found);
end;
result:= Acc <= (Found div Tries);
end;

the scar noob

2007-10-15 15:41:12

From: pwnaz0r

function FollowColor(var x, y: integer; Color: integer; acc: extended): boolean;
var
ColorMark, tries, found: integer;
begin
if not LoggedIn then exit; tries:= 0; found:= 0;
MarkTime(ColorMark);
while FlagPresent do
begin
if (TimeFromMark(ColorMark) >= 20000)then exit;
if not LoggedIn then exit;
Inc(tries);
if FindColorSpiral(x, y, Color, x - 25, y - 25, x + 25, y + 25) then Inc(Found);
end;
result:= Acc <= (Found div Tries);
end;

Wowah, thanks!! As color input I can use the color I gained using GetColor in my CutTree function:p

Thanks!

-Tsn.

Sumilion

2007-10-15 15:44:59

Hmm, personally I use 3631459 with a tol of 20. But really I just picked any color that seemed quite general in the tree..

the scar noob

2007-10-15 15:49:46

From: Sumilion
Hmm, personally I use 3631459 with a tol of 20. But really I just picked any color that seemed quite general in the tree..


Ok, thanks for the information, I will try;)
I'm trying pwnaz0r's function atm.

ShowerThoughts

2007-10-15 16:02:26

you hover the spot again and check for uptext :)

but nice, clay. can you explain me tah same :D

n3ss3s

2007-10-16 08:14:52

Good job!

By the way do you and hermpie speak same language?

Because I noticed that you two are about (no offense to anyone) scripters, though hermpie hasnt used wizzyplugin or FindColorsTolerance yet, so I think if atleast not to be able to do good team work, he could learn something from you ;)

the scar noob

2007-10-16 11:15:13

From: n3ss3s
Good job!

By the way do you and hermpie speak same language?

Because I noticed that you two are about (no offense to anyone) scripters, though hermpie hasnt used wizzyplugin or FindColorsTolerance yet, so I think if atleast not to be able to do good team work, he could learn something from you ;)


Yes we do speak the same language :)
And yes, I think he can learn something from m e, but.. I'm not really good in teaching people stuff.
However thanks for your reply and, yes, I'm on my way to learn m ore things, use them and make scripts again.
I have gain some knowledge scripting since I'm here (already for a year (h) ) and I want to test the things I know and make scripts again :)

-Tsn.