Ok, So, my method is faster, has less code, easier to maintain. Imagine that you have 10000 levels on your heroes rather than 10? Or even 50 would be a pain to do...
Here is what you do, this is the core idea, will give example for when a Heirloom is picked and you should figure out for when dropped/lost:
You make Stat item bonus(or what ever was the name) each with increasing stat bonus. Item Stat Bonus, or something similar is the name of the ability in game, BUT, we are not going to use it as item ability but rather as a unit ability. When you add this to a unit, it stacks and does not show in teh command card. Each ability would have a power of 2 stat bonus.
you need:
1 item - Dummy item, no skills or bonuses, nice description, icon, visuals
X amount of skills depending on how much bonus you want to add to the hero like:
Skill 1 = +1 Atk*
Skill 2 = +2 Atk*
Skill 3 = +4 Atk*
Skill 4 = +8 Atk*
Skill 5 = +16 Atk*
Skill 6 = +32 Atk*
...
Skill 10 = +2^10
...
Skill X = +2^X
*Atk = Whatever bonus you want to do. If you want multiple types of bonuses you will have to do:
Agi_Bonus_SKill 1 = +1 Agi
Agi_Bonus_SKill 2 = +2 Agi
...
Agi_Bonus_SKill X = + +X Agi
Str_Bonus_SKill 1 = +1 Str
Str_Bonus_SKill 2 = +2 Str
...
Str_Bonus_SKill X = + +X Str
And so on.
Disclaimer: The following trigger has been written in plain text with no use of WE. Events, actions, conditions may not match to how they would look in WE. The following trigger is purely a pseudo code of what I am trying to pass over.
-
Event - Unit Aquires an Item
-
Condition - Item being manipulated = Heirloom
-
Actions
-
Int_Or_Real_How_Much_Bonus_To_Add = (Nice_formula_from_hero_level_and_stuff)
-
Loop - For Index_int (Number_Of_Stat_Bonus_Skills to 0)
-

If - (Stat_Bonus_Of_Level[Index_int] >= Int_Or_Real_How_Much_Bonus_To_Add)
-


Add Our_Custom_Skill[Index_int] to triggering unit
-


Int_Or_Real_How_Much_Bonus_To_Add = Int_Or_Real_How_Much_Bonus_To_Add - Stat_Bonus_Of_Level[Index_int]
-


If - (Stat_Bonus_Of_Level[Index_int]) <= 0
This is customize-able as you can use it for multiple systems with a bit of tweeking. You could make custom stat bonuses from multiple sources, e.g. items, auras, skills, terrain, facing, day/night cycle. What I am explaining here could be used for highly customized stat-bonus system.