iroki_
2008-05-06 12:37:53
This function is serching for name of bars and smelting it.
{*******************************************************************************
function SmeltBars(Kind: string): Boolean;
By: iroki
Description: Smelts bars.
*******************************************************************************}
function SmeltBars(Kind: string): Boolean;
var
Msx, Msy, ForInv: Integer;
Smelt, BarsKind, BarsSmelting: String;
begin
repeat
Wait(200 + Random(200));
until not FindText(Msx, Msy, 'What would', NPCChars, 155, 366, 365, 381);
BarsKind := LowerCase(Kind);
case BarsKind of
'bronze' : begin ForInv := 14;
BarsSmelting := 'Bronze'; end;
'blurite' : begin ForInv := 28;
BarsSmelting := 'Blurite'; end;
'iron' : begin ForInv := 28;
BarsSmelting := 'Iron'; end;
'silver' : begin ForInv := 28;
BarsSmelting := 'Silver'; end;
'steel' : begin ForInv := 9;
BarsSmelting := 'Steel'; end;
'gold' : begin ForInv := 28;
BarsSmelting := 'Gold'; end;
'mithril' : begin ForInv := 5;
BarsSmelting := 'Mithril'; end;
'adamant' : begin ForInv := 4;
BarsSmelting := 'Adamant'; end;
'rune' : begin ForInv := 3;
BarsSmelting := 'Rune'; end;
end;
writeln(BarsSmelting);
if (ForInv <= 1) then Smelt := '1';
if ((ForInv <= 5) and (ForInv > 1)) then Smelt := '5';
if ((ForInv <= 10) and (ForInv > 5)) then Smelt := '10';
if (ForInv > 10) then Smelt := 'X';
Wait(RandomRange(400, 600));
if FindText(Msx, Msy, BarsSmelting, StatChars, 28, 428, 488, 443) then
begin
Wait(200 + RandomRange(200, 250));
Mouse(Msx + 5, Msy - 12, 10, 10, False);
Wait(900 + Random(600));
if (ForInv > 10) then
begin
ChooseOption('Smelt ' + Smelt);
Wait(1500 + Random(500));
TypeSend(IntToStr(ForInv));
Wait(500 + Random(500));
Result := True;
end else
begin
ChooseOption('Smelt ' + Smelt);
Result := True;
end;
WriteLn('We are smelting : ' + IntToStr(ForInv) + ' ' + BarsKind + ' bars');
Exit;
end else
Result := False;
end;