• 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.

[Trigger] Event at 10% HP of a unit

Status
Not open for further replies.
Level 6
Joined
Jun 8, 2008
Messages
256
Hello everyone, I've been playing around with a little boss-map, and because of how it will work, there will never be a healer sitting duck and just waiting to heal, and I was thinking to add an event whenever a unit reached 10% hp, to alert the other people that it needed healing.

However, I encountered a tiny problem, probably due to my lack of any idea about triggers :sad:

I don't know how to make anything happen when a unit reaches 10% hp. I've tried to find it, but I can't.

It's probably right in front of my nose, but I just can't find it, so please, help me if you have the time! :wink:
 
Level 20
Joined
Oct 21, 2006
Messages
3,230
  • Justanothertrigger
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • ((Attacked unit) is A Hero) Equal to True
      • (Percentage life of (Attacked unit)) Less than or equal to 10.00
    • Actions
      • Game - Display to (All players) the text: ((Name of (Owner of (Attacked unit))) + has low hp!)
 
Level 11
Joined
Oct 13, 2005
Messages
233
The only issue you might find with that trigger is that it will only go off when a unit is attacked. Also, the health percentage is checked before the attacking unit does any damage as well, and a unit could be killed by spells before a warning message is ever given in this situation. In addition, the message would be displayed every time the unit was attacked when it has 10% hp or less. If this is what you want, then there's no trouble.

My approach would be to have a periodic trigger that checks every unit on the map and if they have 10% hp or less, warns their owners. You would also be able to set how often it's checked (and how often the message would be displayed). For instance, the trigger could go off every 5 seconds and could perhaps ping all of your units that have 10% hp or less. I don't have access to the World Editor, so I can't give you an exact GUI trigger for this, but here's somewhat of how it would look:
Code:
Event: Time - Every 5 seconds of game time
Actions:
    Unit Group - Pick every unit in (playable map area) matching (percent life of (matching unit) less than or equal to 10) and do Actions:
        Cinematic - Ping minimap for (owner of (picked unit)) at (position of (picked unit))
That's not an exact GUI trigger, but it's about as close as I can get without the editor.
 
Level 6
Joined
Jun 8, 2008
Messages
256
Yea, I found the issue with the spam on that trigger as well, and even if I didn't say anything about it in my request for help, I don't think I'll use it.

What I would rather have, is something that checked for any units with 10% hp or less, and then put an exclamation point above their head. (First idea was floating text, but I found the exclamation point somewhere :xxd: )
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
My solution would be to use the specific unit event that fires when they take damage.
You add the event to all units that you want this tro apply to.

You then can get their life percentage via (current life-damage received)/max life <= 0.10

This would be even more accurate.
 
Level 6
Joined
Jun 8, 2008
Messages
256
Alright, I could use any of the above ones, except I don't want to have text spam, I'd rather have something on the unit with low hp, like the exclamation point, but it seems I can't get it working, the exclamation point just never shows up. Any help with that?
 
Level 8
Joined
May 27, 2007
Messages
170
  • Exclamation Mark
    • Events
    • Conditions
    • Actions
      • Special Effect - Create a special effect attached to the overhead of (Triggering unit) using Abilities\Spells\Other\TalkToMe\TalkToMe.mdl

Problem is you will now get a spam exclamation mark using the solutions above. You could use custom values to make sure a unit only gets one exclamation mark. Something like:

  • Exclamation Mark
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Integer((Percentage life of (Triggering unit)))) Less than or equal to 10
      • (Custom value of (Triggering unit)) Equal to 1
    • Actions
      • Unit - Set the custom value of (Triggering unit) to 2
      • Special Effect - Create a special effect attached to the overhead of (Triggering unit) using Abilities\Spells\Other\TalkToMe\TalkToMe.mdl
That sets it so after the first time he is attacked he will not be considered for the actions next time he is attacked and is under 10% health.

Then use a periodic trigger to check if units' health has risen back up. This wouldn't be a good idea in a multiplayer game by the way. Many laggs.

  • Above 10 Percent
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Integer((Percentage life of (Picked unit)))) Greater than 10
            • Then - Actions
              • Unit - Set the custom value of (Picked unit) to 1
            • Else - Actions
              • Do nothing
That enables him to be picked up by the first trigger again.

The only problem is now it's going to be hard to remove that exclamation mark. Don't know how it would be done in GUI without a ridiculous amount of variables, and I have no idea about anything to do with JASS (Which might provide a simple solution) so someone else may be able to help you out with that.
 
Level 6
Joined
Jun 8, 2008
Messages
256
Well, lag is not an option, as the map won't be nice to people who don't have good reaction time.

So, I guess I'll just let this slip. Seems to be too much work for such a small thing.
 
Status
Not open for further replies.
Top