Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.37 KB | None | 0 0
  1. function(allstates, event, unit, ...)
  2. if event == "RAID_TARGET_UPDATE" and aura_env.config["enableIcon"] then
  3. for i = 1,40 do
  4. local u = "nameplate"..i
  5. if UnitExists(u) then
  6. local guid = UnitGUID(u)
  7. if guid and not allstates[guid] and aura_env.config.npcID == select(6,strsplit("-", guid)) then
  8. if aura_env.config["specifiedIcon"][GetRaidTargetIndex(u)] then
  9. allstates[guid] = {
  10. show = true,
  11. changed = true,
  12. name = aura_env.counter[guid] or 1,
  13. PassUnit = u,
  14. }
  15. --sound only fired if nameplate is visible the moment that icon is applied, only relevant for VERY first interrupt.
  16. if aura_env.config.enableSound and allstates[guid].name == aura_env.config["enableSpecified"] then
  17. PlaySoundFile(aura_env.sound[aura_env.config["specifiedSound"]], "MASTER")
  18. end
  19. end
  20. end
  21. end
  22. end
  23. end
  24. if event == "COMBAT_LOG_EVENT_UNFILTERED" then
  25. local subEvent, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags, spellID, spellName, spellschool, extraspellID, extraspellName = ...
  26. if subEvent == "SPELL_CAST_SUCCESS" and aura_env.config.spellID == spellID then
  27. local state = allstates[sourceGUID]
  28. --cancels text aura if counter matches your specified value
  29. if aura_env.config["showText"] and aura_env.caststart[sourceGUID] and aura_env.caststart[sourceGUID] == aura_env.config["enableSpecified"] then
  30. WeakAuras.ScanEvents("HIDE_TEXTAURA", "nilcheck")
  31. end
  32. --count & print failed interrupts in chat (if option is actived)
  33. if aura_env.counter[sourceGUID] then
  34. aura_env.counter[sourceGUID] = aura_env.counter[sourceGUID] + 1
  35. if aura_env.config.printfails and sourceRaidFlags and sourceRaidFlags > 0 then
  36. print((aura_env.counter[sourceGUID]-1)..". interrupt failed on "..aura_env.sendemote[sourceRaidFlags])
  37. end
  38. else aura_env.counter[sourceGUID] = 2
  39. if aura_env.config.printfails and sourceRaidFlags and sourceRaidFlags > 0 then
  40. print((aura_env.counter[sourceGUID]-1)..". interrupt failed on "..aura_env.sendemote[sourceRaidFlags])
  41. end
  42. end
  43. --update state
  44. if state then
  45. state.changed = true
  46. state.name = aura_env.counter[sourceGUID]
  47. end
  48. --check if current count == limit and reset to 1 & update TSU
  49. if aura_env.counter[sourceGUID] == (aura_env.config["limit"]+1) and aura_env.config["limit"] > 0 then
  50. aura_env.counter[sourceGUID] = 1
  51. if state then
  52. state.changed = true
  53. state.name = aura_env.counter[sourceGUID]
  54. end
  55. end
  56. --fire sound if it matches your specified value
  57. if aura_env.config["enableSound"] and aura_env.counter[sourceGUID] then
  58. if aura_env.counter[sourceGUID] == aura_env.config["enableSpecified"] then
  59. PlaySoundFile(aura_env.sound[aura_env.config["specifiedSound"]], "MASTER")
  60. end
  61. end
  62. end
  63. if subEvent == "SPELL_INTERRUPT" and aura_env.config.spellID == extraspellID then
  64. local state = allstates[destGUID]
  65. --cancels text aura if counter matches your specified value
  66. if aura_env.config["showText"] and aura_env.caststart[destGUID] and aura_env.caststart[destGUID] == aura_env.config["enableSpecified"] then
  67. WeakAuras.ScanEvents("HIDE_TEXTAURA", "nilcheck")
  68.  
  69. end
  70. --increase count
  71. if aura_env.counter[destGUID] then
  72. aura_env.counter[destGUID] = aura_env.counter[destGUID] + 1
  73. else aura_env.counter[destGUID] = 2
  74. end
  75. --update state with new count
  76. if state then
  77. state.changed = true
  78. state.name = aura_env.counter[destGUID]
  79. end
  80. --check if current count == limit and reset to 1 & update TSU
  81. if aura_env.counter[destGUID] == (aura_env.config["limit"]+1) and aura_env.config["limit"] > 0 then
  82. aura_env.counter[destGUID] = 1
  83. if state then
  84. state.changed = true
  85. state.name = aura_env.counter[destGUID]
  86. end
  87. end
  88. -- fire sound if it matches your specified value
  89. if aura_env.config["enableSound"] and aura_env.counter[destGUID] then
  90. if aura_env.counter[destGUID] == aura_env.config["enableSpecified"] then
  91. PlaySoundFile(aura_env.sound[aura_env.config["specifiedSound"]], "MASTER")
  92. end
  93. end
  94. end
  95. if subEvent == "SPELL_CAST_START" and aura_env.config.spellID == spellID then
  96. if (aura_env.config.specifiedIcon
  97. and aura_env.config.enableIcon
  98. and sourceRaidFlags
  99. and (aura_env.config.specifiedIcon[aura_env.translate[sourceRaidFlags]]
  100. or sourceRaidFlags == 0 and not aura_env.caststart[sourceGUID]))
  101. or not aura_env.config.enableIcon then
  102. if aura_env.caststart[sourceGUID] then
  103. aura_env.caststart[sourceGUID] = aura_env.caststart[sourceGUID] + 1
  104. else
  105. aura_env.caststart[sourceGUID] = 1
  106. end
  107.  
  108. --reset cast start counter if counter = limit
  109. if aura_env.caststart[sourceGUID] == (aura_env.config["limit"]+1) and aura_env.config["limit"] > 0 then
  110. aura_env.caststart[sourceGUID] = 1
  111. end
  112. --fire cast start sound if it matches your specified value + raidicon
  113. if aura_env.config["enableCastSound"] and aura_env.caststart[sourceGUID] then
  114. if (aura_env.caststart[sourceGUID] == aura_env.config["enableSpecified"]) then
  115. PlaySoundFile(aura_env.castsound[aura_env.config["specifiedCastSound"]], "MASTER")
  116. end
  117. end
  118. --starts text aura if it matches your specified value
  119. if aura_env.config["showText"] and aura_env.caststart[sourceGUID] and aura_env.caststart[sourceGUID] == aura_env.config["enableSpecified"] then
  120. WeakAuras.ScanEvents("SHOW_TEXTAURA", "nilcheck")
  121. end
  122. end
  123. end
  124. --hide anchor-to-nameplate when npc dies
  125. if subEvent == "UNIT_DIED" then
  126. local state = allstates[destGUID]
  127. if state then
  128. state.show = false
  129. state.changed = true
  130. end
  131. end
  132. end
  133. if event == "NAME_PLATE_UNIT_ADDED" then
  134. if unit then
  135. local guid = UnitGUID(unit)
  136. if guid then
  137. local state = allstates[guid]
  138. --update state with current count when nameplate shows
  139. if state then
  140. state.changed = true
  141. state.PassUnit = unit
  142. state.name = aura_env.counter[guid] or 1
  143. end
  144. --create state when nameplate shows
  145. if not state and aura_env.config.npcID == select(6,strsplit("-", guid)) then
  146. if aura_env.config["enableIcon"] and aura_env.config["specifiedIcon"][GetRaidTargetIndex(unit)] or not aura_env.config["enableIcon"] then
  147. allstates[guid] = {
  148. PassUnit = unit,
  149. show = true,
  150. name = aura_env.counter[guid] or 1,
  151. changed = true,
  152. }
  153. end
  154. end
  155. end
  156. end
  157. end
  158. if event == "NAME_PLATE_UNIT_REMOVED" then
  159. if unit then
  160. local guid = UnitGUID(unit)
  161. if guid then
  162. local state = allstates[guid]
  163. if state then
  164. state.changed = true
  165. state.PassUnit = "none"
  166. end
  167. end
  168. end
  169. end
  170. if event == "ENCOUNTER_START" then
  171. aura_env.counter = {}
  172. aura_env.caststart = {}
  173. if IsAddOnLoaded("ExRT")
  174. and _G.VExRT.Note.Text1
  175. and aura_env.config.overrideSettings then
  176. local text = _G.VExRT.Note.Text1
  177. aura_env.count = 0
  178. --counts lines except gaps
  179. for line in string.gmatch(text,'[^\r\n]+') do
  180. aura_env.count = aura_env.count + 1
  181. --searches for "startLine" in Note
  182. if string.match(line, "startLine") then
  183. aura_env.startCount = aura_env.count
  184. end
  185. --searches for "endLine" in Note
  186. if string.match(line, "endLine") then
  187. aura_env.endCount = aura_env.count
  188. end
  189. --checks if your name is found inbetween startLine and endLine
  190. if aura_env.startCount and (aura_env.count or aura_env.myCount and aura_env.myCount) > aura_env.startCount then
  191. if (string.match(line, UnitName("player")) or aura_env.myCount) then
  192. if not aura_env.myCount then
  193. aura_env.myCount = aura_env.count
  194. aura_env.line = line
  195. aura_env.myMark = string.match(line, "%{%a+%}")
  196. elseif aura_env.myCount and aura_env.endCount and aura_env.endCount > aura_env.myCount then
  197. aura_env.resetAfter = 0
  198. for name in string.gmatch(aura_env.line, "|c%x%x%x%x%x%x%x%x([%w-]+)|") do
  199. aura_env.resetAfter = aura_env.resetAfter + 1
  200. if name == UnitName("player") then
  201. aura_env.config.enableSpecified = aura_env.resetAfter
  202. end
  203. end
  204. end
  205. end
  206. end
  207. end
  208. if aura_env.resetAfter then
  209. --set limit to amount of playerNames in your interruptorder
  210. aura_env.config.limit = aura_env.resetAfter
  211. end
  212. if aura_env.myMark then
  213. --disable all currently selected raidicons & enable raidicon from note
  214. for i = 1,8 do
  215. aura_env.config["specifiedIcon"][i] = false
  216. end
  217. aura_env.config["enableIcon"] = true
  218. aura_env.config["specifiedIcon"][aura_env.translateERT[aura_env.myMark]] = true
  219. --aura_env.config.enableSound = true --forces people to use a sound (disabled by default)
  220. end
  221. end
  222. end
  223. return true
  224. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement