SRL Archive - SRL Archives

SmeltBars function


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;

n3ss3s

2008-05-06 13:07:23

The next rev already has a smelting function, in my opinion, if even the amount of bars wanted to do is done inside the SRL function, it is too much away from the scripter.

Besides, I bet most of the people just put something like 88, 56 etc to there, instead of counting the real amount.

Good job though, but you start your function with a possibly endless loop.

Cazax

2008-05-06 17:10:59

My smelt bars:
Function Smelt(Bar : String; HowMany : Integer): Boolean;
Var
BarBox : TBox;
begin
If Not (GetColor(36, 432) = 0) Then Exit;
If (HowMany > 28) Or (HowMany < 1) Then
Begin
srl_Warn('Smelt', 'Invalid range - ' + IntToStr(HowMany), Warn_AllVersions);
End;
Case LowerCase(Bar) Of
'bronze': BarBox := IntToBox(37, 399, 69, 418);
'blurite': BarBox := IntToBox(88, 400, 116, 421);
'iron': BarBox := IntToBox(141, 399, 171, 422);
'silver': BarBox := IntToBox(190, 401, 218, 421);
'steel': BarBox := IntToBox(243, 397, 273, 419);
'gold': BarBox := IntToBox(293, 402, 323, 419);
'mithril': BarBox := IntToBox(346, 399, 377, 423);
'addy','adamant','adamantite': BarBox := IntToBox(399, 396, 430, 420);
'rune','runite': BarBox := IntToBox(453, 400, 482, 422);
Else
Begin
srl_Warn('Smelt', 'Invalid Option - '+ Bar, Warn_AllVersions);
Result := False;
Exit;
End;
End;
MouseBox(BarBox.X1, BarBox.Y1, BarBox.X2, BarBox.Y2, 2);
Wait(150 + Random(100));
If Not (ChooseOption(IntToStr(HowMany))) Then
Begin
ChooseOption('X');
Wait(2000 + Random(1000));
TypeSend(IntToStr(HowMany));
End;
Wait(500 + Random(500));
If FindNPCChatText('Click here', ClickLeft) Then
Begin
srl_Warn('Smelt', 'No Ore(s)', Warn_AllVersions);
Result := False;
Exit;
End Else
Result := True;
End;
No text finding(except the 'click here' when you dont have ores…), mousebox, faster.

n3ss3s

2008-05-07 09:42:28

Unless someone else has got something to say about the current #17's smelting function, if it doesn't work a new one will be picked for #18.