• 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.

[General] Can someone check if this trigger leak?

Level 7
Joined
Feb 22, 2009
Messages
260
I am most worried about the Creepcheck since it is a unit group.


  • Set RandomNumber = (Random integer number between 1 and RandomMax)
  • Set CreepRegion = Bot Right Right <gen>
  • Set CreepCheck = (Units in CreepRegion owned by Neutral Hostile)
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Number of units in CreepCheck) Less than 2
    • Then - Actions
      • Set CreepSpawn = BRR
      • For each (Integer A) from 1 to WeakNumber, do (Actions)
        • Loop - Actions
          • Unit - Create 1 WeakCreep[RandomNumber] for Neutral Hostile at CreepSpawn facing Center
      • For each (Integer A) from 1 to BossNumber, do (Actions)
        • Loop - Actions
          • Unit - Create 1 BossCreep[RandomNumber] for Neutral Hostile at CreepSpawn facing Center
      • For each (Integer A) from 1 to StrongNumber, do (Actions)
        • Loop - Actions
          • Unit - Create 1 StrongCreep[RandomNumber] for Neutral Hostile at CreepSpawn facing Center
      • For each (Integer A) from 1 to SupportNumber, do (Actions)
        • Loop - Actions
          • Unit - Create 1 SupportCreep[RandomNumber] for Neutral Hostile at CreepSpawn facing Center
    • Else - Actions
 
Level 7
Joined
Feb 22, 2009
Messages
260
You are correct. The group should be destroyed after use.
call DestroyGroup(udg_CreepCheck)

So do I have to destroy it after every check because I got 8 regions to check every 300s?


  • Creep spawn Bot
    • Events
      • Time - Every 300.00 seconds of game time
    • Conditions
    • Actions
      • -------- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX --------
      • Set RandomNumber = (Random integer number between 1 and RandomMax)
      • Set CreepRegion = Bot Bot Left <gen>
      • Set CreepCheck = (Units in CreepRegion matching (((Owner of (Matching unit)) Equal to Neutral Hostile) and (((Matching unit) is alive) Equal to True)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in CreepCheck) Less than 2
        • Then - Actions
          • Set CreepSpawn = BBL
          • For each (Integer A) from 1 to WeakNumber, do (Actions)
            • Loop - Actions
              • Unit - Create 1 WeakCreep[RandomNumber] for Neutral Hostile at CreepSpawn facing Center
          • For each (Integer A) from 1 to BossNumber, do (Actions)
            • Loop - Actions
              • Unit - Create 1 BossCreep[RandomNumber] for Neutral Hostile at CreepSpawn facing Center
          • For each (Integer A) from 1 to StrongNumber, do (Actions)
            • Loop - Actions
              • Unit - Create 1 StrongCreep[RandomNumber] for Neutral Hostile at CreepSpawn facing Center
          • For each (Integer A) from 1 to SupportNumber, do (Actions)
            • Loop - Actions
              • Unit - Create 1 SupportCreep[RandomNumber] for Neutral Hostile at CreepSpawn facing Center
        • Else - Actions
      • Custom script: call DestroyGroup(udg_CreepCheck)
      • -------- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX --------
      • -------- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX --------
      • Wait 15.00 seconds
      • Set RandomNumber = (Random integer number between 1 and RandomMax)
      • Set CreepRegion = Bot Bot Right <gen>
      • Set CreepCheck = (Units in CreepRegion matching (((Owner of (Matching unit)) Equal to Neutral Hostile) and (((Matching unit) is alive) Equal to True)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in CreepCheck) Less than 2
        • Then - Actions
          • Set CreepSpawn = BBR
          • For each (Integer A) from 1 to WeakNumber, do (Actions)
            • Loop - Actions
              • Unit - Create 1 WeakCreep[RandomNumber] for Neutral Hostile at CreepSpawn facing Center
          • For each (Integer A) from 1 to BossNumber, do (Actions)
            • Loop - Actions
              • Unit - Create 1 BossCreep[RandomNumber] for Neutral Hostile at CreepSpawn facing Center
          • For each (Integer A) from 1 to StrongNumber, do (Actions)
            • Loop - Actions
              • Unit - Create 1 StrongCreep[RandomNumber] for Neutral Hostile at CreepSpawn facing Center
          • For each (Integer A) from 1 to SupportNumber, do (Actions)
            • Loop - Actions
              • Unit - Create 1 SupportCreep[RandomNumber] for Neutral Hostile at CreepSpawn facing Center
        • Else - Actions
      • Custom script: call DestroyGroup(udg_CreepCheck)
      • -------- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX --------
      • -------- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX --------
      • -------- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX --------
      • Wait 15.00 seconds
      • Set RandomNumber = (Random integer number between 1 and RandomMax)
      • Set CreepRegion = Bot Left Left <gen>
      • Set CreepCheck = (Units in CreepRegion matching (((Owner of (Matching unit)) Equal to Neutral Hostile) and (((Matching unit) is alive) Equal to True)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in CreepCheck) Less than 2
        • Then - Actions
          • Set CreepSpawn = BLL
          • For each (Integer A) from 1 to WeakNumber, do (Actions)
            • Loop - Actions
              • Unit - Create 1 WeakCreep[RandomNumber] for Neutral Hostile at CreepSpawn facing Center
          • For each (Integer A) from 1 to BossNumber, do (Actions)
            • Loop - Actions
              • Unit - Create 1 BossCreep[RandomNumber] for Neutral Hostile at CreepSpawn facing Center
          • For each (Integer A) from 1 to StrongNumber, do (Actions)
            • Loop - Actions
              • Unit - Create 1 StrongCreep[RandomNumber] for Neutral Hostile at CreepSpawn facing Center
          • For each (Integer A) from 1 to SupportNumber, do (Actions)
            • Loop - Actions
              • Unit - Create 1 SupportCreep[RandomNumber] for Neutral Hostile at CreepSpawn facing Center
        • Else - Actions
      • Custom script: call DestroyGroup(udg_CreepCheck)
      • -------- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX --------
      • -------- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX --------
      • -------- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX --------
      • -------- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX --------
      • Wait 15.00 seconds
      • Set RandomNumber = (Random integer number between 1 and RandomMax)
      • Set CreepRegion = Bot Right Right <gen>
      • Set CreepCheck = (Units in CreepRegion matching (((Owner of (Matching unit)) Equal to Neutral Hostile) and (((Matching unit) is alive) Equal to True)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in CreepCheck) Less than 2
        • Then - Actions
          • Set CreepSpawn = BRR
          • For each (Integer A) from 1 to WeakNumber, do (Actions)
            • Loop - Actions
              • Unit - Create 1 WeakCreep[RandomNumber] for Neutral Hostile at CreepSpawn facing Center
          • For each (Integer A) from 1 to BossNumber, do (Actions)
            • Loop - Actions
              • Unit - Create 1 BossCreep[RandomNumber] for Neutral Hostile at CreepSpawn facing Center
          • For each (Integer A) from 1 to StrongNumber, do (Actions)
            • Loop - Actions
              • Unit - Create 1 StrongCreep[RandomNumber] for Neutral Hostile at CreepSpawn facing Center
          • For each (Integer A) from 1 to SupportNumber, do (Actions)
            • Loop - Actions
              • Unit - Create 1 SupportCreep[RandomNumber] for Neutral Hostile at CreepSpawn facing Center
        • Else - Actions
      • Custom script: call DestroyGroup(udg_CreepCheck)












Note that this:
  • (Number of units in CreepCheck) Less than 2
Is also counting dead units.

Also, this does nothing special but I suppose you just like the clarity:
  • Set CreepSpawn = BRR
You could reference BRR directly.

I also need to add a condition that the unit is alive before adding them to the unit group for that to work?

  • Set CreepCheck = (Units in CreepRegion matching (((Owner of (Matching unit)) Equal to Neutral Hostile) and (((Matching unit) is alive) Equal to True)))

Yeah. I reference BRR through a variable because I got 8 regions

  • Creep spawn Top
    • Events
      • Time - Every 300.00 seconds of game time
    • Conditions
    • Actions
      • -------- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX --------
      • Set RandomNumber = (Random integer number between 1 and RandomMax)
      • Set CreepRegion = Top Left Left <gen>
      • Set CreepCheck = (Units in CreepRegion owned by Neutral Hostile)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in CreepCheck) Less than 2
        • Then - Actions
          • Set CreepSpawn = TLL
          • For each (Integer A) from 1 to WeakNumber, do (Actions)
            • Loop - Actions
              • Unit - Create 1 WeakCreep[RandomNumber] for Neutral Hostile at CreepSpawn facing Center
          • For each (Integer A) from 1 to BossNumber, do (Actions)
            • Loop - Actions
              • Unit - Create 1 BossCreep[RandomNumber] for Neutral Hostile at CreepSpawn facing Center
          • For each (Integer A) from 1 to StrongNumber, do (Actions)
            • Loop - Actions
              • Unit - Create 1 StrongCreep[RandomNumber] for Neutral Hostile at CreepSpawn facing Center
          • For each (Integer A) from 1 to SupportNumber, do (Actions)
            • Loop - Actions
              • Unit - Create 1 SupportCreep[RandomNumber] for Neutral Hostile at CreepSpawn facing Center
        • Else - Actions
      • Custom script: call DestroyGroup(udg_CreepCheck)
      • -------- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX --------
      • -------- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX --------
      • Wait 15.00 seconds
      • Set RandomNumber = (Random integer number between 1 and RandomMax)
      • Set CreepRegion = Top Top Left <gen>
      • Set CreepCheck = (Units in CreepRegion owned by Neutral Hostile)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in CreepCheck) Less than 2
        • Then - Actions
          • Set CreepSpawn = TTL
          • For each (Integer A) from 1 to WeakNumber, do (Actions)
            • Loop - Actions
              • Unit - Create 1 WeakCreep[RandomNumber] for Neutral Hostile at CreepSpawn facing Center
          • For each (Integer A) from 1 to BossNumber, do (Actions)
            • Loop - Actions
              • Unit - Create 1 BossCreep[RandomNumber] for Neutral Hostile at CreepSpawn facing Center
          • For each (Integer A) from 1 to StrongNumber, do (Actions)
            • Loop - Actions
              • Unit - Create 1 StrongCreep[RandomNumber] for Neutral Hostile at CreepSpawn facing Center
          • For each (Integer A) from 1 to SupportNumber, do (Actions)
            • Loop - Actions
              • Unit - Create 1 SupportCreep[RandomNumber] for Neutral Hostile at CreepSpawn facing Center
        • Else - Actions
      • -------- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX --------
      • -------- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX --------
      • -------- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX --------
      • Wait 15.00 seconds
      • Set RandomNumber = (Random integer number between 1 and RandomMax)
      • Set CreepRegion = Top Right Right <gen>
      • Set CreepCheck = (Units in CreepRegion owned by Neutral Hostile)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in CreepCheck) Less than 2
        • Then - Actions
          • Set CreepSpawn = TRR
          • For each (Integer A) from 1 to WeakNumber, do (Actions)
            • Loop - Actions
              • Unit - Create 1 WeakCreep[RandomNumber] for Neutral Hostile at CreepSpawn facing Center
          • For each (Integer A) from 1 to BossNumber, do (Actions)
            • Loop - Actions
              • Unit - Create 1 BossCreep[RandomNumber] for Neutral Hostile at CreepSpawn facing Center
          • For each (Integer A) from 1 to StrongNumber, do (Actions)
            • Loop - Actions
              • Unit - Create 1 StrongCreep[RandomNumber] for Neutral Hostile at CreepSpawn facing Center
          • For each (Integer A) from 1 to SupportNumber, do (Actions)
            • Loop - Actions
              • Unit - Create 1 SupportCreep[RandomNumber] for Neutral Hostile at CreepSpawn facing Center
        • Else - Actions
      • -------- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX --------
      • -------- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX --------
      • -------- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX --------
      • -------- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX --------
      • Wait 15.00 seconds
      • Set RandomNumber = (Random integer number between 1 and RandomMax)
      • Set CreepRegion = Top Top Right <gen>
      • Set CreepCheck = (Units in CreepRegion owned by Neutral Hostile)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in CreepCheck) Less than 2
        • Then - Actions
          • Set CreepSpawn = TTR
          • For each (Integer A) from 1 to WeakNumber, do (Actions)
            • Loop - Actions
              • Unit - Create 1 WeakCreep[RandomNumber] for Neutral Hostile at CreepSpawn facing Center
          • For each (Integer A) from 1 to BossNumber, do (Actions)
            • Loop - Actions
              • Unit - Create 1 BossCreep[RandomNumber] for Neutral Hostile at CreepSpawn facing Center
          • For each (Integer A) from 1 to StrongNumber, do (Actions)
            • Loop - Actions
              • Unit - Create 1 StrongCreep[RandomNumber] for Neutral Hostile at CreepSpawn facing Center
          • For each (Integer A) from 1 to SupportNumber, do (Actions)
            • Loop - Actions
              • Unit - Create 1 SupportCreep[RandomNumber] for Neutral Hostile at CreepSpawn facing Center
        • Else - Actions
 
Last edited:

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
I also need to add a condition that the unit is alive before adding them to the unit group for that to work?
Yes, I would use the "Units in region matching" function:
  • Set CreepCheck = (Units in CreepRegion matching (Owner of (Matching unit)) Equal to Neutral Hostile and (Matching unit) is Alive Equal to True)
Then customize the Conditions to fit all of your needs. The other functions may have hidden leaks or other issues, this one is safe to use and fully customizable.

So do I have to destroy it after every check because I got 8 regions to check every 300s?
Yes, the rule for memory leaks: Set, Use, Remove.

You should never be setting a variable that can leak (Point, Unit Group, Player Group, Special Effect, Timer) before removing the previous data it was tracking. Of course this rule only applies to variables that you set more than once. It's perfectly fine to have a constant variable that gets set once and stays that way for the rest of the game. Think of CreepCheck as a temporary data holder, once you're done with the data it's holding you need to "throw it out".
 
Last edited:
Top