Warcraft III resources & community, 2003–2006 · archived

StunUnit

not rated
Submitted by KaTTaNaFunctions0 downloads
Simulates the given unit getting stunned. Works on magic-immune units.

Source

function StunUnit_Child takes nothing returns nothing
    local unit target = bj_makeUnitRescuableUnit
    local effect fx   = AddSpecialEffectTarget("Abilities\\Spells\\Human\\Thunderclap\\ThunderclapTarget.mdl", target, "overhead")
    call PauseUnitBJ( true,  target )
    call PolledWait(bj_enumDestructableRadius)
    call PauseUnitBJ( false, target ) 
    call DestroyEffect(fx)
    call DestroyTrigger( GetTriggeringTrigger() )
endfunction

function StunUnit takes unit target, real duration returns nothing
    local trigger trg = CreateTrigger()
    call TriggerAddAction(trg, function StunUnit_Child)
    set bj_enumDestructableRadius = duration
    set bj_makeUnitRescuableUnit  = target
    call TriggerExecute(trg)
endfunction

Comments

1
Memory Leaks!!
(trigger trg) = memory leak
(unit target) = memory leak
(effect fx) = memory leak
You should probably do a DestroyTrigger(trg) as well as set trg = null