I want to give a hero bonus speed and agility for some time via triggers. However after some time my variables turn null for no apparent reason, which makes me unable to subtract them back.
p.s. is there a way to add and subtract green stats with triggers or I have to use passive item abilities for this purpose?
p.p.s. does this leak?
Lua:
function spell()
local trig = CreateTrigger()
TriggerRegisterAnyUnitEventBJ(trig, EVENT_PLAYER_UNIT_SPELL_EFFECT)
TriggerAddAction(trig, function()
if GetSpellAbilityId() ~= FourCC('A000') then return end
local u = GetTriggerUnit()
SetUnitAnimation(u, 'death')
PauseUnit(u, true)
local tix = 0
TimerStart(CreateTimer(), 0.1, true, function ( )
if tix == 35 then
PauseUnit(u, false)
print('start')
SetUnitVertexColor(u, 50, 20, 20, 100)
SetUnitAnimation(u, 'stand ready')
local sp = 522 - BlzGetUnitRealField(u, UNIT_RF_SPEED)
BlzSetUnitRealField(u, UNIT_RF_SPEED, sp + BlzGetUnitRealField(u, UNIT_RF_SPEED))
print(sp)
local ag = BlzGetUnitIntegerField(u, UNIT_IF_AGILITY)
BlzSetUnitIntegerField(u, UNIT_IF_AGILITY, ag + 15)
print(ag)
elseif tix == 60 then
SetUnitVertexColor(u, 255, 255, 255, 255)
print(sp)
--BlzSetUnitRealField(u, UNIT_RF_SPEED, BlzGetUnitRealField(u, UNIT_RF_SPEED)-sp)
print(ag)
--BlzSetUnitIntegerField(u, UNIT_IF_AGILITY, ag)
PauseTimer(GetExpiredTimer())
DestroyTimer(GetExpiredTimer())
print('end')
end
tix = tix + 1
end)
end)
end
p.s. is there a way to add and subtract green stats with triggers or I have to use passive item abilities for this purpose?
p.p.s. does this leak?