| 12-09-2006, 07:54 AM | #2 |
First of all, doing what you do is extremely leaky. Each time you set the variables you are disbanding a group without destroying or clearing it, and this happens every 0.50 seconds. 3 leaks every 0.50 seconds can add up. To answer your question more specifically, it will set this variable to a completely new group with only the newly designated units in it. To answer your other question, it depends what you want to do. Setting unit life actually subtracts an exact amount from the unit's HP (if thats how you are using it), whereas damage-unit uses resistances and things to get its damage across. In terms of speed, setting the unit's life I believe is quicker, but less effective. For what you are doing, I would use damage-unit. Also, here is a way to fix your memory leaks: JASS:function Trig_Add_Actions takes nothing returns nothing local group temp = CreateGroup() local rect map = bj_mapInitialPlayableArea local unit u call GroupEnumUnitsInRect( temp, map, null ) // if you want the group to reset itself each time, use this code, otherwise delete it. call GroupClear( udg_Festering_Presence_Group[1] ) call GroupClear( udg_Festering_Presence_Group[2] ) call GroupClear( udg_Festering_Presence_Group[3] ) // if it is impossible that one unit has both buffs, use this code. loop set u = FirstOfGroup( temp ) exitwhen ( u == null ) if ( GetUnitAbilityLevel( u, <buff raw code lvl1> ) > 0 ) then call GroupAddUnit( udg_Festering_Presence_Group[1], u ) elseif ( GetUnitAbilityLevel( u, <buff raw code lvl2> ) > 0 ) then call GroupAddUnit( udg_Festering_Presence_Group[2], u ) elseif ( GetUnitAbilityLevel( u, <buff raw code lvl3> ) > 0 ) then call GroupAddUnit( udg_Festering_Presence_Group[3], u ) endif call GroupRemoveUnit( temp, u ) endloop // if it is possible that one unit has both buffs, use this code. loop set u = FirstOfGroup( temp ) exitwhen ( u == null ) if ( GetUnitAbilityLevel( u, <buff raw code lvl1> ) > 0 ) then call GroupAddUnit( udg_Festering_Presence_Group[1], u ) endif if ( GetUnitAbilityLevel( u, <buff raw code lvl2> ) > 0 ) then call GroupAddUnit( udg_Festering_Presence_Group[2], u ) endif if ( GetUnitAbilityLevel( u, <buff raw code lvl3> ) > 0 ) then call GroupAddUnit( udg_Festering_Presence_Group[3], u ) endif call GroupRemoveUnit( temp, u ) endloop call DestroyGroup( temp ) set temp = null set map = null endfunction function InitTrig_Add takes nothing returns nothing set gg_trg_Add = CreateTrigger() call TriggerRegisterTimeEvent( gg_trg_Add, 0.50, true ) call TriggerAddActions( gg_trg_Add, function Trig_Add_Actions ) endfunction This is all done off the top of my head, so if anybody else notices anything wrong please say so. <buff raw code lvlX> is the raw code of he desired buff. Simply go to where the buff is located, and press ctrl+D and it will convert everything to raw code. You should see a number such as: 'B000' if it a custom buff. Simply replace (including the ' marks) <buff raw code lvlX> with that buffcode. |
| 12-09-2006, 07:19 PM | #4 |
Yea, that should fix it, just put a GroupClear before you destroy the group incase that makes any difference at all. |
| 12-09-2006, 08:29 PM | #5 |
Does clearing it before it's destroyed really matter? If so, I've been leaking horrendously... |
| 12-09-2006, 08:33 PM | #6 |
I don't think it matters. I've never done it that way and my maps have been fine. |
| 12-09-2006, 10:34 PM | #7 |
I have no recollection of anyone ever suggesting that groups should be cleared before being destroyed. The code should be fine as it is. Just understand this: you are not adding units to your existing unit group, that function creates a new unit group every time. You might know that now but you originaly said that you were adding units and nobody has yet replied to correct you on that specificaly. |
| 12-09-2006, 11:11 PM | #8 |
Oh, thanks for clarifying. |
