Code
function Trig_cast_Timer takes nothing returns nothing
local timer ta = GetExpiredTimer()
local integer i = GetHandleId(ta)
local unit t = LoadUnitHandle(udg_Hash, ta, 1)
local unit u = LoadUnitHandle(udg_Hash, ta, 0)
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Weapons\\Bolt\\BoltImpact.mdl", t, "chest"))
call UnitDamageTarget(u, t, 300., true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
call SetUnitPosition(t,LoadReal(udg_Hash, ta, 2),LoadReal(udg_Hash, ta, 3))
call PauseTimer(ta)
call DestroyTimer(ta)
call FlushChildHashtable(udg_Hash, i)
set t=null
set u=null
set ta=null
endfunction
function Trig_cast_Actions takes nothing returns nothing
local timer ta=CreateTimer()
local integer i=GetHandleId(ta)
if GetSpellAbilityId() == 'A000' then
call SaveUnitHandle(udg_Hash,ta, 0, GetTriggerUnit())
call SaveUnitHandle(udg_Hash,ta, 1, GetSpellTargetUnit())
call SaveReal(udg_Hash, ta, 2, GetWidgetX(GetSpellTargetUnit()))
call SaveReal(udg_Hash,ta, 3, GetWidgetY(GetSpellTargetUnit()))
call TimerStart(ta, 5., false, function Trig_cast_Timer)
set ta = null
endif
endfunction
//===========================================================================
function InitTrig_cast takes nothing returns nothing
local trigger trig=CreateTrigger( )
local integer index=0
loop
call TriggerRegisterPlayerUnitEvent(trig, Player(index), EVENT_PLAYER_UNIT_SPELL_EFFECT , null)
set index = index + 1
exitwhen index == bj_MAX_PLAYER_SLOTS
endloop
call TriggerAddAction( trig, function Trig_cast_Actions )
set trig=null
endfunction