Spell Passive HELP

Status
Not open for further replies.
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:

  • 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))
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 :) )
 
Level 3
Joined
Aug 24, 2014
Messages
30
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:

  • 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))
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 :) )


Thank you.
+rep
 
Last edited:
Here's my method. But it turned out to be useless. :(
I totally forgot about the fact that the hero's Base Hit Points are 100. The strength attribute points do not get included in the Base Hit Points. (Tomes of Health also)
In my attached map you'll find that i changed the Base Hit Points of the Hero from 100 to 1000 and every time he gains a static value which is 200hp (in case of 20%). I don't know if we can work this mathematically or not. I apologize for letting you down. :(
We'll try to ask Pyrogasm later.
 

Attachments

  • Passive20%.w3x
    16.8 KB · Views: 38
Level 44
Joined
Feb 27, 2007
Messages
5,475
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)?
 
Level 3
Joined
Aug 24, 2014
Messages
30
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)?



this was my idea
but I do not know how to do it
I'm creating a rpg with load / save and wanted for a skill of 20% of all hp = str + hp base + items ...
For a tank if anyone knows how to do this I will be very grateful
 
Level 7
Joined
Apr 17, 2017
Messages
316
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.
 
Level 3
Joined
Aug 24, 2014
Messages
30
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.

how would you ever check the maximum life of the unit?
any idea how to do this?
 
Level 3
Joined
Aug 24, 2014
Messages
30
Create an integer variable then do this:
Set yourvariablename = max hp of your unit

Like this?

1DxGsah

aqui1-png-4f8e5d82-b49d-4f99-91eb-824300218462

UploadDeImagens.com.br - aqui1.png

could you give an example of how to do it?
only to check maximum life every second
 
Level 44
Joined
Feb 27, 2007
Messages
5,475
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
 
Level 3
Joined
Aug 24, 2014
Messages
30
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



(0.20 x (HP_Max[2] - HP_Max[1]))) need convert Real to integer

worked perfectly thanks. +rep
 
Status
Not open for further replies.
Top