• 🏆 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!

[Unit Group] Orders

Status
Not open for further replies.
Level 18
Joined
Oct 25, 2006
Messages
1,171
Hi everyone. I'm currently working on a trigger which automatically orders to every units selected by a player to cast a "Target Unit" spell (useful for maps with lots of units and where you can't select all units one by one).


  • General Capture
    • Event
      • Unit - A unit received an order with an object (a unit ?) as target
    • Conditions
      • (Issued order) Equal to (Order(drain))
    • Actions
      • Trigger - Turn off (This trigger)
      • Unit Group - Pick every unit in (Units currently selected by (Owner of (Triggering unit))) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Picked unit) different from (Triggering unit)
            • Then - Actions
              • Unit - Order (Picked unit) to Blood Mage - Mana Drain (Target unit of issued order)
              • Game - Display to (All players) the text: (Name of (Picked unit))
            • Else - Actions
      • Trigger - Turn on (This trigger)


I had to rework on some parts because I'm working on a french editor and its half english half french (who said translators were stupid ?).

So here's my problem: the unit group include every units I wanted it to include (so every units of the selection excepted the first who cast the spell). I know that because of the text action. BUT only one unit of the selection casts the spell.

Why ? Can you help me solve this ?

Thanks by advance.

Goff'
 
Level 4
Joined
Jan 27, 2010
Messages
133
You were rather unlucky. You tested for the picked unit, but had you also asked for the target unit's name in the loop, you would have discovered that it was missing...

Here's how I made it work (set variable = target unit):

  • Untitled Trigger 001
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Issued order) Equal to (Order(drain))
    • Actions
      • Trigger - Turn off (This trigger)
      • Set Target = (Target unit of issued order)
      • Unit Group - Pick every unit in (Units currently selected by (Owner of (Triggering unit))) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Picked unit) Not equal to (Triggering unit)
            • Then - Actions
              • Unit - Order (Picked unit) to Human Blood Mage - Siphon Mana Target
            • Else - Actions
      • Trigger - Turn on (This trigger)
EDIT
Right! And you should probably do this little hax to prevent your group from leaking:
  • Custom Script: set bj_wantDestroyGroup = true
  • Unit Group - Pick every unit in (Units currently selected by (Owner of (Triggering unit))) and do (Actions)
 
Status
Not open for further replies.
Top