Health percentage detection?

Paragon1338

New Member
Reaction score
0
Hi guys!

I wondering how to make a passive ability that returns the hero's HP back to 100% once it drops below 50%.

This ability would ideally have a 10 second recharge so that it does not become overpowered.

Basically the problem for me is:

-How to detect when a unit's HP drops below a certain percentage?

-How to restore a unit's HP to 100% without altering its other stats?


I do not know how to use JASS (unfortunately :(), and though I know it could be done easily with JASS, I desperately need a way to do it in GUI.

It seems kinda simple compared to what experienced people around here are posting, any help would be very welcome! :D

Thx in advance
 

SineCosine

I'm still looking for my Tangent
Reaction score
77
There's something in the 'Event' box for GUI.
When value of real-variable becomes *Something*

The value you're looking for is:
((Unit's Current HP) / (Unit's MAX HP)) <= 0.5
 

Ayanami

칼리
Reaction score
288
There's something in the 'Event' box for GUI.
When value of real-variable becomes *Something*

The value you're looking for is:
((Unit's Current HP) / (Unit's MAX HP)) <= 0.5

However, you'll be limited to certain units in that event. Thus, I recommend you to use a periodic trigger to check for the unit's health instead.
 

Paragon1338

New Member
Reaction score
0
This is the trigger so far:

Events
Time - Every 0.10 seconds of game time
Conditions
((Triggering unit) is A Hero) Equal to True
(Life of (Triggering unit)) Less than or equal to ((Max life of (Triggering unit)) / 2.00)
Actions
Unit - Set life of (Triggering unit) to 100.00%
Unit - Remove classification of A Hero from (Triggering unit)
Wait 10.00 seconds
Unit - Add classification of A Hero to (Triggering unit)


Y doesn't it work? :(
 

Paragon1338

New Member
Reaction score
0
Still no effect :banghead: This is like when I tried to make a unit damage another unit lol, it just doesn't work D:

I think something is fundamentally wrong with my system

could someone please make this trigger and show it to me? tyvm :)
 

SineCosine

I'm still looking for my Tangent
Reaction score
77
The reason why this is failing is because there is no trigger unit.
 

Paragon1338

New Member
Reaction score
0
Oh wow, I kinda see what you mean, I did the following and it worked perfectly:

Heal
Events
Unit - Blademaster 0154 <gen>'s life becomes Less than ((Max life of Blademaster 0154 <gen>) / 2.00)
Conditions
Actions
Unit - Set life of (Triggering unit) to 100.00%

But that is only one specific unit, and that unit is on the map from the very start! :eek: So its not possible to detect the life of any generic unit? or any unit other than one that you could click on in teh world editor?
 

Ayanami

칼리
Reaction score
288
You can try something like this.

Trigger:
  • Initialization
    • Events
      • Map Initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set Hashtable = (Last created hashtable)


Trigger:
  • Learned Trigger
    • Events
      • Unit - A unit learns an ability
    • Conditions
      • (Learned hero skill) Equal to &lt;Your Skill&gt;
      • (Level of &lt;Your Skill&gt;) Equal to 1
    • Actions
      • Unit Group - Add (Triggering unit) to SkillUnitGroup
      • Custom script: SaveReal(udg_Hashtable, GetHandleId(GetTriggerUnit()), 0, 0)


Trigger:
  • Periodic Trigger
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in SkillUnitGroup and do (Actions)
        • Loop - Actions
          • Custom script: set udg_TempReal = LoadReal(udg_Hashtable, GetHandleId(GetEnumUnit()), 0)
          • If (All conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Life of (Picked unit)) Less than ((Max life of (Picked unit)) x 0.50)
              • TempReal Less than or equal to 0.00
            • Then - Actions
              • Unit - Set life of (Picked unit) to (Max life of (Picked unit))
              • Custom script: SaveReal(udg_Hashtable, GetHandleId(GetEnumUnit()), 0, 10)
            • Else - Actions
              • Custom script: SaveReal(udg_Hashtable, GetHandleId(GetEnumUnit()), 0, udg_TempReal - 0.10)
 

Sartan

New Member
Reaction score
23
he/she we is bugged and doesn't support hashtables?^^
just a guess... atleast i have that problem

newgen don't got the hashtable function in gui :p

i use the normal editor and still have that problem...
 

Laiev

Hey Listen!!
Reaction score
188
some normal WE don't got the hashtable too :x

example is the WE of Glenphir :rolleyes:
 

Inflicted

Currently inactive
Reaction score
63
events:
-every .2 seconds
conditions:
none
actions:
-pick all units matching (matching units percentage life <= 50)
*set life of picked unit to 100%

wouldnt that work?
just add a few conditions in if you want.

this seems like the simplest option, unless im misunderstanding what he'z trying to do :?
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
i would rather suggest the event "unit takes damage" or "units health drops below xxx%", periodic events are bad for the performance and should not be used as long as you've got an alternative
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top