local function ExecuteAlert(eventCode, addonName) ---load this code after default UI is initialized if (addonName):find("^ZO_") then return end EVENT_MANAGER:UnregisterForEvent("Execute_Alert", EVENT_ADD_ON_LOADED) local alertsTable = setmetatable({}, {__index = function() return 0 end}) ZO_CenterScreenAnnounce_SetEventPriority(EVENT_POWER_UPDATE) local function OnPowerUpdate(eventCode, unitTag, _, powerType, powerValue, powerMax) if unitTag == "reticleover" and powerType == POWERTYPE_HEALTH and IsUnitAttackable("reticleover") and GetUnitReaction("reticleover") ~= UNIT_REACTION_NEUTRAL and not IsUnitDead('reticleover') then local unitName = GetUnitName("reticleover") --if target has 20% or less health if (powerValue / powerMax) <= 0.2 then local now = GetFrameTimeSeconds() local alertTime = alertsTable[unitName] --do not show alert for the target with the same name more than every 5 seconds if now - alertTime > 5 then CENTER_SCREEN_ANNOUNCE:AddMessage(eventCode, CSA_EVENT_SMALL_TEXT, SOUNDS.MESSAGE_BROADCAST, ZO_ERROR_COLOR:Colorize("Execute!")) alertsTable[unitName] = now end else alertsTable[unitName] = nil end end end EVENT_MANAGER:RegisterForEvent("Execute_Alert", EVENT_POWER_UPDATE, OnPowerUpdate) end EVENT_MANAGER:RegisterForEvent("Execute_Alert", EVENT_ADD_ON_LOADED, ExecuteAlert)