• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

How do to an instant percentage-based heal via triggers?

Status
Not open for further replies.
Level 4
Joined
Oct 31, 2013
Messages
88
Hello all!

For my map I am trying to create a normal chain-lighting effect that also heals the caster for 25% of his health points (via a Holy Light done through triggers).

I read that the trigger should look something like this:

  • Unit - Set life of (Target unit of ability being cast) to ((Life of (Target unit of ability being cast)) + ((Current life of (Target unit of ability being cast)) x 0.25))

But I am having trouble adding the underline part to the trigger. I believe it is most likely done via Variables, but I don't have much knowledge on it despite trying to read on the matter.

So far, my trigger for the spell is looking something like this.
 
Level 11
Joined
Nov 23, 2013
Messages
665
The underline part of this trigger can be done using the 'arithmetic' function, which allows you to use operators (+, -, x and /), see pictures below:
arithmetic-png.317723
arithmetic2-png.317724
/
 
Level 24
Joined
Feb 9, 2009
Messages
1,787
Set life of caster (250/500) to life of caster (250/500) x 0.25 = 62.5/500.
Be sure to include the current life of the caster in the arithmetic to reach the intended heal of 62.5

Should look like this if you plan on 25% unit heal:
  • Unit - Set Life of (Triggering Unit) to (Life of (Triggering unit)) + (((Max Life of (Triggering Unit)) * 0.25))
The function itself tells you what it does, it SETS the unit's health, it does not ADD, so you must include the unit's current health to create a heal.

Unrelated but it must be said; be sure to use the "Special Effect - Destroy (Last Created Special Effect)" on your holy light special effect as to not create memory leaks!
 
Level 15
Joined
Oct 29, 2012
Messages
1,474
basically take the percentage of yours and divide it by 100.

Just like the fellas said above.
You take the caster unit's life, and then multiply it by your percentage which is already divided by 100. Say 60%? That's mathematically 0.6.

And then you get your result. You add that result by "Unit - Set Life" trigger, just like Devalut mentioned. It gives you a precise "percentile" addition.
 
Status
Not open for further replies.
Top