SRL Archive - Reflection Development

Bank.Simba Revamp


**BANNED The Man

2011-02-13 13:04:17

Ok this will be the compilation as I have done a bit of work on Bank.Simba today.

Bank.Simba now
//------------------------------------------------------------------\\
//-- Simba Reflection Library --||
//-- Bank Routines --||
//------------------------------------------------------------------//

//--- Interface Constants --//
const
INTERFACE_BANK = 762;
INTERFACE_DEPOSITBOX = 11;
INTERFACE_BANK_PIN = 13;
INTERFACE_BANK_BUTTON_CLOSE = 42;
INTERFACE_BANK_BUTTON_DEPOSIT_BEAST_INVENTORY = 36;
INTERFACE_BANK_BUTTON_DEPOSIT_CARRIED_ITEMS = 32;
INTERFACE_BANK_BUTTON_DEPOSIT_WORN_ITEMS = 34;
INTERFACE_BANK_BUTTON_HELP = 43;
INTERFACE_BANK_BUTTON_INSERT = 15;
INTERFACE_BANK_BUTTON_ITEM = 19;
INTERFACE_BANK_BUTTON_NOTE = 19;
INTERFACE_BANK_BUTTON_SEARCH = 17;
INTERFACE_BANK_BUTTON_SWAP = 15;
INTERFACE_BANK_INVENTORY = 92;
INTERFACE_BANK_ITEM_FREE_COUNT = 23;
INTERFACE_BANK_ITEM_FREE_MAX = 24;
INTERFACE_BANK_ITEM_MEMBERS_COUNT = 25;
INTERFACE_BANK_ITEM_MEMBERS_MAX = 26;
INTERFACE_BANK_SCROLLBAR = 114;
INTERFACE_BANK_TAB_ACTIVE = 1419;
INTERFACE_BANK_TAB_ADD_TEXTURE = 1435;
INTERFACE_BANK_MAXSLOTS = 515;
INTERFACE_BANK_SLOTS = 93;
//--- Bank Constants --//
const
RBank_FE = 0; // (Falador East Bank)
RBank_FW = 1; // (Falador West Bank)
RBank_VE = 2; // (Varrock East Bank)
RBank_VW = 3; // (Varrock West Bank)
RBank_DR = 4 ; // (Draynor Bank)
RBank_AK = 5; // (Al-Kharid Bank)
RBank_EV = 6 ; // (Edgeville Bank)
RBank_CT = 7; // (Catherby bank)
RBank_SA = 8; // (South Ardougne bank)
RBank_YN = 9; // (Yanille bank)
RBank_FG = 10; // (Fishing guild bank)
RBank_LB = 11 ; // (Lumbridge Bank)
RBank_SE = 12; // (Seers Bank)
RBank_MC = 13 ; // (MoonClan Bank)
RBank_DA = 14 ; // (Dual Arena Bank)
RBank_PC = 15 ; // (Pest Control Bank)
RBank_SW = 16 ; // (Soul Wars Chest Bank)


Type
TBankItem = Record
ID, Slot, StackSize: Integer;
Name: String;
end;

TBankItemArray = array of TBankItem;

{*******************************************************************************
function NULL_TBANKITEM: TBankItem;
By: mormonman
Description: Checks to see if the bank is open.
*******************************************************************************}
function NULL_TBANKITEM: TBankItem;
begin
Result.ID := NULL_INT;
Result.Slot := NULL_INT;
Result.StackSize := NULL_INT;
Result.Name := NULL_STRING;
end;

{*******************************************************************************
function NewTBankItem: TBankItem;
By: mormonman
Description: Checks to see if the bank is open.
*******************************************************************************}
function NewTBankItem(IDa, S, SS: Integer; N: String): TBankItem;
begin
Result.ID := IDa;
Result.Slot := S;
Result.StackSize := SS;
Result.Name := N;
end;

{*******************************************************************************
procedure DebugTBankItemArray(TBIA: TBankItemArray);
By: mormonman
Description: Dumps info for TBankItemArray.
*******************************************************************************}
procedure DebugTBankItemArray(TBIA: TBankItemArray);
var
i, Hi: Integer;
begin
Hi := High(TBIA);
for i := 0 to Hi do
begin
Writeln('BankItem: '+TBIA[i].Name);
Writeln(' '+'ID: '+ ToStr(TBIA[i].ID));
Writeln(' '+'Slot: '+ ToStr(TBIA[i].Slot));
Writeln(' '+'StackSize: '+ ToStr(TBIA[i].StackSize));
end;
end;

{*******************************************************************************
Function R_BankScreen: Boolean;
By:
Description: Checks to see if the bank is open.
*******************************************************************************}
function R_BankScreen: Boolean;
begin
Result := ValidInterface(INTERFACE_BANK);
end;

{*******************************************************************************
Function R_PinScreen: Boolean;
By: Drags111
Description: Checks to see if the pin screen is up.
*******************************************************************************}
function R_PinScreen: Boolean;
begin
Result := ValidInterface(INTERFACE_BANK_PIN);
end;

{*******************************************************************************
Function R_DepositAll: Boolean;
By: Camero (Camaro?), Updated by: Traveler
Description: Deposits the whole inventory either by
-Fast clicks the button
-Fast = false deposits each item
*******************************************************************************}
procedure R_DepositAll(Fast: Boolean);
var
I, Fs, MT: Integer;
begin
if not R_BankScreen then
Exit;
if(fast)then
DepositAll
else
for I := 1 to 28 do
begin
MarkTime(MT);
while (R_ItemExists(I) and (TimeFromMark(mt) < 6000)) do
begin
MouseItem(I, False);
Wait(40 + random(40));
if (OptionExists('All')) then
begin
R_ChooseOption('All');
end
else
begin
R_ChooseOption('Deposit');
end;
MarkTime(FS);
while (R_ItemExists(I) and (TimeFromMark(FS) < 2500)) do
Wait(44 + random(44));
end;
end;
end;

{*******************************************************************************
function R_DepositAllID(ID : Integer): Boolean;
By: Zyt3x, updated by: Traveler
Description: Deposits all the items with the specified ID
*******************************************************************************}
function R_DepositAllID(ID : Integer): Boolean;
begin
if(R_CountItemID(ID) = 1) then
Result := R_ClickItemID(ID, False, 'Deposit')
else
Result := R_ClickItemID(ID, False, 'All');
end;

{*******************************************************************************
procedure R_DepositAllButIDEx(IDs : TIntegerArray);
By: Zyt3x, updated by Traveler9559
Description: Deposits all items but the items with one of the specified IDs to
the bank.
*******************************************************************************}
procedure R_DepositAllButIDEx(IDs : TIntegerArray);
var
I, T : Integer;
Item : TInvItem;
begin
if not R_BankScreen then
Exit;
for I := 1 to 28 do
begin
Item := GetInvItemAt(I);
if(InIntArray(IDs, Item.ID))then Continue;
if(not R_ItemExists(I)) then Continue;
MouseItem(I, False);
if(OptionExists('All')) then
R_ChooseOption('All')
else
R_ChooseOption('Deposit');
T := GetSystemTime;
while(R_ItemExists(I)) and (GetSystemTime - T < 6000) do
Wait(100+random(100));
end;
end;

{*******************************************************************************
procedure R_DepositAllButID(ID : Integer);
By: Zyt3x
Description: Deposits all items but the items with the specified ID to the bank.
*******************************************************************************}
procedure R_DepositAllButID(ID : Integer);
begin
R_DepositAllButIDEx([ID]);
end;

{*******************************************************************************
function R_NumberOfBankTabs: Integer;
By: mormonman
Description: Returns how many bank tabs you have.
*******************************************************************************}
function R_NumberOfBankTabs: Integer;
var
arr: TIntegerArray;
tmpArr: TStringArray;
i, Hi: Integer;
begin
arr := [62, 60, 58, 56, 54, 52, 50, 48, 46];
Hi := High(arr);
for i := Hi downto 0 do
begin
tmpArr := GetInterfaceComponentActions(INTERFACE_BANK, arr[i]);
if (Length(tmpArr) < 1) then Continue;
if(Pos('all', tmpArr[0]) > 0) then
begin
Result := 1;
Exit;
end;
if(Pos(ToStr(i+1), tmpArr[0]) > 0) then Break;
end;
Result := i+1;
end;

{*******************************************************************************
function R_BankTabExists(TabNum: Integer): Boolean;
By: Shuttleu
Description: Checks if the bank tab exists.
*******************************************************************************}
function R_BankTabExists(TabNum: Integer): Boolean;
begin
Result := (TabNum <= R_NumberOfBankTabs) and (TabNum > 0);
end;

{*******************************************************************************
function R_BankTabID(TabNum: Integer): Integer;
By: Shuttleu
Description: Returns the interface component id for the tab number.
*******************************************************************************}
function R_BankTabID(TabNum: Integer): Integer;
begin
case TabNum of
1: Result := 63;
2: Result := 61;
3: Result := 59;
4: Result := 57;
5: Result := 55;
6: Result := 53;
7: Result := 51;
8: Result := 49;
9: Result := 47;
end;
end;

{*******************************************************************************
function R_CurrentBankTab: Integer;
By: Shuttleu
Description: Returns which tab you are currntly on.
*******************************************************************************}
function R_CurrentBankTab: Integer;
var
i, x: Integer;
begin
if not R_BankScreen then
begin
R_Debug('Bank not open', 'R_CurrentBankTab');
Exit;
end;
for i := 62 downto 45 do
begin
x := GetInterfaceComponentTextureID(INTERFACE_BANK, i);
if (x = INTERFACE_BANK_TAB_ACTIVE) then break;
end;
if InIntArrayEx([62, 60, 58, 56, 54, 52, 50, 48, 46], x, i) then
Result:= (x + 1) else Result := -1;
end;

{*******************************************************************************
function R_BankTab(TabNum: Integer): Boolean;
By: Shuttleu/mormonman
Description: Clicks on the bank tab if it exists.
*******************************************************************************}
function R_BankTab(TabNum: Integer): Boolean;
var
ID, time: Integer;
Position: TBox;
begin
if not R_BankScreen then
begin
R_Debug('Bank not open', 'R_BankTab');
Exit;
end;
if not R_BankTabExists(TabNum) then
begin
R_Debug('Tab does not exist', 'R_BankTab');
Exit;
end;
if (R_CurrentBankTab = TabNum) then
begin
R_Debug('Tab already open', 'R_BankTab');
Result := True;
Exit;
end;

ID := R_BankTabID(TabNum);
Position:= GetInterfaceComponentRelativePosition(INTERFACE_BANK, ID);
Mouse(RandomRange(Position.x1, Position.x2), RandomRange(Position.y1, Position.y2)
, 0, 0, True);
MarkTime(time);
while not (R_CurrentBankTab = TabNum) do
begin
Wait(250);
if (TimeFromMark(time) > 8000) then
Exit;
end;
Result:= (R_CurrentBankTab = TabNum);
Wait(500 + Random(500));
end;

{*******************************************************************************
Function ReadyToTypeBank: Boolean;
By: Shuttleu
Description: Returns true if it is on the item search screen.
*******************************************************************************}
function ReadyToTypeBank: Boolean;
begin
if not R_BankScreen then
begin
R_Debug('Bank not open', 'ReadyToTypeBank');
Exit;
end;
Result:= not GetInterfaceComponentIsHidden(752, 3);
end;

{*******************************************************************************
function R_GetAllBankItems: TBankItemArray;
By: mormonman
Description: Returns all Bank Items.
*******************************************************************************}
function R_GetAllBankItems: TBankItemArray;
var
rCount, slot, tmpID, tmpSS: Integer;
tmpName: String;
begin
if not R_BankScreen then
begin
R_Debug('Bank not open', 'R_ItemsExistInBankMulti');
Exit;
end;
SetLength(Result, INTERFACE_BANK_MAXSLOTS + 1);
for slot := 0 to INTERFACE_BANK_MAXSLOTS do
begin
tmpID := GetChildComponentID(INTERFACE_BANK, INTERFACE_BANK_SLOTS, slot);
if (tmpID > 0) then
begin
//R_Debug('#' +ToStr(slot), 'Slot');
tmpName := TrimHTML(GetChildComponentName(INTERFACE_BANK, INTERFACE_BANK_SLOTS, slot));
tmpSS := GetChildComponentStack(INTERFACE_BANK, INTERFACE_BANK_SLOTS, slot);
Result[rCount] := NewTBankItem(tmpID, slot, tmpSS, tmpName);;
inc(rCount);
end;
end;
SetLength(Result, rCount);
end;

{*******************************************************************************
function R_ItemsExistInBankEx(TheVarArr: TVariantArray; var ItemArray: TBankItemArray): Boolean;
By: mormonman
Description: Returns true if one of the items exists in bank.
It also returns the array of Items.
*******************************************************************************}
function R_ItemsExistInBankEx(TheVarArr: TVariantArray; var ItemArray: TBankItemArray): Boolean;
var
i, Hi, h, vType, resCounter, Hig: Integer;
B: Boolean;
BItems: TBankItemArray;
begin
if not R_BankScreen then
begin
R_Debug('Bank not open', 'R_ItemsExistInBank');
Exit;
end;
BItems := R_GetAllBankItems;
Hig := High(BItems);
resCounter := 0;
SetLength(ItemArray, Hig + 1);
for i := 0 to Hig do
begin
Hi := High(TheVarArr);
for h := 0 to Hi do
begin
vType := VarType(TheVarArr[h]);
if (vType = varString) then
TheVarArr[h] := LowerCase(Trim(TheVarArr[h]));
case vType of
varInteger: B := (BItems[i].ID = TheVarArr[h]);
varString: B := (Pos(TheVarArr[h], LowerCase(Trim(BItems[i].Name))) > 0);
else Exit;
end;
if not B then
Continue;
ItemArray[resCounter] := NewTBankItem(BItems[i].ID, BItems[i].Slot, BItems[i].StackSize, BItems[i].Name);
inc(resCounter);
end;
end;
SetLength(ItemArray, resCounter);
Result := (Length(ItemArray) > 0);
end;

{*******************************************************************************
function R_ItemExistsInBankEx(TheVarArr: TVariantArray; var Item: TBankItem): Boolean;
By: mormonman
Description: Returns true if one of the items exists in bank.
It also returns the first Item.
*******************************************************************************}
function R_ItemExistsInBankEx(TheVarArr: TVariantArray; var Item: TBankItem): Boolean;
var
IA: TBankItemArray;
begin
Item := NULL_TBANKITEM;
Result := R_ItemsExistInBankEx(TheVarArr, IA);
if Result then
Item := IA[0];
end;

{*******************************************************************************
function R_ItemExistsInBank(TheVar: Variant; var Item: TBankItem): Boolean;
By: mormonman
Description: Returns true if the item exists in bank also returns the Item.
*******************************************************************************}
function R_ItemExistsInBank(TheVar: Variant; var Item: TBankItem): Boolean;
begin
Result := R_ItemExistsInBankEx([TheVar], Item);
end;

{*******************************************************************************
function R_GetItemAtBankSlot(BankSlot: Integer): TBankItem;
By: mormonman
Description: Returns the item of the given slot.
*******************************************************************************}
function R_GetItemAtBankSlot(BankSlot: Integer): TBankItem;
begin
Result := NULL_TBANKITEM;
if not R_BankScreen then
begin
R_Debug('Bank not open', 'R_GetItemIDAtBankSlot');
Exit;
end;
if (GetChildComponentID(INTERFACE_BANK, INTERFACE_BANK_SLOTS, BankSlot) > 0) then
begin
Result.ID := GetChildComponentID(INTERFACE_BANK, INTERFACE_BANK_SLOTS, BankSlot);
Result.Name := TrimHTML(GetChildComponentName(INTERFACE_BANK, INTERFACE_BANK_SLOTS, BankSlot));
Result.Slot := BankSlot;
Result.StackSize := GetChildComponentStack(INTERFACE_BANK, INTERFACE_BANK_SLOTS, BankSlot);
end;
end;

{*******************************************************************************
function R_FirstTabItem: TBankItem;
By: mormonman
Description: Returns what tab the ItemSlot is on.
*******************************************************************************}
function R_FirstTabItem: Integer;
var
slot, tmpID: Integer;
begin
Result := NULL_INT;
if not R_BankScreen then
begin
R_Debug('Bank not open', 'R_FirstTabItem');
Exit;
end;
for slot := 0 to INTERFACE_BANK_MAXSLOTS do
begin
tmpID := GetChildComponentID(INTERFACE_BANK, INTERFACE_BANK_SLOTS, slot);
if (tmpID > 0) then
begin
//R_Debug('#' +ToStr(slot), 'Slot');
if (GetChildComponentRelativeY(INTERFACE_BANK, INTERFACE_BANK_SLOTS, slot) = 5) then
Result := tmpID;
end;
end;
end;

{*******************************************************************************
function R_TabSlotIsOn(ItemSlot: Integer): Integer;
By: mormonman
Description: Returns what tab the ItemSlot is on.
*******************************************************************************}
function R_TabSlotIsOn(ItemSlot: Integer): Integer;
var
BankTabItemIDs: TIntegerArray;
I, Tabs, FItem: Integer;
Item: TBankItem;
begin
Result := -1;
if not R_BankScreen then
begin
R_Debug('Bank not open', 'R_TabItemIsOn');
Exit;
end;

Tabs := R_NumberOfBankTabs;
if (Tabs < 2) then
begin
Result := 1;
end;

SetLength(BankTabItemIDs, Tabs);
for I := 0 to High(BankTabItemIDs) do
BankTabItemIDs[I] := GetInterfaceComponentID(INTERFACE_BANK, R_BankTabID(I+1));
//writeln(banktabitemids);
FItem := R_FirstTabItem;writeln(fitem);
BankTabItemIDs[0] := FItem;
for I := ItemSlot downto 0 do
begin
Item := R_GetItemAtBankSlot(I);
if InIntArrayEx(BankTabItemIDs, Result, Item.ID) then
begin
Inc(Result);
Exit;
end;
end;
end;

{*******************************************************************************
function R_WithdrawItemEx(TheVar: Variant; Amount: Integer; var Index: Integer; FirstTab: Boolean): Boolean;
By: Bad Boy JH/mormonman
Description: Withdraws amount of item. Returns the bankslot to Index.
* 0 = withdraw all
* -1 = Withdraw all but one
*******************************************************************************}
function R_WithdrawItemEx(TheVar: Variant; Amount: Integer; var Index: Integer; FirstTab: Boolean): Boolean;
var
WhichBankTab, Mark, InvCou, CountTime: Integer;
RelPoint: TPoint;
ItemBox: TBox;
Item: TBankItem;
begin
if not R_BankScreen then
begin
R_Debug('Bank not open', 'R_WithdrawItemIDEx');
Exit;
end;
if FirstTab then R_BankTab(1);
if not R_ItemExistsInBank(TheVar, Item) then
begin
R_Debug('Item not in bank', 'R_WithdrawItemIDEx');
Exit;
end;
Index := Item.Slot;
writeln(index);

RelPoint.x := GetChildComponentRelativeX(INTERFACE_BANK, INTERFACE_BANK_SLOTS, Index);
RelPoint.y := GetChildComponentRelativeY(INTERFACE_BANK, INTERFACE_BANK_SLOTS, Index);
R_Debug(ToStr(RelPoint), 'RelPoint');
if not PointInBox(RelPoint, MSBOX) then
//this checks if its on the current tab, if its not the Relative Point will be 0
begin
R_BankTab(1);
R_Debug('Item not in current tab, switching tabs', 'R_WithdrawItemIDEx');
WhichBankTab := R_TabSlotIsOn(Index);
//This then clicks the correct Bank Tab
R_Debug('Item in Tab: ' + ToStr(WhichBankTab), 'R_WithdrawItemIDEx');
R_BankTab(WhichBankTab);
RelPoint.x := GetChildComponentRelativeX(INTERFACE_BANK, INTERFACE_BANK_SLOTS, Index);
RelPoint.y := GetChildComponentRelativeY(INTERFACE_BANK, INTERFACE_BANK_SLOTS, Index);
R_Debug(ToStr(RelPoint), 'RelPoint');
if not PointInBox(RelPoint, MSBOX) then
begin
R_Debug('Item not in tab', 'R_WithdrawItemIDEx');
Exit;
end;
end;

//this then gets the box of the Item we want to withdraw.
ItemBox.x1 := RelPoint.x + GetInterfaceComponentRelativeX(INTERFACE_BANK, INTERFACE_BANK_SLOTS) + 4;
ItemBox.y1 := RelPoint.y + GetInterfaceComponentRelativeY(INTERFACE_BANK, INTERFACE_BANK_SLOTS) + 4;
ItemBox.x2 := ItemBox.x1 + GetChildComponentWidth(INTERFACE_BANK, INTERFACE_BANK_SLOTS, Index);
ItemBox.y2 := ItemBox.y1 + GetChildComponentHeight(INTERFACE_BANK, INTERFACE_BANK_SLOTS, Index);

//then it withdraws the items
if Amount = 1 then
begin
MouseBox(ItemBox.x1, ItemBox.y1, ItemBox.x2, ItemBox.y2, 1);
Result := True;
Exit;
end;
MouseBox(ItemBox.x1, ItemBox.y1, ItemBox.x2, ItemBox.y2, 2);
MarkTime(CountTime);
InvCou := R_CountItemID(Item.ID);
if Amount = 0 then
Result := R_ChooseOption('Withdraw-All ' + Item.Name) else
if Amount = -1 then
Result := R_ChooseOption('Withdraw-All but one ' + Item.Name) else
if OptionExists('Withdraw-' + IntToStr(Amount)) then
Result := R_ChooseOption('Withdraw-' + IntToStr(Amount) + ' ' + Item.Name)
else
begin
if R_ChooseOption('Withdraw-X ' + Item.Name) then
begin
MarkTime(Mark);
while not ReadyToTypeBank do
begin
Wait(RandomRange(100, 250));
if (TimeFromMark(Mark) > 10000) then
begin
Result := False;
R_Debug('ReadyToTypeBank timed-out', 'R_WithdrawItemIDEx');
Exit;
end;
end;
Wait(1000 + Random(1000));
TypeSend(IntToStr(Amount));
Result := True;
end;
end;

if not Result then
begin
R_Debug('Tried to withdraw wrong item', 'R_WithdrawItemIDEx');
Exit;
end;

//failsafe
while (R_CountItemID(Item.ID) = InvCou) do
begin
if (TimeFromMark(CountTime) > 8000) then
begin
R_Debug('Item withdraw timed-out', 'R_WithdrawItemIDEx');
Result := False;
Exit;
end;
Wait(500);
end;
end;

{*******************************************************************************
function R_WithdrawItem(TheVar: Variant; Amount: Integer): Boolean;
By: Bad Boy JH/mormonman
Description: Withdraws amount of item.
* 0 = withdraw all
* -1 = Withdraw all but one
*******************************************************************************}
function R_WithdrawItem(TheVar: Variant; Amount: Integer): Boolean;
var
i: Integer;
begin
Result := R_WithdrawItemEx(TheVar, Amount, i, True);
end;

{*******************************************************************************
function R_WithdrawItemIDSearch(ID, HowMany: Integer; Name: String): Boolean;
By: Shuttleu
Description: Withdraws item ID using the search button.
*******************************************************************************}
{function R_WithdrawItemIDSearch(ID, HowMany: Integer; Name: String): Boolean;
var
i, Slot : Integer;
SearchLoc, ItemPos: TBox;
begin
if (not(R_BankScreen)) then Exit;
if (not(R_ItemExistsInBank(ID, Slot))) then Exit;
SearchLoc := GetInterfaceComponentRelativePosition(INTERFACE_BANK, 17);
Mouse(RandomRange(SearchLoc.x1, SearchLoc.x2), RandomRange(SearchLoc.y1, SearchLoc.y2),
0, 0, True);
repeat
Wait(100 + Random(50));
Inc(i);
until ((i > 4) or ReadyToTypeBank);
if ReadyToTypeBank then
begin
TypeSend(Name);
Wait(300 + Random(300));
R_ItemExistsInBank(ID, Slot);
ItemPos := GetChildComponentScreenPosition(INTERFACE_BANK, INTERFACE_BANK_SLOTS, Slot);
if (HowMany = 1) then
begin
Mouse(RandomRange(ItemPos.x1, ItemPos.x2), RandomRange(ItemPos.y1, ItemPos.y2),
0, 0, True);
Result := True;
Exit;
end else
begin
Mouse(RandomRange(ItemPos.x1, ItemPos.x2), RandomRange(ItemPos.y1, ItemPos.y2),
0, 0, False);
Wait(100 + Random(200));
case HowMany of
5, 10: if R_ChooseOption('Withdraw-'+IntToStr(HowMany)) then
begin
Result := True;
Exit;
end;
0: if R_ChooseOption('Withdraw-All') then
begin
Result := True;
Exit;
end;
else
if R_ChooseOption('Withdraw-X') then
begin
Wait(100 + Random(200));
if ReadyToTypeBank then
begin
TypeSend(IntToStr(HowMany));
Result := True;
Exit;
end;
end;
end;
end;
end;
end;

{*******************************************************************************
Function R_OpenBankBooth(Bank : Intger): Boolean;
By: ss23 & TheGuyWhoGotOn Edit: Dynamite
Description: Opens the bank using Bank Booth.
*******************************************************************************}
function R_OpenBankBooth(Bank : Integer) : Boolean;
var
Tiles: TPointArray;
P: TPoint;
Tries: Integer;
begin
Result := R_BankScreen or R_PinScreen;
if Result then Exit;

case (Bank) of
RBank_FE:
Tiles := [Point(3010,3354), Point(3011,3354), Point(3012,3354),
Point(3013,3354), Point(3014,3354), Point(3015,3354)];
RBank_FW:
Tiles := [Point(2945,3367), Point(2946,3367), Point(2947,3367),
Point(2948,3367)];
RBank_VE:
Tiles := [Point(3251,3419), Point(3252,3419), Point(3253,3419),
Point(3254,3419), Point(3255,3419), Point(3256,3419)];
RBank_VW:
Tiles := [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)];
RBank_DR:
Tiles := [Point(3091,3245), Point(3091,3243), Point(3091,3242)];
RBank_AK:
Tiles := [Point(3268,3168), Point(3268,3167), Point(3268,3166),
Point(3268,3169), Point(3268,3164)];
RBank_EV:
Tiles := [Point(3095,3489), Point(3095,3491), Point(3095,3493),
Point(3097,3495)];
RBank_CT:
Tiles := [Point(2807,3442), Point(2809,3442), Point(2810,3442),
Point(2811,3442)];
RBank_SA:
Tiles := [Point(2656, 3286), Point(2656, 3283)];
RBank_YN:
Tiles := [Point(2614, 3094), Point(2614, 3092), Point(2614, 3091)];
RBank_FG:
Tiles := [Point(2584, 3423), Point(2584, 3422)];
RBank_LB:
Tiles := [Point(3208,3221)];
RBank_SE:
Tiles := [Point(2729,3494), Point(2728,3494), Point(2727,3494),
Point(2724,3494), Point(2722,3494), Point(2721,3494)];
RBank_MC:
Tiles := [Point(2098, 3920), Point(2097, 3920), Point(2098, 3920)];
RBank_DA:
Tiles := [Point(3381, 3269), Point(3382, 3270)];
RBank_PC:
Tiles := [Point(2667, 2652), Point(2666, 2652), Point(2665, 2652),
Point(2668, 2652)];
else
begin
SRL_Warn('R_OpenBankBooth', 'Unsupported bank name.', -1);
Exit;
end;
end;
SortTPAFrom(Tiles, GetMyPos);
if (DistanceFrom(Tiles[0]) > 3) 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;

P := TileToMS(Tiles[0], 10);
MMouse(p.x - 5, p.y - 5, 11, 11);
Wait(RandomRange(200, 300));
if IsUpTextMultiCustom(['ank', 'ooth']) then
begin
GetMousePos(P.x, P.y);
Mouse(P.x, P.y, 0, 0, false);
Wait(RandomRange(80, 110));
P.x := 0;
if R_ChooseOptionMulti(['Use-quickly']) then
repeat
R_Flag;
Wait(RandomRange(50, 90));
Inc(Tries);
if (Length(Players) > 0) then
if Players[CurrentPlayer].Pin <> '' then
Result := InPin(Players[CurrentPlayer].Pin);
Result := R_BankScreen or R_PinScreen;
until Result or (Tries > 40);
end;
end;

{*******************************************************************************
Function R_AtBank(Bank : Integer): Boolean;
By: Dynamite
Description: Will result true if at specified bank.
*******************************************************************************}
function R_AtBank(Bank : Integer) : Boolean;
var
Tiles: TPointArray;
P: TPoint;
Tries: Integer;
begin
case (Bank) of
RBank_FE:
Tiles := [Point(3010,3354), Point(3011,3354), Point(3012,3354),
Point(3013,3354), Point(3014,3354), Point(3015,3354)];
RBank_FW:
Tiles := [Point(2945,3367), Point(2946,3367), Point(2947,3367),
Point(2948,3367)];
RBank_VE:
Tiles := [Point(3251,3419), Point(3252,3419), Point(3253,3419),
Point(3254,3419), Point(3255,3419), Point(3256,3419)];
RBank_VW:
Tiles := [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)];
RBank_DR:
Tiles := [Point(3091,3245), Point(3091,3243), Point(3091,3242)];
RBank_AK:
Tiles := [Point(3268,3168), Point(3268,3167), Point(3268,3166),
Point(3268,3169), Point(3268,3164)];
RBank_EV:
Tiles := [Point(3095,3489), Point(3095,3491), Point(3095,3493),
Point(3097,3495)];
RBank_CT:
Tiles := [Point(2807,3442), Point(2809,3442), Point(2810,3442),
Point(2811,3442)];
RBank_SA:
Tiles := [Point(2656, 3286), Point(2656, 3283)];
RBank_YN:
Tiles := [Point(2614, 3094), Point(2614, 3092), Point(2614, 3091)];
RBank_FG:
Tiles := [Point(2584, 3423), Point(2584, 3422)];
RBank_LB:
Tiles := [Point(3208,3221)];
RBank_SE:
Tiles := [Point(2729,3494), Point(2728,3494), Point(2727,3494),
Point(2724,3494), Point(2722,3494), Point(2721,3494)];
RBank_MC:
Tiles := [Point(2098, 3920), Point(2097, 3920), Point(2098, 3920)];
RBank_DA:
Tiles := [Point(3381, 3269), Point(3382, 3270)];
RBank_PC:
Tiles := [Point(2667, 2652), Point(2666, 2652), Point(2665, 2652),
Point(2668, 2652)];
else
begin
SRL_Warn('R_AtBank', 'Unsupported bank name.', -1);
Exit;
end;
end;
SortTPAFrom(Tiles, GetMyPos);
if (DistanceFrom(Tiles[0]) > 4) or not TileOnMS(Tiles[0], 10) then
begin
if not(TileOnMM(Tiles[0])) then
begin
SRL_Warn('R_AtBank', 'Not At '+Bank, 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_AtBank', 'Couldnt get MS Point.', Warn_AllVersions);
Exit;
end;
end;
Result := DistanceFrom(Tiles[0]) =< 4;
end;

{*******************************************************************************
Function R_OpenBankChest(Bank : Intger): Boolean;
By: Dynamite
Description: Opens the bank chest.
*******************************************************************************}
function R_OpenBankChest(Bank : integer) : Boolean;
var
Tiled:TPoint
P: TPoint;
Tries: Integer;
begin
Result := R_BankScreen or R_PinScreen;
if Result then Exit;

case (Bank) of
RBank_SW:
Tiled := Point(1893, 3180);
else
begin
SRL_Warn('R_OpenBankChest', 'Unsupported bank name. Please ask Dynamite to add the chest.', -1);
Exit;
end;
end;
SortTPAFrom(Tiled, GetMyPos);
if (DistanceFrom(Tiled[0]) > 3) or not TileOnMS(Tiled[0], 10) then
begin
if not(TileOnMM(Tiled[0])) then
begin
SRL_Warn('R_OpenBankChest', 'Could not find Chest.', Warn_AllVersions);
Exit;
end;
WalkToTile(Tiled[0], 0, 0);
Wait(50);
R_Flag;
Wait(RandomRange(100, 200));
end;
if not(TileOnMS(Tiled[0], 10)) then
begin
SetAngle(True);
MakeCompass('n');
Wait(RandomRange(200, 400));
if not(TileOnMS(Tiled[0], 10)) then
begin
SRL_Warn('R_OpenBankChest', 'Could get MS Point.', Warn_AllVersions);
Exit;
end;
end;

P := TileToMS(Tiled[0], 10);
MMouse(p.x - 5, p.y - 5, 11, 11);
Wait(RandomRange(200, 300));
if IsUpTextMultiCustom(['ank', 'hest']) then
begin
GetMousePos(P.x, P.y);
Mouse(P.x, P.y, 0, 0, false);
Wait(RandomRange(80, 110));
P.x := 0;
if R_ChooseOptionMulti(['Use']) then
repeat
R_Flag;
Wait(RandomRange(50, 90));
Inc(Tries);
if (Length(Players) > 0) then
if Players[CurrentPlayer].Pin <> '' then
Result := InPin(Players[CurrentPlayer].Pin);
Result := R_BankScreen or R_PinScreen;
until Result or (Tries > 40);
end;
end;

R_AtBank
{*******************************************************************************
Function R_AtBank(Bank : Integer): Boolean;
By: Dynamite
Description: Will result true if at specified bank.
*******************************************************************************}
function R_AtBank(Bank : Integer) : Boolean;
var
Tiles: TPointArray;
P: TPoint;
Tries: Integer;
begin
case (Bank) of
RBank_FE:
Tiles := [Point(3010,3354), Point(3011,3354), Point(3012,3354),
Point(3013,3354), Point(3014,3354), Point(3015,3354)];
RBank_FW:
Tiles := [Point(2945,3367), Point(2946,3367), Point(2947,3367),
Point(2948,3367)];
RBank_VE:
Tiles := [Point(3251,3419), Point(3252,3419), Point(3253,3419),
Point(3254,3419), Point(3255,3419), Point(3256,3419)];
RBank_VW:
Tiles := [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)];
RBank_DR:
Tiles := [Point(3091,3245), Point(3091,3243), Point(3091,3242)];
RBank_AK:
Tiles := [Point(3268,3168), Point(3268,3167), Point(3268,3166),
Point(3268,3169), Point(3268,3164)];
RBank_EV:
Tiles := [Point(3095,3489), Point(3095,3491), Point(3095,3493),
Point(3097,3495)];
RBank_CT:
Tiles := [Point(2807,3442), Point(2809,3442), Point(2810,3442),
Point(2811,3442)];
RBank_SA:
Tiles := [Point(2656, 3286), Point(2656, 3283)];
RBank_YN:
Tiles := [Point(2614, 3094), Point(2614, 3092), Point(2614, 3091)];
RBank_FG:
Tiles := [Point(2584, 3423), Point(2584, 3422)];
RBank_LB:
Tiles := [Point(3208,3221)];
RBank_SE:
Tiles := [Point(2729,3494), Point(2728,3494), Point(2727,3494),
Point(2724,3494), Point(2722,3494), Point(2721,3494)];
RBank_MC:
Tiles := [Point(2098, 3920), Point(2097, 3920), Point(2098, 3920)];
RBank_DA:
Tiles := [Point(3381, 3269), Point(3382, 3270)];
RBank_PC:
Tiles := [Point(2667, 2652), Point(2666, 2652), Point(2665, 2652),
Point(2668, 2652)];
else
begin
SRL_Warn('R_AtBank', 'Unsupported bank name.', -1);
Exit;
end;
end;
SortTPAFrom(Tiles, GetMyPos);
if (DistanceFrom(Tiles[0]) > 4) or not TileOnMS(Tiles[0], 10) then
begin
if not(TileOnMM(Tiles[0])) then
begin
SRL_Warn('R_AtBank', 'Not At '+Bank, 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_AtBank', 'Couldnt get MS Point.', Warn_AllVersions);
Exit;
end;
end;
Result := DistanceFrom(Tiles[0]) =< 4;
end;

R_OpenBankChest
{*******************************************************************************
Function R_OpenBankChest(Bank : Intger): Boolean;
By: Dynamite
Description: Opens the bank chest.
*******************************************************************************}
function R_OpenBankChest(Bank : integer) : Boolean;
var
Tiled:TPoint
P: TPoint;
Tries: Integer;
begin
Result := R_BankScreen or R_PinScreen;
if Result then Exit;

case (Bank) of
RBank_SW:
Tiled := Point(1893, 3180);
else
begin
SRL_Warn('R_OpenBankChest', 'Unsupported bank name. Please ask Dynamite to add the chest.', -1);
Exit;
end;
end;
SortTPAFrom(Tiled, GetMyPos);
if (DistanceFrom(Tiled[0]) > 3) or not TileOnMS(Tiled[0], 10) then
begin
if not(TileOnMM(Tiled[0])) then
begin
SRL_Warn('R_OpenBankChest', 'Could not find Chest.', Warn_AllVersions);
Exit;
end;
WalkToTile(Tiled[0], 0, 0);
Wait(50);
R_Flag;
Wait(RandomRange(100, 200));
end;
if not(TileOnMS(Tiled[0], 10)) then
begin
SetAngle(True);
MakeCompass('n');
Wait(RandomRange(200, 400));
if not(TileOnMS(Tiled[0], 10)) then
begin
SRL_Warn('R_OpenBankChest', 'Could get MS Point.', Warn_AllVersions);
Exit;
end;
end;

P := TileToMS(Tiled[0], 10);
MMouse(p.x - 5, p.y - 5, 11, 11);
Wait(RandomRange(200, 300));
if IsUpTextMultiCustom(['ank', 'hest']) then
begin
GetMousePos(P.x, P.y);
Mouse(P.x, P.y, 0, 0, false);
Wait(RandomRange(80, 110));
P.x := 0;
if R_ChooseOptionMulti(['Use']) then
repeat
R_Flag;
Wait(RandomRange(50, 90));
Inc(Tries);
if (Length(Players) > 0) then
if Players[CurrentPlayer].Pin <> '' then
Result := InPin(Players[CurrentPlayer].Pin);
Result := R_BankScreen or R_PinScreen;
until Result or (Tries > 40);
end;
end;

Bank.Simba now uses Bank Constants which are integers, I have also edited the required functions.

Thanks :)

-Boom

Nava2

2011-02-13 13:06:10

Perhaps make the constants coincide with these: https://github.com/Nava2/SRL-5/blob/master/SRL/core/bank.simba?

NCDS

2011-02-13 13:08:05


LowerCase(Bank)
Wont compile with an Integer..

Also, why not use the constants in the case itself..? That defeats the purpose of them being constants.

From: Nava2
Perhaps make the constants coincide with these: https://github.com/Nava2/SRL-5/blob/master/SRL/core/bank.simba?

I posted them on the other thread ;)

**BANNED The Man

2011-02-13 13:09:27

From: Nava2
Perhaps make the constants coincide with these: https://github.com/Nava2/SRL-5/blob/master/SRL/core/bank.simba?


Umm, they pretty much do, no?
Or do you mean, match integer with integer?
If so, any reason?
People won't use the actual integer anyway, they will use the constant.(The reason they are they xD )

-Boom

Nava2

2011-02-13 13:11:02

From: Dynamite
Umm, they pretty much do, no?
Or do you mean, match integer with integer?
If so, any reason?
People won't use the actual integer anyway, they will use the constant.(The reason they are they xD )

-Boom


Well, making them interchangeable would be ideal.

**BANNED The Man

2011-02-13 13:14:04

From: NCDS

LowerCase(Bank)
Wont compile with an Integer..

Also, why not use the constants in the case itself..? That defeats the purpose of them being constants.


I posted them on the other thread ;)


Afaik, for example…
RBank_FE = 0;
R_OpenBankBooth(RBank_FE)
will work, no?

-Boom

Sir R. M8gic1an

2011-02-13 13:19:52

In the functions you should use the constants rather than the numbers ;)

~RM

**BANNED The Man

2011-02-13 13:20:52

Hmm, ok, well if you guys insist :P xD

EDIT: Done to you guys' wishes :) <3

-Boom

mormonman

2011-02-13 14:11:45

Combine R_OpenBankBooth and R_OpenBankChest. No reason to have two.

NCDS

2011-02-13 14:41:56

You still have

case LowerCase(Bank) of
which won't work with Integers.

Protip: Compile before you post. ;)

Gu3st...

2011-02-13 14:46:17

From: Dynamite
Hmm, ok, well if you guys insist :P xD

-Boom
Not only did they insist, that's the whole point of constants :)

**BANNED The Man

2011-02-13 14:49:34

From: NCDS
You still have

case LowerCase(Bank) of
which won't work with Integers.

Protip: Compile before you post. ;)


Wat… XD thought i edited them all.
Sowwi.. and good tip ;) haha

**BANNED The Man

2011-02-13 15:18:14

From: Zyt3x
Not only did they insist, that's the whole point of constants :)


But what I was saying is that they work both ways.
But, I guess it helps with readability.

-Boom

Sir R. M8gic1an

2011-02-13 15:27:07

From: Dynamite
But what I was saying is that they work both ways.
But, I guess it helps with readability.

-Boom


And updatability, which is the main reason for most consts ;)

eg const BlackOutline, const TreeColor, etc.

~RM