| 04-18-2009, 05:43 PM | #1 |
Hi, i suck in JASS, but i want know if my script leak or not 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 |
doesnt leak, but that local integer l is redundant... just inline that line with GetUnitAbilityLevel(..) |
| 04-18-2009, 05:59 PM | #3 |
Don't understand =o (My english sucks too) |
| 04-18-2009, 06:05 PM | #4 |
He means do this: JASS:call CasterCastAbilityLevel( GetOwningPlayer(u), 'A06J', GetUnitAbilityLevel( u,'A06I') ,"slow", tar, true) JASS:call CasterCastAbilityLevel( GetOwningPlayer(GetTriggerUnit()), 'A06J', GetUnitAbilityLevel(GetTriggerUnit(),'A06I') ,"slow", GetSpellTargetUnit(), true) |
| 04-18-2009, 06:21 PM | #5 |
Okay, thanks |
| 04-18-2009, 07:41 PM | #6 |
If you use OnAbilityEffect, you don't have to create a trigger. It should look like this: JASS:function InitTrig_IcyTouch takes nothing returns nothing call OnAbilityEffect('A06I', "IcyTouch_Actions") endfunction |
| 04-18-2009, 08:43 PM | #7 |
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 | |
Quote:
It's an instant as far as I've seen I'd code that like this: JASS:function IcyTouch_Actions takes nothing returns nothing call CasterCastAbilityLevel(GetOwningPlayer(GetTriggerUnit()), 'A06J', GetUnitAbilityLevel(GetTriggerUnit(),'A06I'),"slow", GetSpellTargetUnit(), true) endfunction Or is it too much simple? :P |
| 04-18-2009, 09:01 PM | #9 |
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 | |
Quote:
Okay, thanks you |
