Advertisement
Wetxius

Untitled

Dec 15th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 36.73 KB | None | 0 0
  1. local T, C, L, _ = unpack(select(2, ...))
  2. if C.combattext.enable ~= true then return end
  3.  
  4. ----------------------------------------------------------------------------------------
  5. -- Combat Text(xCT by Affli)
  6. ----------------------------------------------------------------------------------------
  7. -- Justify messages in frames
  8. local ct = {
  9. ["justify_1"] = "LEFT", -- Incoming damage justify
  10. ["justify_2"] = "RIGHT", -- Incoming healing justify
  11. ["justify_3"] = "CENTER", -- Various messages justify
  12. ["justify_4"] = "RIGHT", -- Outgoing damage/healing justify
  13. }
  14.  
  15. -- Do not edit below unless you know what you are doing
  16. local numf
  17. if C.combattext.damage or C.combattext.healing then
  18. numf = 4
  19. else
  20. numf = 3
  21. end
  22.  
  23. -- Detect vehicle
  24. local function SetUnit()
  25. if UnitHasVehicleUI("player") then
  26. ct.unit = "vehicle"
  27. else
  28. ct.unit = "player"
  29. end
  30. CombatTextSetActiveUnit(ct.unit)
  31. end
  32.  
  33. -- Limit lines
  34. local function LimitLines()
  35. for i = 1, #ct.frames do
  36. f = ct.frames[i]
  37. if i == 4 and C.combattext.icons then
  38. f:SetMaxLines(math.floor(f:GetHeight() / (C.combattext.icon_size * 1.5)))
  39. else
  40. f:SetMaxLines(math.floor(f:GetHeight() / C.font.combat_text_font_size - 1))
  41. end
  42. end
  43. end
  44.  
  45. -- Scrollable frames
  46. local function SetScroll()
  47. for i = 1, #ct.frames do
  48. ct.frames[i]:EnableMouseWheel(true)
  49. ct.frames[i]:SetScript("OnMouseWheel", function(self, delta)
  50. if delta > 0 then
  51. self:ScrollUp()
  52. elseif delta < 0 then
  53. self:ScrollDown()
  54. end
  55. end)
  56. end
  57. end
  58.  
  59. -- Partial resists styler
  60. local part = "-%s [%s %s]"
  61. local r, g, b
  62.  
  63. -- Function, handles everything
  64. local function OnEvent(self, event, subevent, ...)
  65. if event == "COMBAT_TEXT_UPDATE" then
  66. local arg2, arg3 = ...
  67. if SHOW_COMBAT_TEXT == "0" then
  68. return
  69. else
  70. if subevent == "DAMAGE" then
  71. if C.combattext.short_numbers == true then
  72. arg2 = T.ShortValue(arg2)
  73. end
  74. xCT1:AddMessage("-"..arg2, 0.75, 0.1, 0.1)
  75. elseif subevent == "DAMAGE_CRIT" then
  76. if C.combattext.short_numbers == true then
  77. arg2 = T.ShortValue(arg2)
  78. end
  79. xCT1:AddMessage("|cffFF0000"..C.combattext.crit_prefix.."|r".."-"..arg2.."|cffFF0000"..C.combattext.crit_postfix.."|r", 1, 0.1, 0.1)
  80. elseif subevent == "SPELL_DAMAGE" then
  81. if C.combattext.short_numbers == true then
  82. arg2 = T.ShortValue(arg2)
  83. end
  84. xCT1:AddMessage("-"..arg2, 0.75, 0.3, 0.85)
  85. elseif subevent == "SPELL_DAMAGE_CRIT" then
  86. if C.combattext.short_numbers == true then
  87. arg2 = T.ShortValue(arg2)
  88. end
  89. xCT1:AddMessage("|cffFF0000"..C.combattext.crit_prefix.."|r".."-"..arg2.."|cffFF0000"..C.combattext.crit_postfix.."|r", 1, 0.3, 0.5)
  90. elseif subevent == "HEAL" then
  91. if arg3 >= C.combattext.heal_treshold then
  92. if C.combattext.short_numbers == true then
  93. arg3 = T.ShortValue(arg3)
  94. end
  95. if arg2 then
  96. if COMBAT_TEXT_SHOW_FRIENDLY_NAMES == "1" then
  97. xCT2:AddMessage(arg2.." +"..arg3, 0.1, 0.75, 0.1)
  98. else
  99. xCT2:AddMessage("+"..arg3, 0.1, 0.75, 0.1)
  100. end
  101. end
  102. end
  103. elseif subevent == "HEAL_CRIT" then
  104. if arg3 >= C.combattext.heal_treshold then
  105. if C.combattext.short_numbers == true then
  106. arg3 = T.ShortValue(arg3)
  107. end
  108. if arg2 then
  109. if COMBAT_TEXT_SHOW_FRIENDLY_NAMES == "1" then
  110. xCT2:AddMessage(arg2.." +"..arg3, 0.1, 1, 0.1)
  111. else
  112. xCT2:AddMessage("+"..arg3, 0.1, 1, 0.1)
  113. end
  114. end
  115. end
  116. elseif subevent == "PERIODIC_HEAL" then
  117. if arg3 >= C.combattext.heal_treshold then
  118. if C.combattext.short_numbers == true then
  119. arg3 = T.ShortValue(arg3)
  120. end
  121. xCT2:AddMessage("+"..arg3, 0.1, 0.5, 0.1)
  122. end
  123. elseif subevent == "ABSORB_ADDED" and GetCVar("CombatHealingAbsorbSelf") == "1" then
  124. if arg3 >= C.combattext.heal_treshold then
  125. if C.combattext.short_numbers == true then
  126. arg3 = T.ShortValue(arg3)
  127. end
  128. if arg2 then
  129. if COMBAT_TEXT_SHOW_FRIENDLY_NAMES == "1" then
  130. xCT2:AddMessage(arg2.." +"..arg3, 0.6, 0.65, 0.1)
  131. else
  132. xCT2:AddMessage("+"..arg3, 0.6, 0.65, 0.1)
  133. end
  134. end
  135. end
  136. elseif subevent == "SPELL_CAST" then
  137. xCT3:AddMessage(arg2, 1, 0.82, 0)
  138. elseif subevent == "MISS" and COMBAT_TEXT_SHOW_DODGE_PARRY_MISS == "1" then
  139. xCT1:AddMessage(MISS, 0.5, 0.5, 0.5)
  140. elseif subevent == "DODGE" and COMBAT_TEXT_SHOW_DODGE_PARRY_MISS == "1" then
  141. xCT1:AddMessage(DODGE, 0.5, 0.5, 0.5)
  142. elseif subevent == "PARRY" and COMBAT_TEXT_SHOW_DODGE_PARRY_MISS == "1" then
  143. xCT1:AddMessage(PARRY, 0.5, 0.5, 0.5)
  144. elseif subevent == "EVADE" and COMBAT_TEXT_SHOW_DODGE_PARRY_MISS == "1" then
  145. xCT1:AddMessage(EVADE, 0.5, 0.5, 0.5)
  146. elseif subevent == "IMMUNE" and COMBAT_TEXT_SHOW_DODGE_PARRY_MISS == "1" then
  147. xCT1:AddMessage(IMMUNE, 0.5, 0.5, 0.5)
  148. elseif subevent == "DEFLECT" and COMBAT_TEXT_SHOW_DODGE_PARRY_MISS == "1" then
  149. xCT1:AddMessage(DEFLECT, 0.5, 0.5, 0.5)
  150. elseif subevent == "REFLECT" and COMBAT_TEXT_SHOW_DODGE_PARRY_MISS == "1" then
  151. xCT1:AddMessage(REFLECT, 0.5, 0.5, 0.5)
  152. elseif subevent == "SPELL_MISS" and COMBAT_TEXT_SHOW_DODGE_PARRY_MISS == "1" then
  153. xCT1:AddMessage(MISS, 0.5, 0.5, 0.5)
  154. elseif subevent == "SPELL_DODGE"and COMBAT_TEXT_SHOW_DODGE_PARRY_MISS == "1" then
  155. xCT1:AddMessage(DODGE, 0.5, 0.5, 0.5)
  156. elseif subevent == "SPELL_PARRY" and COMBAT_TEXT_SHOW_DODGE_PARRY_MISS == "1" then
  157. xCT1:AddMessage(PARRY, 0.5, 0.5, 0.5)
  158. elseif subevent == "SPELL_EVADE" and COMBAT_TEXT_SHOW_DODGE_PARRY_MISS == "1" then
  159. xCT1:AddMessage(EVADE, 0.5, 0.5, 0.5)
  160. elseif subevent == "SPELL_IMMUNE" and COMBAT_TEXT_SHOW_DODGE_PARRY_MISS == "1" then
  161. xCT1:AddMessage(IMMUNE, 0.5, 0.5, 0.5)
  162. elseif subevent == "SPELL_DEFLECT" and COMBAT_TEXT_SHOW_DODGE_PARRY_MISS == "1" then
  163. xCT1:AddMessage(DEFLECT, 0.5, 0.5, 0.5)
  164. elseif subevent == "SPELL_REFLECT" and COMBAT_TEXT_SHOW_DODGE_PARRY_MISS == "1" then
  165. xCT1:AddMessage(REFLECT, 0.5, 0.5, 0.5)
  166. elseif subevent == "RESIST" then
  167. if arg3 then
  168. if C.combattext.short_numbers == true then
  169. arg2 = T.ShortValue(arg2)
  170. arg3 = T.ShortValue(arg3)
  171. end
  172. if COMBAT_TEXT_SHOW_RESISTANCES == "1" then
  173. xCT1:AddMessage(part:format(arg2, RESIST, arg3), 0.75, 0.5, 0.5)
  174. else
  175. xCT1:AddMessage("-"..arg2, 0.75, 0.1, 0.1)
  176. end
  177. elseif COMBAT_TEXT_SHOW_RESISTANCES == "1" then
  178. xCT1:AddMessage(RESIST, 0.5, 0.5, 0.5)
  179. end
  180. elseif subevent == "BLOCK" then
  181. if arg3 then
  182. if C.combattext.short_numbers == true then
  183. arg2 = T.ShortValue(arg2)
  184. arg3 = T.ShortValue(arg3)
  185. end
  186. if COMBAT_TEXT_SHOW_RESISTANCES == "1" then
  187. xCT1:AddMessage(part:format(arg2, BLOCK, arg3), 0.75, 0.5, 0.5)
  188. else
  189. xCT1:AddMessage("-"..arg2, 0.75, 0.1, 0.1)
  190. end
  191. elseif COMBAT_TEXT_SHOW_RESISTANCES == "1" then
  192. xCT1:AddMessage(BLOCK, 0.5, 0.5, 0.5)
  193. end
  194. elseif subevent == "ABSORB" then
  195. if arg3 then
  196. if C.combattext.short_numbers == true then
  197. arg2 = T.ShortValue(arg2)
  198. arg3 = T.ShortValue(arg3)
  199. end
  200. if COMBAT_TEXT_SHOW_RESISTANCES == "1" then
  201. xCT1:AddMessage(part:format(arg2, ABSORB, arg3), 0.75, 0.5, 0.5)
  202. else
  203. xCT1:AddMessage("-"..arg2, 0.75, 0.1, 0.1)
  204. end
  205. elseif COMBAT_TEXT_SHOW_RESISTANCES == "1" then
  206. xCT1:AddMessage(ABSORB, 0.5, 0.5, 0.5)
  207. end
  208. elseif subevent == "SPELL_RESIST" then
  209. if arg3 then
  210. if C.combattext.short_numbers == true then
  211. arg2 = T.ShortValue(arg2)
  212. arg3 = T.ShortValue(arg3)
  213. end
  214. if COMBAT_TEXT_SHOW_RESISTANCES == "1" then
  215. xCT1:AddMessage(part:format(arg2, RESIST, arg3), 0.5, 0.3, 0.5)
  216. else
  217. xCT1:AddMessage("-"..arg2, 0.75, 0.3, 0.85)
  218. end
  219. elseif COMBAT_TEXT_SHOW_RESISTANCES == "1" then
  220. xCT1:AddMessage(RESIST, 0.5, 0.5, 0.5)
  221. end
  222. elseif subevent == "SPELL_BLOCK" then
  223. if arg3 then
  224. if C.combattext.short_numbers == true then
  225. arg2 = T.ShortValue(arg2)
  226. arg3 = T.ShortValue(arg3)
  227. end
  228. if COMBAT_TEXT_SHOW_RESISTANCES == "1" then
  229. xCT1:AddMessage(part:format(arg2, BLOCK, arg3), 0.5, 0.3, 0.5)
  230. else
  231. xCT1:AddMessage("-"..arg2, 0.75, 0.3, 0.85)
  232. end
  233. elseif COMBAT_TEXT_SHOW_RESISTANCES == "1" then
  234. xCT1:AddMessage(BLOCK, 0.5, 0.5, 0.5)
  235. end
  236. elseif subevent == "SPELL_ABSORB" then
  237. if arg3 then
  238. if C.combattext.short_numbers == true then
  239. arg2 = T.ShortValue(arg2)
  240. arg3 = T.ShortValue(arg3)
  241. end
  242. if COMBAT_TEXT_SHOW_RESISTANCES == "1" then
  243. xCT1:AddMessage(part:format(arg2, ABSORB, arg3), 0.5, 0.3, 0.5)
  244. else
  245. xCT1:AddMessage("-"..arg2, 0.75, 0.3, 0.85)
  246. end
  247. elseif COMBAT_TEXT_SHOW_RESISTANCES == "1" then
  248. xCT1:AddMessage(ABSORB, 0.5, 0.5, 0.5)
  249. end
  250. elseif subevent == "ENERGIZE" and COMBAT_TEXT_SHOW_ENERGIZE == "1" then
  251. if tonumber(arg2) > 0 then
  252. if arg3 and arg3 == "MANA" or arg3 == "RAGE" or arg3 == "FOCUS" or arg3 == "ENERGY" or arg3 == "RUNIC_POWER" or arg3 == "SOUL_SHARDS" or arg3 == "HOLY_POWER" or arg3 == "CHI" then
  253. xCT3:AddMessage("+"..arg2.." ".._G[arg3], PowerBarColor[arg3].r, PowerBarColor[arg3].g, PowerBarColor[arg3].b)
  254. elseif arg3 and arg3 == "ECLIPSE" then
  255. xCT3:AddMessage("+"..arg2.." "..BALANCE_POSITIVE_ENERGY, PowerBarColor[arg3].positive.r, PowerBarColor[arg3].positive.g, PowerBarColor[arg3].positive.b)
  256. end
  257. else
  258. if arg3 and arg3 == "ECLIPSE" then
  259. xCT3:AddMessage("+"..abs(arg2).." "..BALANCE_NEGATIVE_ENERGY, PowerBarColor[arg3].negative.r, PowerBarColor[arg3].negative.g, PowerBarColor[arg3].negative.b)
  260. end
  261. end
  262. elseif subevent == "PERIODIC_ENERGIZE" and COMBAT_TEXT_SHOW_PERIODIC_ENERGIZE == "1" then
  263. if tonumber(arg2) > 0 then
  264. if arg3 and arg3 == "MANA" or arg3 == "RAGE" or arg3 == "FOCUS" or arg3 == "ENERGY" or arg3 == "RUNIC_POWER" or arg3 == "SOUL_SHARDS" or arg3 == "HOLY_POWER" or arg3 == "CHI" then
  265. xCT3:AddMessage("+"..arg2.." ".._G[arg3], PowerBarColor[arg3].r, PowerBarColor[arg3].g, PowerBarColor[arg3].b)
  266. elseif arg3 and arg3 == "ECLIPSE" then
  267. xCT3:AddMessage("+"..arg2.." "..BALANCE_POSITIVE_ENERGY, PowerBarColor[arg3].positive.r, PowerBarColor[arg3].positive.g, PowerBarColor[arg3].positive.b)
  268. end
  269. else
  270. if arg3 and arg3 == "ECLIPSE" then
  271. xCT3:AddMessage("+"..abs(arg2).." "..BALANCE_NEGATIVE_ENERGY, PowerBarColor[arg3].negative.r, PowerBarColor[arg3].negative.g, PowerBarColor[arg3].negative.b)
  272. end
  273. end
  274. elseif subevent == "SPELL_AURA_START" and COMBAT_TEXT_SHOW_AURAS == "1" then
  275. xCT3:AddMessage("+"..arg2, 1, 0.5, 0.5)
  276. elseif subevent == "SPELL_AURA_END" and COMBAT_TEXT_SHOW_AURAS == "1" then
  277. xCT3:AddMessage("-"..arg2, 0.5, 0.5, 0.5)
  278. elseif subevent == "SPELL_AURA_START_HARMFUL" and COMBAT_TEXT_SHOW_AURAS == "1" then
  279. xCT3:AddMessage("+"..arg2, 1, 0.1, 0.1)
  280. elseif subevent == "SPELL_AURA_END_HARMFUL" and COMBAT_TEXT_SHOW_AURAS == "1" then
  281. xCT3:AddMessage("-"..arg2, 0.1, 1, 0.1)
  282. elseif subevent == "HONOR_GAINED" and COMBAT_TEXT_SHOW_HONOR_GAINED == "1" then
  283. arg2 = tonumber(arg2)
  284. if arg2 and abs(arg2) > 1 then
  285. arg2 = floor(arg2)
  286. if arg2 > 0 then
  287. xCT3:AddMessage(HONOR.." +"..arg2, 0.1, 0.1, 1)
  288. end
  289. end
  290. elseif subevent == "FACTION" and COMBAT_TEXT_SHOW_REPUTATION == "1" then
  291. xCT3:AddMessage(arg2.." +"..arg3, 0.1, 0.1, 1)
  292. elseif subevent == "SPELL_ACTIVE" and COMBAT_TEXT_SHOW_REACTIVES == "1" then
  293. xCT3:AddMessage(arg2, 1, 0.82, 0)
  294. end
  295. end
  296. elseif event == "UNIT_HEALTH" and COMBAT_TEXT_SHOW_LOW_HEALTH_MANA == "1" then
  297. if subevent == ct.unit then
  298. if UnitHealth(ct.unit) / UnitHealthMax(ct.unit) <= COMBAT_TEXT_LOW_HEALTH_THRESHOLD then
  299. if not lowHealth then
  300. xCT3:AddMessage(HEALTH_LOW, 1, 0.1, 0.1)
  301. lowHealth = true
  302. end
  303. else
  304. lowHealth = nil
  305. end
  306. end
  307. elseif event == "UNIT_MANA" and COMBAT_TEXT_SHOW_LOW_HEALTH_MANA == "1" then
  308. if subevent == ct.unit then
  309. local _, powerToken = UnitPowerType(ct.unit)
  310. if powerToken == "MANA" and (UnitPower(ct.unit) / UnitPowerMax(ct.unit)) <= COMBAT_TEXT_LOW_MANA_THRESHOLD then
  311. if not lowMana then
  312. xCT3:AddMessage(MANA_LOW, 1, 0.1, 0.1)
  313. lowMana = true
  314. end
  315. else
  316. lowMana = nil
  317. end
  318. end
  319. elseif event == "PLAYER_REGEN_ENABLED" and COMBAT_TEXT_SHOW_COMBAT_STATE == "1" then
  320. xCT3:AddMessage("-"..LEAVING_COMBAT, 0.1, 1, 0.1)
  321. elseif event == "PLAYER_REGEN_DISABLED" and COMBAT_TEXT_SHOW_COMBAT_STATE == "1" then
  322. xCT3:AddMessage("+"..ENTERING_COMBAT, 1, 0.1, 0.1)
  323. elseif event == "UNIT_COMBO_POINTS" and COMBAT_TEXT_SHOW_COMBO_POINTS == "1" then
  324. if subevent == ct.unit then
  325. local cp = GetComboPoints(ct.unit, "target")
  326. if cp > 0 then
  327. r, g, b = 1, 0.82, 0
  328. if cp == MAX_COMBO_POINTS then
  329. r, g, b = 0, 0.82, 1
  330. end
  331. xCT3:AddMessage(format(COMBAT_TEXT_COMBO_POINTS, cp), r, g, b)
  332. end
  333. end
  334. elseif event == "RUNE_POWER_UPDATE" then
  335. local arg1 = subevent
  336. if GetRuneCooldown(arg1) ~= 0 then return end
  337. xCT3:AddMessage("+"..COMBAT_TEXT_RUNE_DEATH, 0.75, 0, 0)
  338. elseif event == "UNIT_ENTERED_VEHICLE" or event == "UNIT_EXITING_VEHICLE" then
  339. if arg1 == "player" then
  340. SetUnit()
  341. end
  342. elseif event == "PLAYER_ENTERING_WORLD" then
  343. SetUnit()
  344. if C.combattext.scrollable then
  345. SetScroll()
  346. else
  347. LimitLines()
  348. end
  349. if C.combattext.damage or C.combattext.healing then
  350. ct.pguid = UnitGUID("player")
  351. end
  352. end
  353. end
  354.  
  355. -- Change damage font
  356. if C.combattext.damage_style then
  357. DAMAGE_TEXT_FONT = C.font.combat_text_font
  358. end
  359.  
  360. -- Hide blizzard combat text
  361. if C.combattext.blizz_head_numbers ~= true then
  362. SetCVar("floatingCombatTextCombatHealing", 0)
  363. SetCVar("floatingCombatTextCombatDamage", 0)
  364. else
  365. SetCVar("floatingCombatTextCombatHealing", 1)
  366. SetCVar("floatingCombatTextCombatDamage", 1)
  367. end
  368.  
  369. local frame = CreateFrame("Frame")
  370. frame:RegisterEvent("PLAYER_LOGOUT")
  371. frame:SetScript("OnEvent", function(self, event)
  372. if event == "PLAYER_LOGOUT" then
  373. SetCVar("floatingCombatTextCombatHealing", 1)
  374. SetCVar("floatingCombatTextCombatDamage", 1)
  375. end
  376. end)
  377.  
  378. -- Frames
  379. ct.locked = true
  380. ct.frames = {}
  381. for i = 1, numf do
  382. local f = CreateFrame("ScrollingMessageFrame", "xCT"..i, UIParent)
  383. f:SetFont(C.font.combat_text_font, C.font.combat_text_font_size, C.font.combat_text_font_style)
  384. f:SetShadowColor(0, 0, 0, C.font.combat_text_font_shadow and 1 or 0)
  385. f:SetShadowOffset(C.font.combat_text_font_shadow and 1 or 0, C.font.combat_text_font_shadow and -1 or 0)
  386. f:SetTimeVisible(C.combattext.time_visible)
  387. f:SetMaxLines(C.combattext.max_lines)
  388. f:SetSpacing(1)
  389. f:SetWidth(128)
  390. f:SetHeight(112)
  391. f:SetPoint("CENTER", 0, 0)
  392. f:SetMovable(true)
  393. f:SetResizable(true)
  394. f:SetMinResize(128, 128)
  395. f:SetMaxResize(768, 768)
  396. f:SetClampedToScreen(true)
  397. f:SetClampRectInsets(0, 0, C.font.combat_text_font_size, 0)
  398. f:SetInsertMode(C.combattext.direction or "bottom")
  399. if i == 1 then
  400. f:SetJustifyH(ct.justify_1)
  401. if C.unitframe.enable == true and _G.oUF_Player then
  402. f:SetPoint("BOTTOMLEFT", "oUF_Player", "TOPLEFT", -3, 60)
  403. else
  404. f:SetPoint("CENTER", -192, -32)
  405. end
  406. elseif i == 2 then
  407. f:SetJustifyH(ct.justify_2)
  408. if C.unitframe.enable == true and _G.oUF_Player then
  409. f:SetPoint("BOTTOMRIGHT", "oUF_Player", "TOPRIGHT", 5, 60)
  410. else
  411. f:SetPoint("CENTER", 192, -32)
  412. end
  413. elseif i == 3 then
  414. f:SetJustifyH(ct.justify_3)
  415. f:SetWidth(256)
  416. f:SetPoint("CENTER", 0, 205)
  417. else
  418. f:SetJustifyH(ct.justify_4)
  419. f:SetWidth(200)
  420. if C.combattext.icons then
  421. f:SetHeight(150)
  422. end
  423. if C.unitframe.enable == true and _G.oUF_Target then
  424. f:SetPoint("BOTTOMRIGHT", "oUF_Target", "TOPRIGHT", 2, 278)
  425. else
  426. f:SetPoint("CENTER", 330, 205)
  427. end
  428. local a, _, c = f:GetFont()
  429. if C.font.combat_text_font_size == "auto" then
  430. if C.combattext.icons then
  431. f:SetFont(a, C.combattext.icon_size / 2, c)
  432. end
  433. elseif type(C.font.combat_text_font_size) == "number" then
  434. f:SetFont(a, C.font.combat_text_font_size, c)
  435. end
  436. end
  437. ct.frames[i] = f
  438. end
  439.  
  440. -- Register events
  441. local xCT = CreateFrame("Frame")
  442. xCT:RegisterEvent("COMBAT_TEXT_UPDATE")
  443. xCT:RegisterEvent("UNIT_HEALTH")
  444. xCT:RegisterEvent("UNIT_MANA")
  445. xCT:RegisterEvent("PLAYER_REGEN_DISABLED")
  446. xCT:RegisterEvent("PLAYER_REGEN_ENABLED")
  447. xCT:RegisterEvent("UNIT_COMBO_POINTS")
  448. if C.combattext.dk_runes and T.class == "DEATHKNIGHT" then
  449. xCT:RegisterEvent("RUNE_POWER_UPDATE")
  450. end
  451. xCT:RegisterEvent("UNIT_ENTERED_VEHICLE")
  452. xCT:RegisterEvent("UNIT_EXITING_VEHICLE")
  453. xCT:RegisterEvent("PLAYER_ENTERING_WORLD")
  454. xCT:SetScript("OnEvent", OnEvent)
  455.  
  456. -- Turn off Blizzard CT
  457. CombatText:UnregisterAllEvents()
  458. CombatText:SetScript("OnLoad", nil)
  459. CombatText:SetScript("OnEvent", nil)
  460. CombatText:SetScript("OnUpdate", nil)
  461.  
  462. -- Steal external messages sent by other addons using CombatText_AddMessage
  463. hooksecurefunc("CombatText_AddMessage", function(message, scrollFunction, r, g, b, displayType, isStaggered)
  464. local lastEntry = COMBAT_TEXT_TO_ANIMATE[#COMBAT_TEXT_TO_ANIMATE]
  465. CombatText_RemoveMessage(lastEntry)
  466. xCT3:AddMessage(message, r, g, b)
  467. end)
  468.  
  469. -- Color printer
  470. local pr = function(msg)
  471. print(tostring(msg))
  472. end
  473.  
  474. -- Configmode and testmode
  475. local StartConfigmode = function()
  476. if not InCombatLockdown()then
  477. for i = 1, #ct.frames do
  478. f = ct.frames[i]
  479. f:SetTemplate("Transparent")
  480. f:SetBackdropBorderColor(1, 0, 0, 1)
  481.  
  482. f.fs = f:CreateFontString(nil, "OVERLAY")
  483. f.fs:SetFont(C.font.combat_text_font, C.font.combat_text_font_size, C.font.combat_text_font_style)
  484. f.fs:SetPoint("BOTTOM", f, "TOP", 0, 0)
  485. if i == 1 then
  486. f.fs:SetText(DAMAGE)
  487. f.fs:SetTextColor(1, 0.1, 0.1, 0.9)
  488. elseif i == 2 then
  489. f.fs:SetText(SHOW_COMBAT_HEALING)
  490. f.fs:SetTextColor(0.1, 1, 0.1, 0.9)
  491. elseif i == 3 then
  492. f.fs:SetText(COMBAT_TEXT_LABEL)
  493. f.fs:SetTextColor(0.1, 0.1, 1, 0.9)
  494. else
  495. f.fs:SetText(SCORE_DAMAGE_DONE.." / "..SCORE_HEALING_DONE)
  496. f.fs:SetTextColor(1, 1, 0, 0.9)
  497. end
  498.  
  499. f.t = f:CreateTexture("ARTWORK")
  500. f.t:SetPoint("TOPLEFT", f, "TOPLEFT", 1, -1)
  501. f.t:SetPoint("TOPRIGHT", f, "TOPRIGHT", -1, -19)
  502. f.t:SetHeight(20)
  503. f.t:SetColorTexture(0.5, 0.5, 0.5)
  504. f.t:SetAlpha(0.3)
  505.  
  506. f.d = f:CreateTexture("ARTWORK")
  507. f.d:SetHeight(16)
  508. f.d:SetWidth(16)
  509. f.d:SetPoint("BOTTOMRIGHT", f, "BOTTOMRIGHT", -1, 1)
  510. f.d:SetColorTexture(0.5, 0.5, 0.5)
  511. f.d:SetAlpha(0.3)
  512.  
  513. if not f.tr then
  514. f.tr = CreateFrame("Frame", nil, f)
  515. f.tr:SetScript("OnDragStart", function(self, button)
  516. self:GetParent():StartMoving()
  517. end)
  518. f.tr:SetScript("OnDragStop", function(self)
  519. self:GetParent():StopMovingOrSizing()
  520. end)
  521. f.tr:EnableMouse(true)
  522. f.tr:RegisterForDrag("LeftButton")
  523. f.tr:SetPoint("TOPLEFT", f, "TOPLEFT", 0, 0)
  524. f.tr:SetPoint("TOPRIGHT", f, "TOPRIGHT", 0, 0)
  525. f.tr:SetHeight(20)
  526. end
  527.  
  528. f:EnableMouse(true)
  529. f:RegisterForDrag("LeftButton")
  530. f:SetScript("OnDragStart", f.StartSizing)
  531. if not C.combattext.scrollable then
  532. if i == 4 and C.combattext.icons then
  533. f:SetScript("OnSizeChanged", function(self)
  534. self:SetMaxLines(math.floor(self:GetHeight() / (C.combattext.icon_size * 1.5)))
  535. self:Clear()
  536. end)
  537. else
  538. f:SetScript("OnSizeChanged", function(self)
  539. self:SetMaxLines(math.floor(self:GetHeight() / C.font.combat_text_font_size - 1))
  540. self:Clear()
  541. end)
  542. end
  543. end
  544.  
  545. f:SetScript("OnDragStop", f.StopMovingOrSizing)
  546. ct.locked = false
  547. end
  548. pr("|cffffff00"..L_COMBATTEXT_UNLOCKED.."|r")
  549. else
  550. pr("|cffffff00"..ERR_NOT_IN_COMBAT.."|r")
  551. end
  552. end
  553.  
  554. local function EndConfigmode()
  555. for i = 1, #ct.frames do
  556. f = ct.frames[i]
  557. f:SetBackdrop(nil)
  558. f.iborder:Hide()
  559. f.oborder:Hide()
  560. f.fs:Hide()
  561. f.fs = nil
  562. f.t:Hide()
  563. f.t = nil
  564. f.d:Hide()
  565. f.d = nil
  566. f.tr = nil
  567. f:EnableMouse(false)
  568. f:SetScript("OnDragStart", nil)
  569. f:SetScript("OnDragStop", nil)
  570. end
  571. ct.locked = true
  572. pr("|cffffff00"..L_COMBATTEXT_UNSAVED.."|r")
  573. end
  574.  
  575. local function StartTestMode()
  576. -- Init random number generator
  577. local random = math.random
  578. random(time()); random(); random(time())
  579.  
  580. local TimeSinceLastUpdate = 0
  581. local UpdateInterval
  582. if C.combattext.damage_color then
  583. ct.dmindex = {}
  584. ct.dmindex[1] = 1
  585. ct.dmindex[2] = 2
  586. ct.dmindex[3] = 4
  587. ct.dmindex[4] = 8
  588. ct.dmindex[5] = 16
  589. ct.dmindex[6] = 32
  590. ct.dmindex[7] = 64
  591. end
  592.  
  593. for i = 1, #ct.frames do
  594. ct.frames[i]:SetScript("OnUpdate", function(self, elapsed)
  595. UpdateInterval = random(65, 100) / 250
  596. TimeSinceLastUpdate = TimeSinceLastUpdate + elapsed
  597. if TimeSinceLastUpdate > UpdateInterval then
  598. if i == 1 then
  599. ct.frames[i]:AddMessage("-"..random(100000), 1, random(255) / 255, random(255) / 255)
  600. elseif i == 2 then
  601. ct.frames[i]:AddMessage("+"..random(50000), 0.1, random(128, 255) / 255, 0.1)
  602. elseif i == 3 then
  603. ct.frames[i]:AddMessage(COMBAT_TEXT_LABEL, random(255) / 255, random(255) / 255, random(255) / 255)
  604. elseif i == 4 then
  605. local msg
  606. local icon
  607. local color = {}
  608. msg = random(40000)
  609. if C.combattext.icons then
  610. _, _, icon = GetSpellInfo(msg)
  611. if not icon then
  612. icon = GetSpellTexture(6603)
  613. end
  614. end
  615. if icon then
  616. msg = msg.." \124T"..icon..":"..C.combattext.icon_size..":"..C.combattext.icon_size..":0:0:64:64:5:59:5:59\124t"
  617. if C.combattext.damage_color then
  618. color = ct.dmgcolor[ct.dmindex[random(#ct.dmindex)]]
  619. else
  620. color = {1, 1, 0}
  621. end
  622. elseif C.combattext.damage_color and not C.combattext.icons then
  623. color = ct.dmgcolor[ct.dmindex[random(#ct.dmindex)]]
  624. elseif not C.combattext.damage_color then
  625. color = {1, 1, random(0, 1)}
  626. end
  627. ct.frames[i]:AddMessage(msg, unpack(color))
  628. end
  629. TimeSinceLastUpdate = 0
  630. end
  631. end)
  632. ct.testmode = true
  633. end
  634. end
  635.  
  636. local function EndTestMode()
  637. for i = 1, #ct.frames do
  638. ct.frames[i]:SetScript("OnUpdate", nil)
  639. ct.frames[i]:Clear()
  640. end
  641. if C.combattext.damage_color then
  642. ct.dmindex = nil
  643. end
  644. ct.testmode = false
  645. end
  646.  
  647. -- Popup dialog
  648. StaticPopupDialogs.XCT_LOCK = {
  649. text = L_COMBATTEXT_POPUP,
  650. button1 = ACCEPT,
  651. button2 = CANCEL,
  652. OnAccept = function() if not InCombatLockdown() then ReloadUI() else EndConfigmode() end end,
  653. OnCancel = EndConfigmode,
  654. timeout = 0,
  655. whileDead = 1,
  656. hideOnEscape = true,
  657. showAlert = true,
  658. preferredIndex = 5,
  659. }
  660.  
  661. local placed = {
  662. "xCT1",
  663. "xCT2",
  664. "xCT3",
  665. "xCT4"
  666. }
  667.  
  668. -- Slash commands
  669. SlashCmdList.XCT = function(input)
  670. input = string.lower(input)
  671. if input == "unlock" then
  672. if ct.locked then
  673. StartConfigmode()
  674. else
  675. pr("|cffffff00"..L_COMBATTEXT_ALREADY_UNLOCKED.."|r")
  676. end
  677. elseif input == "lock" then
  678. if ct.locked then
  679. pr("|cffffff00"..L_COMBATTEXT_ALREADY_LOCKED.."|r")
  680. else
  681. StaticPopup_Show("XCT_LOCK")
  682. end
  683. elseif input == "test" then
  684. if ct.testmode then
  685. EndTestMode()
  686. pr("|cffffff00"..L_COMBATTEXT_TEST_DISABLED.."|r")
  687. else
  688. StartTestMode()
  689. pr("|cffffff00"..L_COMBATTEXT_TEST_ENABLED.."|r")
  690. end
  691. elseif input == "reset" then
  692. for i, v in pairs(placed) do
  693. if _G[v] then
  694. _G[v]:SetUserPlaced(false)
  695. end
  696. end
  697. ReloadUI()
  698. else
  699. pr("|cffffff00"..L_COMBATTEXT_TEST_USE_UNLOCK.."|r")
  700. pr("|cffffff00"..L_COMBATTEXT_TEST_USE_LOCK.."|r")
  701. pr("|cffffff00"..L_COMBATTEXT_TEST_USE_TEST.."|r")
  702. end
  703. end
  704. SLASH_XCT1 = "/xct"
  705. SLASH_XCT2 = "/ั‡ัะต"
  706.  
  707. -- Spam merger
  708. local SQ
  709. if C.combattext.merge_aoe_spam then
  710. if C.combattext.damage or C.combattext.healing then
  711. local pairs = pairs
  712. SQ = {}
  713. for k, v in pairs(T.aoespam) do
  714. SQ[k] = {queue = 0, msg = "", color = {}, count = 0, utime = 0, locked = false}
  715. end
  716. ct.SpamQueue = function(spellId, add)
  717. local amount
  718. local spam = SQ[spellId]["queue"]
  719. if spam and type(spam) == "number" then
  720. amount = spam + add
  721. else
  722. amount = add
  723. end
  724. return amount
  725. end
  726. local tslu = 0
  727. local xCTspam = CreateFrame("Frame")
  728. xCTspam:SetScript("OnUpdate", function(self, elapsed)
  729. local count
  730. tslu = tslu + elapsed
  731. if tslu > 0.5 then
  732. tslu = 0
  733. local utime = time()
  734. for k, v in pairs(SQ) do
  735. if not SQ[k]["locked"] and SQ[k]["queue"] > 0 and SQ[k]["utime"] <= utime then
  736. if SQ[k]["count"] > 1 then
  737. count = " |cffFFFFFF x "..SQ[k]["count"].."|r"
  738. else
  739. count = ""
  740. end
  741. if C.combattext.short_numbers == true then
  742. SQ[k]["queue"] = T.ShortValue(SQ[k]["queue"])
  743. end
  744. xCT4:AddMessage(SQ[k]["queue"]..count..SQ[k]["msg"], unpack(SQ[k]["color"]))
  745. SQ[k]["queue"] = 0
  746. SQ[k]["count"] = 0
  747. end
  748. end
  749. end
  750. end)
  751. end
  752. end
  753.  
  754. -- Damage
  755. if C.combattext.damage then
  756. local unpack, select, time = unpack, select, time
  757. local gflags = bit.bor(COMBATLOG_OBJECT_AFFILIATION_MINE,
  758. COMBATLOG_OBJECT_REACTION_FRIENDLY,
  759. COMBATLOG_OBJECT_CONTROL_PLAYER,
  760. COMBATLOG_OBJECT_TYPE_GUARDIAN
  761. )
  762. local xCTd = CreateFrame("Frame")
  763. if C.combattext.damage_color then
  764. ct.dmgcolor = {}
  765. ct.dmgcolor[1] = {1, 1, 0} -- Physical
  766. ct.dmgcolor[2] = {1, 0.9, 0.5} -- Holy
  767. ct.dmgcolor[4] = {1, 0.5, 0} -- Fire
  768. ct.dmgcolor[8] = {0.3, 1, 0.3} -- Nature
  769. ct.dmgcolor[16] = {0.5, 1, 1} -- Frost
  770. ct.dmgcolor[32] = {0.5, 0.5, 1} -- Shadow
  771. ct.dmgcolor[64] = {1, 0.5, 1} -- Arcane
  772. end
  773. if C.combattext.icons then
  774. ct.blank = "Interface\\AddOns\\ShestakUI\\Media\\Textures\\Blank.tga"
  775. end
  776. local misstypes = {ABSORB = ABSORB, BLOCK = BLOCK, DEFLECT = DEFLECT, DODGE = DODGE, EVADE = EVADE, IMMUNE = IMMUNE, MISS = MISS, MISFIRE = MISS, PARRY = PARRY, REFLECT = REFLECT, RESIST = RESIST}
  777. local dmg = function(self, event, ...)
  778. local msg, icon
  779. local eventType, _, sourceGUID, _, sourceFlags, _, destGUID = select(2, ...)
  780. if (sourceGUID == ct.pguid and destGUID ~= ct.pguid) or (sourceGUID == UnitGUID("pet") and C.combattext.pet_damage) or (sourceFlags == gflags) then
  781. if eventType == "SWING_DAMAGE" then
  782. local amount, _, _, _, _, _, critical = select(12, ...)
  783. if amount >= C.combattext.treshold then
  784. local rawamount = amount
  785. if C.combattext.short_numbers == true then
  786. amount = T.ShortValue(amount)
  787. end
  788. if critical then
  789. amount = "|cffFF0000"..C.combattext.crit_prefix.."|r"..amount.."|cffFF0000"..C.combattext.crit_postfix.."|r"
  790. end
  791. if C.combattext.icons then
  792. if (sourceGUID == UnitGUID("pet")) or (sourceFlags == gflags) then
  793. icon = PET_ATTACK_TEXTURE
  794. else
  795. icon = GetSpellTexture(6603)
  796. end
  797. msg = " \124T"..icon..":"..C.combattext.icon_size..":"..C.combattext.icon_size..":0:0:64:64:5:59:5:59\124t"
  798. end
  799. local color = {1, 1, 1}
  800. if C.combattext.merge_aoe_spam and C.combattext.merge_melee then
  801. local spellId = 6603
  802. SQ[spellId]["locked"] = true
  803. SQ[spellId]["queue"] = ct.SpamQueue(spellId, rawamount)
  804. SQ[spellId]["msg"] = msg
  805. SQ[spellId]["color"] = color
  806. SQ[spellId]["count"] = SQ[spellId]["count"] + 1
  807. if SQ[spellId]["count"] == 1 then
  808. SQ[spellId]["utime"] = time() + T.aoespam[spellId]
  809. end
  810. SQ[spellId]["locked"] = false
  811. return
  812. end
  813. xCT4:AddMessage(amount..""..msg, unpack(color))
  814. end
  815. elseif eventType == "RANGE_DAMAGE" then
  816. local spellId, _, _, amount, _, _, _, _, _, critical = select(12, ...)
  817. if amount >= C.combattext.treshold then
  818. local rawamount = amount
  819. if C.combattext.short_numbers == true then
  820. amount = T.ShortValue(amount)
  821. end
  822. if critical then
  823. amount = "|cffFF0000"..C.combattext.crit_prefix.."|r"..amount.."|cffFF0000"..C.combattext.crit_postfix.."|r"
  824. end
  825. if C.combattext.icons then
  826. icon = GetSpellTexture(spellId)
  827. msg = " \124T"..icon..":"..C.combattext.icon_size..":"..C.combattext.icon_size..":0:0:64:64:5:59:5:59\124t"
  828. end
  829. if C.combattext.merge_aoe_spam then
  830. spellId = T.merge[spellId] or spellId
  831. if T.aoespam[spellId] then
  832. SQ[spellId]["locked"] = true
  833. SQ[spellId]["queue"] = ct.SpamQueue(spellId, rawamount)
  834. SQ[spellId]["msg"] = msg
  835. SQ[spellId]["count"] = SQ[spellId]["count"] + 1
  836. if SQ[spellId]["count"] == 1 then
  837. SQ[spellId]["utime"] = time() + T.aoespam[spellId]
  838. end
  839. SQ[spellId]["locked"] = false
  840. return
  841. end
  842. end
  843. xCT4:AddMessage(amount..""..msg)
  844. end
  845. elseif eventType == "SPELL_DAMAGE" or (eventType == "SPELL_PERIODIC_DAMAGE" and C.combattext.dot_damage) then
  846. local spellId, _, spellSchool, amount, _, _, _, _, _, critical = select(12, ...)
  847. if amount >= C.combattext.treshold then
  848. local color = {}
  849. local rawamount = amount
  850. if C.combattext.short_numbers == true then
  851. amount = T.ShortValue(amount)
  852. end
  853. if critical then
  854. amount = "|cffFF0000"..C.combattext.crit_prefix.."|r"..amount.."|cffFF0000"..C.combattext.crit_postfix.."|r"
  855. end
  856. if C.combattext.icons then
  857. icon = GetSpellTexture(spellId)
  858. end
  859. if C.combattext.damage_color then
  860. if ct.dmgcolor[spellSchool] then
  861. color = ct.dmgcolor[spellSchool]
  862. else
  863. color = ct.dmgcolor[1]
  864. end
  865. else
  866. color = {1, 1, 0}
  867. end
  868. if icon then
  869. msg = " \124T"..icon..":"..C.combattext.icon_size..":"..C.combattext.icon_size..":0:0:64:64:5:59:5:59\124t"
  870. elseif C.combattext.icons then
  871. msg = " \124T"..ct.blank..":"..C.combattext.icon_size..":"..C.combattext.icon_size..":0:0:64:64:5:59:5:59\124t"
  872. else
  873. msg = ""
  874. end
  875. if C.combattext.merge_aoe_spam then
  876. spellId = T.merge[spellId] or spellId
  877. if sourceFlags == gflags then
  878. spellId = 6603
  879. end
  880. if T.aoespam[spellId] then
  881. SQ[spellId]["locked"] = true
  882. SQ[spellId]["queue"] = ct.SpamQueue(spellId, rawamount)
  883. SQ[spellId]["msg"] = msg
  884. SQ[spellId]["color"] = color
  885. SQ[spellId]["count"] = SQ[spellId]["count"] + 1
  886. if SQ[spellId]["count"] == 1 then
  887. SQ[spellId]["utime"] = time() + T.aoespam[spellId]
  888. end
  889. SQ[spellId]["locked"] = false
  890. return
  891. end
  892. end
  893. xCT4:AddMessage(amount..""..msg, unpack(color))
  894. end
  895. elseif eventType == "SWING_MISSED" then
  896. local missType = select(12, ...)
  897. if C.combattext.icons then
  898. if sourceGUID == UnitGUID("pet") or sourceFlags == gflags then
  899. icon = PET_ATTACK_TEXTURE
  900. else
  901. icon = GetSpellTexture(6603)
  902. end
  903. missType = misstypes[missType].." \124T"..icon..":"..C.combattext.icon_size..":"..C.combattext.icon_size..":0:0:64:64:5:59:5:59\124t"
  904. else
  905. missType = misstypes[missType]
  906. end
  907. xCT4:AddMessage(missType)
  908. elseif eventType == "SPELL_MISSED" or eventType == "RANGE_MISSED" then
  909. local spellId, _, _, missType = select(12, ...)
  910. if missType == "IMMUNE" and spellId == 118895 then return end
  911. if C.combattext.icons then
  912. icon = GetSpellTexture(spellId)
  913. missType = misstypes[missType].." \124T"..icon..":"..C.combattext.icon_size..":"..C.combattext.icon_size..":0:0:64:64:5:59:5:59\124t"
  914. else
  915. missType = misstypes[missType]
  916. end
  917. xCT4:AddMessage(missType)
  918. elseif eventType == "SPELL_DISPEL" and C.combattext.dispel then
  919. local id, effect, _, etype = select(15, ...)
  920. local color
  921. if C.combattext.icons then
  922. icon = GetSpellTexture(id)
  923. end
  924. if icon then
  925. msg = " \124T"..icon..":"..C.combattext.icon_size..":"..C.combattext.icon_size..":0:0:64:64:5:59:5:59\124t"
  926. elseif C.combattext.icons then
  927. msg = " \124T"..ct.blank..":"..C.combattext.icon_size..":"..C.combattext.icon_size..":0:0:64:64:5:59:5:59\124t"
  928. else
  929. msg = ""
  930. end
  931. if etype == "BUFF" then
  932. color = {0, 1, 0.5}
  933. else
  934. color = {1, 0, 0.5}
  935. end
  936. xCT3:AddMessage(ACTION_SPELL_DISPEL..": "..effect..msg, unpack(color))
  937. elseif eventType == "SPELL_STOLEN" and C.combattext.dispel then
  938. local id, effect = select(15, ...)
  939. local color = {1, 0.5, 0}
  940. if C.combattext.icons then
  941. icon = GetSpellTexture(id)
  942. end
  943. if icon then
  944. msg = " \124T"..icon..":"..C.combattext.icon_size..":"..C.combattext.icon_size..":0:0:64:64:5:59:5:59\124t"
  945. elseif C.combattext.icons then
  946. msg = " \124T"..ct.blank..":"..C.combattext.icon_size..":"..C.combattext.icon_size..":0:0:64:64:5:59:5:59\124t"
  947. else
  948. msg = ""
  949. end
  950. xCT3:AddMessage(ACTION_SPELL_STOLEN..": "..effect..msg, unpack(color))
  951. elseif eventType == "SPELL_INTERRUPT" and C.combattext.interrupt then
  952. local id, effect = select(15, ...)
  953. local color = {1, 0.5, 0}
  954. if C.combattext.icons then
  955. icon = GetSpellTexture(id)
  956. end
  957. if icon then
  958. msg = " \124T"..icon..":"..C.combattext.icon_size..":"..C.combattext.icon_size..":0:0:64:64:5:59:5:59\124t"
  959. elseif C.combattext.icons then
  960. msg = " \124T"..ct.blank..":"..C.combattext.icon_size..":"..C.combattext.icon_size..":0:0:64:64:5:59:5:59\124t"
  961. else
  962. msg = ""
  963. end
  964. xCT3:AddMessage(ACTION_SPELL_INTERRUPT..": "..effect..msg, unpack(color))
  965. elseif eventType == "PARTY_KILL" and C.combattext.killingblow then
  966. local destGUID, tname = select(8, ...)
  967. local classIndex = select(2, GetPlayerInfoByGUID(destGUID))
  968. local color = classIndex and RAID_CLASS_COLORS[classIndex] or {r = 0.2, g = 1, b = 0.2}
  969. xCT3:AddMessage("|cff33FF33"..ACTION_PARTY_KILL..": |r"..tname, color.r, color.g, color.b)
  970. end
  971. end
  972. end
  973.  
  974. xCTd:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
  975. xCTd:SetScript("OnEvent", dmg)
  976. end
  977.  
  978. -- Healing
  979. if C.combattext.healing then
  980. local unpack, select, time = unpack, select, time
  981. local xCTh = CreateFrame("Frame")
  982. if C.combattext.icons then
  983. ct.blank = "Interface\\AddOns\\ShestakUI\\Media\\Textures\\Blank.tga"
  984. end
  985. local heal = function(self, event, ...)
  986. local msg, icon
  987. local eventType, _, sourceGUID, _, sourceFlags = select(2, ...)
  988. if sourceGUID == ct.pguid or sourceFlags == gflags then
  989. if eventType == "SPELL_HEAL" or (eventType == "SPELL_PERIODIC_HEAL" and C.combattext.show_hots) then
  990. if C.combattext.healing then
  991. local spellId, _, _, amount, overhealing, _, critical = select(12, ...)
  992. if T.healfilter[spellId] then
  993. return
  994. end
  995. if amount >= C.combattext.heal_treshold then
  996. local color = {}
  997. local rawamount = amount
  998. if C.combattext.show_overhealing and abs(overhealing) > 0 then
  999. if C.combattext.short_numbers == true then
  1000. amount = T.ShortValue(math.floor(amount-overhealing)).." ["..T.ShortValue(floor(overhealing)).."]"
  1001. else
  1002. amount = math.floor(amount-overhealing).." ["..floor(overhealing).."]"
  1003. end
  1004. else
  1005. if C.combattext.short_numbers == true then
  1006. amount = T.ShortValue(amount)
  1007. end
  1008. end
  1009.  
  1010. if critical then
  1011. amount = "|cffFF0000"..C.combattext.crit_prefix.."|r"..amount.."|cffFF0000"..C.combattext.crit_postfix.."|r"
  1012. color = {0.1, 1, 0.1}
  1013. else
  1014. color = {0.1, 0.65, 0.1}
  1015. end
  1016. if C.combattext.icons then
  1017. icon = GetSpellTexture(spellId)
  1018. else
  1019. msg = ""
  1020. end
  1021. if icon then
  1022. msg = " \124T"..icon..":"..C.combattext.icon_size..":"..C.combattext.icon_size..":0:0:64:64:5:59:5:59\124t"
  1023. elseif C.combattext.icons then
  1024. msg = " \124T"..ct.blank..":"..C.combattext.icon_size..":"..C.combattext.icon_size..":0:0:64:64:5:59:5:59\124t"
  1025. end
  1026. if C.combattext.merge_aoe_spam then
  1027. spellId = T.merge[spellId] or spellId
  1028. if T.aoespam[spellId] then
  1029. SQ[spellId]["locked"] = true
  1030. SQ[spellId]["queue"] = ct.SpamQueue(spellId, rawamount)
  1031. SQ[spellId]["msg"] = msg
  1032. SQ[spellId]["color"] = color
  1033. SQ[spellId]["count"] = SQ[spellId]["count"] + 1
  1034. if SQ[spellId]["count"] == 1 then
  1035. SQ[spellId]["utime"] = time() + T.aoespam[spellId]
  1036. end
  1037. SQ[spellId]["locked"] = false
  1038. return
  1039. end
  1040. end
  1041. xCT4:AddMessage(amount..""..msg, unpack(color))
  1042. end
  1043. end
  1044. end
  1045. end
  1046. end
  1047.  
  1048. xCTh:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
  1049. xCTh:SetScript("OnEvent", heal)
  1050. end
  1051.  
  1052. -- Check outdated spells
  1053. if C.combattext.merge_aoe_spam then
  1054. for spell in pairs(T.aoespam) do
  1055. local name = GetSpellInfo(spell)
  1056. if not name then
  1057. print("|cffff0000WARNING: spell ID ["..tostring(spell).."] no longer exists! Report this to Shestak.|r")
  1058. end
  1059. end
  1060.  
  1061. for spell in pairs(T.merge) do
  1062. local name = GetSpellInfo(spell)
  1063. if not name then
  1064. print("|cffff0000WARNING: spell ID ["..tostring(spell).."] no longer exists! Report this to Shestak.|r")
  1065. end
  1066. end
  1067. end
  1068.  
  1069. if C.combattext.healing then
  1070. for spell in pairs(T.healfilter) do
  1071. local name = GetSpellInfo(spell)
  1072. if not name then
  1073. print("|cffff0000WARNING: spell ID ["..tostring(spell).."] no longer exists! Report this to Shestak.|r")
  1074. end
  1075. end
  1076. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement