HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Does my script is leakless

04-18-2009, 05:43 PM#1
Magissia
Hi, i suck in JASS, but i want know if my script leak or not


Collapse JASS:
function IcyTouch_Conditions takes nothing returns boolean
    return ( GetSpellAbilityId() == 'A06I' )
endfunction

function IcyTouch_Actions takes nothing returns nothing

 local unit u       =GetTriggerUnit()      
 local unit tar = GetSpellTargetUnit()
 local integer l


    set l = GetUnitAbilityLevel( u,'A06I')
    call CasterCastAbilityLevel( GetOwningPlayer(u), 'A06J', l ,"slow", tar, true)


 set tar=null
 set u=null
endfunction

//===========================================================================
function InitTrig_IcyTouch takes nothing returns nothing
    set gg_trg_IcyTouch = CreateTrigger(  )
    call OnAbilityEffect('A06I', "IcyTouch_Actions")
    call TriggerAddAction( gg_trg_IcyTouch, function IcyTouch_Actions )
endfunction

Thanks =o
04-18-2009, 05:49 PM#2
akolyt0r
doesnt leak, but that local integer l is redundant... just inline that line with GetUnitAbilityLevel(..)
04-18-2009, 05:59 PM#3
Magissia
Don't understand =o

(My english sucks too)
04-18-2009, 06:05 PM#4
busterkomo
He means do this:
Collapse JASS:
call CasterCastAbilityLevel( GetOwningPlayer(u), 'A06J', GetUnitAbilityLevel( u,'A06I') ,"slow", tar, true)
Since it seems like you'll only use that local once. Or better yet:

Collapse JASS:
call CasterCastAbilityLevel( GetOwningPlayer(GetTriggerUnit()), 'A06J', GetUnitAbilityLevel(GetTriggerUnit(),'A06I') ,"slow", GetSpellTargetUnit(), true)
04-18-2009, 06:21 PM#5
Magissia
Okay, thanks
04-18-2009, 07:41 PM#6
0zyx0
If you use OnAbilityEffect, you don't have to create a trigger. It should look like this:

Collapse JASS:
function InitTrig_IcyTouch takes nothing returns nothing
    call OnAbilityEffect('A06I', "IcyTouch_Actions")
endfunction
04-18-2009, 08:43 PM#7
Zerzax
Collapse JASS:
function IcyTouch_Actions takes nothing returns nothing
 local unit u = GetTriggerUnit()  
    
    call CasterCastAbilityLevel( GetOwningPlayer(u), 'A06J', GetUnitAbilityLevel( u,'A06I') ,"slow", GetSpellTargetUnit(), true)

 set u=null
endfunction

Just to clear up the variable inconsistencies. You want "u" because you need to reference the unit multiple times. You don't need tar because GetSpellTargetUnit() is only referenced once.
04-18-2009, 08:46 PM#8
Michael Peppers
Quote:
Originally Posted by Zerzax
You want "u" because you need to reference the unit multiple times.
I'm confused... at this point is the "u" variable really necessary?
It's an instant as far as I've seen

I'd code that like this:
Collapse JASS:
function IcyTouch_Actions takes nothing returns nothing
    call CasterCastAbilityLevel(GetOwningPlayer(GetTriggerUnit()), 'A06J', GetUnitAbilityLevel(GetTriggerUnit(),'A06I'),"slow", GetSpellTargetUnit(), true)
endfunction
No variables, no nulling stuff, an unique line...

Or is it too much simple? :P
04-18-2009, 09:01 PM#9
Zerzax
It's only two references, you're right. But at the same time, it's good practice anyway. Function calls quickly become much slower than variable declaration / nulling (or so I believe).
04-18-2009, 11:30 PM#10
Magissia
Quote:
Originally Posted by 0zyx0
If you use OnAbilityEffect, you don't have to create a trigger. It should look like this:

Collapse JASS:
function InitTrig_IcyTouch takes nothing returns nothing
    call OnAbilityEffect('A06I', "IcyTouch_Actions")
endfunction

Okay, thanks you