Roberty Bob
2006-07-02 11:22:51
Another One I made just now. I know this can be helpful for you :)
I don't know if someone has already shared a similar function. :rolleyes:
For my exact autocolors, this works absolutely perfect on zero tolerance, never a misclick or unplanned random mouse movement again. :)
but if your colors aren't exact, I put the tolerance in for you!! It seems to work beautifully.
Its currently designed for main screen object finding, but easily changed :P but you can think of it as a potential bitmap / DTM substitute.
Example… pass in an array of several unique bank symbol colors, boxsize of 30, tolerance 30. bingo, I'm sure you will find the bank symbol every time, in milliseconds. Its really fast too, as it only needs to perform the several small ColorSpiral procedures.
note: a more advanced version could also refine the below… but I didn't want to overclutter it.
[PHP]
x:= MSCX-250+random(500);
y:= MSCY-200+random(400);
[/PHP]
A more advanced version could refine this with addition of a DistFromPlayer parameter etc.
ENJOY :D (lol… I also attached an example of this in action too. I do it for any function I make :P )
[PHP]
{*******************************************************************************
function FindAllColorsInBoxTolerance(var x,y: integer; ColorArray: array of Integer; BoxSize,Tol:integer):boolean;
By: Roberty Bob
Description: Pass in an array of object colors with principal reference color in Array[0]
Returns true if all the colors were found in a box surrounding the principal reference color.
*******************************************************************************}
function FindAllColorsInBoxTolerance(var x,y: integer; ColorArray: array of Integer; BoxSize,Tol:integer):boolean;
var
i,j,a,b,HBox,ArraySize,Sx,Sy,Ex,Ey: integer;
var
AllFound,ColorMissing: boolean;
begin
//******** Set these to your specific search area, to make function more efficient.
Sx:= MSX1; //currently main screen
Sy:= MSY1;
Ex:= MSX2;
Ey:= MSY2;
//********
HBox:= (BoxSize/2);
ColorMissing:= false;
AllFound:= false;
ArraySize:= GetArrayLength(ColorArray);
x:= MSCX-250+random(500);
y:= MSCY-200+random(400);
repeat
FindColorSpiralTolerance(x,y,ColorArray[0],Sx,Sy,Ex,Ey,Tol);
a:= x;
b:= y;
i:= 0;
repeat
if FindColorSpiralTolerance(a,b,ColorArray,a-(HBox),b-(HBox),a+(HBox),b+(HBox),Tol) then
AllFound:=true
else
begin
ColorMissing:= true;
AllFound:= false;
break;
end;
i:= i+1;
until i= (ArraySize-1)
if ColorMissing then break;
j:= j+1;
until AllFound or (j=10)
result:= AllFound;
end;
[/PHP]
I don't know if someone has already shared a similar function. :rolleyes:
For my exact autocolors, this works absolutely perfect on zero tolerance, never a misclick or unplanned random mouse movement again. :)
but if your colors aren't exact, I put the tolerance in for you!! It seems to work beautifully.
Its currently designed for main screen object finding, but easily changed :P but you can think of it as a potential bitmap / DTM substitute.
Example… pass in an array of several unique bank symbol colors, boxsize of 30, tolerance 30. bingo, I'm sure you will find the bank symbol every time, in milliseconds. Its really fast too, as it only needs to perform the several small ColorSpiral procedures.
note: a more advanced version could also refine the below… but I didn't want to overclutter it.
[PHP]
x:= MSCX-250+random(500);
y:= MSCY-200+random(400);
[/PHP]
A more advanced version could refine this with addition of a DistFromPlayer parameter etc.
ENJOY :D (lol… I also attached an example of this in action too. I do it for any function I make :P )
[PHP]
{*******************************************************************************
function FindAllColorsInBoxTolerance(var x,y: integer; ColorArray: array of Integer; BoxSize,Tol:integer):boolean;
By: Roberty Bob
Description: Pass in an array of object colors with principal reference color in Array[0]
Returns true if all the colors were found in a box surrounding the principal reference color.
*******************************************************************************}
function FindAllColorsInBoxTolerance(var x,y: integer; ColorArray: array of Integer; BoxSize,Tol:integer):boolean;
var
i,j,a,b,HBox,ArraySize,Sx,Sy,Ex,Ey: integer;
var
AllFound,ColorMissing: boolean;
begin
//******** Set these to your specific search area, to make function more efficient.
Sx:= MSX1; //currently main screen
Sy:= MSY1;
Ex:= MSX2;
Ey:= MSY2;
//********
HBox:= (BoxSize/2);
ColorMissing:= false;
AllFound:= false;
ArraySize:= GetArrayLength(ColorArray);
x:= MSCX-250+random(500);
y:= MSCY-200+random(400);
repeat
FindColorSpiralTolerance(x,y,ColorArray[0],Sx,Sy,Ex,Ey,Tol);
a:= x;
b:= y;
i:= 0;
repeat
if FindColorSpiralTolerance(a,b,ColorArray,a-(HBox),b-(HBox),a+(HBox),b+(HBox),Tol) then
AllFound:=true
else
begin
ColorMissing:= true;
AllFound:= false;
break;
end;
i:= i+1;
until i= (ArraySize-1)
if ColorMissing then break;
j:= j+1;
until AllFound or (j=10)
result:= AllFound;
end;
[/PHP]