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

[General] Using Unit Group twice needs conditions?

Level 4
Joined
Feb 1, 2024
Messages
37
Hi, I wonder if I set a Unit Group, then set conditions to apply specific actions only on some units of that group, do I have to set the conditions again when I pick every unit in that group once again to remove the actions on picked units in the other trigger or I simply pick and remove the actions?

I will remove leak in the other trigger when the actions and effects completed.

  • Set TelekinesisGroup = (Units within 510 of TelekinesisPoint)
    • Unit Group - Pick every unit in TelekinesisGroup and do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • And - All (Conditions) are true
              • Conditions
                • ((Picked unit) is A structure) Equal to False
                • ((Picked unit) is alive) Equal to True
                • ((Picked unit) belongs to an enemy of (Owner of (Triggering unit))) Equal to True
                • ((Picked unit) is invulnerable) Equal to False
          • Then - Actions
            • Unit - Add Storm Crow Form to (Picked unit)
            • Unit - Remove Storm Crow Form from (Picked unit)
            • Animation - Change (Picked unit) flying height to 350.00 at 437.00
            • Unit - Create 1 Dummy for (Owner of (Triggering unit)) at TelekinesisPoint facing (Facing of (Triggering unit)) degrees
            • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
            • Unit - Add Telekinesis_Stun to (Last created unit)
            • Unit - Order (Last created unit) to Human Mountain King - Storm Bolt (Picked unit)
          • Else - Actions
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,574
Hi, I wonder if I set a Unit Group, then set conditions to apply specific actions only on some units of that group, do I have to set the conditions again when I pick every unit in that group once again to remove the actions on picked units in the other trigger or I simply pick and remove the actions?

I will remove leak in the other trigger when the actions and effects completed.
Your Unit Group contains (Units within 510.00 range of TelekinesisPoint). So literally every single Unit that's near that Point is being added. Simply checking the status of those Units has absolutely nothing to do with Adding or Removing them from the Unit Group.

If you want to create a Unit Group that contains specific units you would either do it at the time of creation:
  • Set TelekinesisGroup = (Units within 510 of TelekinesisPoint matching (Matching unit) is alive Equal to True and (Matching unit) is A structure) Equal to False...)
Or filter out unwanted units while looping over them:
  • Set TelekinesisGroup = (Units within 510 of TelekinesisPoint)
  • Unit Group - Pick every unit in TelekinesisGroup and do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Picked unit) is alive) Equal to True
          • ((Picked unit) belongs to an enemy of (Owner of (Triggering unit))) Equal to True
          • ((Picked unit) is A structure) Equal to False
          • ((Picked unit) is invulnerable) Equal to False
        • Then - Actions
          • -------- It's a valid target --------
        • Else - Actions
          • Unit Group - Remove (Picked unit) from TelekinesisGroup
In the Else - Actions we are removing units that don't meet our conditions.

Also, some tips:

1) You don't need to use And - All (Conditions) are true, it's redundant since all conditions need to be true by default. It's intended purpose is to be combined with the Or condition to create situations like "Condition A and B or Condition C". This is rarely necessary.

2) You don't need to create multiple Dummy units. One Dummy unit can Stun all of the (Picked units). Here's an example:
  • Unit - Create 1 Dummy for (Owner of (Triggering unit)) at TelekinesisPoint facing (Default building) degrees
  • Set Telekinesis_Dummy = (Last created unit)
  • Unit - Add a 0.20 second Generic expiration timer to Telekinesis_Dummy
  • Unit - Add Telekinesis_Stun to Telekinesis_Dummy
  • Set TelekinesisGroup = (Units within 510 of TelekinesisPoint)
  • Unit Group - Pick every unit in TelekinesisGroup and do (Actions)
    • Loop - Actions
      • Unit - Order Telekinesis_Dummy to Human Mountain King - Storm Bolt (Picked unit)
If this doesn't work it's because your Dummy unit isn't setup properly. Here's how to create a Dummy unit:
  • Copy and paste the Locust and change it's Movement Type = None, Speed Base = 0, Attacks Enabled = None, Model = None, Shadow = None.
  • Also, don't forget to give Storm Bolt the proper ability settings: 0 second cd, 0 mana cost, 99999 cast range, proper Targets Allowed.

Here's an optimized final trigger:
  • Set Telekinesis_Player = (Owner of (Triggering unit))
  • Unit - Create 1 Dummy for Telekinesis_Player at TelekinesisPoint facing (Default building) degrees
  • Set Telekinesis_Dummy = (Last created unit)
  • Unit - Add a 0.20 second Generic expiration timer to Telekinesis_Dummy
  • Unit - Add Telekinesis_Stun to Telekinesis_Dummy
  • Set TelekinesisGroup = (Units within 510.00 range of TelekinesisPoint)
  • Unit Group - Pick every unit in TelekinesisGroup and do (Actions)
    • Loop - Actions
      • Set Telekinesis_Target = (Picked unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Telekinesis_Target is alive) Equal to True
          • (Telekinesis_Target belongs to an enemy of Telekinesis_Player Equal to True
          • (Telekinesis_Target is A structure) Equal to False
          • (Telekinesis_Target is invulnerable) Equal to False
        • Then - Actions
          • Unit - Add Storm Crow Form to Telekinesis_Target
          • Unit - Remove Storm Crow Form from Telekinesis_Target
          • Animation - Change Telekinesis_Target flying height to 350.00 at 437.00
          • Unit - Order Telekinesis_Dummy to Human Mountain King - Storm Bolt Telekinesis_Target
        • Else - Actions
          • Unit Group - Remove Telekinesis_Target from TelekinesisGroup
The variable usage reduces the number of function calls (which are inefficient) and helps avoid the issue of Event Responses being overwritten.
 
Last edited:
Top