Here's the Setup trigger. This is the main trigger that you need to configure.
Set
AH_None = Some ability that your Heroes will NEVER Learn.
Set
AH_Hero = The Hero you want to add to the system.
Set
AH_Ability[X] = The Ability you want to add to the system for that Hero. This can go up to
AH_Ability[5] since Heroes can only learn up to 5 Skills.
-
Setup AH
-
Events
-
Conditions
-
Actions
-
-------- Create Hashtable --------
-
Hashtable - Create a hashtable
-
Set VariableSet AH_Hash = (Last created hashtable)
-
-------- --------
-
-------- ///////////////////////////////////////////////////// --------
-
-------- CONFIGURE: --------
-
-------- ///////////////////////////////////////////////////// --------
-
-------- --------
-
-------- Set this to an Ability that your Heros will NEVER Learn --------
-
Set VariableSet AH_None = No Ability (Used for AH)
-
-------- --------
-
-------- Set Default Values For Abilities --------
-
For each (Integer AH_Loop) from 1 to 7, do (Actions)
-
Loop - Actions
-
Set VariableSet AH_Ability[AH_Loop] = AH_None
-
-------- --------
-
-------- Add Heros to System: --------
-
Set VariableSet AH_Hero = Paladin
-
Set VariableSet AH_Ability[1] = Holy Light
-
Set VariableSet AH_Ability[2] = Divine Shield
-
Set VariableSet AH_Ability[3] = Devotion Aura
-
Set VariableSet AH_Ability[4] = Resurrection
-
Trigger - Run Save to AH <gen> (ignoring conditions)
-
-------- --------
-
Set VariableSet AH_Hero = Archmage
-
Set VariableSet AH_Ability[1] = Blizzard
-
Set VariableSet AH_Ability[2] = Summon Water Elemental
-
Set VariableSet AH_Ability[3] = Brilliance Aura
-
Set VariableSet AH_Ability[4] = Mass Teleport
-
Trigger - Run Save to AH <gen> (ignoring conditions)
These Save/Load Triggers are used to Save the Abilities to the Hashtable and Load them from the Hashtable. I use the Hero's Id as the Parent in the Hashtable, and save the Abilities as the Child Keys from 1 to X. Total Abilities for your Hero is saved as 0.
-
Save to AH
-
Events
-
Conditions
-
Actions
-
-------- Set Hero Id --------
-
Custom script: set udg_AH_Integers[0] = udg_AH_Hero
-
For each (Integer AH_Loop) from 1 to 5, do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
AH_Ability[AH_Loop] Not equal to AH_None
-
Then - Actions
-
-------- Set Ability Id --------
-
Custom script: set udg_AH_Integers[udg_AH_Loop] = udg_AH_Ability[udg_AH_Loop]
-
-------- Abilities = 1 to X --------
-
Hashtable - Save AH_Integers[AH_Loop] as AH_Loop of AH_Integers[0] in AH_Hash.
-
-------- Total Abilities = 0 --------
-
Hashtable - Save AH_Loop as 0 of AH_Integers[0] in AH_Hash.
-
Else - Actions
-
-------- --------
-
-------- Set Default Values For Abilities --------
-
For each (Integer AH_Loop) from 1 to 5, do (Actions)
-
Loop - Actions
-
Set VariableSet AH_Ability[AH_Loop] = AH_None
-
Load from AH
-
Events
-
Conditions
-
Actions
-
-------- Set Hero Id --------
-
Custom script: set udg_AH_Integers[0] = GetUnitTypeId(udg_AH_Unit)
-
-------- --------
-
-------- Set Total Abilities --------
-
Set VariableSet AH_TotalAbilities = (Load 0 of AH_Integers[0] from AH_Hash.)
-
-------- --------
-
-------- Set Hero Abilities --------
-
For each (Integer AH_Loop) from 1 to AH_TotalAbilities, do (Actions)
-
Loop - Actions
-
-------- Set Ability Id --------
-
Set VariableSet AH_Integers[AH_Loop] = (Load AH_Loop of AH_Integers[0] from AH_Hash.)
-
Custom script: set udg_AH_Ability[udg_AH_Loop] = udg_AH_Integers[udg_AH_Loop]
This is an example of putting the system to use.
Simply set
AH_Unit = the Hero you created/want to learn skills for, then
Run Load from AH (ignoring conditions).
This will set
AH_Ability[1] to
AH_Ability[X] as your Heroes Abilities.
You can then use
Custom script: call SelectHeroSkill( udg_AH_Unit, udg_AH_Ability[X] ) to learn one of these Abilities.
You can also reference
AH_TotalAbilities to get how the total number of abilities your Hero has (so 4 in this case).
-
Example AH
-
Events
-
Player - Player 1 (Red) types a chat message containing paladin as An exact match
-
Conditions
-
Actions
-
Unit - Create 1 Paladin for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
-
Hero - Set (Last created unit) Hero-level to 6, Hide level-up graphics
-
-------- --------
-
-------- Load your Hero's abilities setting them as AH_Ability[1] - AH_Ability[X] --------
-
-------- Also sets AH_TotalAbilities = The # of Abilities your Hero has --------
-
Set VariableSet AH_Unit = (Last created unit)
-
Trigger - Run Load from AH <gen> (ignoring conditions)
-
-------- --------
-
-------- Then you can learn the skills like so: --------
-
Custom script: call SelectHeroSkill( udg_AH_Unit, udg_AH_Ability[1] )
-
Custom script: call SelectHeroSkill( udg_AH_Unit, udg_AH_Ability[1] )
-
Custom script: call SelectHeroSkill( udg_AH_Unit, udg_AH_Ability[1] )
-
Custom script: call SelectHeroSkill( udg_AH_Unit, udg_AH_Ability[2] )
-
Custom script: call SelectHeroSkill( udg_AH_Unit, udg_AH_Ability[3] )
-
Custom script: call SelectHeroSkill( udg_AH_Unit, udg_AH_Ability[4] )