Advertisement
Wetxius

Untitled

Dec 15th, 2016
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 36.46 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) - 1))
  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. f:SetScript("OnSizeChanged", function(self)
  533. self:SetMaxLines(math.floor(self:GetHeight() / C.font.combat_text_font_size - 1))
  534. self:Clear()
  535. end)
  536. end
  537.  
  538. f:SetScript("OnDragStop", f.StopMovingOrSizing)
  539. ct.locked = false
  540. end
  541. pr("|cffffff00"..L_COMBATTEXT_UNLOCKED.."|r")
  542. else
  543. pr("|cffffff00"..ERR_NOT_IN_COMBAT.."|r")
  544. end
  545. end
  546.  
  547. local function EndConfigmode()
  548. for i = 1, #ct.frames do
  549. f = ct.frames[i]
  550. f:SetBackdrop(nil)
  551. f.iborder:Hide()
  552. f.oborder:Hide()
  553. f.fs:Hide()
  554. f.fs = nil
  555. f.t:Hide()
  556. f.t = nil
  557. f.d:Hide()
  558. f.d = nil
  559. f.tr = nil
  560. f:EnableMouse(false)
  561. f:SetScript("OnDragStart", nil)
  562. f:SetScript("OnDragStop", nil)
  563. end
  564. ct.locked = true
  565. pr("|cffffff00"..L_COMBATTEXT_UNSAVED.."|r")
  566. end
  567.  
  568. local function StartTestMode()
  569. -- Init random number generator
  570. local random = math.random
  571. random(time()); random(); random(time())
  572.  
  573. local TimeSinceLastUpdate = 0
  574. local UpdateInterval
  575. if C.combattext.damage_color then
  576. ct.dmindex = {}
  577. ct.dmindex[1] = 1
  578. ct.dmindex[2] = 2
  579. ct.dmindex[3] = 4
  580. ct.dmindex[4] = 8
  581. ct.dmindex[5] = 16
  582. ct.dmindex[6] = 32
  583. ct.dmindex[7] = 64
  584. end
  585.  
  586. for i = 1, #ct.frames do
  587. ct.frames[i]:SetScript("OnUpdate", function(self, elapsed)
  588. UpdateInterval = random(65, 100) / 250
  589. TimeSinceLastUpdate = TimeSinceLastUpdate + elapsed
  590. if TimeSinceLastUpdate > UpdateInterval then
  591. if i == 1 then
  592. ct.frames[i]:AddMessage("-"..random(100000), 1, random(255) / 255, random(255) / 255)
  593. elseif i == 2 then
  594. ct.frames[i]:AddMessage("+"..random(50000), 0.1, random(128, 255) / 255, 0.1)
  595. elseif i == 3 then
  596. ct.frames[i]:AddMessage(COMBAT_TEXT_LABEL, random(255) / 255, random(255) / 255, random(255) / 255)
  597. elseif i == 4 then
  598. local msg
  599. local icon = GetSpellTexture(6603)
  600. local color = {}
  601. msg = random(40000)
  602. if C.combattext.icons then
  603. _, _, icon = GetSpellInfo(msg)
  604. end
  605. if icon then
  606. msg = msg.." \124T"..icon..":"..C.combattext.icon_size..":"..C.combattext.icon_size..":0:0:64:64:5:59:5:59\124t"
  607. if C.combattext.damage_color then
  608. color = ct.dmgcolor[ct.dmindex[random(#ct.dmindex)]]
  609. else
  610. color = {1, 1, 0}
  611. end
  612. elseif C.combattext.damage_color and not C.combattext.icons then
  613. color = ct.dmgcolor[ct.dmindex[random(#ct.dmindex)]]
  614. elseif not C.combattext.damage_color then
  615. color = {1, 1, random(0, 1)}
  616. end
  617. ct.frames[i]:AddMessage(msg, unpack(color))
  618. end
  619. TimeSinceLastUpdate = 0
  620. end
  621. end)
  622. ct.testmode = true
  623. end
  624. end
  625.  
  626. local function EndTestMode()
  627. for i = 1, #ct.frames do
  628. ct.frames[i]:SetScript("OnUpdate", nil)
  629. ct.frames[i]:Clear()
  630. end
  631. if C.combattext.damage_color then
  632. ct.dmindex = nil
  633. end
  634. ct.testmode = false
  635. end
  636.  
  637. -- Popup dialog
  638. StaticPopupDialogs.XCT_LOCK = {
  639. text = L_COMBATTEXT_POPUP,
  640. button1 = ACCEPT,
  641. button2 = CANCEL,
  642. OnAccept = function() if not InCombatLockdown() then ReloadUI() else EndConfigmode() end end,
  643. OnCancel = EndConfigmode,
  644. timeout = 0,
  645. whileDead = 1,
  646. hideOnEscape = true,
  647. showAlert = true,
  648. preferredIndex = 5,
  649. }
  650.  
  651. local placed = {
  652. "xCT1",
  653. "xCT2",
  654. "xCT3",
  655. "xCT4"
  656. }
  657.  
  658. -- Slash commands
  659. SlashCmdList.XCT = function(input)
  660. input = string.lower(input)
  661. if input == "unlock" then
  662. if ct.locked then
  663. StartConfigmode()
  664. else
  665. pr("|cffffff00"..L_COMBATTEXT_ALREADY_UNLOCKED.."|r")
  666. end
  667. elseif input == "lock" then
  668. if ct.locked then
  669. pr("|cffffff00"..L_COMBATTEXT_ALREADY_LOCKED.."|r")
  670. else
  671. StaticPopup_Show("XCT_LOCK")
  672. end
  673. elseif input == "test" then
  674. if ct.testmode then
  675. EndTestMode()
  676. pr("|cffffff00"..L_COMBATTEXT_TEST_DISABLED.."|r")
  677. else
  678. StartTestMode()
  679. pr("|cffffff00"..L_COMBATTEXT_TEST_ENABLED.."|r")
  680. end
  681. elseif input == "reset" then
  682. for i, v in pairs(placed) do
  683. if _G[v] then
  684. _G[v]:SetUserPlaced(false)
  685. end
  686. end
  687. ReloadUI()
  688. else
  689. pr("|cffffff00"..L_COMBATTEXT_TEST_USE_UNLOCK.."|r")
  690. pr("|cffffff00"..L_COMBATTEXT_TEST_USE_LOCK.."|r")
  691. pr("|cffffff00"..L_COMBATTEXT_TEST_USE_TEST.."|r")
  692. end
  693. end
  694. SLASH_XCT1 = "/xct"
  695. SLASH_XCT2 = "/ั‡ัะต"
  696.  
  697. -- Spam merger
  698. local SQ
  699. if C.combattext.merge_aoe_spam then
  700. if C.combattext.damage or C.combattext.healing then
  701. local pairs = pairs
  702. SQ = {}
  703. for k, v in pairs(T.aoespam) do
  704. SQ[k] = {queue = 0, msg = "", color = {}, count = 0, utime = 0, locked = false}
  705. end
  706. ct.SpamQueue = function(spellId, add)
  707. local amount
  708. local spam = SQ[spellId]["queue"]
  709. if spam and type(spam) == "number" then
  710. amount = spam + add
  711. else
  712. amount = add
  713. end
  714. return amount
  715. end
  716. local tslu = 0
  717. local xCTspam = CreateFrame("Frame")
  718. xCTspam:SetScript("OnUpdate", function(self, elapsed)
  719. local count
  720. tslu = tslu + elapsed
  721. if tslu > 0.5 then
  722. tslu = 0
  723. local utime = time()
  724. for k, v in pairs(SQ) do
  725. if not SQ[k]["locked"] and SQ[k]["queue"] > 0 and SQ[k]["utime"] <= utime then
  726. if SQ[k]["count"] > 1 then
  727. count = " |cffFFFFFF x "..SQ[k]["count"].."|r"
  728. else
  729. count = ""
  730. end
  731. if C.combattext.short_numbers == true then
  732. SQ[k]["queue"] = T.ShortValue(SQ[k]["queue"])
  733. end
  734. xCT4:AddMessage(SQ[k]["queue"]..count..SQ[k]["msg"], unpack(SQ[k]["color"]))
  735. SQ[k]["queue"] = 0
  736. SQ[k]["count"] = 0
  737. end
  738. end
  739. end
  740. end)
  741. end
  742. end
  743.  
  744. -- Damage
  745. if C.combattext.damage then
  746. local unpack, select, time = unpack, select, time
  747. local gflags = bit.bor(COMBATLOG_OBJECT_AFFILIATION_MINE,
  748. COMBATLOG_OBJECT_REACTION_FRIENDLY,
  749. COMBATLOG_OBJECT_CONTROL_PLAYER,
  750. COMBATLOG_OBJECT_TYPE_GUARDIAN
  751. )
  752. local xCTd = CreateFrame("Frame")
  753. if C.combattext.damage_color then
  754. ct.dmgcolor = {}
  755. ct.dmgcolor[1] = {1, 1, 0} -- Physical
  756. ct.dmgcolor[2] = {1, 0.9, 0.5} -- Holy
  757. ct.dmgcolor[4] = {1, 0.5, 0} -- Fire
  758. ct.dmgcolor[8] = {0.3, 1, 0.3} -- Nature
  759. ct.dmgcolor[16] = {0.5, 1, 1} -- Frost
  760. ct.dmgcolor[32] = {0.5, 0.5, 1} -- Shadow
  761. ct.dmgcolor[64] = {1, 0.5, 1} -- Arcane
  762. end
  763. if C.combattext.icons then
  764. ct.blank = "Interface\\AddOns\\ShestakUI\\Media\\Textures\\Blank.tga"
  765. end
  766. local misstypes = {ABSORB = ABSORB, BLOCK = BLOCK, DEFLECT = DEFLECT, DODGE = DODGE, EVADE = EVADE, IMMUNE = IMMUNE, MISS = MISS, MISFIRE = MISS, PARRY = PARRY, REFLECT = REFLECT, RESIST = RESIST}
  767. local dmg = function(self, event, ...)
  768. local msg, icon
  769. local eventType, _, sourceGUID, _, sourceFlags, _, destGUID = select(2, ...)
  770. if (sourceGUID == ct.pguid and destGUID ~= ct.pguid) or (sourceGUID == UnitGUID("pet") and C.combattext.pet_damage) or (sourceFlags == gflags) then
  771. if eventType == "SWING_DAMAGE" then
  772. local amount, _, _, _, _, _, critical = select(12, ...)
  773. if amount >= C.combattext.treshold then
  774. local rawamount = amount
  775. if C.combattext.short_numbers == true then
  776. amount = T.ShortValue(amount)
  777. end
  778. if critical then
  779. amount = "|cffFF0000"..C.combattext.crit_prefix.."|r"..amount.."|cffFF0000"..C.combattext.crit_postfix.."|r"
  780. end
  781. if C.combattext.icons then
  782. if (sourceGUID == UnitGUID("pet")) or (sourceFlags == gflags) then
  783. icon = PET_ATTACK_TEXTURE
  784. else
  785. icon = GetSpellTexture(6603)
  786. end
  787. msg = " \124T"..icon..":"..C.combattext.icon_size..":"..C.combattext.icon_size..":0:0:64:64:5:59:5:59\124t"
  788. end
  789. local color = {1, 1, 1}
  790. if C.combattext.merge_aoe_spam and C.combattext.merge_melee then
  791. local spellId = 6603
  792. SQ[spellId]["locked"] = true
  793. SQ[spellId]["queue"] = ct.SpamQueue(spellId, rawamount)
  794. SQ[spellId]["msg"] = msg
  795. SQ[spellId]["color"] = color
  796. SQ[spellId]["count"] = SQ[spellId]["count"] + 1
  797. if SQ[spellId]["count"] == 1 then
  798. SQ[spellId]["utime"] = time() + T.aoespam[spellId]
  799. end
  800. SQ[spellId]["locked"] = false
  801. return
  802. end
  803. xCT4:AddMessage(amount..""..msg, unpack(color))
  804. end
  805. elseif eventType == "RANGE_DAMAGE" then
  806. local spellId, _, _, amount, _, _, _, _, _, critical = select(12, ...)
  807. if amount >= C.combattext.treshold then
  808. local rawamount = amount
  809. if C.combattext.short_numbers == true then
  810. amount = T.ShortValue(amount)
  811. end
  812. if critical then
  813. amount = "|cffFF0000"..C.combattext.crit_prefix.."|r"..amount.."|cffFF0000"..C.combattext.crit_postfix.."|r"
  814. end
  815. if C.combattext.icons then
  816. icon = GetSpellTexture(spellId)
  817. msg = " \124T"..icon..":"..C.combattext.icon_size..":"..C.combattext.icon_size..":0:0:64:64:5:59:5:59\124t"
  818. end
  819. if C.combattext.merge_aoe_spam then
  820. spellId = T.merge[spellId] or spellId
  821. if T.aoespam[spellId] then
  822. SQ[spellId]["locked"] = true
  823. SQ[spellId]["queue"] = ct.SpamQueue(spellId, rawamount)
  824. SQ[spellId]["msg"] = msg
  825. SQ[spellId]["count"] = SQ[spellId]["count"] + 1
  826. if SQ[spellId]["count"] == 1 then
  827. SQ[spellId]["utime"] = time() + T.aoespam[spellId]
  828. end
  829. SQ[spellId]["locked"] = false
  830. return
  831. end
  832. end
  833. xCT4:AddMessage(amount..""..msg)
  834. end
  835. elseif eventType == "SPELL_DAMAGE" or (eventType == "SPELL_PERIODIC_DAMAGE" and C.combattext.dot_damage) then
  836. local spellId, _, spellSchool, amount, _, _, _, _, _, critical = select(12, ...)
  837. if amount >= C.combattext.treshold then
  838. local color = {}
  839. local rawamount = amount
  840. if C.combattext.short_numbers == true then
  841. amount = T.ShortValue(amount)
  842. end
  843. if critical then
  844. amount = "|cffFF0000"..C.combattext.crit_prefix.."|r"..amount.."|cffFF0000"..C.combattext.crit_postfix.."|r"
  845. end
  846. if C.combattext.icons then
  847. icon = GetSpellTexture(spellId)
  848. end
  849. if C.combattext.damage_color then
  850. if ct.dmgcolor[spellSchool] then
  851. color = ct.dmgcolor[spellSchool]
  852. else
  853. color = ct.dmgcolor[1]
  854. end
  855. else
  856. color = {1, 1, 0}
  857. end
  858. if icon then
  859. msg = " \124T"..icon..":"..C.combattext.icon_size..":"..C.combattext.icon_size..":0:0:64:64:5:59:5:59\124t"
  860. elseif C.combattext.icons then
  861. msg = " \124T"..ct.blank..":"..C.combattext.icon_size..":"..C.combattext.icon_size..":0:0:64:64:5:59:5:59\124t"
  862. else
  863. msg = ""
  864. end
  865. if C.combattext.merge_aoe_spam then
  866. spellId = T.merge[spellId] or spellId
  867. if sourceFlags == gflags then
  868. spellId = 6603
  869. end
  870. if T.aoespam[spellId] then
  871. SQ[spellId]["locked"] = true
  872. SQ[spellId]["queue"] = ct.SpamQueue(spellId, rawamount)
  873. SQ[spellId]["msg"] = msg
  874. SQ[spellId]["color"] = color
  875. SQ[spellId]["count"] = SQ[spellId]["count"] + 1
  876. if SQ[spellId]["count"] == 1 then
  877. SQ[spellId]["utime"] = time() + T.aoespam[spellId]
  878. end
  879. SQ[spellId]["locked"] = false
  880. return
  881. end
  882. end
  883. xCT4:AddMessage(amount..""..msg, unpack(color))
  884. end
  885. elseif eventType == "SWING_MISSED" then
  886. local missType = select(12, ...)
  887. if C.combattext.icons then
  888. if sourceGUID == UnitGUID("pet") or sourceFlags == gflags then
  889. icon = PET_ATTACK_TEXTURE
  890. else
  891. icon = GetSpellTexture(6603)
  892. end
  893. missType = misstypes[missType].." \124T"..icon..":"..C.combattext.icon_size..":"..C.combattext.icon_size..":0:0:64:64:5:59:5:59\124t"
  894. else
  895. missType = misstypes[missType]
  896. end
  897. xCT4:AddMessage(missType)
  898. elseif eventType == "SPELL_MISSED" or eventType == "RANGE_MISSED" then
  899. local spellId, _, _, missType = select(12, ...)
  900. if missType == "IMMUNE" and spellId == 118895 then return end
  901. if C.combattext.icons then
  902. icon = GetSpellTexture(spellId)
  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_DISPEL" and C.combattext.dispel then
  909. local id, effect, _, etype = select(15, ...)
  910. local color
  911. if C.combattext.icons then
  912. icon = GetSpellTexture(id)
  913. end
  914. if icon then
  915. msg = " \124T"..icon..":"..C.combattext.icon_size..":"..C.combattext.icon_size..":0:0:64:64:5:59:5:59\124t"
  916. elseif C.combattext.icons then
  917. msg = " \124T"..ct.blank..":"..C.combattext.icon_size..":"..C.combattext.icon_size..":0:0:64:64:5:59:5:59\124t"
  918. else
  919. msg = ""
  920. end
  921. if etype == "BUFF" then
  922. color = {0, 1, 0.5}
  923. else
  924. color = {1, 0, 0.5}
  925. end
  926. xCT3:AddMessage(ACTION_SPELL_DISPEL..": "..effect..msg, unpack(color))
  927. elseif eventType == "SPELL_STOLEN" and C.combattext.dispel then
  928. local id, effect = select(15, ...)
  929. local color = {1, 0.5, 0}
  930. if C.combattext.icons then
  931. icon = GetSpellTexture(id)
  932. end
  933. if icon then
  934. msg = " \124T"..icon..":"..C.combattext.icon_size..":"..C.combattext.icon_size..":0:0:64:64:5:59:5:59\124t"
  935. elseif C.combattext.icons then
  936. msg = " \124T"..ct.blank..":"..C.combattext.icon_size..":"..C.combattext.icon_size..":0:0:64:64:5:59:5:59\124t"
  937. else
  938. msg = ""
  939. end
  940. xCT3:AddMessage(ACTION_SPELL_STOLEN..": "..effect..msg, unpack(color))
  941. elseif eventType == "SPELL_INTERRUPT" and C.combattext.interrupt then
  942. local id, effect = select(15, ...)
  943. local color = {1, 0.5, 0}
  944. if C.combattext.icons then
  945. icon = GetSpellTexture(id)
  946. end
  947. if icon then
  948. msg = " \124T"..icon..":"..C.combattext.icon_size..":"..C.combattext.icon_size..":0:0:64:64:5:59:5:59\124t"
  949. elseif C.combattext.icons then
  950. msg = " \124T"..ct.blank..":"..C.combattext.icon_size..":"..C.combattext.icon_size..":0:0:64:64:5:59:5:59\124t"
  951. else
  952. msg = ""
  953. end
  954. xCT3:AddMessage(ACTION_SPELL_INTERRUPT..": "..effect..msg, unpack(color))
  955. elseif eventType == "PARTY_KILL" and C.combattext.killingblow then
  956. local destGUID, tname = select(8, ...)
  957. local classIndex = select(2, GetPlayerInfoByGUID(destGUID))
  958. local color = classIndex and RAID_CLASS_COLORS[classIndex] or {r = 0.2, g = 1, b = 0.2}
  959. xCT3:AddMessage("|cff33FF33"..ACTION_PARTY_KILL..": |r"..tname, color.r, color.g, color.b)
  960. end
  961. end
  962. end
  963.  
  964. xCTd:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
  965. xCTd:SetScript("OnEvent", dmg)
  966. end
  967.  
  968. -- Healing
  969. if C.combattext.healing then
  970. local unpack, select, time = unpack, select, time
  971. local xCTh = CreateFrame("Frame")
  972. if C.combattext.icons then
  973. ct.blank = "Interface\\AddOns\\ShestakUI\\Media\\Textures\\Blank.tga"
  974. end
  975. local heal = function(self, event, ...)
  976. local msg, icon
  977. local eventType, _, sourceGUID, _, sourceFlags = select(2, ...)
  978. if sourceGUID == ct.pguid or sourceFlags == gflags then
  979. if eventType == "SPELL_HEAL" or (eventType == "SPELL_PERIODIC_HEAL" and C.combattext.show_hots) then
  980. if C.combattext.healing then
  981. local spellId, _, _, amount, overhealing, _, critical = select(12, ...)
  982. if T.healfilter[spellId] then
  983. return
  984. end
  985. if amount >= C.combattext.heal_treshold then
  986. local color = {}
  987. local rawamount = amount
  988. if C.combattext.show_overhealing and abs(overhealing) > 0 then
  989. if C.combattext.short_numbers == true then
  990. amount = T.ShortValue(math.floor(amount-overhealing)).." ["..T.ShortValue(floor(overhealing)).."]"
  991. else
  992. amount = math.floor(amount-overhealing).." ["..floor(overhealing).."]"
  993. end
  994. else
  995. if C.combattext.short_numbers == true then
  996. amount = T.ShortValue(amount)
  997. end
  998. end
  999.  
  1000. if critical then
  1001. amount = "|cffFF0000"..C.combattext.crit_prefix.."|r"..amount.."|cffFF0000"..C.combattext.crit_postfix.."|r"
  1002. color = {0.1, 1, 0.1}
  1003. else
  1004. color = {0.1, 0.65, 0.1}
  1005. end
  1006. if C.combattext.icons then
  1007. icon = GetSpellTexture(spellId)
  1008. else
  1009. msg = ""
  1010. end
  1011. if icon then
  1012. msg = " \124T"..icon..":"..C.combattext.icon_size..":"..C.combattext.icon_size..":0:0:64:64:5:59:5:59\124t"
  1013. elseif C.combattext.icons then
  1014. msg=" \124T"..ct.blank..":"..C.combattext.icon_size..":"..C.combattext.icon_size..":0:0:64:64:5:59:5:59\124t"
  1015. end
  1016. if C.combattext.merge_aoe_spam then
  1017. spellId = T.merge[spellId] or spellId
  1018. if T.aoespam[spellId] then
  1019. SQ[spellId]["locked"] = true
  1020. SQ[spellId]["queue"] = ct.SpamQueue(spellId, rawamount)
  1021. SQ[spellId]["msg"] = msg
  1022. SQ[spellId]["color"] = color
  1023. SQ[spellId]["count"] = SQ[spellId]["count"] + 1
  1024. if SQ[spellId]["count"] == 1 then
  1025. SQ[spellId]["utime"] = time() + T.aoespam[spellId]
  1026. end
  1027. SQ[spellId]["locked"] = false
  1028. return
  1029. end
  1030. end
  1031. xCT4:AddMessage(amount..""..msg, unpack(color))
  1032. end
  1033. end
  1034. end
  1035. end
  1036. end
  1037.  
  1038. xCTh:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
  1039. xCTh:SetScript("OnEvent", heal)
  1040. end
  1041.  
  1042. -- Check outdated spells
  1043. if C.combattext.merge_aoe_spam then
  1044. for spell in pairs(T.aoespam) do
  1045. local name = GetSpellInfo(spell)
  1046. if not name then
  1047. print("|cffff0000WARNING: spell ID ["..tostring(spell).."] no longer exists! Report this to Shestak.|r")
  1048. end
  1049. end
  1050.  
  1051. for spell in pairs(T.merge) do
  1052. local name = GetSpellInfo(spell)
  1053. if not name then
  1054. print("|cffff0000WARNING: spell ID ["..tostring(spell).."] no longer exists! Report this to Shestak.|r")
  1055. end
  1056. end
  1057. end
  1058.  
  1059. if C.combattext.healing then
  1060. for spell in pairs(T.healfilter) do
  1061. local name = GetSpellInfo(spell)
  1062. if not name then
  1063. print("|cffff0000WARNING: spell ID ["..tostring(spell).."] no longer exists! Report this to Shestak.|r")
  1064. end
  1065. end
  1066. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement