• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

HP Regen Spell

Status
Not open for further replies.
Level 28
Joined
Sep 26, 2009
Messages
2,520
You need 2 triggers - a loop trigger that regenerates health and another trigger that switches the first one on.
  • Heal Start
    • Events
      • Unit - YourUnit's life becomes Less than or equal to (0.25 x (Max life of YourUnit))
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Loop <gen> is on) Equal to False
        • Then - Actions
          • Trigger - Turn on Loop <gen>
        • Else - Actions
This is the trigger that switches loop trigger on.
The Event is "Unit - Life"
And as the value it uses the function "Arithmetic" and is set as "A x B" where A is 0.25 and B is "Unit - Property".
So whenever YourUnit's life is less than 25%, this trigger will fire the action.
Action only checks if loop trigger is already on; if not, it switches Loop trigger on.
The conditon here is from Boolean => Trigger - Trigger is on

The loop trigger is this:
  • Loop
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Percentage life of (Picked unit)) Greater than 25.00
              • ((Picked unit) is dead) Equal to True
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
          • Set HealAmount = (((Real((Level of Acid Bomb for (Picked unit)))) x 5.00) + 5.00)
          • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) + HealAmount)
This fires every 1 second and it first checks through the If/Then/Else if your unit has either more than 25% health or if that hero is dead; It uses the "Or" in conditions, meaning that if any of those conditions are true, then it will pass. If it pass, trigger will turn off.
Those conditions are:
Real => "Unit - Percentage Life"
and
Boolean => "Unit - Unit is dead"
I add the conditon Unit is dead so this trigger won't loop every second for no reason.

If no conditon is true, then it will first set HealAmount - this is REAL variable.
The calculation used here is set as arithmetic
[ (A + B ] where A is another Arithmetic (Y x Z).
Y is "Conversion - Convert Integer to Real" because ability level is integer number. It is the "Unit - Level of Ability for Unit"
Z is 5
so A = Y x Z
and B is 5

Once calculation is done, I simply use the action Unit - Set life (to value) as Arithmetic (A + B)
where A is "Unit - Property of Unit" and B is HealAmount

---------
In case that hero of yours is not pre-placed in game, you won't be able to add him into the first trigger's event.
To solve this, you will need another trigger:
  • Untitled Trigger 001
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to YourUnit
    • Actions
      • Trigger - Add to Heal Start <gen> the event (Unit - (Triggering unit)'s life becomes Less than or equal to (0.25 x (Max life of (Triggering unit))))
This will fire when a unit is created (summoned by spell or trained/bought). Condition checks if that unit-type is equal to your desired unit/hero.
As an action it uses "Trigger - Add new event" - this action adds new event to selected trigger - in this case it adds to "Heal Start" trigger this created unit as the triggering unit whose life will be checked.
If you do it this way, then in your "Heal Start" trigger you don't need any event, as those events will be add through this trigger.
 
Level 21
Joined
Mar 27, 2012
Messages
3,232
Like this?
Reg Ability is a 3-level ability based on "Item Life Regeneration".
It adds:10/15/20 life reg
Passive reg is a 3-level ability that could be based on any ability you want(even an active, it doesn't care).
  • Init
    • Events
      • Unit - A unit Is attacked
    • Conditions
    • Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Passive Reg for (Triggering unit)) Greater than (>) 0
          • (Percentage life of (Triggering unit)) Less than or equal to (<=) 25.00
          • ((Triggering unit) is in RegGroup) Equal to (==) False
        • Then - Actions
          • Unit - Add Reg Ability to (Triggering unit)
          • Unit - Set level of Reg Ability for (Triggering unit) to (Level of Passive Reg for (Triggering unit))
          • Unit Group - Add (Triggering unit) to RegGroup
          • Trigger - Turn on Loop <gen>
        • Else - Actions
  • Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set TempInt = 0
      • Unit Group - Pick every unit in RegGroup and do (Actions)
        • Loop - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Percentage life of (Picked unit)) Less than or equal to (<=) 25.00
            • Then - Actions
              • Set TempInt = (TempInt + 1)
            • Else - Actions
              • Unit Group - Remove (Picked unit) from RegGroup
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • TempInt Equal to (==) 0
          • Then - Actions
            • Trigger - Turn off (This trigger)
          • Else - Actions

  • PLR Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set PLRAbil[1] = Passive Life Reg
      • Set PLRRegAbil[1] = Passive Life Reg Ability
      • Set PLRAbils = 1
  • PLR On Hit
    • Events
      • Unit - A unit Is attacked
    • Conditions
    • Actions
      • Do Multiple ActionsFor each (Integer PLRLooper) from 1 to PLRAbils, do (Actions)
        • Loop - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of PLRAbil[PLRLooper] for (Triggering unit)) Greater than (>) 0
              • (Percentage life of (Triggering unit)) Less than or equal to (<=) 25.00
              • ((Triggering unit) is in RegGroup) Equal to (==) False
            • Then - Actions
              • Unit - Add PLRRegAbil[PLRLooper] to (Triggering unit)
              • Unit - Set level of PLRRegAbil[PLRLooper] for (Triggering unit) to (Level of PLRAbil[PLRLooper] for (Triggering unit))
              • Unit Group - Add (Triggering unit) to RegGroup
              • Trigger - Turn on PLR Loop <gen>
            • Else - Actions
  • PLR Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set TempInt = 0
      • Unit Group - Pick every unit in RegGroup and do (Actions)
        • Loop - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Percentage life of (Picked unit)) Less than or equal to (<=) 25.00
            • Then - Actions
              • Set TempInt = (TempInt + 1)
            • Else - Actions
              • Do Multiple ActionsFor each (Integer PLRLooper) from 1 to PLRAbils, do (Actions)
                • Loop - Actions
                  • Unit - Remove PLRRegAbil[PLRLooper] from (Picked unit)
              • Unit Group - Remove (Picked unit) from RegGroup
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • TempInt Equal to (==) 0
          • Then - Actions
            • Trigger - Turn off (This trigger)
          • Else - Actions


EDIT: Second verson attached. I've also decided that from now on I put all my trigger help in one map and add to it every time that someone asks something new.
If this map gets big enough, then I'll post it as a tutorial.
 
Last edited:
Level 5
Joined
Jul 30, 2012
Messages
93
Now i have a 2 problem...

-I don't have regen skill and my hero's HP is less than %25, then i learns regen skill but it doesn't work.If someone hit me,then it start regeneration.It must work even after i learn.

-And it doens't stop. *-* It continues regeneration while my HP is greater than %25. ^^

Edit:where i'm wrong ?

  • Guardian Regeneration
    • Events
      • Unit - A unit Is attacked
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Guardian's Regeneration-[E] for (Triggering unit)) Greater than 0
          • (Percentage life of (Triggering unit)) Less than 25.00
          • ((Triggering unit) is in RegGroup) Equal to False
        • Then - Actions
          • Unit - Add Guardian's Loop to (Triggering unit)
          • Unit - Set level of Guardian's Regeneration-[E] for (Triggering unit) to (Level of Guardian's Loop for (Triggering unit))
          • Unit Group - Add (Triggering unit) to RegGroup
          • Trigger - Turn on Guardian Regeneration Loop <gen>
        • Else - Actions
  • Guardian Regeneration Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set RegenInt = 0
      • Unit Group - Pick every unit in RegGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Percentage life of (Picked unit)) Less than 25.00
            • Then - Actions
              • Set RegenInt = (RegenInt + 1)
            • Else - Actions
              • Unit Group - Remove (Picked unit) from RegGroup
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • RegenInt Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
 
Last edited:
Level 5
Joined
Dec 25, 2011
Messages
45
Now i have a 2 problem...

-I don't have regen skill and my hero's HP is less than %25, then i learns regen skill but it doesn't work.If someone hit me,then it start regeneration.It must work even after i learn.

-And it doens't stop. *-* It continues regeneration while my HP is greater than %25. ^^

Edit:where i'm wrong ?

  • Guardian Regeneration
    • Events
      • Unit - A unit Is attacked
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Guardian's Regeneration-[E] for (Triggering unit)) Greater than 0
          • (Percentage life of (Triggering unit)) Less than 25.00
          • ((Triggering unit) is in RegGroup) Equal to False
        • Then - Actions
          • Unit - Add Guardian's Loop to (Triggering unit)
          • Unit - Set level of Guardian's Regeneration-[E] for (Triggering unit) to (Level of Guardian's Loop for (Triggering unit))
          • Unit Group - Add (Triggering unit) to RegGroup
          • Trigger - Turn on Guardian Regeneration Loop <gen>
        • Else - Actions
  • Guardian Regeneration Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set RegenInt = 0
      • Unit Group - Pick every unit in RegGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Percentage life of (Picked unit)) Less than 25.00
            • Then - Actions
              • Set RegenInt = (RegenInt + 1)
            • Else - Actions
              • Unit Group - Remove (Picked unit) from RegGroup
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • RegenInt Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
First of all: i find it very difficult to fix issues in other people's triggers - that's why I'm also posting my own suggestion for this issue

Correct me if I'm wrong, but i always had problems with the 'greater than 0' ability condition.
This is because in your case the ability is in the beginning neither greater, nor smaller than zero; but undefined, which is probably the reason why it leaks - I prefer using 'is equal to' here

Anyways the reason why it also wouldn't work is that when you set the level of the abilities - you switched the two variables in contrast to Xonok's trigger.

And the part is missing where the health regen ability is removed again - that is why the regeneration doesn't stop.

My trigger could be some kind of leaky because the loop after the ability is learned is always on, but removes the difficult part of creating a unit group, 'if then else' conditions and so on.

The loop is turned off at first and you need only the hero ability (Regeneration).
  • Regen Activate
    • Events
      • Unit - A unit learns an ability
    • Conditions
      • (Learned Hero Skill) Equal to Regeneration
    • Actions
      • Set Hero = (Triggering unit)
      • Trigger - Turn on Regen Loop <gen>
  • Regen Loop
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
      • (Percentage life of Hero) Less than 25.00
    • Actions
      • Unit - Set life of Hero to ((Life of Hero) + (5 + (5.00 x (Real((Level of Regeneration for Hero))))))
 
Level 21
Joined
Mar 27, 2012
Messages
3,232
  • Regen Activate
    • Events
      • Unit - A unit learns an ability
    • Conditions
      • (Learned Hero Skill) Equal to Regeneration
    • Actions
      • Set Hero = (Triggering unit)
      • Trigger - Turn on Regen Loop <gen>

  • Regen Activate
    • Events
      • Unit - A unit learns an ability
    • Conditions
      • (Learned Hero Skill) Equal to Regeneration
    • Actions
      • Unit Group - Add (Triggering Unit) to RegGroup
      • Unit - Add Reg ability to (Triggering Unit)
      • Trigger - Turn on Regen Loop <gen>
This is how it would work together with my system.
 
Level 5
Joined
Jul 30, 2012
Messages
93
I tried both of way but still doesn't work.Now it ignores %25 percentage and gains regeneration whenever someone attack me :'(

  • Guardian Regeneration
    • Events
      • Unit - A unit Learns a skill
    • Conditions
      • (Learned Hero Skill) Equal to Guardian's Regeneration-[E]
    • Actions
      • Unit Group - Add (Triggering unit) to RegGroup
      • Unit - Add Guardian's Loop to (Triggering unit)
      • Trigger - Turn on Guardian Regeneration Loop <gen>
  • Guardian Regeneration Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set RegenInt = 0
      • Unit Group - Pick every unit in RegGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Percentage life of (Picked unit)) Less than 25.00
            • Then - Actions
              • Set RegenInt = (RegenInt + 1)
            • Else - Actions
              • Unit Group - Remove (Picked unit) from RegGroup
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • RegenInt Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
I know that it won't work with this cuz this method is set my hero's HP to 10.

  • Guardian Regeneration
    • Events
      • Unit - A unit Learns a skill
    • Conditions
      • (Learned Hero Skill) Equal to Guardian's Regeneration-[E]
    • Actions
      • Set triggerunit = (Triggering unit)
      • Trigger - Turn on Guardian Regeneration Loop <gen>
  • Guardian Regeneration Loop
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
      • (Percentage life of triggerunit) Less than 25.00
    • Actions
      • Unit - Set life of triggerunit to (5.00 + (5.00 x (Real((Level of Guardian's Regeneration-[E] for triggerunit)))))
 
Level 21
Joined
Mar 27, 2012
Messages
3,232
I tried both of way but still doesn't work.Now it ignores %25 percentage and gains regeneration whenever someone attack me :'(

  • Guardian Regeneration
    • Events
      • Unit - A unit Learns a skill
    • Conditions
      • (Learned Hero Skill) Equal to Guardian's Regeneration-[E]
    • Actions
      • Unit Group - Add (Triggering unit) to RegGroup
      • Unit - Add Guardian's Loop to (Triggering unit)
      • Trigger - Turn on Guardian Regeneration Loop <gen>
  • Guardian Regeneration Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set RegenInt = 0
      • Unit Group - Pick every unit in RegGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Percentage life of (Picked unit)) Less than 25.00
            • Then - Actions
              • Set RegenInt = (RegenInt + 1)
            • Else - Actions
              • Unit Group - Remove (Picked unit) from RegGroup
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • RegenInt Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
I know that it won't work with this cuz this method is set my hero's HP to 10.

  • Guardian Regeneration
    • Events
      • Unit - A unit Learns a skill
    • Conditions
      • (Learned Hero Skill) Equal to Guardian's Regeneration-[E]
    • Actions
      • Set triggerunit = (Triggering unit)
      • Trigger - Turn on Guardian Regeneration Loop <gen>
  • Guardian Regeneration Loop
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
      • (Percentage life of triggerunit) Less than 25.00
    • Actions
      • Unit - Set life of triggerunit to (5.00 + (5.00 x (Real((Level of Guardian's Regeneration-[E] for triggerunit)))))

There's 2 mistakes, one of which is mine.
Firstly I forgot the condition.
  • Guardian Regeneration
    • Events
      • Unit - A unit Learns a skill
    • Conditions
      • (Learned Hero Skill) Equal to Guardian's Regeneration-[E]
      • Percentage life of (Triggering Unit) is less than or equal to 25%
    • Actions
      • Unit Group - Add (Triggering unit) to RegGroup
      • Unit - Add Guardian's Loop to (Triggering unit)
      • Trigger - Turn on Guardian Regeneration Loop <gen>
Second, the loop
  • Guardian Regeneration Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set RegenInt = 0
      • Unit Group - Pick every unit in RegGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Percentage life of (Picked unit)) Less than 25.00
            • Then - Actions
              • Set RegenInt = (RegenInt + 1)
            • Else - Actions
              • Unit Group - Remove (Picked unit) from RegGroup
              • Remove Regen ability from (Picked unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • RegenInt Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
EDIT: Just check how I made it in this map.
 

Attachments

  • Xonok's Trigger Help v0.00.w3x
    18.2 KB · Views: 46
Level 5
Joined
Dec 25, 2011
Messages
45
I know that it won't work with this cuz this method is set my hero's HP to 10.

  • Actions
    • Unit - Set life of Hero to (5 + (5.00 x (Real((Level of Regeneration for Hero))))))

Sorry due to a translation mistake the trigger didn't appear on the board as how i've written it down.

this is how it should be (you could have done the maths too I believe -_- )

  • Unit - Set life of Hero to ((life of Hero) + (5 + (5.00 x (Real((Level of Regeneration for Hero))))))
 
Status
Not open for further replies.
Top