Heysus
2009-01-24 14:24:57
R_Withdraw
R_Deposit
This is the same OpenBankReflection but I combined all the tiles into one TPA since there is no real reason to have them seperated. (It finds the nearest one anyway) Also changed it to R_OpenBank cuz most of the other reflection procedures start with "R_".
{*******************************************************************************
Function R_Withdraw(Name, Amount: string): boolean;
By: Heysus
Description: Withdraws an item from the bank.
*******************************************************************************}
Function R_Withdraw(Name, Amount: string): boolean;
var
I: integer;
P: TPoint;
BankSlots: TBankSlotArray;
begin
Result := false;
if not R_LoggedIn then
exit;
if not R_BankScreen then
if not R_OpenBank then
exit;
BankSlots := GetBankArray;
for i:=0 to High(BankSlots) do
begin
if Lowercase(BankSlots[i].Name) = Lowercase(Name) then
begin
P := BankIndexToMSPoint(i + 1);
Mouse(P.x + 16, P.y + 16, 4, 4, Amount = '1')
if Amount = '1' then
begin
Result := true;
exit;
end;
Wait(RandomRange(50, 100));
if OptionExists(Amount) then
begin
R_ChooseOption(Amount);
Result := true;
exit;
end else
begin
R_ChooseOption('Withdraw-X');
MarkTime(t);
While TimeFromMark(t) < 4000 do
begin
Wait(100);
if GetInterfaceText(752, 4) = 'Enter amount:' then
break;
end;
Wait(RandomRange(400, 800));
if GetInterfaceText(752, 4) = 'Enter amount:' then
begin
TypeSend(Amount);
Result := true;
exit;
end;
end;
end;
end;
end;
R_Deposit
{*******************************************************************************
Function R_Deposit(ID: integer; Amount: string): boolean;
By: Heysus
Description: Deposits an item into the bank.
*******************************************************************************}
Function R_Deposit(ID: integer; Amount: string): boolean;
var
N: integer;
Slots: TIntegerArray;
begin
Result := false;
if not R_LoggedIn then
exit;
if not R_BankScreen then
if not R_OpenBank then
exit;
if Amount = '0' then
begin
Result := true;
exit;
end;
if not InventoryContains(ID, Slots) then
exit;
if R_CountItemsStacks(ID) = 1 then
Amount := '1';
MouseItem(Slots[0], Amount = '1');
if Amount = '1' then
begin
Result := true;
exit;
end;
Wait(RandomRange(50, 100));
if OptionExists(Amount) then
begin
R_ChooseOption(Amount);
Result := true;
exit;
end else
begin
R_ChooseOption('Deposit-X');
MarkTime(t);
While TimeFromMark(t) < 4000 do
begin
Wait(100);
if GetInterfaceText(752, 4) = 'Enter amount:' then
break;
end;
Wait(RandomRange(400, 800));
if GetInterfaceText(752, 4) = 'Enter amount:' then
begin
TypeSend(Amount);
Result := true;
exit;
end;
end;
end;This is the same OpenBankReflection but I combined all the tiles into one TPA since there is no real reason to have them seperated. (It finds the nearest one anyway) Also changed it to R_OpenBank cuz most of the other reflection procedures start with "R_".
function R_OpenBankBooth: Boolean;
var
Tiles : TPointArray;
P : TPoint;
iTime, Tries : Integer;
begin
Result := R_BankScreen or PinScreen;
if Result then Exit;
Tiles := [
// Varrock East
Point(3251,3419), Point(3252,3419), Point(3253,3419), Point(3254,3419),
Point(3255,3419), Point(3256,3419),
// Varrock West
Point(3190,3435), Point(3190,3437), Point(3190,3439), Point(3190,3441),
Point(3190,3443), Point(3181,3444), Point(3181,3442), Point(3181,3440),
Point(3181,3438), Point(3181,3436),
// Falador West
Point(2945,3367), Point(2946,3367), Point(2947,3367), Point(2948,3367),
// Falador East
Point(3010,3354), Point(3011,3354), Point(3012,3354), Point(3013,3354),
Point(3014,3354), Point(3015,3354),
// Lumbridge
Point(3208,3221),
// Draynor
Point(3091,3419), Point(3091,3245), Point(3091,3244), Point(3091,3243),
Point(3091,3242),
//Al-Kharid
Point(3268,3168), Point(3268,3167), Point(3268,3166), Point(3268,3165),
Point(3268,3164),
// Seers
Point(2729,3494), Point(2728,3494), Point(2727,3494), Point(2724,3494),
Point(2722,3494),
// Edgeville
Point(3095,3489), Point(3095,3491), Point(3095,3493), Point(3097,3495),
// Catherby
Point(2807, 3442), Point(2809, 3442), Point(2810, 3442), Point(2811, 3442),
// Fishing Guild
Point(2585, 3422), Point(2585, 3421), Point(2585, 3419), Point(2585, 3418)
];
SortTPAFrom(Tiles, GetMyPos);
if (DistanceFrom(Tiles[0]) > 2) or not TileOnMS(Tiles[0], 10) then
begin
if not(TileOnMM(Tiles[0])) then
begin
SRL_Warn('R_OpenBankBooth', 'Could not find Bank Booth.', Warn_AllVersions);
Exit;
end;
WalkToTile(Tiles[0], 0, 0);
Wait(50);
R_Flag;
Wait(RandomRange(100, 200));
end;
if not(TileOnMS(Tiles[0], 10)) then
begin
SetAngle(True);
MakeCompass('n');
Wait(RandomRange(200, 400));
if not(TileOnMS(Tiles[0], 10)) then
begin
SRL_Warn('R_OpenBankBooth', 'Could get MS Point.', Warn_AllVersions);
Exit;
end;
end;
iTime := GetTimeRunning + 45000;
repeat
P := TileToMS(Tiles[0], 10);
MMouse(p.x - 5, p.y - 5, 11, 11);
Wait(RandomRange(200, 300));
if IsUpText('ank') then
begin
GetMousePos(P.x, P.y);
Mouse(P.x, P.y, 0, 0, false);
Wait(RandomRange(80, 110));
P.x := 0;
if R_ChooseActionMulti(['e-q']) then
repeat
R_Flag;
Wait(RandomRange(50, 90));
Inc(Tries);
Result := R_BankScreen or PinScreen;
until Result or (Tries > 40);
end;
until Result or (GetTimeRunning > iTime);
end;
function R_OpenBankBankers: Boolean;
var
NPCs : TNPCArray;
I, H, iTime : Integer;
P : TPoint;
begin
Result := R_BankScreen or PinScreen;
if Result then Exit;
NPCs := SortNPCs(GetNPCsByName('ank'));
H := High(NPCs);
if H = -1 then Exit;
for I := 0 to H do
begin
if not R_LoggedIn then Exit;
if DistanceFrom(NPCs[I].Tile) > 4 then
begin
WalkToTile(NPCs[I].Tile, 2, 0);
R_Flag;
end;
P := TileToMS(NPCs[I].Tile, NPCs[I].Height / 2);
if not PointInBox(P, IntToBox(MSX1, MSY1, MSX2, MSY2)) then
begin
SRL_Warn('R_OpenBankers', 'Could not get the Main screen point.', Warn_AllVersions);
Exit;
end;
MMouse(P.x, P.y, 4, 4);
Wait(RandomRange(80, 110));
if IsUpText('ank') then
begin
GetMousePos(P.x, P.y);
Mouse(P.x, P.y, 0, 0, False);
Wait(RandomRange(100, 150));
R_ChooseActionMulti(['ank']);
R_Flag;
iTime := GetTimeRunning + 4000;
while not (Result) and R_LoggedIn and (GetTimeRunning < iTime) do
begin
Wait(100);
Result := R_BankScreen or PinScreen;
end;
Wait(Random(80));
if Result then Break;
end;
end;
if not Result then
SRL_Warn('OpenBankBankers', 'Could not open the Bank.', Warn_AllVersions);
end;
Function R_OpenBank: Boolean;
var
Functs : array [0..1] of function: Boolean;
I : Integer;
begin
Result := R_BankScreen or PinScreen;
if R_BankScreen or PinScreen then Exit;
case Random(2) of
0: begin
Functs[0] := @R_OpenBankBooth;
Functs[1] := @R_OpenBankBankers;
end;
1: begin
Functs[0] := @R_OpenBankBankers;
Functs[1] := @R_OpenBankBooth;
end;
end;
Result := True;
for I := 0 to 1 do
if Functs[I]() then
Exit;
Result := False;
end;