SRL Archive - OSR Help

Trouble scrolling through atpa


rj

2013-03-28 15:53:20

So I am using this function to gather colors on the minimap and test their distance between each other, and if they are a certain distance between each other then it will click there but it does not seem to be working:

{$I SRL/SRL.Simba}
{$I SRL/SRL/Misc/Debug.simba}
Procedure WalkPoint;
Var
Point_1, Point_2, Spot_Click: TPointArray;
Point_1_ATPA, Point_2_ATPA, Spot_ATPA: T2DPointArray;
I, J, K, Dist_Get_1, Dist_Get_2, Moves:Integer;
Begin
FindColorsTolerance(Point_1, 2442088, 547, 33, 710, 193, 25);
FindColorsTolerance(Point_2, 404792, 547, 33, 710, 193, 25);
FindColorsTolerance(Spot_Click, 5658204, 547, 33, 710, 193, 25);
SplitTPAWrap(Point_1, 7, Point_1_ATPA);
SplitTPAWrap(Point_2, 7, Point_2_ATPA);
SplitTPAWrap(Spot_Click, 7, Spot_ATPA);
DebugATPABounds(Point_1_ATPA);
DebugATPABounds(Point_2_ATPA);
DebugATPABounds(Spot_ATPA);
SetLength(Point_1, 15);
SetLength(Point_2, 15);
for I:= 0 To High(Point_1) Do
for J:= 0 To High(Point_2) Do
//for K:= 0 To High(Spot_Click) Do
begin
Moves := 0;
Repeat
if (Length(Spot_Click) = 0) or
(Length(Point_1) = 0) or
(Length(Point_2) = 0)then
Begin
Writeln('No colors were found');
Exit;
End;
If Moves >= 15 Then
Begin
Writeln('Moves > 15 stopping')
Exit;
End;
Moves := Moves +1
Dist_Get_1 := Distance(Spot_Click[0].x, Spot_Click[0].y,Point_1[0].x,Point_1[0].y);
Dist_Get_2 := Distance(Spot_Click[0].x, Spot_Click[0].y,Point_2[0].x,Point_2[0].y);
If (Dist_Get_1 <= 39) and (Dist_Get_2 <= 39) and
(Dist_Get_1 >= 2) and (Dist_Get_2 >= 2) Then
Begin
Writeln('colors were found');
mmouse(Spot_Click[0].x,Spot_Click[0].y,1,1)
ClickMouse2(Mouse_Left)
// While (SS_FFlag) Do
Wait(50)
Exit;
End;
Until Moves > 15
End;
End;
begin
MouseSpeed := 15;
WalkPoint;
end.

Anybody know what I'm doing wrong?

rj

2013-03-28 16:46:41

I'm trying to walk to the spot inbetween the archery story and armour shop as a test and the Debug is splitting the whole minimap for some reason


Le Jingle

2013-03-28 16:48:43

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)


{$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.

rj

2013-03-28 16:55:35

From: 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)


{$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:

if (Length(GatherATPA) = 0) Then
Exit;

{$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:

FilterPointsPie(Gather[i], 0, 360, 0, 75, 635, 113);

But still the same result

Le Jingle

2013-03-28 17:00:45

Yes, I suppose adding a failsafe that checks for length of Gather after the filterpoints pie is greater than 0, then proceed, else, exit.

rj

2013-03-28 17:05:58

From: Le Jingle
Yes, I suppose adding a failsafe that checks for length of Gather after the filterpoints pie is greater than 0, then proceed, else, exit.


I don't think it's working I used common colors and high max distance

if ((D1 <= 30) and (D1 >= 0)) and ((D2 <= 50) and (D2 >= 0)) then

And all of the same color

Le Jingle

2013-03-28 17:21:16

Did you try also lowering your Split distance from 15 to something lower?

rj

2013-03-28 17:25:49

From: Le Jingle
Did you try also lowering your Split distance from 15 to something lower?


I went all the way down to 5 still no result

Le Jingle

2013-03-28 17:31:33

From: RJJ95
I'm trying to walk to the spot inbetween the archery story and armour shop as a test and the Debug is splitting the whole minimap for some reason



Just saw this post;
If you're trying to walk between those two buildings, would not RadialWalk suffice to walk the path that is also indeed inbetween both?

rj

2013-03-28 17:36:18

From: Le Jingle
Just saw this post;
If you're trying to walk between those two buildings, would not RadialWalk suffice to walk the path that is also indeed inbetween both?


Because I want to use this method for other things I am just testing it in a area that would be difficult for rotated DTM's