local _,ns = ...
ns.ADDUIEVENT("PLAYER_LOGIN", function()
if AddUIDB.stop ==  false  then return end

-------------------------------------
-- 打斷提示 
-------------------------------------
local frame = CreateFrame("Frame", nil, UIParent)
frame:RegisterEvent('COMBAT_LOG_EVENT_UNFILTERED')
frame:SetScript("OnEvent", function(self, event, ...)
    local _, subevent, _, _, sourceName, sourceFlag, _, _, destName, _, destRaidFlags, _, _, _, extraSpellID = CombatLogGetCurrentEventInfo()
    if (subevent ~= 'SPELL_INTERRUPT') then return end
    if (bit.band(sourceFlag, COMBATLOG_OBJECT_AFFILIATION_MINE) == 0) then return end
    if (not sourceName) then return end
	if (destName == UnitName("Player")) then return end
	local iconnumber = (math.log(destRaidFlags) / math.log(2) + 1)
	local icon = tonumber(destRaidFlags)>0 and "{rt"..iconnumber.."}" or ""
    local msg = format("%s>%s<的%s",  "已打断", icon..destName or "", C_Spell.GetSpellLink(extraSpellID))
	SendChatMessage(msg, "EMOTE")
end)
--驱散
local frame2 = CreateFrame("Frame", nil, UIParent)
frame2:RegisterEvent('COMBAT_LOG_EVENT_UNFILTERED')
frame2:SetScript("OnEvent", function(self, event, ...)
    local _, subevent, _, _, sourceName, sourceFlag, RaidFlags, _, destName, _, _, _, _, _, extraSpellID = CombatLogGetCurrentEventInfo()
	if (subevent ~= 'SPELL_DISPEL') then return end
	if sourceName==UnitName("player") or sourceName==UnitName("pet") then
		PlaySoundFile("Interface\\AddOns\\AddUI\\Func\\call\\驱散成功音效.mp3","Master")
	end
end)

local frame3 = CreateFrame("Frame", nil, UIParent)
frame3:RegisterEvent("PLAYER_FOCUS_CHANGED")
frame3:RegisterEvent("RAID_TARGET_UPDATE")
frame3:SetScript("OnEvent", function(self, event, ...)
	if not AddUIDB.sayfocus  then return end
	if not IsInGroup() then return end
	if event == "PLAYER_FOCUS_CHANGED" then
		if UnitIsPlayer("focus") then return end
		self.icon = GetRaidTargetIndex("focus")
		if self.icon then
			SendChatMessage("我断  {rt"..self.icon.."}", "PARTY")
		else
			local name = UnitName("focus")
			if not name then return end
			SendChatMessage("我断  "..name, "PARTY")
		end
	elseif event == "RAID_TARGET_UPDATE" then
		if UnitIsPlayer("focus") then return end
		if self.icon ~= GetRaidTargetIndex("focus") then
			self.icon = GetRaidTargetIndex("focus")
			if GetRaidTargetIndex("focus") then
				SendChatMessage("我断  {rt"..GetRaidTargetIndex("focus").."}", "PARTY")
			end
		end
	end
	
end)

end)