SRL Archive - OSR Help

ACA Help


RlagkRud

2013-07-03 02:55:10

Hey guys I was wondering if you guys could help me decipher the code from the ACA program.

This is the code from my kyatt program.

function FindClimb: Boolean;
var
arP: TPointArray;
ararP: T2DPointArray;
tmpCTS, i, arL: Integer;
Colors : Array of Integer;
P: TPoint;
begin

Cycle := 0;

Repeat

tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.00, 0.00);

Case Cycle of
0: begin
if not(FindColorsTolerance(arP, 855310, MSX1, MSY1, MSX2, MSY2-75, 1)) then
begin
Debugger('Failed to find the color, no object found. 0');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
end;
end;

1: begin
if not(FindColorsTolerance(arP, 789517, MSX1, MSY1, MSX2, MSY2-75, 1)) then
begin
Debugger('Failed to find the color, no object found. 1');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
end;
end;

2: begin
if not(FindColorsTolerance(arP, 855309, MSX1, MSY1, MSX2, MSY2-75, 1)) then
begin
Debugger('Failed to find the color, no object found. 2');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;
end;



end;

SortTPAFrom(arP, Point(MSCX, MSCY));
ararP := SplitTPAEx(arP, 10, 10);
arL := High(ararP);

for i := 0 to arL do
begin
if (Length(ararP[i]) < 20) then Continue;
P := MiddleTPA(ararP[i]);
HumanMMouse(P.x, P.y, 5, 5);
Wait(100 + Random(100));
if (IsUpText('Climb')) then
begin;
Result := True;
Exit;
end;
end;

ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);

if (i = arL + 1) then
begin
Debugger('FindClimb could not find object. Cycle: ' + IntToStr(Cycle));
end;

Cycle := Cycle + 1;

Until ( Cycle = 3 )

Result := False;

end;

As you can see, I used 'cycle' to cycle through the various possible colors instead of putting them into an array. If you guys have any suggestions any improvements to this or if its fine as it is to achieve that function.

My main confusion is the
SortTPAFrom(arP, Point(MSCX, MSCY));
ararP := SplitTPAEx(arP, 10, 10);
arL := High(ararP);

for i := 0 to arL do
begin
if (Length(ararP[i]) < 20) then Continue;
P := MiddleTPA(ararP[i]);
HumanMMouse(P.x, P.y, 5, 5);
Wait(100 + Random(100));
if (IsUpText('Climb')) then
begin;
Result := True;
Exit;
end;
end;

I can select the 'max length' in the ACA function maker and I can see it translates to [if (Length(ararP) < 20) then Continue;]
Is this a way to ignore the random single pixels that might have matching colors from the findcolortolerance or is it something completely different?

Thanks!

riwu

2013-07-03 07:06:32

If the object contains multiple colors, you may want to add up all the points in which the colors are found, rather than just searching for a single color at a time and handling them 1 by 1.
Eg.

colors:= [855310, 789517, 855309];
SetLength(ATPA, Length(colors));
for i:=0 to High(colors) do
FindColorsTolerance(ATPA[i], colors[i], ...);
MergeATPAWrap(ATPA, arP);
//other codes

You are right about the purpose of length check :)

RlagkRud

2013-07-05 01:42:57

From: riwu
If the object contains multiple colors, you may want to add up all the points in which the colors are found, rather than just searching for a single color at a time and handling them 1 by 1.
Eg.

colors:= [855310, 789517, 855309];
SetLength(ATPA, Length(colors));
for i:=0 to High(colors) do
FindColorsTolerance(ATPA[i], colors[i], ...);
MergeATPAWrap(ATPA, arP);
//other codes

You are right about the purpose of length check :)


Tanks for the help!