/Tukui/modules/extras/announce.lua
http://github.com/Asphyxia/Tukui · Lua · 270 lines · 218 code · 33 blank · 19 comment · 54 complexity · 35bd8abed8b5fee6bf5805b7ed0e0a3f MD5 · raw file
- local T, C, L = unpack(select(2, ...))
- -----------------------------------------------
- -- announce your interrupts(by Elv22)
- -----------------------------------------------
- if C["interruptanncounce"].enable == true then
- local interrupt_announce = CreateFrame("Frame")
- interrupt_announce:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
- interrupt_announce:SetScript("OnEvent", function(self, _, _, event, _, sourceGUID, _, _, _, _, destName, _, _, _, _, _, spellID, spellName)
- if not (event == "SPELL_INTERRUPT" and sourceGUID == UnitGUID('player')) then return end
- SendChatMessage(INTERRUPTED.." "..destName..": \124cff71d5ff\124Hspell:"..spellID.."\124h["..spellName.."]\124h\124r!", "YELL", nil, nil) -- change "YELL" to whatever channel you like
- end)
- end
- -----------------------------------------------
- -- enemy drinking(by Duffed)
- -----------------------------------------------
- local drinking_announce = CreateFrame("Frame")
- drinking_announce:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
- drinking_announce:SetScript("OnEvent", function(self, event, ...)
- if not (event == "UNIT_SPELLCAST_SUCCEEDED" and GetZonePVPInfo() == "arena") then return end
- local unit, spellName, spellrank, spelline, spellID = ...
- if UnitIsEnemy("player", unit) and (spellID == 80167 or spellID == 94468 or spellID == 43183 or spellID == 57073 or spellName == "Drinking") then
- if GetRealNumRaidMembers() > 0 then
- SendChatMessage(UnitName(unit).." is drinking.", "RAID")
- elseif GetRealNumPartyMembers() > 0 and not UnitInRaid("player") then
- SendChatMessage(UnitName(unit).." is drinking.", "PARTY")
- else
- SendChatMessage(UnitName(unit).." is drinking.", "SAY")
- end
- end
- end)
- -----------------------------------------
- -- fDispelAnnounce made by Foof
- -----------------------------------------
- local fDispelAnnounce = CreateFrame("Frame", fDispelAnnounce)
- local band = bit.band
- local font = C.media.pixelfont -- HOOG0555.ttf
- local fontflag = "OUTLINEMONOCHROME" -- for pixelfont stick to this else OUTLINE or THINOUTLINE
- local fontsize = 18 -- font size
- local COMBATLOG_OBJECT_AFFILIATION_MINE = COMBATLOG_OBJECT_AFFILIATION_MINE
-
- -- Registered events
- local events = {
- ["SPELL_STOLEN"] = {
- ["enabled"] = true,
- ["msg"] = "Removed",
- ["color"] = "69CCF0",
- },
- ["SPELL_DISPEL"] = {
- ["enabled"] = true,
- ["msg"] = "Removed",
- ["color"] = "3BFF33",
- },
- ["SPELL_DISPEL_FAILED"] = {
- ["enabled"] = true,
- ["msg"] = "FAILED",
- ["color"] = "C41F3B",
- },
- ["SPELL_HEAL"] = {
- ["enabled"] = false,
- ["msg"] = "Healed",
- ["color"] = "3BFF33",
- },
- }
-
- -- Frame function
- local function CreateMessageFrame(name)
- local f = CreateFrame("ScrollingMessageFrame", name, UIParent)
- f:SetHeight(80)
- f:SetWidth(500)
- f:SetPoint("CENTER", 0, 150)
- f:SetFrameStrata("HIGH")
- f:SetTimeVisible(1.5)
- f:SetFadeDuration(3)
- f:SetMaxLines(3)
- f:SetFont(font, fontsize, fontflag)
- return f
- end
-
- -- Create messageframe
- local dispelMessages = CreateMessageFrame("fDispelFrame")
-
- local function OnEvent(self, event, timestamp, eventType, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags, ...)
- if(not events[eventType] or not events[eventType].enabled or band(sourceFlags, COMBATLOG_OBJECT_AFFILIATION_MINE) ~= COMBATLOG_OBJECT_AFFILIATION_MINE or sourceGUID ~= UnitGUID("player")) then
- return
- end
- -- Print to partychat
- local numraid = GetNumRaidMembers()
- if (numraid > 0 and numraid < 6) then
- SendChatMessage(events[eventType].msg .. ": " .. select(5, ...), "PARTY")
- end
- -- Add to messageframe
- dispelMessages:AddMessage("|cff" .. events[eventType].color .. events[eventType].msg .. ":|r " .. select(5, ...))
- end
-
- -- finally
- fDispelAnnounce:RegisterEvent('COMBAT_LOG_EVENT_UNFILTERED')
- fDispelAnnounce:SetScript('OnEvent', OnEvent)
- -------------------------------------------------------------------------------------
- -- Credit Alleykat
- -- Entering combat and allertrun function (can be used in anther ways)
- ------------------------------------------------------------------------------------
- local speed = .057799924 -- how fast the text appears
- local font = C.media.pixelfont -- HOOG0555.ttf
- local fontflag = "OUTLINEMONOCHROME" -- for pixelfont stick to this else OUTLINE or THINOUTLINE
- local fontsize = 16 -- font size
-
- local GetNextChar = function(word,num)
- local c = word:byte(num)
- local shift
- if not c then return "",num end
- if (c > 0 and c <= 127) then
- shift = 1
- elseif (c >= 192 and c <= 223) then
- shift = 2
- elseif (c >= 224 and c <= 239) then
- shift = 3
- elseif (c >= 240 and c <= 247) then
- shift = 4
- end
- return word:sub(num,num+shift-1),(num+shift)
- end
-
- local updaterun = CreateFrame("Frame")
-
- local flowingframe = CreateFrame("Frame",nil,UIParent)
- flowingframe:SetFrameStrata("HIGH")
- flowingframe:SetPoint("CENTER",UIParent,0, 170) -- where we want the textframe
- flowingframe:SetHeight(64)
-
- local flowingtext = flowingframe:CreateFontString(nil,"OVERLAY")
- flowingtext:SetFont(font,fontsize, fontflag)
- flowingtext:SetShadowOffset(1,-1)
-
- local rightchar = flowingframe:CreateFontString(nil,"OVERLAY")
- rightchar:SetFont(font,60, fontflag)
- rightchar:SetShadowOffset(1,-1)
- rightchar:SetJustifyH("LEFT") -- left or right
-
- local count,len,step,word,stringE,a,backstep
-
- local nextstep = function()
- a,step = GetNextChar (word,step)
- flowingtext:SetText(stringE)
- stringE = stringE..a
- a = string.upper(a)
- rightchar:SetText(a)
- end
-
- local backrun = CreateFrame("Frame")
- backrun:Hide()
-
- local updatestring = function(self,t)
- count = count - t
- if count < 0 then
- count = speed
- if step > len then
- self:Hide()
- flowingtext:SetText(stringE)
- rightchar:SetText()
- flowingtext:ClearAllPoints()
- flowingtext:SetPoint("RIGHT")
- flowingtext:SetJustifyH("RIGHT")
- rightchar:ClearAllPoints()
- rightchar:SetPoint("RIGHT",flowingtext,"LEFT")
- rightchar:SetJustifyH("RIGHT")
- self:Hide()
- count = 1.456789
- backrun:Show()
- else
- nextstep()
- end
- end
- end
-
- updaterun:SetScript("OnUpdate",updatestring)
- updaterun:Hide()
-
- local backstepf = function()
- local a = backstep
- local firstchar
- local texttemp = ""
- local flagon = true
- while a <= len do
- local u
- u,a = GetNextChar(word,a)
- if flagon == true then
- backstep = a
- flagon = false
- firstchar = u
- else
- texttemp = texttemp..u
- end
- end
- flowingtext:SetText(texttemp)
- firstchar = string.upper(firstchar)
- rightchar:SetText(firstchar)
- end
-
- local rollback = function(self,t)
- count = count - t
- if count < 0 then
- count = speed
- if backstep > len then
- self:Hide()
- flowingtext:SetText()
- rightchar:SetText()
- else
- backstepf()
- end
- end
- end
-
- backrun:SetScript("OnUpdate",rollback)
-
- local allertrun = function(f,r,g,b)
- flowingframe:Hide()
- updaterun:Hide()
- backrun:Hide()
-
- flowingtext:SetText(f)
- local l = flowingtext:GetWidth()
-
- local color1 = r or 1
- local color2 = g or 1
- local color3 = b or 1
-
- flowingtext:SetTextColor(color1*.95,color2*.95,color3*.95) -- color in RGB(red green blue)(alpha)
- rightchar:SetTextColor(color1,color2,color3)
-
- word = f
- len = f:len()
- step,backstep = 1,1
- count = speed
- stringE = ""
- a = ""
-
- flowingtext:SetText("")
- flowingframe:SetWidth(l)
- flowingtext:ClearAllPoints()
- flowingtext:SetPoint("LEFT")
- flowingtext:SetJustifyH("LEFT")
- rightchar:ClearAllPoints()
- rightchar:SetPoint("LEFT",flowingtext,"RIGHT")
- rightchar:SetJustifyH("LEFT")
-
- rightchar:SetText("")
- updaterun:Show()
- flowingframe:Show()
- end
-
- SlashCmdList.ALLEYRUN = function(lol) allertrun(lol) end
- SLASH_ALLEYRUN1 = "/arn" -- /command to test the text
-
- local a = CreateFrame ("Frame")
- a:RegisterEvent("PLAYER_REGEN_ENABLED")
- a:RegisterEvent("PLAYER_REGEN_DISABLED")
- a:SetScript("OnEvent", function (self,event)
- if (UnitIsDead("player")) then return end
- if event == "PLAYER_REGEN_ENABLED" then
- allertrun("LEAVING COMBAT",0.1,1,0.1)
- else
- allertrun("ENTERING COMBAT",1,0.1,0.1)
- end
- end)