Find Object In Object. Basically you find the colour of the floor the crates are on.. Pass it to the function below. Next find the outline of the crates and pass it to the previous call. Finally Find the one crate that stacks on the second crate and pass it to the function below. It will return you a TPA of the exact crate you want.
Simba Code:
Function FindObjectInObject(TPA: TPointArray; Color, Width, Height, Tolerance: Integer; Speed: TExtendedArray): TPointArray;
var
CTS, L, I: Integer;
TPACopy: TPointArray;
ATPA, ATPA2: T2DPointArray;
B: TBox;
begin
CTS:= GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(Speed[0], Speed[1]);
if (Length(TPA) < 1) then
Exit;
TPACopy:= CopyTPA(TPA);
if (Length(TPACopy) < 1) then
Exit;
ATPA:= TPAToATPAEx(TPACopy, Width, Height);
SortATPASize(ATPA, True);
L := High(ATPA);
SetArrayLength(ATPA2, L+1);
For I:= 0 To L do
begin
B := GetTPABounds(ATPA[I]);
with B do
begin
FindColorsTolerance(ATPA2[I], Color, B.X1, B.Y1, B.X2, B.Y2, Tolerance);
if (Length(ATPA2[I]) < 1) then
Continue;
end;
end;
if (Length(ATPA2) > 0) then
Result:= MergeATPA(ATPA2)
else
Result:= [];
ColorToleranceSpeed(CTS);
SetColorSpeed2Modifiers(0.02, 0.02);
end;
Can be used like this:
Crate On Crate In Outline on floor. Make sense I hope Example of Marble altar:
Simba Code:
Function FindAltar: Boolean;
var
CTS, X, Y: Integer;
TPA, TPA2, TPA3: TPointArray;
begin
CTS:= GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.10, 0.20);
FindColorsTolerance(TPA, 3096661, 0, 0, 1000, 617, 11); //Finds the brown outline of the altar..
ColorToleranceSpeed(CTS);
SetColorSpeed2Modifiers(0.02, 0.02);
If Length(TPA) < 1 then
Exit;
TPA2:= FindObjectInObject(TPA, 10726065, 186, 138, 23, [0.37, 0.36]); //With the brown outline, search inside it for the white marble..
If (Length(TPA2) < 1) then
Exit;
TPA3:= FindObjectInObject(TPA2, 10458003, 186, 138, 16, [0.11, 0.14]); //With the white marble, search inside that for the prayer book..
If (Length(TPA3) < 1) then
Exit;
MiddleTPAEx(TPA3, X, Y); //Our altar is found 100% of the time.
MMouse(X, Y, 0, 0);
end;