kecske123

Skada Absorb and Heal/sec (3.3.5) SkadaAbsorbs\Absorbs.lua

Nov 29th, 2017
452
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.56 KB | None | 0 0
  1. -- Based on RecountGuessedAbsorbs by Elsia
  2.  
  3. local L = LibStub("AceLocale-3.0"):GetLocale("Skada", false)
  4.  
  5. local Skada = Skada
  6. local mod = Skada:NewModule(L["Absorbs"])
  7. local playermod = Skada:NewModule(L["Absorb details"])
  8. local combined = Skada:NewModule(L["Absorbs and healing"])
  9.  
  10. -- This bit shamelessly copied straight from RecountGuessedAbsorbs - thanks!
  11. local AbsorbSpellDuration =
  12. {
  13. -- Death Knight
  14. [48707] = 5, -- Anti-Magic Shell (DK) Rank 1 -- Does not currently seem to show tracable combat log events. It shows energizes which do not reveal the amount of damage absorbed
  15. [51052] = 10, -- Anti-Magic Zone (DK)( Rank 1 (Correct spellID?)
  16. -- Does DK Spell Deflection show absorbs in the CL?
  17. [51271] = 20, -- Unbreakable Armor (DK)
  18. -- Druid
  19. [62606] = 10, -- Savage Defense proc. (Druid) Tooltip of the original spell doesn't clearly state that this is an absorb, but the buff does.
  20. -- Mage
  21. [11426] = 60, -- Ice Barrier (Mage) Rank 1
  22. [13031] = 60,
  23. [13032] = 60,
  24. [13033] = 60,
  25. [27134] = 60,
  26. [33405] = 60,
  27. [43038] = 60,
  28. [43039] = 60, -- Rank 8
  29. [6143] = 30, -- Frost Ward (Mage) Rank 1
  30. [8461] = 30,
  31. [8462] = 30,
  32. [10177] = 30,
  33. [28609] = 30,
  34. [32796] = 30,
  35. [43012] = 30, -- Rank 7
  36. [1463] = 60, -- Mana shield (Mage) Rank 1
  37. [8494] = 60,
  38. [8495] = 60,
  39. [10191] = 60,
  40. [10192] = 60,
  41. [10193] = 60,
  42. [27131] = 60,
  43. [43019] = 60,
  44. [43020] = 60, -- Rank 9
  45. [543] = 30 , -- Fire Ward (Mage) Rank 1
  46. [8457] = 30,
  47. [8458] = 30,
  48. [10223] = 30,
  49. [10225] = 30,
  50. [27128] = 30,
  51. [43010] = 30, -- Rank 7
  52. -- Paladin
  53. [58597] = 6, -- Sacred Shield (Paladin) proc (Fixed, thanks to Julith)
  54. -- Priest
  55. [17] = 30, -- Power Word: Shield (Priest) Rank 1
  56. [592] = 30,
  57. [600] = 30,
  58. [3747] = 30,
  59. [6065] = 30,
  60. [6066] = 30,
  61. [10898] = 30,
  62. [10899] = 30,
  63. [10900] = 30,
  64. [10901] = 30,
  65. [25217] = 30,
  66. [25218] = 30,
  67. [48065] = 30,
  68. [48066] = 30, -- Rank 14
  69. [47509] = 12, -- Divine Aegis (Priest) Rank 1
  70. [47511] = 12,
  71. [47515] = 12, -- Divine Aegis (Priest) Rank 3 (Some of these are not actual buff spellIDs)
  72. [47753] = 12, -- Divine Aegis (Priest) Rank 1
  73. [54704] = 12, -- Divine Aegis (Priest) Rank 1
  74. [47788] = 10, -- Guardian Spirit (Priest) (50 nominal absorb, this may not show in the CL)
  75. -- Warlock
  76. [7812] = 30, -- Sacrifice (warlock) Rank 1
  77. [19438] = 30,
  78. [19440] = 30,
  79. [19441] = 30,
  80. [19442] = 30,
  81. [19443] = 30,
  82. [27273] = 30,
  83. [47985] = 30,
  84. [47986] = 30, -- rank 9
  85. [6229] = 30, -- Shadow Ward (warlock) Rank 1
  86. [11739] = 30,
  87. [11740] = 30,
  88. [28610] = 30,
  89. [47890] = 30,
  90. [47891] = 30, -- Rank 6
  91. -- Consumables
  92. [29674] = 86400, -- Lesser Ward of Shielding
  93. [29719] = 86400, -- Greater Ward of Shielding (these have infinite duration, set for a day here :P)
  94. [29701] = 86400,
  95. [28538] = 120, -- Major Holy Protection Potion
  96. [28537] = 120, -- Major Shadow
  97. [28536] = 120, -- Major Arcane
  98. [28513] = 120, -- Major Nature
  99. [28512] = 120, -- Major Frost
  100. [28511] = 120, -- Major Fire
  101. [7233] = 120, -- Fire
  102. [7239] = 120, -- Frost
  103. [7242] = 120, -- Shadow Protection Potion
  104. [7245] = 120, -- Holy
  105. [6052] = 120, -- Nature Protection Potion
  106. [53915] = 120, -- Mighty Shadow Protection Potion
  107. [53914] = 120, -- Mighty Nature Protection Potion
  108. [53913] = 120, -- Mighty Frost Protection Potion
  109. [53911] = 120, -- Mighty Fire
  110. [53910] = 120, -- Mighty Arcane
  111. [17548] = 120, -- Greater Shadow
  112. [17546] = 120, -- Greater Nature
  113. [17545] = 120, -- Greater Holy
  114. [17544] = 120, -- Greater Frost
  115. [17543] = 120, -- Greater Fire
  116. [17549] = 120, -- Greater Arcane
  117. [28527] = 15, -- Fel Blossom
  118. [29432] = 3600, -- Frozen Rune usage (Naxx classic)
  119. -- Item usage
  120. [36481] = 4, -- Arcane Barrier (TK Kael'Thas) Shield
  121. [57350] = 6, -- Darkmoon Card: Illusion
  122. [17252] = 30, -- Mark of the Dragon Lord (LBRS epic ring) usage
  123. [25750] = 15, -- Defiler's Talisman/Talisman of Arathor Rank 1
  124. [25747] = 15,
  125. [25746] = 15,
  126. [23991] = 15,
  127. [31000] = 300, -- Pendant of Shadow's End Usage
  128. [30997] = 300, -- Pendant of Frozen Flame Usage
  129. [31002] = 300, -- Pendant of the Null Rune
  130. [30999] = 300, -- Pendant of Withering
  131. [30994] = 300, -- Pendant of Thawing
  132. [31000] = 300, --
  133. [23506]= 20, -- Arena Grand Master Usage (Aura of Protection)
  134. [12561] = 60, -- Goblin Construction Helmet usage
  135. [31771] = 20, -- Runed Fungalcap usage
  136. [21956] = 10, -- Mark of Resolution usage
  137. [29506] = 20, -- The Burrower's Shell
  138. [4057] = 60, -- Flame Deflector
  139. [4077] = 60, -- Ice Deflector
  140. [39228] = 20, -- Argussian Compass (may not be an actual absorb)
  141. -- Item procs
  142. [27779] = 30, -- Divine Protection - Priest dungeon set 1/2 Proc
  143. [11657] = 20, -- Jang'thraze (Zul Farrak) proc
  144. [10368] = 15, -- Uther's Strength proc
  145. [37515] = 15, -- Warbringer Armor Proc
  146. [42137] = 86400, -- Greater Rune of Warding Proc
  147. [26467] = 30, -- Scarab Brooch proc
  148. [26470] = 8, -- Scarab Brooch proc (actual)
  149. [27539] = 6, -- Thick Obsidian Breatplate proc
  150. [28810] = 30, -- Faith Set Proc Armor of Faith
  151. [54808] = 12, -- Noise Machine proc Sonic Shield
  152. [55019] = 12, -- Sonic Shield (one of these too ought to be wrong)
  153. [64411] = 15, -- Blessing of the Ancient (Val'anyr Hammer of Ancient Kings equip effect)
  154. [64413] = 8, -- Val'anyr, Hammer of Ancient Kings proc Protection of Ancient Kings
  155. -- Misc
  156. [40322] = 30, -- Teron's Vengeful Spirit Ghost - Spirit Shield
  157. -- Boss abilities
  158. [65874] = 15, -- Twin Val'kyr's Shield of Darkness 175000
  159. [67257] = 15, -- 300000
  160. [67256] = 15, -- 700000
  161. [67258] = 15, -- 1200000
  162. [65858] = 15, -- Twin Val'kyr's Shield of Lights 175000
  163. [67260] = 15, -- 300000
  164. [67259] = 15, -- 700000
  165. [67261] = 15, -- 1200000
  166. }
  167.  
  168. local shields = {}
  169.  
  170. local function AuraApplied(timestamp, eventtype, srcGUID, srcName, srcFlags, dstGUID, dstName, dstFlags, ...)
  171. local spellId, spellName, spellSchool, auraType = ...
  172. if AbsorbSpellDuration[spellId] then
  173.  
  174. shields[dstName] = shields[dstName] or {}
  175. shields[dstName][spellId] = shields[dstName][spellId] or {}
  176. shields[dstName][spellId][srcName] = timestamp + AbsorbSpellDuration[spellId]
  177.  
  178. end
  179. end
  180.  
  181. local function AuraRemoved(timestamp, eventtype, srcGUID, srcName, srcFlags, dstGUID, dstName, dstFlags, ...)
  182. local spellId, spellName, spellSchool, auraType = ...
  183. if AbsorbSpellDuration[spellId] then
  184.  
  185. if shields[dstName] and shields[dstName][spellId] and shields[dstName][spellId][dstName] then
  186. -- As advised in RecountGuessedAbsorbs, do not remove shields straight away as an absorb can come after the aura removed event.
  187. shields[dstName][spellId][dstName] = timestamp + 0.1
  188. end
  189.  
  190. end
  191. end
  192.  
  193. local function log_absorb(set, srcName, dstName, absorbed)
  194. -- Get the player.
  195. local player = Skada:get_player(set, UnitGUID(srcName), UnitName(srcName))
  196. if player then
  197. player.totalabsorbs = player.totalabsorbs + absorbed
  198. player.absorbs[dstName] = (player.absorbs[dstName] or 0) + absorbed
  199. set.absorbs = set.absorbs + absorbed
  200. end
  201. end
  202.  
  203. local function consider_absorb(absorbed, dstName, srcName, timestamp)
  204. local mintime = nil
  205. local found_shield_src
  206. for shield_id, spells in pairs(shields[dstName]) do
  207. for shield_src, ts in pairs(spells) do
  208. if ts - timestamp > 0 and (mintime == nil or ts - timestamp < mintime) then
  209. found_shield_src = shield_src
  210. end
  211. end
  212. end
  213.  
  214. if found_shield_src then
  215.  
  216. log_absorb(Skada.current, found_shield_src, dstName, absorbed)
  217. log_absorb(Skada.total, found_shield_src, dstName, absorbed)
  218.  
  219. end
  220. end
  221.  
  222. local function SwingDamage(timestamp, eventtype, srcGUID, srcName, srcFlags, dstGUID, dstName, dstFlags, ...)
  223. local samount, soverkill, sschool, sresisted, sblocked, absorbed, scritical, sglancing, scrushing = ...
  224. if absorbed and absorbed > 0 and dstName and shields[dstName] and srcName then
  225. --Skada:Print(dstName.." absorbed "..absorbed.." from "..srcName)
  226. consider_absorb(absorbed, dstName, srcName, timestamp)
  227. end
  228. end
  229.  
  230. local function SpellDamage(timestamp, eventtype, srcGUID, srcName, srcFlags, dstGUID, dstName, dstFlags, ...)
  231. local spellId, spellName, spellSchool, samount, soverkill, sschool, sresisted, sblocked, absorbed, scritical, sglancing, scrushing = ...
  232. if absorbed and absorbed > 0 and dstName and shields[dstName] and srcName then
  233. --Skada:Print(dstName.." absorbed "..absorbed.." from "..srcName)
  234. consider_absorb(absorbed, dstName, srcName, timestamp)
  235. end
  236. end
  237.  
  238. local function SpellMissed(timestamp, eventtype, srcGUID, srcName, srcFlags, dstGUID, dstName, dstFlags, ...)
  239. local spellId, spellName, spellSchool, misstype, amount = ...
  240. if misstype == "ABSORB" and amount > 0 and dstName and shields[dstName] and srcName then
  241. --Skada:Print(dstName.." absorbed "..absorbed.." from "..srcName.." (MISS)")
  242. consider_absorb(amount, dstName, srcName, timestamp)
  243. end
  244. end
  245.  
  246. local function SwingMissed(timestamp, eventtype, srcGUID, srcName, srcFlags, dstGUID, dstName, dstFlags, ...)
  247. SpellMissed(timestamp, eventtype, srcGUID, srcName, srcFlags, dstGUID, dstName, dstFlags, nil, nil, nil, ...)
  248. end
  249.  
  250. function mod:Update(win, set)
  251. local nr = 1
  252. local max = 0
  253.  
  254. for i, player in ipairs(set.players) do
  255. if player.totalabsorbs > 0 then
  256.  
  257. local d = win.dataset[nr] or {}
  258. win.dataset[nr] = d
  259.  
  260. d.id = player.id
  261. d.value = player.totalabsorbs
  262. d.label = player.name
  263. d.valuetext = Skada:FormatNumber(player.totalabsorbs)..(" (%02.1f%%)"):format(player.totalabsorbs / set.absorbs * 100)
  264. d.class = player.class
  265.  
  266. if player.totalabsorbs > max then
  267. max = player.totalabsorbs
  268. end
  269.  
  270. nr = nr + 1
  271. end
  272. end
  273.  
  274. win.metadata.maxvalue = max
  275. end
  276.  
  277. function playermod:Enter(win, id, label)
  278. playermod.playerid = id
  279. playermod.title = label..L["'s Absorbs"]
  280. end
  281.  
  282. function playermod:Update(win, set)
  283. local player = Skada:find_player(set, self.playerid)
  284.  
  285. local nr = 1
  286. local max = 0
  287.  
  288. if player then
  289.  
  290. for dstName, absorbed in pairs(player.absorbs) do
  291. local d = win.dataset[nr] or {}
  292. win.dataset[nr] = d
  293.  
  294. d.id = dstName
  295. d.value = absorbed
  296. d.label = dstName
  297. d.valuetext = Skada:FormatNumber(absorbed)..(" (%02.1f%%)"):format(absorbed / player.totalabsorbs * 100)
  298. d.class = select(2, UnitClass(dstName))
  299.  
  300. if absorbed > max then
  301. max = absorbed
  302. end
  303.  
  304. nr = nr + 1
  305. end
  306.  
  307. win.metadata.maxvalue = max
  308.  
  309. end
  310. end
  311.  
  312. local function getAHPS(set, player)
  313. local totaltime = Skada:PlayerActiveTime(set, player)
  314.  
  315. return (player.totalabsorbs + (player.healing or 0)) / math.max(1,totaltime)
  316. end
  317.  
  318. function combined:Update(win, set)
  319. local nr = 1
  320. local max = 0
  321.  
  322. for i, player in ipairs(set.players) do
  323. if player.totalabsorbs > 0 or player.healing > 0 then
  324.  
  325. local d = win.dataset[nr] or {}
  326. win.dataset[nr] = d
  327.  
  328. d.id = player.id
  329. d.value = player.totalabsorbs + (player.healing or 0)
  330. d.label = player.name
  331. -- d.valuetext = Skada:FormatNumber(player.totalabsorbs + (player.healing or 0))..(" (%02.1f%%)"):format((player.totalabsorbs + (player.healing or 0)) / (set.absorbs + (set.healing or 0)) * 100)
  332. d.valuetext = Skada:FormatNumber(player.totalabsorbs + (player.healing or 0))..string.format(" (%02.1f,", getAHPS(set, player))..string.format(" %02.1f%%)", (player.totalabsorbs + (player.healing or 0)) / (set.absorbs + (set.healing or 0)) * 100)
  333.  
  334. d.class = player.class
  335.  
  336. if (player.totalabsorbs + player.healing) > max then
  337. max = player.totalabsorbs + player.healing
  338. end
  339.  
  340. nr = nr + 1
  341. end
  342. end
  343.  
  344. win.metadata.maxvalue = max
  345. end
  346.  
  347. function mod:OnEnable()
  348. combined.metadata = {showspots = 1, click1 = playermod}
  349. mod.metadata = {showspots = 1, click1 = playermod}
  350. playermod.metadata = {}
  351.  
  352. Skada:RegisterForCL(AuraApplied, 'SPELL_AURA_REFRESH', {src_is_interesting_nopets = true})
  353. Skada:RegisterForCL(AuraApplied, 'SPELL_AURA_APPLIED', {src_is_interesting_nopets = true})
  354. Skada:RegisterForCL(AuraRemoved, 'SPELL_AURA_REMOVED', {src_is_interesting_nopets = true})
  355. Skada:RegisterForCL(SpellDamage, 'DAMAGE_SHIELD', {dst_is_interesting_nopets = true})
  356. Skada:RegisterForCL(SpellDamage, 'SPELL_DAMAGE', {dst_is_interesting_nopets = true})
  357. Skada:RegisterForCL(SpellDamage, 'SPELL_PERIODIC_DAMAGE', {dst_is_interesting_nopets = true})
  358. Skada:RegisterForCL(SpellDamage, 'SPELL_BUILDING_DAMAGE', {dst_is_interesting_nopets = true})
  359. Skada:RegisterForCL(SpellDamage, 'RANGE_DAMAGE', {dst_is_interesting_nopets = true})
  360. Skada:RegisterForCL(SwingDamage, 'SWING_DAMAGE', {dst_is_interesting_nopets = true})
  361. Skada:RegisterForCL(SpellMissed, 'SPELL_MISSED', {dst_is_interesting_nopets = true})
  362. Skada:RegisterForCL(SpellMissed, 'SPELL_PERIODIC_MISSED', {dst_is_interesting_nopets = true})
  363. Skada:RegisterForCL(SpellMissed, 'SPELL_BUILDING_MISSED', {dst_is_interesting_nopets = true})
  364. Skada:RegisterForCL(SpellMissed, 'RANGE_MISSED', {dst_is_interesting_nopets = true})
  365. Skada:RegisterForCL(SwingMissed, 'SWING_MISSED', {dst_is_interesting_nopets = true})
  366.  
  367. Skada:AddMode(self)
  368. Skada:AddMode(combined)
  369. end
  370.  
  371. function mod:OnDisable()
  372. Skada:RemoveMode(self)
  373. Skada:RemoveMode(combined)
  374. end
  375.  
  376. function mod:AddToTooltip(set, tooltip)
  377. end
  378.  
  379. function mod:GetSetSummary(set)
  380. return Skada:FormatNumber(set.absorbs)
  381. end
  382.  
  383. function combined:GetSetSummary(set)
  384. return Skada:FormatNumber(set.absorbs + set.healing)
  385. end
  386.  
  387. -- Called by Skada when a new player is added to a set.
  388. function mod:AddPlayerAttributes(player)
  389. if not player.absorbs then
  390. player.absorbs = {}
  391. player.totalabsorbs = 0
  392. end
  393. end
  394.  
  395. -- Called by Skada when a new set is created.
  396. -- Conveniently this is when a new fight starts, so we can clear our shield cache.
  397. function mod:AddSetAttributes(set)
  398. if not set.absorbs then
  399. set.absorbs = 0
  400. end
  401. shields = {}
  402. end
Advertisement
Add Comment
Please, Sign In to add comment