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

[Trigger] Can anyone help me fix the leaks?

Status
Not open for further replies.
Level 20
Joined
Apr 14, 2012
Messages
2,901
Okay so I've been making this spell that, according to Maker, leaks. I have updated it 4 times, though it still leaks. In my knowledge, the possible variables that can leak in the trigger are groups and points, because I destroy the effects created instantly.

Please help me find and fix the remaining leaks!



  • ZS Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer ZS_CurrentIndex) from 1 to ZS_MaxIndex, do (Actions)
        • Loop - Actions
          • Set ZS_CasterLoc[ZS_CurrentIndex] = (Position of ZS_Caster[ZS_CurrentIndex])
          • -------- [START] Circle War Stomp [START] --------
          • For each (Integer ZS_CirclInt) from 1 to ZS_StartCircleNum[ZS_Level], do (Actions)
            • Loop - Actions
              • Set ZS_TempPoint = (ZS_CasterLoc[ZS_CurrentIndex] offset by ZS_StartCircleOffset[ZS_Level] towards ((Real(ZS_CirclInt)) x (360.00 / (Real(ZS_StartCircleNum[ZS_Level])))) degrees)
              • Special Effect - Create a special effect at ZS_TempPoint using ZS_StartSFX[ZS_Level]
              • Animation - Play ZS_Caster[ZS_CurrentIndex]'s attack 1 animation
              • Special Effect - Destroy (Last created special effect)
          • Set ZS_TempGroup1 = (Units within ZS_StartRange[ZS_Level] of ZS_CasterLoc[ZS_CurrentIndex] matching (((Matching unit) belongs to an enemy of ZS_TempPlayer[ZS_CurrentIndex]) Equal to True))
          • Unit Group - Pick every unit in ZS_TempGroup1 and do (Actions)
            • Loop - Actions
              • Set ZS_TempUnit = (Picked unit)
              • Unit - Cause ZS_Caster[ZS_CurrentIndex] to damage ZS_TempUnit, dealing ZS_StartCircleDamage[ZS_Level] damage of attack type Chaos and damage type Divine
          • Custom script: call DestroyGroup(udg_ZS_TempGroup1)
          • Custom script: call RemoveLocation(udg_ZS_TempPoint)
          • -------- [END] Circle War Stomp [END] --------
          • Animation - Change ZS_Caster[ZS_CurrentIndex]'s animation speed to 200.00% of its original speed
          • Animation - Play ZS_Caster[ZS_CurrentIndex]'s attack 1 animation
          • -------- [START]1-second Omnislash[START] --------
          • For each (Integer ZS_LoopInt) from 1 to ZS_OmniLoop[ZS_Level], do (Actions)
            • Loop - Actions
              • Set ZS_TempGroup1 = (Units within ZS_OmniRange[ZS_Level] of ZS_CasterLoc[ZS_CurrentIndex] matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is alive) Equal to True) and ((((Matching unit) belongs to an enemy of ZS_TempPlayer[ZS_CurrentIndex]) Equ
              • Set ZS_TempUnit = (Random unit from ZS_TempGroup1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ZS_TempUnit Equal to No unit
                • Then - Actions
                • Else - Actions
                  • Animation - Change ZS_Caster[ZS_CurrentIndex]'s vertex coloring to (100.00%, 100.00%, 100.00%) with 50.00% transparency
                  • Animation - Change ZS_Caster[ZS_CurrentIndex]'s animation speed to 300.00% of its original speed
                  • Unit Group - Pick every unit in ZS_TempGroup1 and do (Actions)
                    • Loop - Actions
                      • Set ZS_PickedUnit[ZS_LoopInt] = (Picked unit)
                      • Set ZS_PickedUnitLoc[ZS_LoopInt] = (Position of ZS_PickedUnit[ZS_LoopInt])
                      • -------- Start of Omnislashing --------
                      • Set ZS_TempPoint2 = (ZS_PickedUnitLoc[ZS_LoopInt] offset by ((Real(ZS_LoopInt)) + ZS_JumpIncrement[ZS_Level]) towards (Angle from ZS_CasterLoc[ZS_CurrentIndex] to ZS_PickedUnitLoc[ZS_CurrentIndex]) degrees)
                      • Custom script: if IsPointJumpable(GetLocationX(udg_ZS_TempPoint2), GetLocationY(udg_ZS_TempPoint2)) then
                      • Custom script: call SetUnitX( udg_ZS_Caster[udg_ZS_CurrentIndex], GetLocationX(udg_ZS_PickedUnitLoc[udg_ZS_LoopInt]))
                      • Custom script: call SetUnitY( udg_ZS_Caster[udg_ZS_CurrentIndex], GetLocationY(udg_ZS_PickedUnitLoc[udg_ZS_LoopInt]))
                      • Animation - Play ZS_Caster[ZS_CurrentIndex]'s ZS_OmniAnim[ZS_Level] animation
                      • Unit - Cause ZS_Caster[ZS_CurrentIndex] to damage ZS_PickedUnit[ZS_LoopInt], dealing ZS_OmniDamage[ZS_Level] damage of attack type ZS_OmniAttType[ZS_Level] and damage type ZS_OmniDmgType[ZS_Level]
                      • Special Effect - Create a special effect attached to the chest of ZS_PickedUnit[ZS_LoopInt] using ZS_OmniSfx[ZS_Level]
                      • Custom script: call Jump.start(udg_ZS_PickedUnit[udg_ZS_LoopInt], GetLocationX(udg_ZS_TempPoint2), GetLocationY(udg_ZS_TempPoint2), udg_ZS_JumpMaxZ[udg_ZS_Level], udg_ZS_JumpDuration[udg_ZS_Level], udg_ZS_JumpGravity[udg_ZS_Level])
                      • Special Effect - Destroy (Last created special effect)
                      • Custom script: endif
                      • Custom script: call RemoveLocation(udg_ZS_TempPoint2)
                  • Animation - Change ZS_Caster[ZS_CurrentIndex]'s vertex coloring to (100.00%, 100.00%, 100.00%) with 0.00% transparency
                  • Animation - Change ZS_Caster[ZS_CurrentIndex]'s animation speed to 100.00% of its original speed
                  • Custom script: set udg_ZS_TempPoint2 = null
                  • Custom script: call RemoveLocation(udg_ZS_TempPoint2)
          • -------- [END] Omnislash[END] --------
          • -------- [START] Final Circle War Stomp [START] --------
          • For each (Integer ZS_CirclInt) from 1 to ZS_FinalCircleNum[ZS_Level], do (Actions)
            • Loop - Actions
              • Set ZS_TempPoint = (ZS_CasterLoc[ZS_CurrentIndex] offset by ZS_FinalCircleOffset[ZS_Level] towards ((Real(ZS_CirclInt)) x (360.00 / (Real(ZS_FinalCircleNum[ZS_Level])))) degrees)
              • Special Effect - Create a special effect at ZS_TempPoint using ZS_FinalSFX[ZS_Level]
              • Animation - Play ZS_Caster[ZS_CurrentIndex]'s attack 2 animation
              • Special Effect - Destroy (Last created special effect)
          • Set ZS_TempGroup1 = (Units within ZS_FinalRange[ZS_Level] of ZS_CasterLoc[ZS_CurrentIndex] matching (((Matching unit) belongs to an enemy of ZS_TempPlayer[ZS_CurrentIndex]) Equal to True))
          • Unit Group - Pick every unit in ZS_TempGroup1 and do (Actions)
            • Loop - Actions
              • Set ZS_TempUnit = (Picked unit)
              • Unit - Cause ZS_Caster[ZS_CurrentIndex] to damage ZS_TempUnit, dealing ZS_FinalCircleDamage[ZS_Level] damage of attack type Chaos and damage type Divine
          • -------- [END] Final Circle War Stomp [END] --------
          • Animation - Change ZS_Caster[ZS_CurrentIndex]'s animation speed to 100.00% of its original speed
          • Custom script: call RemoveLocation(udg_ZS_TempPoint)
          • Custom script: call RemoveLocation(udg_ZS_CasterLoc[udg_ZS_CurrentIndex])
          • Custom script: call RemoveLocation(udg_ZS_TempPoint2)
          • Custom script: set udg_ZS_TempPoint = null
          • Custom script: set udg_ZS_TempPoint2 = null
          • -------- Recycling --------
          • Set ZS_Caster[ZS_CurrentIndex] = ZS_Caster[ZS_MaxIndex]
          • Set ZS_CasterLoc[ZS_CurrentIndex] = ZS_CasterLoc[ZS_MaxIndex]
          • Set ZS_Counter[ZS_CurrentIndex] = ZS_Counter[ZS_MaxIndex]
          • Set ZS_TempPlayer[ZS_CurrentIndex] = ZS_TempPlayer[ZS_MaxIndex]
          • Set ZS_MaxIndex = (ZS_MaxIndex - 1)
          • Set ZS_CurrentIndex = (ZS_CurrentIndex - 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ZS_MaxIndex Equal to 0
            • Then - Actions
              • Trigger - Turn off (This trigger)
            • Else - Actions
          • -------- Instance Recycled --------
          • -------- End Loop --------
          • -------- End Cast --------
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
You need to remove location within this loop:

  • For each (Integer ZS_CirclInt) from 1 to ZS_StartCircleNum[ZS_Level], do (Actions)
    • Loop - Actions
      • Set ZS_TempPoint = (ZS_CasterLoc[ZS_CurrentIndex] offset by ZS_StartCircleOffset[ZS_Level] towards ((Real(ZS_CirclInt)) x (360.00 / (Real(ZS_StartCircleNum[ZS_Level])))) degrees)
      • Special Effect - Create a special effect at ZS_TempPoint using ZS_StartSFX[ZS_Level]
      • Animation - Play ZS_Caster[ZS_CurrentIndex]'s attack 1 animation
      • Special Effect - Destroy (Last created special effect)
Even though you are "re-using" the ZS_TempPoint variable, the references created every time you set it do leak.

  • Set ZS_TempGroup1 = (Units within ZS_OmniRange[ZS_Level] of ZS_CasterLoc[ZS_CurrentIndex] matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is alive) Equal to True) and ((((Matching unit) belongs to an enemy of ZS_TempPlayer[ZS_CurrentIndex]) Equ
Creating unit groups with conditions apparently also leaks.

Do this:
  • Set ZS_TempGroup1 = (Units within ZS_OmniRange[ZS_Level] of ZS_CasterLoc[ZS_CurrentIndex])
  • Unit Group - Pick every unit in ZS_TempGroup1 and do actions
    • Loop - Actions
      • If (all conds are true) then do (actions) else do (actions)
        • If - Conditions
          • Picked unit is a structure equal to false
          • Picked unit is alive equal to true
          • // etc, put all the "matching" conditions here
        • Then
          • // do nothing
        • Else
          • Unit Group - remove picked unit from ZS_TempGroup1
 
you should just filter them inside the group enumerations(picking)
Also,its readable.

bj_wantDestroyGroup destroys the group. This only works for BJs and GUI.

JASS:
function IsUnitGroupDeadBJ takes group g returns boolean

    // If the user wants the group destroyed, remember that fact and clear

    // the flag, in case it is used again in the callback.

    local boolean wantDestroy = bj_wantDestroyGroup

    set bj_wantDestroyGroup = false



    set bj_isUnitGroupDeadResult = true

    call ForGroup(g, function IsUnitGroupDeadBJEnum)



    // If the user wants the group destroyed, do so now.

    if (wantDestroy) then

        call DestroyGroup(g)

    endif

    return bj_isUnitGroupDeadResult

endfunction

//===========================================================================

// Returns true if the group contains no units.

//

function IsUnitGroupEmptyBJ takes group g returns boolean

    // If the user wants the group destroyed, remember that fact and clear

    // the flag, in case it is used again in the callback.

    local boolean wantDestroy = bj_wantDestroyGroup

    set bj_wantDestroyGroup = false



    set bj_isUnitGroupEmptyResult = true

    call ForGroup(g, function IsUnitGroupEmptyBJEnum)



    // If the user wants the group destroyed, do so now.

    if (wantDestroy) then

        call DestroyGroup(g)

    endif

    return bj_isUnitGroupEmptyResult

endfunction

//***************************************************************************

//*

//*  Group and Force Utility Functions

//*

//***************************************************************************



//===========================================================================

function ForGroupBJ takes group whichGroup, code callback returns nothing

    // If the user wants the group destroyed, remember that fact and clear

    // the flag, in case it is used again in the callback.

    local boolean wantDestroy = bj_wantDestroyGroup

    set bj_wantDestroyGroup = false



    call ForGroup(whichGroup, callback)



    // If the user wants the group destroyed, do so now.

    if (wantDestroy) then

        call DestroyGroup(whichGroup)

    endif

endfunction
 
Status
Not open for further replies.
Top