Files
wow-weakauras/FreshShit/StinkyDetector/event3.lua
2024-10-14 16:17:49 +02:00

86 lines
2.2 KiB
Lua

-- CHAT_MSG_ADDON TICKER_1000
---@param allstates allstates
---@param e string
---@param prefix string
---@param msg string
function(allstates, e, prefix, msg, ...)
if e == "TICKER_1000" then
local ttl = aura_env.config.ttl or 120
for _, state in pairs(allstates) do
if state.progress then
local elapsedTime = GetTime() - state.index
if elapsedTime > ttl then
state.show = false
state.changed = true
else
local prettyTime = ""
local minutes = 0
while elapsedTime > 60 do
elapsedTime = elapsedTime - 60
minutes = minutes + 1
end
if minutes > 0 then
prettyTime = string.format("%s%dm", prettyTime, minutes)
end
if elapsedTime > 0 then
prettyTime = string.format("%s %ds", prettyTime, elapsedTime)
end
state.progress = string.format("%20s", prettyTime)
state.changed = true
end
end
end
for i = 1, 40 do
if UnitIsPlayer("nameplate" .. i) then
local name = UnitName("nameplate" .. i)
local faction = UnitFactionGroup("nameplate" .. i)
local _, race = UnitRace("nameplate" .. i)
local raceFaction = aura_env.raceFactions[race]
if not raceFaction then
print("Unknown race faction", race)
else
faction = raceFaction
end
WeakAurasSaved.Cyka.PlayerFactionCache[name] = faction
end
end
return true
end
if not prefix or prefix ~= aura_env.addonprefix then return end
local name, threat, note = string.split(aura_env.separator, msg)
threat = tonumber(threat)
if not name then
if aura_env.config.debug then
print("Could not get name for " .. msg)
end
return
end
if threat < aura_env.config.threatThreshold then
if aura_env.config.debug then
print(string.format("Skipping notify due to low threat (%d < %d)", threat, aura_env.config.threatThreshold))
end
return
end
allstates[name] = {
show = true,
changed = true,
name = string.format("%-30s", name),
progressType = "timed",
duration = 60,
expirationTime = GetTime() + 60,
autohide = true,
index = GetTime(),
progress = string.format("%20s", "0s"),
}
PlaySoundFile("Interface\\Sounds\\Domination.ogg", "Master")
return true
end