Dynamite
2011-12-23 11:35:31
Why does the line specified result in an Out of Range Error?
-Boom
Function MineOre(which: TOre; Var X, Y : Integer; X1, Y1, X2, Y2 : Integer): Boolean;
Var
TPA : TPointArray;
ATPA : T2DPointArray;
T: TPoint;
K, G, Z: Extended;
Colors: array [0..1] of tIntegerArray;
I, J, xX, yY, Blah: Integer;
DoubleTPA: array [0..1] of TPointArray;
wat: array [0..1] of Integer;
begin
if not LoggedIn then Exit;
ColorToleranceSpeed(2);
for I := 0 to 1 do
begin
SetColorSpeed2Modifiers(which.RockTPA[I][Hue], which.RockTPA[I][Sat]);
FindColorsTolerance(DoubleTPA[I], which.RockTPA[I][Colour], MSx1, MSy1, MSx2, MSy2, which.RockTPA[I][Tol]);
Debug('Length of TPA = '+IntToStr(Length(DoubleTPA[I])));
if Length(DoubleTPA[I]) = 0 then
Exit;
Colors[I] := GetColors(DoubleTPA[I]);
Debug('Length of Colors = '+IntToStr(Length(Colors[I])));
for J := 0 to high(Colors[I]) do
begin
ColorToXYZ(Colors[I][J], K, G, Z);
if InRange(Round(K), 35, 49) then
if InRange(Round(G), 36, 50) then
if InRange(Round(Z), 38, 54) then
begin
wat[I] := J;
Debug('Which['+IntToStr(I)+'] = '+IntToStr(J));
Break;
end;
end;
end;
ColorToleranceSpeed(1);
SetColorSpeed2Modifiers(0.20, 0.20);
Repeat
SetArrayLength(TPA, 0);
FindColorsTolerance(TPA, Colors[J][wat[J]], MSX1, MSY1, MSX2, MSY2, 3); // THIS LINE
if Length(TPA) <= 0 then
Exit;
ATPA := TPAToATPAEx(TPA, 25, 25);
SortATPASize(ATPA, true);
for I := 0 to high(ATPA) do
begin
if I = 3 then
Break;
T := MiddleTPA(ATPA[I]);
MMouse(T.x, T.y, 5, 5);
Wait(400 + Random(200));
if WaitUpTextMulti(which.Uptext, 350) then
begin
getMousePos(xX, yY);
Blah := RandomRange(0, DependClick);
if Blah = 0 then begin
Mouse(xX, yY, 0, 0, False);
WaitOption('ine', 500)
end else Mouse(xX, yY, 0, 0, True);
Result := True;
Blah := 0;
Exit;
end;
Inc(J);
end;
until J > 1;
Debug('Found the rock!');
End;-Boom