
Originally Posted by
cadet54
Well since the colours are not using hue's and CTS the colours tend to cross over allot, brown cows match the fence though the cows are a lighter colour than the fence, I guess with CTS it would be able to home in on those colours better? or am I getting the wrong end of the stick?
Ah nice thanks for the advice runaway, will give it a go.
There are 3 different types of CTS (actually 4 but 1 of them is kind new and not really used) CTS 0 compares colours in a very bad way and is rarely used. CTS 1 is what you are using, is uses a single value to compare colours, it is ok. CTS 2 is normally the best for comparing 2 colours, it uses 3 values for tolerance, the tolerance, a hue modifier and a saturation modifier.
Have you tries using ACA to get the colours of the cows?
This is my object finding function, I think you might find it of some use:
Simba Code:
Function FindObject(Colours : array of TColour; UpText : array of String; SortFrom : TPoint; ClickType, ATPAHeight, ATPAWidth, ATPASizeCount : integer; CheckForRedClick, Debug : Boolean) : Boolean;
Var
Points, Points2 : array of TPoint;
ATPA : array of array of TPoint;
i, H, CTS : integer;
begin
CTS := GetColorToleranceSpeed;
SetColorToleranceSpeed(2);
H := high(Colours);
SetArrayLength(Points, 0);
for i := 0 to H do
begin
SetToleranceSpeed2Modifiers(Colours[i].Hue, Colours[i].Sat);
FindColorsTolerance(Points2, Colours[i].Colour, MSX1, MSY1, MSX2, MSY2, Colours[i].Tolerance);
CombineTPAWrap(Points, Points2, Points);
end;
SetColorToleranceSpeed(CTS);
SortTPAFrom(Points, SortFrom);
TPAtoATPAExWrap(Points, ATPAWidth, ATPAHeight, ATPA);
if(Debug)then
begin
SMART_ClearCanvasArea(MSBox);
SMART_DrawDotsEx(False, Points, clGray);
end;
SetArrayLength(Points, GetArrayLength(ATPA));
H := high(Points);
for i := 0 to H do
begin
Points[i] := MiddleTPA(ATPA[i]);
if(Debug)then
SMART_DrawCircle(False, Points[i], 5, GetArrayLength(ATPA[i]) >= ATPASizeCount, Random(clWhite));
end;
H := high(Points);
for i := 0 to H do
begin
if(GetArrayLength(ATPA[i]) < ATPASizeCount)then
Continue;
MouseBox(Points[i].x - 5, Points[i].y - 5, Points[i].x + 5, Points[i].y + 5, mouse_Move);
Wait(Random(20));
if(WaitUpTextMulti(UpText, 200+Random(500)))then
begin
ClickMouse2(ClickType);
if(CheckForRedClick)then
Result := DidRedClick
else
Result := True;
exit;
end;
end;
end;
You will need some other things to use it, put these above the function:
Simba Code:
type
TColour = record
Colour, Tolerance : integer;
Hue, Sat : extended;
end;
Function Colour(Col, Tol : integer; Hue, Sat : extended) : TColour;
begin
Result.Colour := Col;
Result.Hue := Hue;
Result.Tolerance := Tol;
Result.Sat := Sat;
end;
Ok this is how you use it:
Simba Code:
Function FindObject(Colours : array of TColour; UpText : array of String; SortFrom : TPoint; ClickType, ATPAHeight, ATPAWidth, ATPASizeCount : integer; CheckForRedClick, Debug : Boolean) : Boolean;
Colours are the colours of your object, you get these from ACA, they are defined like this:
Simba Code:
[Colour(5132113, 5, 1.12, 0.12), Colour(29472, 8, 0.23, 0.27)]
//Colour(Col, Tolerance, Hue, Saturation) - You get these from ACA
Uptexts are the uptexts of the object, you know how to use these
SortFrom is the point to sort the colours from, if you want to click the object nearest to you this will be
ClickType is the mouse button to use, this can be mouse_left, mouse_right or mouse_move
ATPAHeight is the height of the object, ATPA Width is the width (roughly) (best to make these less rather than more)
ATPAMinCount is the minimum number of pixels of the correct colour for the object to check that point
CheckForRed is whether it checks for the redcrosshair to know if it was successful (only put true if using mouse_left)
Debug is whether you want the objects painted on screen
In the end it looks something like this:
Simba Code:
if(FindObject([Colour(5132113, 5, 1.12, 0.12), Colour(29472, 8, 0.23, 0.27)], ['ausol', 'eposit', 'leum'], Point(MSCX, MSCY), mouse_Left, 40, 40, 10, True, False))then
//DoSomething;