SCAR Code:
program New;
{.include SRL/SRL.scar}
{.include SRL/SRL/skill/mining.scar}
function FindObjectTin(var fx, fy: Integer): Boolean;
var
arP, arAP: TPointArray;
arC, arUC: TIntegerArray;
ararP: T2DPointArray;
tmpCTS, i, j, arL, arL2: Integer;
P: TPoint;
H, S, L: Extended;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(1);
if not(FindColorsTolerance(arP, 6118756, MSX1, MSY1, MSX2, MSY2, 113)) then
begin
Writeln('Failed to find the color, tin not found.');
ColorToleranceSpeed(tmpCTS);
Exit;
end;
arC := GetColors(arP);
arUC := arC;
ClearSameIntegers(arUC);
arL := High(arUC);
arL2 := High(arC);
for i := 0 to arL do
begin
ColorToHSL(arC[i], H, S, L);
if (H >= 0.00) and (H <= 3.35) and (S >= 3.14) and (S <= 6.40) and (L >= 12.14) and (L <= 63.16) then
begin
ColorToXYZ(arC[i], X, Y, Z);
if (X >= 1.27) and (X <= 33.76) and (Y >= 1.31) and (Y <= 34.38) and (Z >= 1.40) and (Z <= 35.88) then
begin
for j := 0 to arL2 do
begin
if (arUC[i] = arC[j]) then
begin
SetLength(arAP, Length(arAP) + 1);
arAP[High(arAP)] := arP[j];
end;
end;
end;
end;
end;
SortTPAFrom(arAP, Point(MSCX, MSCY));
ararP := SplitTPAEx(arAP, 10, 10);
arL := High(ararP);
for i := 0 to arL do
begin
if (Length(ararP[i]) < 10) then Continue;
P := MiddleTPA(ararP[i]);
MMouse(P.x, P.y, 5, 5);
Wait(100 + Random(100));
if (IsUpText('Mine')) then
begin;
Result := True;
Break;
end;
end;
ColorToleranceSpeed(tmpCTS);
if (i = arL + 1) then
begin
Writeln('FindObjectTin could not find Tin.');
Exit;
end;
GetMousePos(fx, fy);
end;
function AutoColorTin: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
H, S, L: Extended;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(1);
FindColorsSpiralTolerance(MSCX, MSCY, arP, 6118756, MSX1, MSY1, MSX2, MSY2, 113);
if (Length(arP) = 0) then
begin
Writeln('Failed to find the color, no result.');
ColorToleranceSpeed(tmpCTS);
Exit;
end;
arC := GetColors(arP);
ClearSameIntegers(arC);
arL := High(arC);
for i := 0 to arL do
begin
ColorToHSL(arC[i], H, S, L);
if (H >= 0.00) and (H <= 3.35) and (S >= 3.14) and (S <= 6.40) and (L >= 12.14) and (L <= 63.16) then
begin
ColorToXYZ(arC[i], X, Y, Z);
if (X >= 1.27) and (X <= 33.76) and (Y >= 1.31) and (Y <= 34.38) and (Z >= 1.40) and (Z <= 35.88) then
begin
Result := arC[i];
Writeln('AutoColor = ' + IntToStr(arC[i]));
Break;
end;
end;
end;
ColorToleranceSpeed(tmpCTS);
if (i = arL + 1) then
Writeln('AutoColor failed in finding the color.');
end;
procedure TinProcess;//find the tin, mines it, then drops it
var
x,y:integer;
begin
repeat
if (FindObjectTin(x,y)) then
begin
FindPick;
if (not(FindGas(x,y))) then
begin
MMouse(x,y,0,0);
if (IsUpText('Mine')) then
begin
Mouse(x,y,0,0,true);
wait(200+random(700))
end else
begin
Mouse(x,y,0,0,false);
ChooseOption('Mine');
wait(250+random(700));
end;
end;
end else
begin
if (FindColor(x,y,AutoColorTin,MSX1, MSY1, MSX2, MSY2)) then
begin
FindPick;
if (not(FindGas(x,y,))) then
begin
MMouse(x,y,0,0);
if (IsUpText('Mine')) then
begin
Mouse(x,y,0,0,true);
wait(200+random(700))
end else
begin
Mouse(x,y,0,0,false);
ChooseOption('Mine');
wait(250+random(700));
end;
end;
end;
end;
end else
begin
Writeln('Couldnot find the tin rock, LoggingOut');
Logout;
TerminateScript;
end;
until(InvFull = True);
begin
MMouse(576,225,0,0);
if (IsUpText('Weil')) then
begin
DropItem(2);
DropItem(3);
DropItem(4);
DropItem(5);
DropItem(6);
DropItem(7);
DropItem(8);
DropItem(9);
DropItem(10);
DropItem(11);
DropItem(12);
DropItem(13);
DropItem(14);
DropItem(15);
DropItem(16);
DropItem(17);
DropItem(18);
DropItem(19);
DropItem(20);
DropItem(21);
DropItem(22);
DropItem(23);
DropItem(24);
DropItem(25);
DropItem(26);
DropItem(27);
DropItem(28);
end else
begin
DropAll;
end;
end;
end;
begin
SetupSRL;
FindPickHeadColor;
TinProcess;
end;