/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

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