1. Find your way through the deepest dungeon in the 18th Mini Mapping Contest Poll.
    Dismiss Notice
  2. A brave new world lies beyond the seven seas. Join the 34th Modeling Contest today!
    Dismiss Notice
  3. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
Hive 3 Remoosed BETA - NOW LIVE. Go check it out at BETA Hive Workshop! Post your feedback in this new forum BETA Feedback.
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

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

Discussion in 'World Editor Help Zone' started by Elladaryn, Mar 3, 2019.

  1. Elladaryn

    Elladaryn

    Joined:
    Oct 31, 2013
    Messages:
    73
    Resources:
    0
    Resources:
    0
    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.
     
  2. Daffa

    Daffa

    Joined:
    Jan 30, 2013
    Messages:
    8,213
    Resources:
    31
    Packs:
    1
    Maps:
    9
    Spells:
    18
    Tutorials:
    3
    Resources:
    31
    Arithmetics.
     
  3. Sieben

    Sieben

    Joined:
    Nov 23, 2013
    Messages:
    661
    Resources:
    0
    Resources:
    0
    The underline part of this trigger can be done using the 'arithmetic' function, which allows you to use operators (+, -, x and /), see pictures below:
    [​IMG]
    [​IMG] /
     
  4. Elladaryn

    Elladaryn

    Joined:
    Oct 31, 2013
    Messages:
    73
    Resources:
    0
    Resources:
    0
    Thanks, both of you!

    Still tinkering around to get the intended result but I am much closer now.
     
  5. Devalut

    Devalut

    Joined:
    Feb 9, 2009
    Messages:
    1,490
    Resources:
    3
    Spells:
    2
    Tutorials:
    1
    Resources:
    3
    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!
     
  6. jonhysone

    jonhysone

    Joined:
    Oct 29, 2012
    Messages:
    1,244
    Resources:
    1
    Maps:
    1
    Resources:
    1
    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.