LUA - Detecting if target is frozen.

Post by Stigoz

I'm currently putting together a new UI, but I'm worthless at code and because of that, have come to a small obstacle.

In my Stuf target unit frame, I would like to have a custom LUA text that detects if a target is frozen and returns "Frozen" if it is and nothing if it isn't. If possible, a timer with it would be wonderful so it would display as (example): "Frozen 12,3".

I don't know if this is simple or not, but any advice would be wonderful.

Thank you.

Post by Neffi

There is no one-off way to detect this on other units right now. I tried when I was developing a CC alert like the one added to the default UI. Your only option is tracking individual spells. You can do this in one of two ways.

Store a table of known spells. Eg:

local freeze_effects = { = true,}

You either need to listen to UNIT_AURA or COMBAT_LOG_EVENT_UNFILTERED.

If you listen to UNIT_AURA, you need to compare argument1 to the unit in quest, and then iterate over the table to look for effects present:

local function UNIT_AURA(unit) if unit ~= 'target' then return end for spell in pairs(freeze_effects) do local _,_,_ = UnitAura(target,'HARMFUL',spell) end

Check the returns to see if the debuff exists (first arg will be non-nil) and then check the other returns to obtain the duration. Track it as you please.

The other way is listening to the combat log. I can give you an example from my own code that you can adapt. See the procs section: http://code.google.com/p/neffi-wow/source/browse/trunk/nfCombatText/regions/alerts.lua#85 . It looks for a specific sub-event (aura application), checks that the unit is the unit I care about (player) by comparing GUID, and then checks if the spell being applied is one of the spells I care about (within the table).

Edit: The line might be confusing:

if not player(dest) then return end

That's a utility function which is essentially just doing:

if dest ~= UnitGUID('player') then return end

Post by Stigoz

Thanks alot, man!

I'll tinker around with it and see if I can make it work.

Mad propz.

Post Reply

You are not logged in. Please log in to post a reply or register if you don't already have an account.