Add 1s timer to remove buffs

This commit is contained in:
2024-12-22 14:11:25 +01:00
parent fab50babc6
commit b1dd53d6d9
2 changed files with 24 additions and 1 deletions

View File

@@ -1,6 +1,10 @@
local addonname, shared = ...
---@cast addonname string
---@class shared
---@field timer number?
shared = { timer = nil }
---@class DechickenatorData
---@field blacklistedBuffs table<string, boolean>
@@ -8,6 +12,25 @@ if not Dechickenator_Data then Dechickenator_Data = {} end
if not Dechickenator_Data.blacklistedBuffs then Dechickenator_Data.blacklistedBuffs = {} end
if not Dechickenator_Data.message then Dechickenator_Data.message = "Индивидуум %s хочет поделиться своим истинным обликом" end
local function init()
local function RemoveBuff(buff)
if UnitAffectingCombat("player") then return end
CancelUnitBuff("player", buff)
end
local function RemoveBuffs()
if UnitAffectingCombat("player") then return end
for buff, enabled in pairs(Dechickenator_Data.blacklistedBuffs) do
if enabled then
RemoveBuff(buff)
end
end
end
if not shared.timer then
shared.timer = C_Timer.NewTicker(1, function()
RemoveBuffs()
end)
end
local cleuFrame = CreateFrame("Frame")
cleuFrame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
cleuFrame:SetScript("OnEvent", function(self, event, ...)
@@ -19,7 +42,7 @@ local function init()
if not Dechickenator_Data.blacklistedBuffs[spellName] then return end
local source = CLEUParser.GetSourceName(...)
local msg = string.format(Dechickenator_Data.message, tostring(source))
CancelUnitBuff("player", spellName)
RemoveBuff(spellName)
SendChatMessage(msg, "EMOTE")
DoEmote("spit", source)
end

Binary file not shown.