SRL Archive - SRL Archives

[FIXED] WithdrawAxe


Sir R. M8gic1an

2008-05-06 17:27:41


{*******************************************************************************
function WithdrawAxe(AxeName:string): Boolean;
By: Rasta Magician
Description: Withdraws the desired axe. Bank Must be Open!
Options: Bronze -> Dragon, 'Best';
*******************************************************************************}
Function WithdrawAxe(AxeName:string): boolean;
var
i, h, bx, by:integer;
begin
if not LoggedIn then exit;
if not BankScreen then exit;
AxeName:=Lowercase(AxeName);
if AxeName <> 'best' then
begin
case AxeName of
'bronze': i:= 0;
'iron' : i:= 1;
'steel' : i:= 2;
'black' : i:= 3;
'mith' : i:= 4;
'addy' : i:= 5;
'rune' : i:= 6;
'dragon': i:= 7;
end;
if FindBitmapToleranceIn(srl_GetBitmap(47+i),bx, by, 60, 60, 454, 292, 10) then
begin
MMouse(bx, by, 2, 2);
wait(250);
if IsUpText('axe') then
begin
GetMousePos(bx, by);
Mouse(bx, by, 0, 0, True);
Result := True;
writeln('withdrawn '+AxeName+' axe succesfully.');
end;
end else begin
writeln('could not withdraw the desired axe.');
Result:= False;
end;
end else begin //if they choose best possible
if Players[CurrentPlayer].Level[20] > 0 then
begin
if Players[CurrentPlayer].Level[20] > 40 then i:= 6 else
if Players[CurrentPlayer].Level[20] > 30 then i:= 5 else
if Players[CurrentPlayer].Level[20] > 20 then i:= 4 else
if Players[CurrentPlayer].Level[20] > 5 then i:= 3
end else
i:= 6;
IncEx(i, 47);
for h:= i DownTo 47 do //not including dragon axe because a member might be in f2p
//begin
if not FindBitmapToleranceIn(srl_GetBitmap(h),bx, by, 60, 60, 454, 292, 10) then
Continue
else begin
MMouse(bx, by, 2, 2);
wait(250);
if IsUpText('axe') then
begin
GetMousePos(bx, by);
Mouse(bx, by, 0, 0, True);
Result := True;
writeln('withdrawn '+AxeName+' axe succesfully.');
exit;
end;
end;
//end;
end;
end;

just a nice addition, i just made this, intended to use it for my script. if this is added, adding one for pickaxes as well wouldn't be a bad idea :)


~RM

EvilChicken!

2008-05-06 17:54:34

{*******************************************************************************
function WithdrawAxe(AxeName:string): Boolean;
By: Rasta Magician
Description: Withdraws the desired axe. Bank Must be Open!
Options: Bronze -> Dragon, 'Best';
*******************************************************************************}

function WithdrawAxe(AxeName: string): boolean;
var
bx, by: integer;
i, h: Byte;

begin
if (not LoggedIn) or (not BankScreen) then exit;
if Lowercase(AxeName) <> 'best' then
begin
case Lowercase(AxeName) of
'bronze': i := 0;
'iron': i := 1;
'steel': i := 2;
'black': i := 3;
'mith': i := 4;
'addy': i := 5;
'rune': i := 6;
'dragon': i := 7;
end;
if FindBitmapToleranceIn(srl_GetBitmap(47 + i), bx, by, 60, 60, 454, 292, 10) then
begin
MMouse(bx, by, 2, 2);
Wait(195 + random(175));
if Pos('axe', RS_GetUpText) <> 0 then
begin
GetMousePos(bx, by);
Mouse(bx, by, 0, 0, True);
Result := True;
WriteLn('Withdrawn ' + Capitalize(LowerCase(AxeName)) + ' axe succesfully.');
end;
end else begin
WriteLn('Could not withdraw the desired axe.');
Result := False;
end;
end else begin
if Players[CurrentPlayer].Level[20] > 0 then
begin
if Players[CurrentPlayer].Level[20] > 40 then i := 6 else
if Players[CurrentPlayer].Level[20] > 30 then i := 5 else
if Players[CurrentPlayer].Level[20] > 20 then i := 4 else
if Players[CurrentPlayer].Level[20] > 5 then i := 3
end else
i := 6;
IncEx(i, 47);
for h := i downto 47 do
if not FindBitmapToleranceIn(srl_GetBitmap(h), bx, by, 60, 60, 454, 292, 10) then
Continue
else begin
MMouse(bx, by, 2, 2);
Wait(195 + random(175));
if Pos('axe', RS_GetUpText) <> 0 then
begin
GetMousePos(bx, by);
Mouse(bx, by, 0, 0, True);
Result := True;
WriteLn('Withdrawn ' + Lowercase(AxeName) + ' axe succesfully.');
end;
end;
end;
end;

Improoved it slightly in my opinion. :)

Sir R. M8gic1an

2008-05-07 11:59:31

im not sure how much more efficient that is evil, and i just realized i should add in there

edit: bullz just taught me about the right use of the finally command, so what i had posted there just made me look stupid :)



~RM

n3ss3s

2008-05-07 14:24:41

Rasta, your version did AxeName:=Lowercase(AxeName); which wouldn't work because AxeName wasn't declared using Var, so you need to use LowerCase(AxeName) in the case ;)

Sir R. M8gic1an

2008-05-07 15:23:10

oh thank you, i had the impression it had worked, but it does make some sense. when you say my version i'll take it that there is a different fixed version? ;)

~RM :)

EvilChicken!

2008-05-07 15:46:25

*points towards salf with exagerrated gestures*

I just added some minor things like randomness, the thing N3s said and someting more..

P1nky

2008-05-07 16:22:53

Thanks i needed this the 1 i made wouldnt even withdraw anything

appreciate it!

Sir R. M8gic1an

2008-05-07 17:11:31

welcome pinky, nice addition EC ;)

edit: i had time to check it now:


function IsUpText(UpText: string): Boolean;
begin
Result := (Pos(UpText, rs_GetUpText) > 0);
end;

oh and actually n3ss3s, the lowercasing does work. although your method is more correct, but the way i did it scar accepts it too. i think it just wouldn't accept it if i had actually declared it as a const.


program New;

function LowercaseThis(s:string):string;
begin
Result := lowercase(s);
end;

begin
writeln(LowercaseThis('Rasta Magician'));
end.

~RM