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

[Solved] Killing all units in Unit Group from second batch does not work

Status
Not open for further replies.
Hallo, I would like to ask why my triggers don't kill the picked units at the Third (see comment "Third") batch, I literally did the same thing every batch but with different distances and count but there seem to be an issue with Unit Groups I just can't figure out where I did go wrong. I will really appreciate a help. :)

Additional Notes:
• At Second batch (see comment "Second") the Battle Wall dies, but when the trigger is at the Third batch the Battle Wall no longer dies, same goes to Fourth and Last batch.
• Ignore the Lightnings not getting removed.

  • Dev Battle Wall Test
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • Camera - Pan camera for Player 1 (Red) to (Position of Dummy - General Use 0201 <gen>) over 0.00 seconds
      • Wait 2.00 seconds
      • -------- --------
      • -------- Second --------
      • Cinematic - Ping minimap for (All players) at (Position of Dummy - General Use 0201 <gen>) for 5.00 seconds, using a Warning ping of color (100.00%, 75.00%, 50.00%)
      • Set Around_Real = 0.00
      • Set Around_FirstUnit = No unit
      • Set Around_PreviousUnit = No unit
      • For each (Integer A) from 1 to 96, do (Actions)
        • Loop - Actions
          • -------- --------
          • -------- Create unit for unit group --------
          • Unit - Create 1 Battle Wall for Neutral Passive at ((Position of Dummy - General Use 0201 <gen>) offset by 16384.00 towards Around_Real degrees) facing Default building facing degrees
          • Unit Group - Add (Last created unit) to Around_UnitGroup
          • -------- --------
          • -------- Get the first unit so we can connect the first unit to the last unit --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Integer A) Equal to 1
            • Then - Actions
              • Set Around_FirstUnit = (Last created unit)
            • Else - Actions
              • Do nothing
          • -------- --------
          • -------- Create lightning if there are two units possible --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Around_PreviousUnit Not equal to No unit
            • Then - Actions
              • Lightning - Create a Lightning Attack lightning effect from source (Position of (Last created unit)) to target (Position of Around_PreviousUnit)
            • Else - Actions
              • Do nothing
          • -------- --------
          • -------- Now we check if we're at the last unit so we can connect the lightning to the first unit --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Integer A) Equal to 96
            • Then - Actions
              • Lightning - Create a Lightning Attack lightning effect from source (Position of (Last created unit)) to target (Position of Around_FirstUnit)
            • Else - Actions
              • Do nothing
          • Set Around_PreviousUnit = (Last created unit)
          • -------- --------
          • -------- Distance between tall walls --------
          • Set Around_Real = (Around_Real + 3.75)
      • Wait 5.00 seconds
      • -------- --------
      • -------- Kill the units --------
      • Unit Group - Pick every unit in Around_UnitGroup and do (Actions)
        • Loop - Actions
          • Unit - Kill (Picked unit)
      • Unit Group - Remove all units from Around_UnitGroup
      • Custom script: call DestroyGroup(udg_Around_UnitGroup)
      • Wait 1.00 seconds
      • -------- --------
      • -------- Third --------
      • Cinematic - Ping minimap for (All players) at (Position of Dummy - General Use 0201 <gen>) for 5.00 seconds, using a Warning ping of color (100.00%, 75.00%, 50.00%)
      • Set Around_Real = 0.00
      • Set Around_FirstUnit = No unit
      • Set Around_PreviousUnit = No unit
      • For each (Integer A) from 1 to 48, do (Actions)
        • Loop - Actions
          • -------- --------
          • -------- Create unit for unit group --------
          • Unit - Create 1 Battle Wall for Neutral Passive at ((Position of Dummy - General Use 0201 <gen>) offset by 8192.00 towards Around_Real degrees) facing Default building facing degrees
          • Unit Group - Add (Last created unit) to Around_UnitGroup
          • -------- --------
          • -------- Get the first unit so we can connect the first unit to the last unit --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Integer A) Equal to 1
            • Then - Actions
              • Set Around_FirstUnit = (Last created unit)
            • Else - Actions
              • Do nothing
          • -------- --------
          • -------- Create lightning if there are two units possible --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Around_PreviousUnit Not equal to No unit
            • Then - Actions
              • Lightning - Create a Lightning Attack lightning effect from source (Position of (Last created unit)) to target (Position of Around_PreviousUnit)
            • Else - Actions
              • Do nothing
          • -------- --------
          • -------- Now we check if we're at the last unit so we can connect the lightning to the first unit --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Integer A) Equal to 48
            • Then - Actions
              • Lightning - Create a Lightning Attack lightning effect from source (Position of (Last created unit)) to target (Position of Around_FirstUnit)
            • Else - Actions
              • Do nothing
          • Set Around_PreviousUnit = (Last created unit)
          • -------- --------
          • -------- Distance between tall walls --------
          • Set Around_Real = (Around_Real + 7.50)
      • Wait 5.00 seconds
      • -------- --------
      • -------- Kill the units --------
      • Unit Group - Pick every unit in Around_UnitGroup and do (Actions)
        • Loop - Actions
          • Unit - Kill (Picked unit)
      • Unit Group - Remove all units from Around_UnitGroup
      • Custom script: call DestroyGroup(udg_Around_UnitGroup)
      • Wait 1.00 seconds
      • -------- --------
      • -------- Fourth --------
      • Cinematic - Ping minimap for (All players) at (Position of Dummy - General Use 0201 <gen>) for 5.00 seconds, using a Warning ping of color (100.00%, 75.00%, 50.00%)
      • Set Around_Real = 0.00
      • Set Around_FirstUnit = No unit
      • Set Around_PreviousUnit = No unit
      • For each (Integer A) from 1 to 24, do (Actions)
        • Loop - Actions
          • -------- --------
          • -------- Create unit for unit group --------
          • Unit - Create 1 Battle Wall for Neutral Passive at ((Position of Dummy - General Use 0201 <gen>) offset by 4096.00 towards Around_Real degrees) facing Default building facing degrees
          • Unit Group - Add (Last created unit) to Around_UnitGroup
          • -------- --------
          • -------- Get the first unit so we can connect the first unit to the last unit --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Integer A) Equal to 1
            • Then - Actions
              • Set Around_FirstUnit = (Last created unit)
            • Else - Actions
              • Do nothing
          • -------- --------
          • -------- Create lightning if there are two units possible --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Around_PreviousUnit Not equal to No unit
            • Then - Actions
              • Lightning - Create a Lightning Attack lightning effect from source (Position of (Last created unit)) to target (Position of Around_PreviousUnit)
            • Else - Actions
              • Do nothing
          • -------- --------
          • -------- Now we check if we're at the last unit so we can connect the lightning to the first unit --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Integer A) Equal to 24
            • Then - Actions
              • Lightning - Create a Lightning Attack lightning effect from source (Position of (Last created unit)) to target (Position of Around_FirstUnit)
            • Else - Actions
              • Do nothing
          • Set Around_PreviousUnit = (Last created unit)
          • -------- --------
          • -------- Distance between tall walls --------
          • Set Around_Real = (Around_Real + 15.00)
      • Wait 5.00 seconds
      • -------- --------
      • -------- Kill the units --------
      • Unit Group - Pick every unit in Around_UnitGroup and do (Actions)
        • Loop - Actions
          • Unit - Kill (Picked unit)
      • Unit Group - Remove all units from Around_UnitGroup
      • Custom script: call DestroyGroup(udg_Around_UnitGroup)
      • Wait 1.00 seconds
      • -------- --------
      • -------- Last Circle --------
      • Cinematic - Ping minimap for (All players) at (Position of Dummy - General Use 0201 <gen>) for 5.00 seconds, using a Warning ping of color (100.00%, 75.00%, 50.00%)
      • Set Around_Real = 0.00
      • Set Around_FirstUnit = No unit
      • Set Around_PreviousUnit = No unit
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • -------- --------
          • -------- Create unit for unit group --------
          • Unit - Create 1 Battle Wall for Neutral Passive at ((Position of Dummy - General Use 0201 <gen>) offset by 2048.00 towards Around_Real degrees) facing Default building facing degrees
          • Unit Group - Add (Last created unit) to Around_UnitGroup
          • -------- --------
          • -------- Get the first unit so we can connect the first unit to the last unit --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Integer A) Equal to 1
            • Then - Actions
              • Set Around_FirstUnit = (Last created unit)
            • Else - Actions
              • Do nothing
          • -------- --------
          • -------- Create lightning if there are two units possible --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Around_PreviousUnit Not equal to No unit
            • Then - Actions
              • Lightning - Create a Lightning Attack lightning effect from source (Position of (Last created unit)) to target (Position of Around_PreviousUnit)
            • Else - Actions
              • Do nothing
          • -------- --------
          • -------- Now we check if we're at the last unit so we can connect the lightning to the first unit --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Integer A) Equal to 12
            • Then - Actions
              • Lightning - Create a Lightning Attack lightning effect from source (Position of (Last created unit)) to target (Position of Around_FirstUnit)
            • Else - Actions
              • Do nothing
          • Set Around_PreviousUnit = (Last created unit)
          • -------- --------
          • -------- Distance between tall walls --------
          • Set Around_Real = (Around_Real + 30.00)
      • Wait 10.00 seconds
      • -------- --------
      • -------- Kill the units --------
      • Unit Group - Pick every unit in Around_UnitGroup and do (Actions)
        • Loop - Actions
          • Unit - Kill (Picked unit)
      • Unit Group - Remove all units from Around_UnitGroup
      • Custom script: call DestroyGroup(udg_Around_UnitGroup)
 
Last edited:
Basically, you only can use a unit group if it exits. A destroyed group doesn't exist, so you can't add/emove units, or enumerate through it.
From default, GUI automatically creates the group in background, when the game starts, so you won't have to care about it. But once you destroy it, you would have to create a new one before you can use it again.

As solution here you can use the GUI function to only clear the group, insead of destroying it.
It also won't leak (at least when looking at this trigger), as you don't create always new groups. You simply add units to an already existing group.

A new group creation would look like...
Set Around_UnitGroup = (All Unts By (Player 1) In Region (Entire World) )
(the part after the "=" symbol is the part which would create a new group, and give the group variable the new value)
So only when creating new groups over an already existing group, this is the part where you firstly have to destroy the old group.
 
I just realized I am actually picking a locust unit, my bad. I recreated the triggers with different approach, this time it uses coundown timers, and I am not storing the units in unit groups anymore, for some reason it doesn't really work in my main map but it does work in the test map. I also removed the Custom Script: Destroy Groups like you said :D

However my only problem now is that it doesn't really create perfect circles, some walls are misplaced.

(I'll fix the point leaks later)
  • Battle Battle Setup
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Set Battle_WallType = Battle Royale Wall
      • Set Battle_CenterUnitType = Dummy - General Use
      • Set Battle_Countdown = 5.00
      • Set Battle_WallCount = 48
      • Set Battle_WaveCount = 4.00
      • Set Battle_WallOffset = 8192.00
      • Set Battle_WallDistance = 7.50
      • Unit - Create 1 Battle_CenterUnitType for Neutral Passive at (Center of BattleWallSpawn <gen>) facing Default building facing degrees
      • Set Battle_CenterCircleUnit = (Last created unit)
      • Countdown Timer - Create a timer window for Battle_Timer with title Adjusting Playable ...
      • Set Battle_TimerWindow = (Last created timer window)
      • Countdown Timer - Show Battle_TimerWindow
      • Camera - Pan camera for Player 1 (Red) to (Position of Battle_CenterCircleUnit) over 0.00 seconds
      • Trigger - Run Battle Initiate Battle Timer <gen> (ignoring conditions)
  • Battle Initiate Battle Timer
    • Events
    • Conditions
    • Actions
      • Countdown Timer - Start Battle_Timer as a One-shot timer that will expire in Battle_Countdown seconds
      • Countdown Timer - Resume Battle_Timer
  • Battle Expiration
    • Events
      • Time - Battle_Timer expires
    • Conditions
    • Actions
      • Countdown Timer - Destroy Battle_TimerWindow
      • For each (Integer A) from 1 to Battle_WallCount, do (Actions)
        • Loop - Actions
          • -------- --------
          • -------- Create unit for unit group --------
          • Unit - Create 1 Battle_WallType for Player 1 (Red) at ((Position of Battle_CenterCircleUnit) offset by Battle_WallOffset towards Battle_TempReal degrees) facing Default building facing degrees
          • Set Battle_WallUnitArray[(Integer A)] = (Last created unit)
          • -------- --------
          • -------- Get the first unit so we can connect the first unit to the last unit --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Integer A) Equal to 1
            • Then - Actions
              • Set Battle_FirstUnit = (Last created unit)
            • Else - Actions
              • Do nothing
          • -------- --------
          • -------- Create lightning if there are two units possible --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Battle_PreviousUnit Not equal to No unit
            • Then - Actions
              • Lightning - Create a Lightning Attack lightning effect from source (Position of (Last created unit)) to target (Position of Battle_PreviousUnit)
              • Set Battle_LightningWallArray[(Integer A)] = (Last created lightning effect)
            • Else - Actions
              • Do nothing
          • -------- --------
          • -------- Now we check if we're at the last unit so we can connect the lightning to the first unit --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Integer A) Equal to Battle_WallCount
            • Then - Actions
              • Lightning - Create a Lightning Attack lightning effect from source (Position of (Last created unit)) to target (Position of Battle_FirstUnit)
              • Set Battle_LightningWallArray[1] = (Last created lightning effect)
            • Else - Actions
              • Do nothing
          • Set Battle_PreviousUnit = (Last created unit)
          • -------- --------
          • -------- Debug --------
          • Game - Display to (All players) the text: (Wall: + (String(Battle_WallCount)))
          • Game - Display to (All players) the text: (Offset: + (String(Battle_WallOffset)))
          • Game - Display to (All players) the text: (Distance: + (String(Battle_WallDistance)))
          • Game - Display to (All players) the text: (Offset: + (String(Battle_TempReal)))
          • -------- --------
          • -------- Distance between tall walls --------
          • Set Battle_TempReal = (Battle_TempReal + Battle_WallDistance)
      • -------- --------
      • -------- Initiate the next wave --------
      • Wait 5.00 seconds
      • -------- --------
      • -------- Decrease Wave --------
      • Set Battle_WaveCount = (Battle_WaveCount - 1.00)
      • -------- --------
      • -------- Check if there is still next wave --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Battle_WaveCount Greater than or equal to 1.00
        • Then - Actions
          • For each (Integer A) from 1 to Battle_WallCount, do (Actions)
            • Loop - Actions
              • -------- --------
              • -------- Kill the units --------
              • Unit - Kill Battle_WallUnitArray[(Integer A)]
              • Lightning - Destroy Battle_LightningWallArray[(Integer A)]
          • -------- --------
          • -------- Decrease circle size and wall count, and increase distance --------
          • Set Battle_WallCount = (Battle_WallCount / 2)
          • Set Battle_WallOffset = (Battle_WallOffset / 2.00)
          • Set Battle_WallDistance = (Battle_WallDistance x 2.00)
          • -------- --------
          • -------- Clear variables --------
          • Set Battle_TempReal = 0.00
          • Set Battle_FirstUnit = No unit
          • Set Battle_PreviousUnit = No unit
          • Set Battle_TempReal = 0.00
          • -------- --------
          • -------- Rerun battle timer --------
          • Trigger - Run Battle Initiate Battle Timer <gen> (ignoring conditions)
        • Else - Actions
          • Do nothing

Edit: I attached images. Also the tall white lines are the walls. The walls do have locust ability but this still happen.

Another Edit: I fixed it by not setting the dummy/walls to amphibious, it works good now. Thanks for your help Iceman :D
 

Attachments

  • WC3ScrnShot_073019_191037_01.png
    WC3ScrnShot_073019_191037_01.png
    1.6 MB · Views: 56
  • WC3ScrnShot_073019_191045_02.png
    WC3ScrnShot_073019_191045_02.png
    1.6 MB · Views: 59
  • WC3ScrnShot_073019_191056_04.png
    WC3ScrnShot_073019_191056_04.png
    1.6 MB · Views: 51
Last edited:
Status
Not open for further replies.
Top