• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Banks..?

Status
Not open for further replies.
I'm attempting to self-teach myself banks.
My questions are faily basic to anyone who has any experience with them.

I'm creating an experience bar monitored by integer variables.
To my understand it's as simple as:

Editing x variable,
Applying x variable to y bank,
Recalling y bank when needed,
Applying y bank to x variable.

Or is as simple as,

Editing x variable,
Saving x variable as y bank,
Recalling y bank when needed?

Thanks ahead of time for the help.
 
Level 22
Joined
Feb 4, 2005
Messages
3,971
Even before you have any data you want to store, you need to have

AreasPassedTracking = 0 <Integer>
AreasPassedTrackingBank = No Bank <Bank>

  • Areas Passed Tracking
    • Events
      • Game - Map initialization
    • Local Variables
    • Conditions
    • Actions
      • Bank - Preload and synchronize bank "AreasPassedTracking" for player 1
      • Bank - Open bank "AreasPassedTracking" for player 1
      • Variable - Set AreasPassedTrackingBank = (Last opened bank)
      • Variable - Set AreasPassedTracking = (Load "MyKey" of section "MySection" from bank AreasPassedTrackingBank as integer value)
That is Preload and Open bank for the player or players should be always on some Map Init event. This tells it to load the data that the Bank contains for the player, so that the map can use it. Also, the variable I will further modify always loads the Data of the Bank where I saved such value.

You can pick all players and open bank for (Picked player) but doing so for Preload won't work. Always Preload with a separate action,

Bank - Preload and synchronize bank "AreasPassedTracking" for player 1
Bank - Preload and synchronize bank "AreasPassedTracking" for player 2 etc.

The first time you run the trigger, the Variable will be 0 as there is no bank to take the data from. The next time, it will load the value from the file that saved in your Banks\ folder.

You save information (integers, reals, strings) in specific Sections under specific Keys. Key is just the name of the value (integer, real etc) that you will store, Section is the location or the line within the Bank where the Key will be stored.

These Keys and Sections are created when you decide to save the bank, like I decide to track how many times I restarted the map, so when the map ends - which happens when I enter a region, I give the triggers to save the bank:

  • Next Area
    • Events
      • Unit - Any Unit Enters Next Area
    • Local Variables
    • Conditions
    • Actions
      • Variable - Modify AreasPassedTracking: + 1
      • Bank - Store integer AreasPassedTracking as "MyKey" of section "MySection" in bank AreasPassedTrackingBank
      • Bank - Save bank AreasPassedTrackingBank
      • Game - End game in Victory for player 1 (Hide dialogs, Hide score screen)
I increase the variable (which is loaded from the bank or zero if for the first time) every time the map ends, then when the map starts, I have already given it to load the info from the Bank and when it ends again it modifies this value further.

This is what a Bank looks like edited as TXT

PHP:
<?xml version="1.0" encoding="utf-8"?>
<Bank version="1">
    <Section name="MySection">
        <Key name="MyKey">
            <Value int="16"/>
        </Key>
    </Section>
</Bank>

I set all under a single Section, with a Key name the same as the Section. If you got more than 1 Section, that is you set different Keys in different sections or the same Key name in different sections you would get, (e.g save Key: Life in Section HeroStats, save Energy in Section HeroStats in TheSameBank)

PHP:
    <Section name="Name1">
        <Key name="KeyName1">
            <Value int="16"/>
   <Section name="HeroStats">
        <Key name="Life">
            <Value int="1500"/>
        <Key name="Energy">
            <Value int="500"/>
   <Section name="Another Name">
        <Key name="Another key name">
            <Value int="100"/>

Avoid using spaces or numbers, non-letter characters when typing the bank name, while you can for Keys and Sections. A bank must be up to 10KB in size, you could make several banks but that would be inefficient for the same map.
 
Last edited:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,255
When designing your map it is important to factor in players not being the same slot when replaying the map. This is usually designed by decoupling the bank data from the player slot so that every player gets a compatible bank with every slot.

Of course there are situations where you will not want to do this, such as if a slot has unique save behaviour. In this case you should either use a separate bank or different entries to make sure that there will be no incompatibility with the player playing as other slots in a different session.
 
eImtoR would you mind creating a test map for me so I can view the triggers in more detail?

I'll have a very basic system:

When a player kills an enemy unit it will gain experience, represented by an integer variable which I will have a trigger add to.

Every so often it will save the experience integer as a bank.

When the map starts it will load a player's experience bank and set the experience integer to that value.

And the cycle continues.

Also; +Rep! Thank you for your help so far. I'm starting to understand them a bit better.

Edit: Am I striking a key here?
Wow this is really simple lol... Dialogs are much harder.. I've always been afraid to go anywhere near banks.

  • Bank Load Test
    • Events
      • Game - Map initialization
    • Local Variables
    • Conditions
    • Actions
      • Bank - Preload and synchronize bank "Experience" for player 1
      • Bank - Open bank "Experience" for player 1
      • Variable - Set P1 ExperienceBank = (Last opened bank)
      • Variable - Set P1 Experience = (Load "ExperienceKey" of section "ExperienceSection" from bank P1 ExperienceBank as integer value)
      • -------
      • Bank - Preload and synchronize bank "Experience" for player 2
      • Bank - Open bank "Experience" for player 2
      • Variable - Set P2 ExperienceBank = (Last opened bank)
      • Variable - Set P2 Experience = (Load "ExperienceKey" of section "ExperienceSection" from bank P2 ExperienceBank as integer value)
      • -------
      • Bank - Preload and synchronize bank "Experience" for player 3
      • Bank - Open bank "Experience" for player 3
      • Variable - Set P3 ExperienceBank = (Last opened bank)
      • Variable - Set P3 Experience = (Load "ExperienceKey" of section "ExperienceSection" from bank P3 ExperienceBank as integer value)
      • -------
      • Bank - Preload and synchronize bank "Experience" for player 4
      • Bank - Open bank "Experience" for player 4
      • Variable - Set P4 ExperienceBank = (Last opened bank)
      • Variable - Set P4 Experience = (Load "ExperienceKey" of section "ExperienceSection" from bank P4 ExperienceBank as integer value)
  • Bank Save Test
    • Events
      • Timer - Every 5.0 seconds of Real Time
    • Local Variables
    • Conditions
    • Actions
      • Bank - Store integer P1 Experience as "ExperienceKey" of section "ExperienceSection" in bank P1 ExperienceBank
      • Bank - Save bank P1 ExperienceBank
      • -------
      • Bank - Store integer P2 Experience as "ExperienceKey" of section "ExperienceSection" in bank P2 ExperienceBank
      • Bank - Save bank P2 ExperienceBank
      • -------
      • Bank - Store integer P3 Experience as "ExperienceKey" of section "ExperienceSection" in bank P3 ExperienceBank
      • Bank - Save bank P3 ExperienceBank
      • -------
      • Bank - Store integer P3 Experience as "ExperienceKey" of section "ExperienceSection" in bank P3 ExperienceBank
      • Bank - Save bank P3 ExperienceBank
 
Level 22
Joined
Feb 4, 2005
Messages
3,971
Just like in war3, I think it's preferable the periodic event isn't used, especially for saving needlessly more times or missing to save if smth happens during the 5 seconds wait. You could run the actions when with a unit dies event.

Yes, wherever within the triggers you have to type as a text, you have to type the Keys, Sections, especially Bank names accurately, just paste the names.


Here is a map I use Pick Each Integer because idk but sometimes unlike war3 where it runs fine, Pick Each Player basically does actions for ONE OF the players picked like wtf??, rather than for every player, and that's why picked players have to be added to a Player Group and rather pick all players from the Player Group (variable) Players work properly... That's why with Pick Each Integer (or For each integer i..) - works better than Pick each player

Do you want the Bank to store info for all players like you and computers - all on the same bank, or do you want for an online map where every player has his own Bank with his own information only? I will assume you use it for online with other bnet players (because it may be a little different for if you are the only User and all other are computers)

On my Wins-Losses map, it does matter if you will play this with others or with computers, or the information of the Bank may mix. Because if it tells a Computer Player to save the Bank for him, it will save on YOUR Computer, at the same time you are the User of your Computer, so it will overwrite the information - that's why with computers you need to save at different sections.

While if you do it with real Players only, it will load the data from everybody's computer and nothing will overlap, so all will be fine.

Here is a map, the Conditions for Player Status is because it would be pointless to display 0 value for players that are not playing at all.
 

Attachments

  • Experience.SC2Map
    23.3 KB · Views: 67
Status
Not open for further replies.
Top