Hello,
The question isn't clear enough. From my understanding, i guess you mean when the Hero has 1000 Base Hit Points and learns the skill he'll get to 1200 Base Hp ?
In that case, you can create a custom Upgrade in the Object Editor where the Effect is "Hit Point Bonus %" and set it to 20%. (You can have multiple levels. Let us assume you are using 3)
Add that upgrade to your Hero (Techtree - Upgrades used) then create a trigger for that, so when the hero learns the spell the trigger will increase the Upgrade's level.
Something like this:
Note that you shouldn't use the same method for multiple heroes with the same skill in the same team and if the tome of retraining is available in your map. (We can always fix those issues but i wanted to give you a general idea on how to do this
PassiveSkill
Events
Unit - A unit Learns a skill
Conditions
(Learned Hero Skill) Equal to (Whatever Passive Spell You Wanna use)
Actions
Player - Set the current research level of PassiveSkillUpgrade to ((Current research level of PassiveSkillUpgrade for (Owner of (Triggering unit))) + 1) for (Owner of (Triggering unit))
)
Yes the upgrade only works with base HP before str and items.
I think the real question is: should it be a dynamic 20%? Say you learn the skill and increase life by 20% from 1000 to 1200. The hero then picks up a Health Stone, giving them +50 hp. Should they also gain 20% additional HP from the item, bringing them to 1200+50+10=1260?
What if instead of picking up a +HP item the unit used something like Bear Form to morph into another unit? What about when the hero levels up and naturally gains HP (granted that is from STR)?
Calculations are not that hard. But the point is there are a lot of factors that can change a unit's hp. For example leveling up, buying, selling items or some triggered spells that reduce unit's max hp. So one has to check unit's hp constantly because of those factors above.
Create an integer variable then do this:
Set yourvariablename = max hp of your unit
Can't see the picture. Sadly I am not on my pc right now. I'll do it when I have time.
Since there are many discrete events can possibly change max hp, the best solution is simply to keep checking max HP periodically and if it's different from the last time you checked either add 20% of the 'new' health as additional max hp, or remove 20% of the 'lost' health from the current max HP:
Events
Unit - A unit learns a skill
Conditions
(Learned hero skill) equal to HP_BUFF
Actions
-------- note this isn't MUI and also won't work if you load a hero that already has the skill learned (you will have to manually assign the variables and turn on the trigger in that case) --------
Set HP_Unit = (Triggering Unit)
Set HP_Max[1] = (Max life of HP_Unit)
-------- this is called "unit - property" in GUI, and HP_Max should be a real variable not an integer --------
Trigger - Turn on THE_PERIODIC_TRIGGER
Events
Time - Every 0.25 seconds of game-time
Conditions
Actions
Set HP_Max[2] = (Max life of HP_Unit)
If (All conditions are true) then do (Then actions) else do (Else actions)
If - Conditions
Abs(HP_Max[2] - HP_Max[1]) greater than 0.10
-------- Abs is absolute value; here we check if the change is greater than 0.10 because floating point precision in wc3 is not perfect and you might get something like 254.0003 one time and 254.0024 the second time, which should really be the same number it's just imprecise --------
Then - Actions
Unit - Set Max HP of HP_Unit to ((Max HP of HP_UNIT) + (0.20 x (HP_Max[2] - HP_Max[1])))
Set HP_Max[1] = HP_Max[2]
Else - Actions