Jump to content
Wanted

OSI Banking additions and other stuff 12/12/2011

Recommended Posts

https://github.com/OSI1/OSI1/commit/5b02c1be417213453d2e08df393ebc1d75c8db95

 

So I have been getting a lot of requests and such to finish banking, I spent a long time today and manged to get everything done except for actual banking opening functions (NPCBank, OpenBooth, OpenBank etc.) however there are now 18 new banking functions in OSI.

 

Here's a complete list of OSI banking functions

 

 * function BankScreen: Boolean;
    By: Wanted
* function PinScreen: Boolean;
    By: Wanted
* function EnterBankPin(Pin: string): Boolean;
    By: Wanted
* function CloseBank(CheckBS: Boolean): Boolean;
    By: Wanted
* function DepositAllEx(CheckBS, Inv, Equip, Summon: Boolean): Boolean;
    By: Wanted
* function DepositAll(CheckBS: Boolean): Boolean;
    By: Wanted
* function DepositItemsEx(Slots: TIntegerArray; Exclude: Boolean; CheckBS: Boolean): Boolean;
    By: Wanted
* function DepositItems(Slots: TIntegerArray; CheckBS: Boolean): Boolean;
    By: Wanted
* function DepositAllExclude(Exclude: TIntegerArray; CheckBS: Boolean): Boolean;
    By: Wanted
* function ToggleUseNotes(Use: Boolean): Boolean;
    By: Wanted
* function ToggleSwapMode(Use: Boolean): Boolean;
    By: Wanted
* function SearchBank(CheckBS: Boolean; SearchText: string): Boolean;
    By: Wanted
* function BankShowEquipStats(CheckBS: Boolean): Boolean;
    By: Wanted
* function FixBank(FixUp: Boolean): Boolean;
    By: Wanted
* function GetBankSlotIndex(Row, Column: Integer): Integer;
    By: Wanted
* function GetBankSlotBounds(Slot: Integer): TBox;
    By: Wanted
* function GetBankTabBounds(Tab: Integer): TBox;
    By: Wanted
* function CordsToBankSlot(P: TPoint): Integer;
    By: Wanted
* function BankItemExists(Slot: Integer; CheckBS: Boolean): Boolean;
    By: Wanted
* function MouseBankItem(Slot: Integer; TypeC: ClickActions; CheckBS: Boolean): Boolean;
    By: Wanted
* function DragBankItem(FromSlot, ToSlot: Integer; CheckBS: Boolean): Boolean;
    By: Wanted
* function GetCurrentBankTab: Integer;
    By: Wanted
* function BankTabExists(Tab: Integer): Boolean;
    By: Wanted
* function SetBankTab(Tab: Integer; CheckBS: Boolean): Boolean;
    By: Wanted
* function WithdrawEx2(Options: TStringArray; B: TBox; CheckBS: Boolean): Boolean;
    By: Wanted
* function WithdrawEx(Amount: Integer; B: TBox; CheckBS: Boolean): Boolean;
    By: Wanted
* function WithdrawSlotEx(Options: TStringArray; Slot: Integer; CheckBS: Boolean): Boolean;
    By: Wanted
* function Withdraw(Amount, Slot: Integer; CheckBS: Boolean): Boolean;
    By: Wanted

 

Notice the differences in DepositEx / DepositItems Exclude ... these same type of changes were done in inventory.scar with the drop functions. This will make your lives easier. You now have DropItems, and DepositItems.

 

Here's dome debugs and indexes

 

qnsa40.png

 

Withdraw can be used a few ways

 

Either you can use it with a slot index (this will scroll the bank up when you do so) or you can use it with a B: Box for mouse box.

 

You can (if you want to) use Ex to put in your own text to use with chooseoption, however the other one is quite powerful

 

You can use it like such

 

Withdraw(Withdraw_All_But_One, 0, True);

Withdraw(5, 0, True);

Withdraw(68432, 0, True);

 

it will automatically do what's appropriate (withdraw-x, custom saved withdraw, existing withdraw, left click no chooseoption.. etc

 

Here are the new indexes

 

{=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
const Withdraw function indexes
Contributors: Wanted
Description: Index handles for withdrawing routines.
Date Created: December 11th, 2011. By Wanted. RS2 Build 688.
Last Modification: December 11th, 2011. By Wanted. RS2 Build 688.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=}

const
 Withdraw_1 = 1;
 Withdraw_5 = 5;
 Withdraw_10 = 10;
 Withdraw_All = -1337;
 Withdraw_All_But_One = -13337;

 

Unfortunately I had to add captial 'A' to the trim in chooseoptions because the OCR doesn't like it either ... like the i, and y (sometimes space)

 

There's a few other small things I changed but this is everything notable

 

Enjoy!

 

I hope to get the bank opening functions done sometime in the next few days

 

-Wanted

Link to comment
Share on other sites

Withdraw routines have a small issue. Just tried to withdraw 3 and it selected 30. If you attempt to withdraw 4 and the option 42 exists it will select 42. You get the idea...

 

Ran into the same issue when I wrote my own withdraw routines (before OSI had banking). Can't recall how I solved it and cbf to look it up before heading off to bed.

Link to comment
Share on other sites

Withdraw routines have a small issue. Just tried to withdraw 3 and it selected 30. If you attempt to withdraw 4 and the option 42 exists it will select 42. You get the idea...

 

Ran into the same issue when I wrote my own withdraw routines (before OSI had banking). Can't recall how I solved it and cbf to look it up before heading off to bed.

 

I haven't forgot about this, I plan on finding this.. implementing SMART debug canvas shit, and probably some other stuff by the end of tomorrow to OSI... like XP Bar stuff and other random stuff.

Link to comment
Share on other sites

Testing new version of my superheater and as a consequence am paying super attention to everything to ensure I have the bugs out. I have noticed one banking issue that is fairly consistent. It doesn't happen every time but it does happen a lot.

 

The first time banking (which is almost right away according to the flow of my script) after SMART has just loaded: The deposit works fine, then when it calls WithdrawEx the option menu pops up and it fails to select anything.

 

Watching the screen closely I notice the spacing of the option text takes a huge jump almost right away. You can literally watch the characters slide to the right. After that the spacing is much more consistent. So when I stop the script and restart it things work. Related?

 

Just for giggles just tried this using the browser as a client (man I had forgotten how *fast* it is compared to using SMART) and it works fine with the web browser.

 

Sitting here typing this I just realized fully 60-70% (or more) of all my SCAR issues are centered around SMART in one way or another. :mad:

Link to comment
Share on other sites

Testing new version of my superheater and as a consequence am paying super attention to everything to ensure I have the bugs out. I have noticed one banking issue that is fairly consistent. It doesn't happen every time but it does happen a lot.

 

The first time banking (which is almost right away according to the flow of my script) after SMART has just loaded: The deposit works fine, then when it calls WithdrawEx the option menu pops up and it fails to select anything.

 

Watching the screen closely I notice the spacing of the option text takes a huge jump almost right away. You can literally watch the characters slide to the right. After that the spacing is much more consistent. So when I stop the script and restart it things work. Related?

 

Just for giggles just tried this using the browser as a client (man I had forgotten how *fast* it is compared to using SMART) and it works fine with the web browser.

 

Sitting here typing this I just realized fully 60-70% (or more) of all my SCAR issues are centered around SMART in one way or another. :mad:

 

Yeah this was an issue i was having, I would also get the Text.scar error right after it quit. But i didnt think to use the browser as my scripts are imbedded into smart =/ Have you tried uping the refresh rate bar on the side of smart? Its default is 26 or something in all my script i push it up to about 29 and havent had that issue quite as often.

[scar]SmartSetRefresh(29); [/scar]

Link to comment
Share on other sites

Yeah this was an issue i was having, I would also get the Text.scar error right after it quit. But i didnt think to use the browser as my scripts are imbedded into smart =/ Have you tried uping the refresh rate bar on the side of smart? Its default is 26 or something in all my script i push it up to about 29 and havent had that issue quite as often.

[scar]SmartSetRefresh(29); [/scar]

Hmm. Worth trying. I manually set it down so I can do other things at the same time.
Link to comment
Share on other sites

Still doing it on my test machine. And to make it more fun this usually results in SCAR crashing when I try to quit. All of which only happens when running my script, which means there is something still not quite right with my script.

 

I give up. Going back to being a leech and just running other peoples scripts. Life is simpler that way.

Link to comment
Share on other sites

Still doing it on my test machine. And to make it more fun this usually results in SCAR crashing when I try to quit. All of which only happens when running my script, which means there is something still not quite right with my script.

 

I give up. Going back to being a leech and just running other peoples scripts. Life is simpler that way.

 

Lol... this is another thing i added to my open bank that i think may of fixed the issue. Try this:

 

[scar]

repeat

Try

OpenBankEX(Cut_Loc[CurrentPlayer],True,True,True);

except

Wait(1000);

end;

wait(1000);

until BankScreen or (T < GetSystemTime);

[/scar]

Link to comment
Share on other sites

Just for kicks hacked together a custom deposit routine that basically does the exact same thing as OSI's DepositAllExclude and it runs approx 1.5x faster. Runs at about the speed the OSI routines used to, but haven't for a couple of OSI updates. Wish I had taken notice exactly when it started happening.

Link to comment
Share on other sites

Just for kicks hacked together a custom deposit routine that basically does the exact same thing as OSI's DepositAllExclude and it runs approx 1.5x faster. Runs at about the speed the OSI routines used to, but haven't for a couple of OSI updates. Wish I had taken notice exactly when it started happening.

 

When I originally wrote these functions they were made in a way where there was no possible faster way. It would be helpful the most to me to explain what you changed.. in order to save me some diagnostic time.

Link to comment
Share on other sites

Give me a few. I'll throw together that contains just the 2 routines.

 

To test this login ahead of time and open the bank (leave the bank open and enable smart and press play). I had the following inventory setup:

- 1 item in slot 0 (which will get excluded).

- 10 of another item.

- 10 of yet another item.

 

Comment/uncomment lines 39 and 40 to change which method to use. Comment/uncomment line 27 to add a pause for menu to go away between deposits (slows it down a bit).

 

program new;

{$DEFINE RS2}
{$DEFINE OSI_COLOR_ANTI_RANDOMS}  // Comment out to disable random handling.
{$DEFINE SMART}                   // Comment out to disable smart client.

{$I OSI\OSI.scar}

function MyDepositItems(ExcludeSlots: TIntArray): Boolean;
var
 DepositSlots: TIntArray;
 ItemBox: TBox;
 I: Integer;
begin
 Result := False;
 DepositSlots := [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27];
 for I := 0 to High(ExcludeSlots) do
   TIARemove(DepositSlots, ExcludeSlots[i]);
 for I := 0 to High(DepositSlots) do
 begin
   if InvItemExists(DepositSlots[i]) then
   begin
     ItemBox := GetItemBounds(DepositSlots[i]);
     ItemBox := Box((ItemBox.X1 + 1), (ItemBox.Y1 + 1), (ItemBox.X2 - 1), (ItemBox.Y2 - 1));
     MouseBox(ItemBox.X1, ItemBox.Y1, ItemBox.X2, ItemBox.Y2, ClickRight);
     ChooseOptionMulti(['t-A', 'All', 'posit']);
     WaitFunc(@OptionBoxExists, False, 5, 10, 2500, 5000);
   end;
 end;
end;

procedure TestBanking;
var
 ExcludeSlots: TIntArray;  // Inventory slots to not deposit.
begin
 ExcludeSlots := [0];    
 // Deposit items.

 DepositAllExclude(ExcludeSlots, False);
//  MyDepositItems(ExcludeSlots);
end;

procedure ScriptTerminate;
begin
 FreeOSI;
end;

begin
 SetUpOSI;
 TestBanking;
end.

 

OSI's DesositAllExlcude: Successfully executed (27727.6478 ms)

MyDepositItems (without wait for menu): Successfully executed (8253.1003 ms)

MyDepositItems (with wait for menu): Successfully executed (9827.8091 ms)

This was running inside a VM so both routines are a bit slower than running full speed outside a VM. Times were fairly consistent across several runs. Edited by Bixby Sayz
Link to comment
Share on other sites

Give me a few. I'll throw together that contains just the 2 routines.

 

To test this login ahead of time and open the bank (leave the bank open and enable smart and press play). I had the following inventory setup:

- 1 item in slot 0 (which will get excluded).

- 10 of another item.

- 10 of yet another item.

 

Comment/uncomment lines 39 and 40 to change which method to use. Comment/uncomment line 27 to add a pause for menu to go away between deposits (slows it down a bit).

 

program new;

{$DEFINE RS2}
{$DEFINE OSI_COLOR_ANTI_RANDOMS}  // Comment out to disable random handling.
{$DEFINE SMART}                   // Comment out to disable smart client.

{$I OSI\OSI.scar}

function MyDepositItems(ExcludeSlots: TIntArray): Boolean;
var
 DepositSlots: TIntArray;
 ItemBox: TBox;
 I: Integer;
begin
 Result := False;
 DepositSlots := [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27];
 for I := 0 to High(ExcludeSlots) do
   TIARemove(DepositSlots, ExcludeSlots[i]);
 for I := 0 to High(DepositSlots) do
 begin
   if InvItemExists(DepositSlots[i]) then
   begin
     ItemBox := GetItemBounds(DepositSlots[i]);
     ItemBox := Box((ItemBox.X1 + 1), (ItemBox.Y1 + 1), (ItemBox.X2 - 1), (ItemBox.Y2 - 1));
     MouseBox(ItemBox.X1, ItemBox.Y1, ItemBox.X2, ItemBox.Y2, ClickRight);
     ChooseOptionMulti(['t-A', 'All', 'posit']);
     WaitFunc(@OptionBoxExists, False, 5, 10, 2500, 5000);
   end;
 end;
end;

procedure TestBanking;
var
 ExcludeSlots: TIntArray;  // Inventory slots to not deposit.
begin
 ExcludeSlots := [0];    
 // Deposit items.

 DepositAllExclude(ExcludeSlots, False);
//  MyDepositItems(ExcludeSlots);
end;

procedure ScriptTerminate;
begin
 FreeOSI;
end;

begin
 SetUpOSI;
 TestBanking;
end.

 

This was running inside a VM so both routines are a bit slower than running full speed outside a VM. Times were fairly consistent across several runs.

 

Should be fixed after you read this http://forums.scar-divi.com/showthread.php?1212-IMPORTANT-Tab-Screen-Check-Restructure-UPDATE-YOUR-SCRIPTS-NOW-OSI-Dev-3-30-12

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...