--TSU
--COMBAT_LOG_EVENT_UNFILTERED
function(allstates, e, ...)
    for k, v in pairs(allstates) do
        v.show = false
        v.changed = true
    end
    local se = select(2, ...)
    local pname = UnitName("player")
    if se == "SPELL_AURA_APPLIED" or se == "SPELL_AURA_APPLIED_DOSE" then
        local caster, target, aura = select(5, ...), select(9, ...), select(13, ...)
        --print(caster, target, aura, pname)
        if caster == pname and target == pname and aura == "Fingers of Frost" then
            aura_env.stacks = aura_env.stacks + 1
            --print("1", aura_env.stacks)
        end
    elseif (se == "SPELL_AURA_REMOVED" or se == "SPELL_AURA_REMOVED_DOSE") and GetTime() - aura_env.cast > 2 then
        local caster, target, aura = select(5, ...), select(9, ...), select(13, ...)
        --print(caster, target, aura)
        if caster == pname and target == pname and aura == "Fingers of Frost" then
            aura_env.stacks = aura_env.stacks - 1
            --print("2", aura_env.stacks)
        end
    elseif se == "SPELL_CAST_SUCCESS" then
        local caster, spell = select(5, ...), select(13, ...)
        if caster == pname and spell == "Ice Lance" and aura_env.stacks > 0 then
            aura_env.stacks = aura_env.stacks - 1
            aura_env.cast = GetTime()
            --print("3", aura_env.stacks)
        end
    end
    for i = 1, aura_env.stacks do
        allstates[i] = {
            show = true,
            changed = true,
        }
    end
    --DevTools_Dump(allstates)
    return true
end

--INIT
aura_env.stacks = 0
aura_env.cast = 0
