Town
2007-04-14 09:59:00
Yes, I know there enough already, but I still made this one. It is like FindObjArea except if it doesn't find the object then it continues searching by making a larger box. Incase you made your intervals too small and it would take a long time for it to find or not find your object, you can set a stop time (in milliseconds). AmountOfIncreaseX and AmountOfIncreaseY are the intervals at which it makes your box bigger. I have tested it and it wotks very well, but it might be a bit slow if your intervals are too small and you don't know where your looking for a color..
{.include SRL\SRL.scar}
Function ContFindObjArea(var x,y:integer; ObjectText:String; x1,y1,x2,
y2,AmountOfIncreaseX,AmountOfIncreaseY,ObjectColor,ObjectTolerance,
Stop:Integer): Boolean;
var
Pointss: TPointArray;
Numss, CenX, CenY, hh, bb: Integer;
begin
Numss := 0;
hh := 0;
CenX := x2 / 2;
CenY := y2 / 2;
FindColorsSpiralTolerance(CenX, CenY, Pointss, ObjectColor, x1, y1, x2, y2,
ObjectTolerance)
if Not (GetArrayLength(Pointss) <> 0) then
begin
repeat
FindColorsSpiralTolerance(CenX, CenY, Pointss, ObjectColor, x1, y1, x2, y2,
ObjectTolerance)
if Not (GetArrayLength(Pointss) <> 0) then
begin
If(Not(x1+ (AmountOfIncreaseX / 2) < 0)) Then x1:= x1+ (AmountOfIncreaseX / 2)
Else hh:=hh+1
If(Not(y1+ (AmountOfIncreaseY / 2) < 0)) Then y1:= y1+ (AmountOfIncreaseY / 2)
Else hh:=hh+1
If(Not(x1+ (AmountOfIncreaseX / 2) > 764)) Then x2:= x2+ (AmountOfIncreaseX / 2)
Else hh:=hh+1
If(Not(y1+ (AmountOfIncreaseY / 2) > 502)) Then y2:= y2+ (AmountOfIncreaseY / 2)
Else hh:=hh+1
end
If(hh = 4) Then Exit;
Until(GetArrayLength(Pointss) <> 0)
end
if (GetArrayLength(Pointss) <> 0) then
begin
MarkTime(bb)
repeat
MMouse(Pointss[Numss].x, Pointss[Numss].y, 0, 0);
Wait(450 + Random(50));
if (ReadUpText(ObjectText)) then
begin
Result := True;
x := Pointss[Numss].x;
y := Pointss[Numss].y;
end else
begin
If(Not(x1+ (AmountOfIncreaseX / 2) < 0)) Then x1:= x1+ (AmountOfIncreaseX / 2)
Else hh:=hh+1
If(Not(y1+ (AmountOfIncreaseY / 2) < 0)) Then y1:= y1+ (AmountOfIncreaseY / 2)
Else hh:=hh+1
If(Not(x1+ (AmountOfIncreaseX / 2) > 764)) Then x2:= x2+ (AmountOfIncreaseX / 2)
Else hh:=hh+1
If(Not(y1+ (AmountOfIncreaseY / 2) > 502)) Then y2:= y2+ (AmountOfIncreaseY / 2)
Else hh:=hh+1
end;
If(TimeFromMark(bb) > Stop) Then Exit;
until (hh = 4) or (Result)
end;
end;