Help removing a LEAK

Level 5
Joined
Jul 2, 2013
Messages
141
Hello, I made a MUI Spell. I need help to clear the unit group leak properly without making the spell malfunctioning.
  • Vampire Dance
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Summon Water Elemental
    • Actions
      • Set VD_Index = (VD_Index + 1)
      • Set VD_Group[VD_Index] = (Units within 500.00 of (Position of (Triggering unit)) matching (((Matching unit) belongs to an ally of (Owner of (Triggering unit))) Equal to True))
      • Set VD_Counter[VD_Index] = 0
      • Unit Group - Pick every unit in VD_Group[VD_Index] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is A melee attacker) Equal to True
            • Then - Actions
              • Unit - Add Item Life Steal to (Picked unit)
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • VD_Index Equal to 1
        • Then - Actions
          • Trigger - Turn on VD Loop <gen>
        • Else - Actions
  • VD Loop
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer VD_LoopInteger) from 1 to VD_Index, do (Actions)
        • Loop - Actions
          • Set VD_Counter[VD_LoopInteger] = (VD_Counter[VD_LoopInteger] + 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • VD_Counter[VD_LoopInteger] Greater than or equal to 5
            • Then - Actions
              • Game - Display to (All players) the text: REMOVE
              • Unit Group - Pick every unit in VD_Group[VD_LoopInteger] and do (Actions)
                • Loop - Actions
                  • Unit - Remove Item Life Steal from (Picked unit)
              • Set VD_Group[VD_LoopInteger] = VD_Group[VD_Index]
              • Set VD_Counter[VD_LoopInteger] = VD_Counter[VD_Index]
              • Set VD_Index = (VD_Index - 1)
              • Set VD_LoopInteger = (VD_LoopInteger - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • VD_Index Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
            • Else - Actions
 
Level 13
Joined
Oct 16, 2010
Messages
691
If I remember correctly of the top of my head...

It's something like this,

call DestroyGroup(udg_VD_Group[udg_VD_LoopInteger])


Also you don't actually reindex the unit group like you do the count. Also a point is that if you have 2 units effected by different instances of the spell the lifesteal will be removed when one finishes but not added back to the unit as they are counted by the second instance. Could pick all units in the group periodically and give the lifesteal ability if they don't have it?

Last thing... you leak a point in the cast trigger, gunna guess that you know how to deal with that!
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
Simple optimization:
"((Picked unit) is A melee attacker) Equal to True"
You only give the ability to melee units, no need to remove them from units that dont have that ability.
So you can do "Unit Group - Remove (Picked unit) from (VD_Group[VD_Index])" in the else actions of that If/Then/Else.
 
Level 12
Joined
May 22, 2015
Messages
1,051
Simple optimization:
"((Picked unit) is A melee attacker) Equal to True"
You only give the ability to melee units, no need to remove them from units that dont have that ability.
So you can do "Unit Group - Remove (Picked unit) from (VD_Group[VD_Index])" in the else actions of that If/Then/Else.

Would it not be better to remove the unit in the else part of the first loop?

Actually, I don't even know if removing units from ForGroup loops is safe lol.
 
Top