SCAR Code:
function FindAnvil(var x, y: integer): boolean;
var Anvil: TPointArray;
Anvil2: T2DPointArray;
H, i, TCTS: integer;
begin
if FailSafes then exit;
TCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
result := false;
FindColorsSpiralTolerance(x, y, Anvil, AnvilColor, MSX1 + 100, MSY1 + 100, MSX2 - 100, MSY2 - 100, 2);
Anvil2 := TPAtoATPAEx(Anvil, 20, 20);
H := High(Anvil2);
for i:= 0 to H do
begin
MiddleTPAEx(Anvil2[i], x, y);
MMouse(x, y, 2, 2);
if IsUpText('nvil') then
begin
result := true;
break;
end;
end;
GetMousePos(x, y);
ColorToleranceSpeed(TCTS);
end;
function Smith: boolean;
var Retry: label; //Apparent error... :(
begin
result := false;
if Failsafes then exit;
if AnvilColor = 0 then
AnvilColor := FindAnvilColorMS;
if FindDTM(BarDTM, x, y, MIX1, MIY1, MIX2, MIY2) then
begin
MMouse(x, y, 4, 4);
Wait(100+random(50));
NMouse(x, y, 1, 1, 'se');
if FindAnvil then
NMouse(x, y, 0, 0, 'nvil')
else
if WeLost('Smithing') then
exit;
if not SmithScreen then
exit;
FixSmithScreen(Hi);
MouseBox(x1, y1, x2, y2, 2);
Wait(100+random(50));
if IsUpText(IText) then
begin
GetMousePos(x, y);
Retry;
Mouse(x, y, 0, 0, false);
Wait(100+random(50));
case random(10) of
0..8: ChooseOption('ll');
9: begin
ChooseOption('10');
Wait(7000+random(4000));
GoTo Retry;
end;
end;
result := true;
end;
end else;
begin
Writeln('Could not find any bars in your inventory; banking to get more.');
PLoc('Banking to get more bars.', false);
exit;
end;
end;