I'm having problems with this trigger, specifically when I use it there is a 1-2 second lag spike where my CPU usage spikes as well. As a note, A01Y is a dummy ability based off of channel, A01Z is a spellbook that holds A020, a negative armor gain based off of spiked carapace. (The premises behind the spell being a DoT that applies a stacking armor debuff each tick)
JASS:
function Trig_expose_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A01Y'
endfunction
function Trig_expose_Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local unit t = GetSpellTargetUnit()
local real damage = I2R(GetHeroAgi(u,true))*.5
local integer dura = GetUnitAbilityLevel(u, 'A01Y')+5
local integer i = 1
call UnitAddAbility(t,'A01Z')
call SetUnitAbilityLevel(t,'A020',1)
call SetPlayerAbilityAvailable(GetOwningPlayer(t), 'A01Z', false)
call PolledWait2(0.25)
loop
exitwhen i > dura
call UnitDamageTarget2(u, t, damage, false)
call SetUnitAbilityLevel(t,'A020', i)
call PolledWait2(2.0)
set i = i + 1
endloop
call SetUnitAbilityLevel(t,'A020',0)
call UnitRemoveAbility(t,'A01Z')
set u = null
set t = null
endfunction
//===========================================================================
function InitTrig_expose takes nothing returns nothing
set gg_trg_expose = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_expose, EVENT_PLAYER_UNIT_SPELL_FINISH )
call TriggerAddCondition( gg_trg_expose, Condition( function Trig_expose_Conditions ) )
call TriggerAddAction( gg_trg_expose, function Trig_expose_Actions )
endfunction