Been using this code for my upcoming astral script
function AltarColor: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.00, 0.25);
if not (FindColorsTolerance(arP, 8818061, MSX1, MSY1, MSX2, MSY2, 2)) then
begin
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;
arC := GetColors(arP);
ClearSameIntegers(arC);
arL := High(arC);
for i := 0 to arL do
begin
Result := arC[i];
Break;
end;
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
end;
Function FindObjEx_F(ColorA, ColorB, Tol, Bounds, sX, sY: Integer; UpText: TStringArray; Var X, Y: Integer): Boolean;
var
B: TBox;
TPA: TPointArray;
L,i,CTS: Integer;
ATPA,ATPA2: T2DPointArray;
begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
FindColorsSpiralTolerance(sX, sY, TPA, ColorA, MSX1, MSY1, MSX2, MSY2, Tol);
if Length(TPA) < 1 then
begin
ColorToleranceSpeed(CTS);
Exit;
end;
ATPA := TPAtoATPAEx(TPA, Bounds, Bounds);
L := High(ATPA);
SetArrayLength(ATPA2, L+1);
for i := 0 to L do
begin
B := GetTPABounds(ATPA[i]);
with B do
begin
FindColorsSpiralTolerance(sX, sY, ATPA2[i], ColorB, B.X1-Bounds, B.Y1-Bounds, B.X2+Bounds, B.Y2+Bounds, Tol);
ColorToleranceSpeed(CTS);
if Length(ATPA2[i]) > 0 then
begin
MiddleTPAEx(ATPA2[i], X, Y);
MMouse(X, Y, 5, 5);
if WaitUpTextMulti(UpText, 150) then
begin
Result := True;
GetMousePos(X, Y);
Exit;
end;
end;
end;
end;
end;
function FindAltar: Boolean;
var
x, y, i: Integer;
label
Start;
begin
Gametab(tab_Inv);
Start:
if FindObjEx_F(6514535, 10133921, 15, 10, MSCX+50, MSCY, ['Craft','rune','Altar'], X, Y) then
begin
HumanMMouse(x, y, 10, 10);
ClickMouse2(true);
Wait(RandomRange(600, 800));
Result := true;
if did not DidRedClick then
goto Start;
end else if FindObjTPA(x, y, AltarColor, 15, 2, 105, 105, 3, ['raft', 'Craft']) then
begin
HumanMMouse(x, y, 10, 10);
ClickMouse2(true);
Wait(RandomRange(600, 800));
Result := true;
if did not DidRedClick then
goto Start;
end else
begin
Inc(i);
if i > 3 then
begin
Writeln('Failed to find altar');
Exit;
end else
goto Start;
end;
end;