[JASS] Super Quick Question

Status
Not open for further replies.
Level 3
Joined
Dec 22, 2007
Messages
35
Does this leak in any way? I do not want to remove the trigger unit

JASS:
    local unit u = CreateUnit( GetOwningPlayer(GetTriggerUnit()), 'e002', GetWidgetX(GetTriggerUnit()), GetWidgetY(GetTriggerUnit()), GetUnitFacing(GetTriggerUnit()) )               
    call UnitDamageTarget( gg_unit_e002_0029, GetTriggerUnit(), 80.00, true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
    call UnitAddAbility(u, 'A00O')
    call SetUnitAbilityLevel(u, 'A00O', GetUnitAbilityLevel(GetTriggerUnit(), GetSpellAbilityId()) )
    call IssueImmediateOrder(u, "spiritwolf" )
    call PolledWait(10.00) // for some reason removing the unit removes the units it summoned
    call RemoveUnit( u )
    set u = null

Also, I'm aware that ForGroupBj is leaky, what about ForGroup? Thanks!!
 
Level 11
Joined
Feb 22, 2006
Messages
752
It's not leaking anything, though it could be a little more efficient by saving GetTriggerUnit() to a local and then referencing the local instead of calling GetTriggerUnit() a bunch of times.

If the 'e002' unit you are creating is some kind of dummy caster, call UnitApplyTimedLife() to get rid of it.

ForGroupBJ does not leak nor does ForGroup. If you hear people saying ForGroupBJ leaks it's because that is the function that the GUI action "For Every Unit In Group do Actions" calls, and lots of times in GUI whenever you use that action, you create a unitgroup so ForGroupBJ can take that unitgroup as an argument. But it isnt ForGroupBJ that is leaking (because ForGroupBJ in itself does not create a unitgroup every time it is called), it is the creation of a unitgroup and then never destroying it that leaks. In GUI this leak is easily fixable by adding a custom script action "set bj_wantDestroyGroup = true" before any instances of "For Every Unit In Group do Actions" (unless of course you don't want the group to be destroyed).
 
Level 3
Joined
Dec 28, 2007
Messages
46
Whats the difference? A unit with a timed life is considered a summoned unit. Summoned units dont leave corpses. So that would mean its the same thing as removing from game.

and plz dont double post. Just edit your last post.
 
Level 19
Joined
Aug 24, 2007
Messages
2,888
1- Dont use PolledWait for something like this (it will just decrease speed)
2- ForGroup is lame if you ask me :/
3- Beware of using null as boolexpr (Vexorian says it leaks somehow)
 
Level 3
Joined
Dec 22, 2007
Messages
35
Thanks for all the help, but now I have two more questions...

1. When should I use TriggerSleepAction and when should I use PolledWait then? I've heard many different things that often conflict.

2. What's the alternative to ForGroup?

3. Where do I have a boolexpr that I pass null to?
 
Level 19
Joined
Aug 24, 2007
Messages
2,888
1- Well its for accurite. TriggerSleepAction isnt too much accurite (may wait 10.1 instead of 10.0 etc)

2- GroupEnumUnits... Take first unit of group do actions with it, remove it from group loop until first of group is null (group is empty)

3- You dont just warning :p
 
Status
Not open for further replies.
Top