The stats don't have to be a separate variable but they make your life easier.
Instead of memorizing that Stats[4] = Health, you can just reference the Health variable. IE:
-
Unit - Add StatsAbilities[Health] to Triggering unit
That's a lot easier than having to look things up over and over again.
And I'd recommend looking up some tutorials on Hashtables, they can be a bit confusing at first.
Hashtables and MUI
I'll try to simplify Hashtables as best I can:
I like to think of Hashtables as a 2-dimensional Array, which is a standard Array with an extra Index []:
-
Set Variable StatsChosen[1][3] = Strength
I like to make the first Index [] represent the Player's Number. So 1 represents Player 1 (Red), 2 represents Player 2 (Blue), etc.
And the second Index [] represent the data's position in our array. So like we've been doing already in our standard Arrays.
So in that example, Player
1's
3rd Chosen Stat is
Strength. StatsChosen[2][3] would represent Player 2's 3rd Chosen Stat.
Now Hashtables function very similar to this, but they offer even greater control. That control is what adds to the complexity of them and is why they look a bit different than a 2-dimensional Array.
In a Hashtable you have a Child key, a Parent key, and the Hashtable variable.
The Hashtable variable is rather self-explanatory:
-
Hashtable - Create a hashtable
-
Set Variable SomeHashtable = (Last created hashtable)
It's like creating any other Variable but with a couple extra steps. You usually create all of these Hashtables at Map Initialization and then Save data to them afterwards.
Data is the value that you want to save, which could be an Integer, Unit, Item, etc.. It's Saved in your desired Hashtable so that it can be Loaded at a later time.
-
Hashtable - Save Data as Child of Parent in SomeHashtable
So if we wanted to save "StatsChosen[1][3] = Strength" in our Stat's Hashtable it could look like this:
-
Hashtable - Save Strength as 3 of 1 in StatsHashtable
The Child (3) and the Parent (1) act as the Indexes, same as the ones in our 2-dimensional Array example I showed you earlier. The Parent key in this case is the Player Number and the Children are all of the different data values that we want to save under that Parent. So each Parent has a bunch of Children stored under it (the names start to make sense now).
This allows us to store unique data for EACH player inside of the same Hashtable. All we have to do is adjust the Parent key. So if we changed the Parent key from
1 to
2 in the above example, we'd now be saving data under Player 2 instead of Player 1.
-
Hashtable - Save Strength as 3 of 2 in StatsHashtable
I won't go into any greater detail for now, but understand that you can take Hashtables even futher by making use of Handles. You can read more about these in some Hashtable tutorials.