PageRenderTime 32ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/Tukui/modules/misc/damage.lua

http://github.com/Asphyxia/Tukui
Lua | 132 lines | 112 code | 13 blank | 7 comment | 39 complexity | 7a4de1cad65b634ae2010c473d62bc74 MD5 | raw file
  1. local T, C, L = unpack(select(2, ...)) -- Import: T - functions, constants, variables; C - config; L - locales
  2. -------------------------------------------------------------
  3. -- DAMAGE / HEAL DISPLAY REPLACEMENT FOR EYEFINITY
  4. -- BECAUSE REGULAR 3D WORLD DAMAGE ISN'T COMPATIBLE
  5. -------------------------------------------------------------
  6. if not T.eyefinity then return end
  7. local displaydamage = GetCVar("CombatDamage")
  8. local displayheal = GetCVar("CombatHealing")
  9. local displaydot = GetCVar("CombatLogPeriodicSpells")
  10. local gflags = bit.bor(COMBATLOG_OBJECT_AFFILIATION_MINE, COMBATLOG_OBJECT_REACTION_FRIENDLY, COMBATLOG_OBJECT_CONTROL_PLAYER, COMBATLOG_OBJECT_TYPE_GUARDIAN)
  11. local function OnEvent(self, event, ...)
  12. local timestamp, eventType, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags
  13. if T.toc < 40200 then
  14. timestamp, eventType, hideCaster, sourceGUID, sourceName, sourceFlags, destGUID, destName, destFlags = select(1,...)
  15. else
  16. timestamp, eventType, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags = select(1,...)
  17. end
  18. if sourceGUID == UnitGUID("player") or sourceGUID == UnitGUID("pet") or sourceFlags == gflags then
  19. -- dmg
  20. if displaydamage then
  21. if eventType == "SWING_DAMAGE" then
  22. local _, amount, critical
  23. if T.toc < 40200 then
  24. _, amount, _, _, _, _, critical = select(9, ...)
  25. else
  26. _, _, _, amount, _, _, _, _, critical = select(9, ...)
  27. end
  28. self:AddMessage(amount, 1, 1, 1)
  29. elseif eventType == "SPELL_DAMAGE" or eventType == "SPELL_PERIODIC_DAMAGE" then
  30. local _, spellId, spellSchool, amount, critical
  31. if T.toc < 40200 then
  32. _, spellId, _, spellSchool, amount, _, _, _, _, _, critical = select(9, ...)
  33. else
  34. _, _, _, spellId, _, spellSchool, amount, _, _, _, _, _, critical = select(9, ...)
  35. end
  36. if eventType == "SPELL_PERIODIC_DAMAGE" then
  37. if displaydot then self:AddMessage(amount, 151/255, 70/255, 194/255) end
  38. else
  39. self:AddMessage(amount, 1, 1, 0)
  40. end
  41. elseif eventType == "RANGE_DAMAGE" then
  42. local _, spellId, amount, critical
  43. if T.toc < 40200 then
  44. _, spellId, _, _, amount, _, _, _, _, _, critical = select(9, ...)
  45. else
  46. _, _, _, spellId, _, _, amount, _, _, _, _, _, critical = select(9, ...)
  47. end
  48. self:AddMessage(amount, 1, 1, 1)
  49. elseif eventType == "SWING_MISSED" then
  50. local _, missType
  51. if T.toc < 40200 then
  52. _, missType, _ = select(9, ...)
  53. else
  54. _, _, _, missType, _ = select(9, ...)
  55. end
  56. self:AddMessage(missType, 1, 1, 1)
  57. elseif eventType == "SPELL_MISSED" or eventType == "RANGE_MISSED" then
  58. local _, spellId, missType
  59. if T.toc < 40200 then
  60. _, spellId, _, _, missType, _ = select(9,...)
  61. else
  62. _, _, _, spellId, _, _, missType, _ = select(9,...)
  63. end
  64. self:AddMessage(missType, 1, 1, 1)
  65. end
  66. end
  67. -- heal
  68. if displayheal then
  69. if eventType == "SPELL_HEAL" or eventType== "SPELL_PERIODIC_HEAL" then
  70. local _, amount
  71. if T.toc < 40200 then
  72. _, _, _, _, amount, _, _, _ = select(9,...)
  73. else
  74. _, _, _, _, _, _, amount, _, _, _ = select(9,...)
  75. end
  76. self:AddMessage(amount, 0, 1, 0)
  77. end
  78. end
  79. end
  80. end
  81. local f = CreateFrame("ScrollingMessageFrame", "TukuiEyefinityDamage", UIParent)
  82. f:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
  83. f:SetScript("OnEvent",OnEvent)
  84. f:SetSize(200, 200)
  85. f:SetPoint("TOP", 0, -50)
  86. f:SetFont(C.media.dmgfont,36,"OUTLINE")
  87. f:SetShadowColor(0,0,0,0)
  88. f:SetFading(true)
  89. f:SetFadeDuration(0.5)
  90. f:SetTimeVisible(1)
  91. f:SetMaxLines(64)
  92. f:SetSpacing(2)
  93. local o = CreateFrame("Frame")
  94. o:RegisterEvent("CVAR_UPDATE")
  95. o:SetScript("OnEvent", function(self, event, cvar, value)
  96. if cvar == "SHOW_DAMAGE_TEXT" then
  97. if value == 1 then
  98. displaydamage = true
  99. else
  100. displaydamage = false
  101. end
  102. end
  103. if cvar == "LOG_PERIODIC_EFFECTS" then
  104. if value == 1 then
  105. displaydot = true
  106. else
  107. displaydot = false
  108. end
  109. end
  110. if cvar == "SHOW_COMBAT_HEALING" then
  111. if value == 1 then
  112. displayheal = true
  113. else
  114. displayheal = false
  115. end
  116. end
  117. end)
  118. -- kill
  119. InterfaceOptionsCombatTextPanelPetDamage:Kill()