• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Trigger] "Unit Group - Pick every unit" doesn't run?

Status
Not open for further replies.
  • Pylon illusion
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Pylon Effect
    • Actions
      • Set PylonPosition[(Custom value of (Triggering unit))] = (Position of (Triggering unit))
      • Unit - Create 1 Locust for (Owner of (Triggering unit)) at PylonPosition[(Custom value of (Triggering unit))] facing Default building facing degrees
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Unit - Add Copy to (Last created unit)
      • Custom script: if udg_PylonTargetGroup[GetUnitUserData(GetTriggerUnit())] == null then
      • Custom script: set udg_PylonTargetGroup[GetUnitUserData(GetTriggerUnit())] = CreateGroup()
      • Custom script: endif
      • Unit Group - Pick every unit in (Units within 512.00 of PylonPosition[(Custom value 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) is alive) Equal to True
              • ((Picked unit) is A ground unit) Equal to True
              • ((Picked unit) is Able to attack ground units) Equal to True
              • ((Picked unit) is Magic Immune) Equal to False
              • ((Picked unit) is A structure) Equal to False
              • ((Picked unit) is an illusion) Equal to False
            • Then - Actions
              • Unit Group - Add (Picked unit) to PylonTargetGroup[(Custom value of (Triggering unit))]
            • Else - Actions
      • Unit Group - Pick every unit in (Random 1 units from PylonTargetGroup[(Custom value of (Triggering unit))]) and do (Actions)
        • Loop - Actions
          • Custom script: call IssueTargetOrderById( GetLastCreatedUnit(), 852274, GetEnumUnit() )
      • Custom script: call RemoveLocation (udg_PylonPosition[GetUnitUserData(GetTriggerUnit())])
      • Custom script: call DestroyGroup (udg_PylonTargetGroup[GetUnitUserData(GetTriggerUnit())])
This trigger does the following: When the ability is cast, a random unit is chosen to be "copied" (creates an illusion). However when I test, the ability only works on 1st cast, all subsequent casts fail (dummy units still get made but illusions don't).
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
To the end of the trigger add:
"Custom script: set udg_PylonTargetGroup[GetUnitUserData(GetTriggerUnit())] = null"

Also:
"(Custom value of (Triggering unit))" should be stored in an integer variable for both efficiency and readability.
"Unit Group - Pick every unit in (Units within 512.00 of PylonPosition[(Custom value of (Triggering unit))]) and do (Actions)" leaks a unit group.
"(Random 1 units from PylonTargetGroup[(Custom value of (Triggering unit))])" is also leaking but should be done without a group loop because you only want one unit.
For more efficiency, you should store data in variables if you use it multiple times:
(Picked unit), (Last created unit), (Triggering unit)
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
No unit is simply a GUI thing for null.
In most other gui variable types, you dont really need it (according to blizzard) so almost none have that.
However, it is simple to replicate by using "null" in custom scripts.

The problem of not nulling the variable is that the group will not really be removed until all references to it are pointing to something else, next to which the variable can point to a destroyed group (which is not the same as null) so it will not create a new group so wont be able to add units to it.
 
Status
Not open for further replies.
Top