PageRenderTime 19ms CodeModel.GetById 2ms app.highlight 12ms RepoModel.GetById 2ms app.codeStats 0ms

/Tukui/modules/extras/announce.lua

http://github.com/Asphyxia/Tukui
Lua | 270 lines | 218 code | 33 blank | 19 comment | 29 complexity | 35bd8abed8b5fee6bf5805b7ed0e0a3f MD5 | raw file
  1local T, C, L = unpack(select(2, ...)) 
  2-----------------------------------------------
  3--	announce your interrupts(by Elv22) 
  4-----------------------------------------------
  5if C["interruptanncounce"].enable == true then
  6
  7local interrupt_announce = CreateFrame("Frame")
  8interrupt_announce:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
  9interrupt_announce:SetScript("OnEvent", function(self, _, _, event, _, sourceGUID, _, _, _, _, destName, _, _, _, _, _, spellID, spellName)
 10	if not (event == "SPELL_INTERRUPT" and sourceGUID == UnitGUID('player')) then return end
 11
 12    SendChatMessage(INTERRUPTED.." "..destName..": \124cff71d5ff\124Hspell:"..spellID.."\124h["..spellName.."]\124h\124r!", "YELL", nil, nil) -- change "YELL" to whatever channel you like
 13    end)
 14end
 15-----------------------------------------------
 16-- enemy drinking(by Duffed)
 17-----------------------------------------------
 18local drinking_announce = CreateFrame("Frame")
 19drinking_announce:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
 20drinking_announce:SetScript("OnEvent", function(self, event, ...)
 21	if not (event == "UNIT_SPELLCAST_SUCCEEDED" and GetZonePVPInfo() == "arena") then return end
 22
 23	local unit, spellName, spellrank, spelline, spellID = ...
 24	if UnitIsEnemy("player", unit) and (spellID == 80167 or spellID == 94468 or spellID == 43183 or spellID == 57073 or spellName == "Drinking") then
 25		if GetRealNumRaidMembers() > 0 then
 26			SendChatMessage(UnitName(unit).." is drinking.", "RAID")
 27		elseif GetRealNumPartyMembers() > 0 and not UnitInRaid("player") then
 28			SendChatMessage(UnitName(unit).." is drinking.", "PARTY")
 29		else
 30			SendChatMessage(UnitName(unit).." is drinking.", "SAY")
 31		end
 32	end
 33end)
 34
 35-----------------------------------------
 36-- fDispelAnnounce made by Foof
 37-----------------------------------------
 38
 39local fDispelAnnounce = CreateFrame("Frame", fDispelAnnounce)
 40local band = bit.band
 41local font = C.media.pixelfont -- HOOG0555.ttf 
 42local fontflag = "OUTLINEMONOCHROME" -- for pixelfont stick to this else OUTLINE or THINOUTLINE
 43local fontsize = 18 -- font size
 44local COMBATLOG_OBJECT_AFFILIATION_MINE = COMBATLOG_OBJECT_AFFILIATION_MINE
 45 
 46-- Registered events
 47local events = {
 48	["SPELL_STOLEN"] = {
 49		["enabled"] = true,
 50		["msg"] = "Removed",
 51		["color"] = "69CCF0",
 52	},
 53	["SPELL_DISPEL"] = {
 54		["enabled"] = true,
 55		["msg"] = "Removed",
 56		["color"] = "3BFF33",
 57	},
 58	["SPELL_DISPEL_FAILED"] = {
 59		["enabled"] = true,
 60		["msg"] = "FAILED",
 61		["color"] = "C41F3B",
 62	},
 63	["SPELL_HEAL"] = {
 64		["enabled"] = false,
 65		["msg"] = "Healed",
 66		["color"] = "3BFF33",
 67	},
 68}
 69 
 70-- Frame function
 71local function CreateMessageFrame(name)
 72	local f = CreateFrame("ScrollingMessageFrame", name, UIParent)
 73	f:SetHeight(80)
 74	f:SetWidth(500)
 75	f:SetPoint("CENTER", 0, 150)
 76	f:SetFrameStrata("HIGH")
 77	f:SetTimeVisible(1.5)
 78	f:SetFadeDuration(3)
 79	f:SetMaxLines(3)
 80	f:SetFont(font, fontsize, fontflag)
 81	return f
 82end
 83 
 84-- Create messageframe
 85local dispelMessages = CreateMessageFrame("fDispelFrame")
 86 
 87local function OnEvent(self, event, timestamp, eventType, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags, ...)
 88	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
 89		return
 90	end
 91	-- Print to partychat
 92	local numraid = GetNumRaidMembers()
 93	if (numraid > 0 and numraid < 6) then
 94		SendChatMessage(events[eventType].msg .. ": " .. select(5, ...), "PARTY")
 95	end
 96	-- Add to messageframe
 97	dispelMessages:AddMessage("|cff" .. events[eventType].color .. events[eventType].msg .. ":|r " .. select(5, ...))
 98end
 99 
100-- finally
101fDispelAnnounce:RegisterEvent('COMBAT_LOG_EVENT_UNFILTERED')
102fDispelAnnounce:SetScript('OnEvent', OnEvent)
103
104-------------------------------------------------------------------------------------
105-- Credit Alleykat 
106-- Entering combat and allertrun function (can be used in anther ways)
107------------------------------------------------------------------------------------
108local speed = .057799924 -- how fast the text appears
109local font = C.media.pixelfont -- HOOG0555.ttf 
110local fontflag = "OUTLINEMONOCHROME" -- for pixelfont stick to this else OUTLINE or THINOUTLINE
111local fontsize = 16 -- font size
112 
113local GetNextChar = function(word,num)
114	local c = word:byte(num)
115	local shift
116	if not c then return "",num end
117		if (c > 0 and c <= 127) then
118			shift = 1
119		elseif (c >= 192 and c <= 223) then
120			shift = 2
121		elseif (c >= 224 and c <= 239) then
122			shift = 3
123		elseif (c >= 240 and c <= 247) then
124			shift = 4
125		end
126	return word:sub(num,num+shift-1),(num+shift)
127end
128 
129local updaterun = CreateFrame("Frame")
130 
131local flowingframe = CreateFrame("Frame",nil,UIParent)
132	flowingframe:SetFrameStrata("HIGH")
133	flowingframe:SetPoint("CENTER",UIParent,0, 170) -- where we want the textframe
134	flowingframe:SetHeight(64)
135 
136local flowingtext = flowingframe:CreateFontString(nil,"OVERLAY")
137	flowingtext:SetFont(font,fontsize, fontflag)
138	flowingtext:SetShadowOffset(1,-1)
139 
140local rightchar = flowingframe:CreateFontString(nil,"OVERLAY")
141	rightchar:SetFont(font,60, fontflag)
142	rightchar:SetShadowOffset(1,-1)
143	rightchar:SetJustifyH("LEFT") -- left or right
144 
145local count,len,step,word,stringE,a,backstep
146 
147local nextstep = function()
148	a,step = GetNextChar (word,step)
149	flowingtext:SetText(stringE)
150	stringE = stringE..a
151	a = string.upper(a)
152	rightchar:SetText(a)
153end
154 
155local backrun = CreateFrame("Frame")
156backrun:Hide()
157 
158local updatestring = function(self,t)
159	count = count - t
160		if count < 0 then
161			count = speed
162			if step > len then
163				self:Hide()
164				flowingtext:SetText(stringE)
165				rightchar:SetText()
166				flowingtext:ClearAllPoints()
167				flowingtext:SetPoint("RIGHT")
168				flowingtext:SetJustifyH("RIGHT")
169				rightchar:ClearAllPoints()
170				rightchar:SetPoint("RIGHT",flowingtext,"LEFT")
171				rightchar:SetJustifyH("RIGHT")
172				self:Hide()
173				count = 1.456789
174				backrun:Show()
175			else
176				nextstep()
177			end
178		end
179end
180 
181updaterun:SetScript("OnUpdate",updatestring)
182updaterun:Hide()
183 
184local backstepf = function()
185	local a = backstep
186	local firstchar
187		local texttemp = ""
188		local flagon = true
189		while a <= len do
190			local u
191			u,a = GetNextChar(word,a)
192			if flagon == true then
193				backstep = a
194				flagon = false
195				firstchar = u
196			else
197				texttemp = texttemp..u
198			end
199		end
200	flowingtext:SetText(texttemp)
201	firstchar = string.upper(firstchar)
202	rightchar:SetText(firstchar)
203end
204 
205local rollback = function(self,t)
206	count = count - t
207		if count < 0 then
208			count = speed
209			if backstep > len then
210				self:Hide()
211				flowingtext:SetText()
212				rightchar:SetText()
213			else
214				backstepf()
215			end
216		end
217end
218 
219backrun:SetScript("OnUpdate",rollback)
220 
221local allertrun = function(f,r,g,b)
222	flowingframe:Hide()
223	updaterun:Hide()
224	backrun:Hide()
225 
226	flowingtext:SetText(f)
227	local l = flowingtext:GetWidth()
228 
229	local color1 = r or 1
230	local color2 = g or 1
231	local color3 = b or 1
232 
233	flowingtext:SetTextColor(color1*.95,color2*.95,color3*.95) -- color in RGB(red green blue)(alpha)
234	rightchar:SetTextColor(color1,color2,color3)
235 
236	word = f
237	len = f:len()
238	step,backstep = 1,1
239	count = speed
240	stringE = ""
241	a = ""
242 
243	flowingtext:SetText("")
244	flowingframe:SetWidth(l)
245	flowingtext:ClearAllPoints()
246	flowingtext:SetPoint("LEFT")
247	flowingtext:SetJustifyH("LEFT")
248	rightchar:ClearAllPoints()
249	rightchar:SetPoint("LEFT",flowingtext,"RIGHT")
250	rightchar:SetJustifyH("LEFT")
251 
252	rightchar:SetText("")
253	updaterun:Show()
254	flowingframe:Show()
255end
256 
257SlashCmdList.ALLEYRUN = function(lol) allertrun(lol) end
258SLASH_ALLEYRUN1 = "/arn" -- /command to test the text
259 
260local a = CreateFrame ("Frame")
261	a:RegisterEvent("PLAYER_REGEN_ENABLED")
262	a:RegisterEvent("PLAYER_REGEN_DISABLED")
263	a:SetScript("OnEvent", function (self,event)
264		if (UnitIsDead("player")) then return end
265		if event == "PLAYER_REGEN_ENABLED" then
266			allertrun("LEAVING COMBAT",0.1,1,0.1)
267		else
268			allertrun("ENTERING COMBAT",1,0.1,0.1)
269		end
270	end)