• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Is this the proper way to remove a unit group for leaks?

Status
Not open for further replies.
Level 12
Joined
Dec 2, 2016
Messages
733
  • Update Income Tier1 Goldmine
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Integer_Seconds Equal to 60
          • TempBool Equal to False
        • Then - Actions
          • Unit Group - Pick every unit in (Units in Level Slayers <gen>) and do (Hero - Set (Picked unit) Hero-level to ((Hero level of (Picked unit)) + 1), Show level-up graphics)
          • Unit Group - Remove all units of (Last created unit group) from (Last created unit group)
          • Set tempSlayerGroup = (Last created unit group)
          • Set TempBool = True
          • For each (Integer A) from 1 to (Number of players), do (Actions)
            • Loop - Actions
              • Player - Set (Player((Integer A))) Current gold to (((Player((Integer A))) Current gold) + Goldmines[(Player number of (Player((Integer A))))])
              • Player - Set (Player((Integer A))) Current gold to (((Player((Integer A))) Current gold) + Goldmines[(Player number of (Player((Integer A))))])
          • Wait 5.00 seconds
          • Set TempBool = False
        • Else - Actions
 
Level 6
Joined
Aug 28, 2015
Messages
213
There are two ways to remove the unit group
Dynamic Unit Groups

This trigger will instantly destroy dynamically generated unit groups.

Unit Groups
  • base.gif
    Trigger
    • joinminus.gif
      events.gif
      Events
      • line.gif
        joinbottom.gif
        if.gif
        Event
    • joinminus.gif
      cond.gif
      Conditions
      • line.gif
        joinbottom.gif
        cond.gif
        Conditions
    • joinbottomminus.gif
      actions.gif
      Actions
      • empty.gif
        join.gif
        page.gif
        Custom script: set bj_wantDestroyGroup = true
      • empty.gif
        joinbottom.gif
        unitgroup.gif
        Unit Group - Pick every unit in (Playable Map Area) and do (Unit - Hide (Picked unit))

Another way to avoid a group leak is to store the group into a variable, and then destroy it manually.

Unit Groups
  • set.gif
    Set GroupVar = Pick every unit in (Playable Map Area)
  • unitgroup.gif
    Unit Group - Pick every unit in GroupVar and do (Unit - Hide (Picked unit))
  • page.gif
    Custom script: call DestroyGroup(udg_GroupVar)

This is useful if you want to use the group more than once in the trigger.
I always use the post from Ralle here: Things That Leak
That is a good source to learn about the leaks and get the right native before you know them out of the top of you head ;)

You should also use a own variable iinsted of IntegerA because this could cause problems.
also wait is evil maybe start a second timer that sets the boolean to false.
 
Level 6
Joined
Aug 28, 2015
Messages
213
Bj is a blizzard made prefix for some of their natives, I'm not that sure about the differences if you want to learn more about this look in the tutorial section.

It doesn't remove the group by call it set the flag that the next group will be removed if not needed anymore.
So you have to set it every time you dynamically create a group like by pick all units in region and do...
 
Status
Not open for further replies.
Top