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

Should I destroy a group that runs every loop?

Status
Not open for further replies.
Level 5
Joined
Jan 23, 2014
Messages
152
All I do is pick units within range of a point and add it to a group, which damages those picked units every x seconds in another trigger.

  • LBRT Move Hound
    • Events
      • Time - Every 0.06 seconds of game time
    • Conditions
    • Actions
      • Set LBRT_Distance[0] = (LBRT_Distance[0] + 80.00)
      • Set LBRT_Path[0] = (LBRT_TPoint[0] offset by LBRT_Distance[0] towards (Angle from LBRT_TPoint[0] to LBRT_TPoint[1]) degrees)
      • Unit - Move LBRT_Hound instantly to LBRT_Path[0], facing (Facing of LBRT_Hound) degrees
      • Set LBRT_Path[1] = (Position of LBRT_Hound)
      • Set LBRT_Distance[1] = (Distance between LBRT_Path[1] and LBRT_TPoint[1])
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 166.00 of LBRT_Path[1] matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is in LBRT_Grp[1]) Equal to False) and (((Matching unit) belongs to an enemy of (Owner of LBRT_Caster)) Equal to True)))) and do (Actions)
        • Loop - Actions
          • Unit Group - Add (Picked unit) to LBRT_Grp[0]
          • Special Effect - Create a special effect attached to the origin of (Picked unit) using Lightning.mdx
          • Special Effect - Destroy (Last created special effect)
      • Custom script: call RemoveLocation (udg_LBRT_Path[0])
      • Custom script: call RemoveLocation (udg_LBRT_Path[1])


  • LBRT Damage
    • Events
      • Time - Every 0.30 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in LBRT_Grp[0] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is in LBRT_Grp[1]) Equal to False
            • Then - Actions
              • Special Effect - Create a special effect attached to the origin of (Picked unit) using LightningT.mdx
              • Special Effect - Destroy (Last created special effect)
              • Unit - Cause LBRT_Caster to damage (Picked unit), dealing (((Real((Level of Lightning Beast Running Technique for LBRT_Caster))) x 4.00) x (Real((Agility of LBRT_Caster (Exclude bonuses))))) damage of attack type Spells and damage type Lightning
              • Game - Display to (All players) the text: damage
              • Unit Group - Add (Picked unit) to LBRT_Grp[1]
            • Else - Actions


  • LBRT Clean Up
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Dying unit)) Equal to Lightning hound
    • Actions
      • Special Effect - Destroy LBRT_SFX[0]
      • Special Effect - Destroy LBRT_SFX[1]
      • Set LBRT_Distance[0] = (LBRT_Distance[0] - LBRT_Distance[0])
      • Unit Group - Remove all units from LBRT_Grp[0]
      • Unit Group - Remove all units from LBRT_Grp[1]
      • Trigger - Turn off LBRT Move Hound <gen>
      • Trigger - Turn off LBRT Damage <gen>
      • Custom script: call RemoveLocation (udg_LBRT_TPoint[0])
      • Custom script: call RemoveLocation (udg_LBRT_TPoint[1])
      • Trigger - Turn off (This trigger)



I'm not sure if this one leaks. So should I destroy the LBRT_Grp array?
 
Level 5
Joined
Jan 23, 2014
Messages
152
Ohh ok thanks! I've been using the leak checker sytem from here and it reported that I had a group leak. While we're at it, did I destroy all the points?
 
Level 28
Joined
Sep 26, 2009
Messages
2,520
There doesn't seem to be any leaks.
It may be that the group array is considered leak, because it is not destroyed. However it's not leak, because you continually use those very same unit groups (same handles) and you did not lose every reference to them, since the array still points at them.

Also, this line:
  • Set LBRT_Distance[0] = (LBRT_Distance[0] - LBRT_Distance[0])
doesn't make sense. It will always return 0, so you don't need to make any calculations and simply write 0 in there.


You may want to null variables at then end (e.g. "custom script: set udg_LBRT_TPoint[0] = null") but null them after you destroy what they point at. Don't null that unit group array though, or you'll get leak.
But that may not be that important since they're not local.
 
Status
Not open for further replies.
Top