StunUnit( unit u, real time, boolean show)
by Zacharias
by Zacharias
Include this code in your map and you can stun any unit for a specific time (unit is paused). It´s also possible to display the stun effect (e.g. as in thunderclab) by the parameter show.
Use this function to start stun on an unit, everything else will be done automatically:
name | StunUnit | |
return type | void | |
parameter | ||
type | name | comment |
unit | u | target unit |
real | time | duration |
boolean | show | show stun effect |
Have fun and give credits
JASS:
globals
integer stunCount=0
unit array stunUnits
real array stunTime
effect array stunEffect
timer stunTimer = CreateTimer()
endglobals
function exeStunTimer takes nothing returns nothing
local integer i = 0
local integer count = 0
loop
exitwhen count>=stunCount
if stunUnits[i]!=null then
if stunTime[i]<=0 then
// destroy effect
if stunEffect[i] != null then
call DestroyEffect(stunEffect[i])
set stunEffect[i] = null
endif
//wake up
call PauseUnit(stunUnits[i],false)
set stunUnits[i]=null
set stunCount=stunCount-1
else
set stunTime[i] = stunTime[i]-0.1
set count=count+1
endif
endif
set i=i+1
endloop
if stunCount== 0 then
call PauseTimer(stunTimer)
endif
endfunction
function StunUnit takes unit u, real time, boolean show returns nothing
local integer i=0
local boolean start = false
//call Print("stun "+GetUnitName(u))
loop
exitwhen stunUnits[i]==null
set i=i+1
endloop
call PauseUnit(u, true)
set stunCount=stunCount+1
set stunUnits[i] = u
set stunTime[i] = time
if show then
set stunEffect[i] = AddSpecialEffectTarget("Abilities\\Spells\\Human\\Thunderclap\\ThunderclapTarget.mdl",u,"overhead")
else
set stunEffect[i] = null
endif
if stunCount==1 then
call TimerStart(stunTimer,0.1,true, function exeStunTimer)
endif
endfunction
Last edited: