• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Slight Problem

Status
Not open for further replies.
Level 8
Joined
Aug 15, 2010
Messages
216
Hey everyone,
can anyone of you gents teach me how can i select the most wounded unit within a unit group? it'd be much Appriciated!

i already made the spell description in the tooltip, so... i really don't wanna go back and delete that :D
 
Triggers & Scripts - forum is if you already have created code by yourself.

If you have a question --> World Editor Help Zone.
If you want someone to work for you -- > Requests.

teach me how can i select the most wounded unit within a unit group

Something like this:

  • Aktionen
    • Set u = No Unit
    • Set life = 0.00
    • Unit Group - Pick every unit in YourGroup and do (Actions)
      • Loop - Actions
        • Set tmpReal = (Life of (Picked unit))
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • 'IF'-Bedingungen
            • Or - Any (Conditions) are true
              • Conditions
                • life == 0.00
                • tmpReal < life
          • Then -Actions
            • Set u = (Picked unit)
            • Set life = tmpReal
          • Else -Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • 'IF'-Bedingungen
        • u != No Unit
      • Then -Actions
        • -------- u is the unit you want. --------
      • Else -Actions
        • -------- no unit was picked. --------
Variables:

u: unit
life: real
tmpReal: real


I don't know what unit group you have / will create... so you might want consider to add an additional condition to check if PickedUnit is not dead.
 
Last edited:
Level 4
Joined
Nov 27, 2012
Messages
85
  • Aktionen
    • Set u = No Unit
    • Set life = 0.00
    • Unit Group - Pick every unit in YourGroup and do (Actions)
      • Loop - Actions
        • Set tmpReal = (Life of (Picked unit))
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • 'IF'-Bedingungen
            • Or - Any (Conditions) are true
              • Conditions
                • life == 0.00
                • tmpReal < life
          • Then -Actions
            • Set u = (Picked unit)
          • Else -Actions

how could tmpReal (life of picked unit) ever be less than life (0.00)?
Also setting life to 0 at the beginning of the trigger and using it as an "if life = 0" which is also an OR, will cause the Then actions to run for every unit.
 
Status
Not open for further replies.
Top