• 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.
  • It's time for the first HD Modeling Contest of 2025. Join the theme discussion for Hive's HD Modeling Contest #7! Click here to post your idea!

making a unit use an ability at % health

Status
Not open for further replies.
Level 2
Joined
Jul 11, 2009
Messages
5
How do i make it so that my unit will use one of its abilities at say only 50%- 54% and if it doesn't enter that range of health before it dies then it won't use the ability.
Been wondering about this for a long time.
 
  • Trigger
  • Events
    • Unit - A unit starts the effect of an ability
  • Conditions
  • Actions
    • For each (Integer A) from 50 to 54, do (Actions)
      • Loop - Actions
        • If (All conditions are true) then do (Actions) else do (Actions)
          • If - Conditions
            • (Percent life of (Triggering unit)) Not Equal to (Integer A)
          • Then - Actions
            • Game - Display to (Player Group(Owner of (Triggering unit))) the text "Your health should be between 50 - 54%, in order to cast this ability."
          • Else - Actions
            • <The ability effect>
To detect whether the unit has entered this life range of 50 - 54%, it might be hard; I didn't test it, but you can give it a try:
  • Trigger2
  • Events
    • Time - Every 1.00 seconds of game-time
  • Conditions
    • ((Your unit) is alive) Equal to True [Boolean Comparison]
  • Actions
    • For each (Integer B) from 50 to 54, do (Actions)
      • Loop - Actions
        • If (Conditions are true) then do (Actions) else do (Actions)
          • If - Conditions
            • (Percentage Life of (Your unit)) Equal to (Integer B)
          • Then - Actions
            • Unit Group - Add (your unit) to EnteredLifeRange (Unit Group variable)
          • Else - Actions
  • Trigger3
  • Events
    • Unit - A unit dies
  • Conditions
  • Actions
    • If (All conditions are true) then do (Actions) else do (Actions)
      • If - Conditions
        • (Dying unit is in (EnteredLifeRange)) Equal to False (Boolean comparison)
      • Then - Actions
        • Player - Disable (Your ability) for (Owner of (Triggering unit))
      • Else - Actions
 
Level 15
Joined
Aug 14, 2007
Messages
936
lol wrong , that's too might work dude

E.G it;s pretty simple actually

Event : unit cast an ability
Cond: ability being cast is blabla
Action:
if (Triggering unit life is greater than or equal to 50% of max hitpoints of triggeriing unti AND Triggering unit life is less than or equal to 54% of max hitpoints of triggeriing unti )
do actions
blabla


That's short and simple
 
Status
Not open for further replies.
Top