• 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] Unit with lowest HP in a group !!!

Status
Not open for further replies.
Level 5
Joined
Mar 21, 2007
Messages
155
well, it depends, you could do this

  • helping
    • Events
      • Time - Every 2.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
            • Then - Actions
            • Else - Actions

then design apropriate conditions, if you know how to do that

:infl_thumbs_up:
 
Last edited by a moderator:
Level 40
Joined
Dec 14, 2005
Messages
10,532
Variables--

Real HealthAmount
Unit LowestHealth
Group GroupParam

Trigger--

Note: I set HealthAmount to 10000. It should actually be the health of your strongest unit + 1.

  • LowestHealthFromGroup
    • Events
    • Conditions
    • Actions
      • Set HealthAmount = 10000
      • Unit Group - Pick Every Unit in GroupParam and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Life of (Picked Unit)) Less than HealthAmount)
            • Then - Actions
              • Set HealthAmount = (Life of (Picked Unit))
              • Set LowestHealth = (Picked Unit)
            • Else - Actions
Usage --

  • Some Trigger
    • Events
      • Some Events
    • Conditions
      • Some Conditions
    • Actions
      • -------- Do something --------
      • Set GroupParam = <what the group to check should contain>
      • Trigger - Run LowestHealthFromGroup (ignoring conditions)
      • -------- Do something --------
 
Level 2
Joined
Jun 10, 2007
Messages
19
Redo

Variables--

  • LowestHealthFromGroup
    • Events
    • Conditions
    • Actions
      • Set HealthAmount = 10000
      • Unit Group - Pick Every Unit in GroupParam and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Life of (Picked Unit)) Less than HealthAmount)
            • Then - Actions
              • Set HealthAmount = (Life of (Picked Unit))
              • Set LowestHealth = (Picked Unit)
            • Else - Actions



One thing u should change, im not sure if it matters but u should add it. This For each integer A function should do it :).
  • LowestHealthFromGroup
    • Events
    • Conditions
    • Actions
      • Set HealthAmount = 10000
      • For each (Integer A) from 1 to (Number of Units in (Units in (Group Param))), do (Actions)
        • Unit Group - Pick Every Unit in GroupParam and do (Actions)
          • Loop - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • ((Life of (Picked Unit)) Less than HealthAmount)
              • Then - Actions
                • Set HealthAmount = (Life of (Picked Unit))
                • Set LowestHealth = (Picked Unit)
              • Else - Actions
 
Status
Not open for further replies.
Top