• 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] health percent condition check

Status
Not open for further replies.
Level 5
Joined
Jan 2, 2013
Messages
84
im trying to do a pokemon theme map for my brothers to play.

I need a condition to check the targets health percent like 100%-71% = fail chance, 70%-51% = okay chance, 50%-21% = great chance, and 20%-0.01% awesome chance.

anyone can help?
 
Last edited:
Level 45
Joined
Feb 27, 2007
Messages
5,578
Since Wc3 doesn't have switch/case the best you can do is the following. I would not recommend using a bunch of nested if-blocks because that will be much harder to edit later.

  • Events
    • Time - Elapsed game time is 0.10 seconds
  • Conditions
  • Actions
    • Set Chance_NumBreakpoints = 4
    • -------- --------
    • Set Chance_BreakPoint[1] = 70.00 //above this percentage, the effect has a Chance_Factor[1] chance
    • Set Chance_BreakPoint[2] = 50.00 //above this percentage but below the previous breakpoint, the effect has a Chance_Factor[2] chance
    • Set Chance_BreakPoint[3] = 20.00 //etc.
    • Set Chance_BreakPoint[4] = 0.00 //the last one should probably always be 0
    • -------- --------
    • Set Chance_Factor[1] = 0.00
    • Set Chance_Factor[2] = 30.00
    • Set Chance_Factor[3] = 75.00
    • Set Chance_Factor[4] = 95.00
  • -------- in whatever trigger runs where you want the chance: --------
  • Set LifePct = (Percentage life of SOME UNIT)
  • Set Chance_Boolean = false
  • For each (Integer A) from 1 to Chance_NumBreakPoints do (Actions)
    • Loop - Actions
      • If (All conditions) then (actions) else (actions)
        • If - Conditions
          • LifePct greater than Chance_BreakPoint[(Integer A)]
          • (Random real number between 0.00 and 100.00) less than or equal to Chance_Factor[(Integer A)]
        • Then - Actions
          • Set Chance_Boolean = true
          • Custom script: exitwhen true //this line is optional, it exits the loop early once a true chance is found
        • Else - Actions
  • If (All conditions) then (actions) else (actions)
    • If - Conditions
      • Chance_Boolean equal to true
    • Then - Actions
      • -------- Do whatever here --------
    • Else - Actions
 
Status
Not open for further replies.
Top