SRL Archive - RS3 Help

ATPA Debugging, and ignoring areas with less than X matched TPoints


Twinki

2015-01-15 03:12:19

I've been using The Mayors sub-tutorial on ATPA's and TPA's. I've ran into some trouble as banker i'm trying to find correctly has the same colors as the surrounds.

This is what i'm using for testing

const
COLOR = 6522777;
TOL = 2;
HUE = 0.21;
SAT = 0.62;

procedure ColorTesting;
var
x, y, i: integer;
TPA: TPointArray;
ATPA: T2DPointArray;

begin
findColorsSpiralTolerance(x, y, TPA, COLOR, mainScreen.getBounds(), TOL, colorSetting(2, HUE, SAT));

if length(TPA) < 1 then
exit;

ATPA := TPA.toATPA(30, 30);
ATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugATPA(ATPA);

for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['anker','ank','ooth'], 500) then
begin
fastClick(MOUSE_LEFT);
break;
end;
end;

end;

The spot:
I'm trying to find that Gnome Banker, but the problem is I keep picking up all these TP's with the same color, and the ATPA is drawing a box over it and hovering. Is there some way to stop from creating a ATPA if it doesn't have enough TP's?

Also, is there any way to visually see how many TP's are in a ATPA box? Like how smartImage.debugTPA(TPA, false); also tells you how many TP's were found, is there a way to make that show up in the individual ATPA's?

cosmasjdz

2015-01-15 03:16:53

From: Twinki
I've been using The Mayors sub-tutorial on ATPA's and TPA's. I've ran into some trouble as banker i'm trying to find correctly has the same colors as the surrounds.

This is what i'm using for testing

const
COLOR = 6522777;
TOL = 2;
HUE = 0.21;
SAT = 0.62;

procedure ColorTesting;
var
x, y, i: integer;
TPA: TPointArray;
ATPA: T2DPointArray;

begin
findColorsSpiralTolerance(x, y, TPA, COLOR, mainScreen.getBounds(), TOL, colorSetting(2, HUE, SAT));

if length(TPA) < 1 then
exit;

ATPA := TPA.toATPA(30, 30);
ATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugATPA(ATPA);

for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['anker','ank','ooth'], 500) then
begin
fastClick(MOUSE_LEFT);
break;
end;
end;

end;

The spot:
I'm trying to find that Gnome Banker, but the problem is I keep picking up all these TP's with the same color, and the ATPA is drawing a box over it and hovering. Is there some way to stop from creating a ATPA if it doesn't have enough TP's?

Also, is there any way to visually see how many TP's are in a ATPA box? Like how smartImage.debugTPA(TPA, false); also tells you how many TP's were found, is there a way to make that show up in the individual ATPA's?


I think for tpa it is smartimage.debugtpa(tpa) shows dots white.

I think best way to get banker is either use minimap to mainscreen transfer for searchbox, and dont search whole screen. Or to search both his face color and jacket color and if colors in some distance then click that tpa. This could be even better. Also could use white papers to count distance too..Also the tolerances could be little toobig there in your functions since jacket seems not so ununique color. Have you tried searching for his head instead?

Hoodz

2015-01-15 03:20:35

ATPA := TPA.toATPA(30, 30);
I'd prefer to use floodFillTPA (makes from all the points that are connected to each other one TPA)


for i := 0 to high(ATPA) do
begin
if (length(ATPA[I]) < 50) then {simply gets the current tpa length and if it has less than 50 matching points it wont execute it but will go to the next index of the ATPA}
continue;
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['anker','ank','ooth'], 500) then
begin
fastClick(MOUSE_LEFT);
break;
end;
end;

too lazy to post debug code

Twinki

2015-01-15 03:27:22

From: hoodz
ATPA := TPA.toATPA(30, 30);
I'd prefer to use floodFillTPA (makes from all the points that are connected to each other one TPA)


for i := 0 to high(ATPA) do
begin
if (length(ATPA[I]) < 50) then {simply gets the current tpa length and if it has less than 50 matching points it wont execute it but will go to the next index of the ATPA}
continue;
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['anker','ank','ooth'], 500) then
begin
fastClick(MOUSE_LEFT);
break;
end;
end;


Ahh that worked, and I was trying length(ATPA), that makes a lot more sense the way you have it. Now I need to figure out how to add a lot more randomness to the moving and clicking.

The Mayor

2015-01-15 04:21:07

From: Twinki
Ahh that worked, and I was trying length(ATPA), that makes a lot more sense the way you have it. Now I need to figure out how to add a lot more randomness to the moving and clicking.


I actually wrote this the other day to find the burthorpe bank guy, you're welcome to use it


program test;
{$DEFINE SMART}
{$i srl-6/srl.simba}

function mayorFind(overText: TStringArray; cols: T2DColorData): Boolean;
var
i, x, y: Integer;
TPAs, ATPA: T2DPointArray;
begin
setLength(TPAs, length(cols));

for i := 0 to high(cols) do
begin
cols[i].gatherIn(TPAs[i], mainScreen.getBounds());
mainscreen.filterPointsPlayer(TPAs[i]);
if length(TPAs[i]) < 1 then exit(false);
end;

ATPA := TPAs[high(cols)].cluster(10);
ATPA.sortFromMidPoint(mainScreen.PlayerPoint);

for i := 0 to high(ATPA) do
if TPAs[0].isPointNear(middleTPA(ATPA[i]), 10) then
begin
mouse(ATPA[i].getBounds().getRandomPoint());

if isMouseOverText(overText, 150) then
begin
getMousePos(x, y);
result := multiClick([x, y], 15, 3);
smallRandomMouse();
break();
end;
end;
end;

procedure openBank();
var
bankTimer: TTimeMarker;
begin
bankTimer.start();

repeat
if not mayorFind(['ank'], [[10340079, 11, [2, [0.14, 2.27, 0.00]]], [6116433, 9, [2, [0.46, 0.41, 0.00]]]]) then
//sps.walkToPos(point(179, 173)) // failsafe if you're using sps
else if bankScreen.isOpen(5000) then
begin
bankScreen.quickDeposit(QUICK_DEPOSIT_INVENTORY);
bankScreen.close();
break();
end;
until bankTimer.getTime() > 120000 or (not isLoggedIn());
end;

begin
setupSRL();
openBank();
end.

Twinki

2015-01-15 06:02:39

From: The Mayor
I actually wrote this the other day to find the burthorpe bank guy, you're welcome to use it


program test;
{$DEFINE SMART}
{$i srl-6/srl.simba}

function mayorFind(overText: TStringArray; cols: T2DColorData): Boolean;
var
i, x, y: Integer;
TPAs, ATPA: T2DPointArray;
begin
setLength(TPAs, length(cols));

for i := 0 to high(cols) do
begin
cols[i].gatherIn(TPAs[i], mainScreen.getBounds());
mainscreen.filterPointsPlayer(TPAs[i]);
if length(TPAs[i]) < 1 then exit(false);
end;

ATPA := TPAs[high(cols)].cluster(10);
ATPA.sortFromMidPoint(mainScreen.PlayerPoint);

for i := 0 to high(ATPA) do
if TPAs[0].isPointNear(middleTPA(ATPA[i]), 10) then
begin
mouse(ATPA[i].getBounds().getRandomPoint());

if isMouseOverText(overText, 150) then
begin
getMousePos(x, y);
result := multiClick([x, y], 15, 3);
smallRandomMouse();
break();
end;
end;
end;

procedure openBank();
var
bankTimer: TTimeMarker;
begin
bankTimer.start();

repeat
if not mayorFind(['ank'], [[10340079, 11, [2, [0.14, 2.27, 0.00]]], [6116433, 9, [2, [0.46, 0.41, 0.00]]]]) then
//sps.walkToPos(point(179, 173)) // failsafe if you're using sps
else if bankScreen.isOpen(5000) then
begin
bankScreen.quickDeposit(QUICK_DEPOSIT_INVENTORY);
bankScreen.close();
break();
end;
until bankTimer.getTime() > 120000 or (not isLoggedIn());
end;

begin
setupSRL();
openBank();
end.



That did help clear some issues, I love examples.

If you're interested here's my custom Object Finding so far, still have to add some more when I start working on the script, but so far so good i'd say.

function FindTheTwinki(Hue, Sat: extended; Color, Tolerance, clickType: Integer; mouseOverText, chooseOptions: array of string): boolean;
var
X, Y, i: integer;
TPA: TPointArray;
ATPA: T2DPointArray;
time: TTimeMarker;

begin
//if not isLoggedIn() then
//exit;
time.start();
repeat
findColorsSpiralTolerance(X, Y, TPA, Color, mainScreen.getBounds(), Tolerance, colorSetting(2, Hue, Sat));
if length(TPA) < 1 then
exit;

ATPA := TPA.toATPA(30, 30);
ATPA.sortFromMidPoint(mainscreen.playerPoint);
//Setup Debug setting here
smartImage.debugATPA(ATPA);

for i := 0 to high(ATPA) do
begin
if (length(ATPA[i]) < 50) then
Continue;
Mouse(ATPA[i].getBounds().getRandomPoint(), MOUSE_MOVE);

if isMouseOverText(mouseOverText, 150) then
begin
fastClick(clickType);
SmallRandomMouse();
Wait(randomRange(250, 750));
if chooseOption.optionsExist(chooseOptions) then
chooseOption.select(chooseOptions, 1000);
exit(true);
end;
end;
until time.getTime() > 20000;
end;