PDA

View Full Version : Finding 2+ colors near by each other



vwxz
01-22-2014, 04:39 AM
Looking over the TPA related functions in the docs, I don't see an immediate way to do this directly. However, it does seem like a lot of the existing library functions cover most of this. What is the cleanest/best way to find an object in the main screen consisting of 2+ colors which must be near by each other, reusing as much existing library code as possible? (Note: DTMs don't seem to work well here because the object is basically a random mass of these colors intermingled.) Thanks in advance!

Foundry
01-22-2014, 04:53 AM
Looking over the TPA related functions in the docs, I don't see an immediate way to do this directly. However, it does seem like a lot of the existing library functions cover most of this. What is the cleanest/best way to find an object in the main screen consisting of 2+ colors which must be near by each other, reusing as much existing library code as possible? (Note: DTMs don't seem to work well here because the object is basically a random mass of these colors intermingled.) Thanks in advance!

Could this (http://villavu.com/forum/showthread.php?t=81393&highlight=) be what you are looking for? Looks quite similar to what you are talking about.

vwxz
01-22-2014, 05:01 AM
Sorry, I may have been to abstract/generic in my earlier post. The specific things I'm trying to find are Runespan nodes, which at a rough approximation are blobs of 2+ colors together.


Could this (http://villavu.com/forum/showthread.php?t=81393&highlight=) be what you are looking for? Looks quite similar to what you are talking about.

That looks very promising. Not too sure at the moment, though.

The Mayor
01-22-2014, 05:58 AM
I wrote this up. It works but the pros might have a better way.

This finds two colors, and puts each into its own TPA. It then splits one of the TPAs into an ATPA (30 by 30 box, you can change) and sorts it from the player. Then it sees if the second TPA is near the midpoint of each TPA in the ATPA (currently within a distance of 5 pixels, you can change). If so, it moves the mouse there and clicks if the overText matches.




function find2Colors: boolean;
var
x, y, x1, y1, i: integer;

TPA1, TPA2: TPointArray;
ATPA: T2DPointArray;

begin
if not isLoggedIn then
exit;

findColorsSpiralTolerance(x, y, TPA1, 424876, mainScreen.getBounds(), 6, colorSetting(2, 0.16, 0.93));
findColorsSpiralTolerance(x1, y1, TPA2, 79474, mainScreen.getBounds(), 3, colorSetting(2, 0.31, 0.58));

if (Length(TPA1) < 1) then
exit;

ATPA := TPA1.toATPA(30, 30);
ATPA.sortFromMidPoint(mainscreen.playerPoint);

for i := 0 to high(ATPA) do
begin
if TPA2.isPointNear(middleTPA(ATPA[i]), 5) then
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Attack', 'ttack'], 500) then
begin
fastClick(MOUSE_LEFT);
exit(true);
end;
end;
end;
end;

vwxz
01-22-2014, 06:42 AM
Awesome. Thank you both! Think I have a variation that works for what I'm doing now.

bonsai
01-22-2014, 09:15 AM
I posted some code (http://villavu.com/forum/showthread.php?t=106777&highlight=) that has this functionality too.

The function TObjFind._doFilterInclusiveExact is the one that performs multiple color comparison.