
Originally Posted by
Le Jingle
My revision from what I understand via your short description + code.
(Note: be sure to read the comments in the code to understand what I'm trying to do)
Simba Code:
{$include_once srl/srl.simba}
function WalkToPointOnMM(): Boolean;
var
i, j, k, D1, D2: Integer;
GatherColors: TIntegerArray;
Gather: array [0..2] of TPointArray; // 0 = Pt1, 1 = Pt2, 2 = Spot Click
GatherATPA: array [0..2] of T2DPointArray;
begin
Result := False;
GatherColors := [228, 15331301, 6912900]; // Colors
// Find color, filter color, split color
for i := 0 to high(Gather) do
begin
FindColorsTolerance(Gather[i], GatherColors[i], MMX1, MMY1, MMX2, MMY2, 25);
FilterPointsPie(Gather[i], 0, 360, 0, 72, MMCx, MMCy);
SplitTPAWrap(Gather[i], 15, GatherATPA[i]);
end;
// So we have 2 ATPA's...
for i := 0 to high(GatherATPA) do
// Now we have 'x' TPA's in each ATPA, from the original split TPA's...
for j := 0 to high(GatherATPA[i]) do
// Then in each TPA we test distances now between points...
for k := 0 to high(GatherATPA[i][j]) do
begin
(* Note the Index values, 2, 1, and 0.
* These reference the order of the colors specified in GatherColors.
* Thus making it relevant to use the indexed values as shown below,
* because it matches the pattern/description you wish to search for.
*)
D1 := Distance(GatherATPA[2][j][k].x, GatherATPA[2][j][k].y,
GatherATPA[0][j][k].x, GatherATPA[0][j][k].y);
D2 := Distance(GatherATPA[2][j][k].x, GatherATPA[2][j][k].y,
GatherATPA[1][j][k].y, GatherATPA[1][j][k].y);
if ((D1 <= 25) and (D1 >= 0)) and ((D2 <= 20) and (D2 >= 0)) then
begin
Result := True;
MMouse(GatherATPA[2][j][k].x, GatherATPA[2][j][k].y, 1, 1);
ClickMouse2(Mouse_Right);
Exit;
end;
end;
end;
begin
SetupSRL;
WalkToPointOnMM();
end.
I'm getting a range check error at line 36, I don't know why I added failsafe incase it can't find color:
Simba Code:
if (Length(GatherATPA) = 0) Then
Exit;
Simba Code:
{$include srl/srl.simba}
function WalkToPointOnMM(): Boolean;
var
i, j, k, D1, D2: Integer;
GatherColors: TIntegerArray;
Gather: array [0..2] of TPointArray; // 0 = Pt1, 1 = Pt2, 2 = Spot Click
GatherATPA: array [0..2] of T2DPointArray;
begin
Result := False;
GatherColors := [11363426, 5658204, 5658204]; // Colors
// Find color, filter color, split color
for i := 0 to high(Gather) do
begin
FindColorsTolerance(Gather[i], GatherColors[i], 547, 33, 710, 193, 25);
FilterPointsPie(Gather[i], 0, 360, 0, 72, 635, 113);
SplitTPAWrap(Gather[i], 15, GatherATPA[i]);
end;
// So we have 2 ATPA's...
for i := 0 to high(GatherATPA) do
// Now we have 'x' TPA's in each ATPA, from the original split TPA's...
for j := 0 to high(GatherATPA[i]) do
// Then in each TPA we test distances now between points...
for k := 0 to high(GatherATPA[i][j]) do
begin
if (Length(GatherATPA) = 0) Then
Exit;
(* Not
e the Index values, 2, 1, and 0.
* These reference the order of the colors specified in GatherColors.
* Thus making it relevant to use the indexed values as shown below,
* because it matches the pattern/description you wish to search for.
*)
D1 := Distance(GatherATPA[2][j][k].x, GatherATPA[2][j][k].y,
GatherATPA[0][j][k].x, GatherATPA[0][j][k].y);
D2 := Distance(GatherATPA[2][j][k].x, GatherATPA[2][j][k].y,
GatherATPA[1][j][k].y, GatherATPA[1][j][k].y);
if ((D1 <= 25) and (D1 >= 0)) and ((D2 <= 20) and (D2 >= 0)) then
begin
Result := True;
MMouse(GatherATPA[2][j][k].x, GatherATPA[2][j][k].y, 1, 1);
ClickMouse2(Mouse_Right);
Exit;
end;
end;
end;
begin
SetupSRL;
WalkToPointOnMM();
end.
EDIT:
I also tried to change the 75 at thhis line assuming it was looking for he colors 75 pixels from the middle of the minimap:
Simba Code:
FilterPointsPie(Gather[i], 0, 360, 0, 75, 635, 113);
But still the same result