/Tukui/modules/datatext/armor.lua

http://github.com/Asphyxia/Tukui · Lua · 55 lines · 47 code · 4 blank · 4 comment · 8 complexity · 903524e15fc1aa946ed3080ee23dee4f MD5 · raw file

  1. local T, C, L = unpack(select(2, ...)) -- Import: T - functions, constants, variables; C - config; L - locales
  2. --------------------------------------------------------------------
  3. -- player Armor
  4. --------------------------------------------------------------------
  5. if C["datatext"].armor and C["datatext"].armor > 0 then
  6. local Stat = CreateFrame("Frame")
  7. Stat:EnableMouse(true)
  8. Stat:SetFrameStrata("HIGH")
  9. Stat:SetFrameLevel(3)
  10. local Text = TukuiInfoLeft:CreateFontString(nil, "OVERLAY")
  11. Text:SetFont(C.media.pixelfont, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
  12. T.PP(C["datatext"].armor, Text)
  13. local function Update(self)
  14. baseArmor , effectiveArmor, armor, posBuff, negBuff = UnitArmor("player");
  15. Text:SetText(L.datatext_armor..": "..T.datacolor..(effectiveArmor))
  16. --Setup Armor Tooltip
  17. self:SetAllPoints(Text)
  18. end
  19. Stat:RegisterEvent("UNIT_INVENTORY_CHANGED")
  20. Stat:RegisterEvent("UNIT_AURA")
  21. Stat:RegisterEvent("PLAYER_ENTERING_WORLD")
  22. Stat:SetScript("OnMouseDown", function() ToggleCharacter("PaperDollFrame") end)
  23. Stat:SetScript("OnEvent", Update)
  24. Stat:SetScript("OnEnter", function(self)
  25. if not InCombatLockdown() then
  26. local anchor, panel, xoff, yoff = T.DataTextTooltipAnchor(Text)
  27. GameTooltip:SetOwner(panel, anchor, xoff, yoff)
  28. GameTooltip:ClearLines()
  29. GameTooltip:AddLine(L.datatext_mitigation)
  30. local lv = 83
  31. for i = 1, 4 do
  32. local format = string.format
  33. local mitigation = (effectiveArmor/(effectiveArmor+(467.5*lv-22167.5)));
  34. if mitigation > .75 then
  35. mitigation = .75
  36. end
  37. GameTooltip:AddDoubleLine(lv,format("%.2f", mitigation*100) .. "%",1,1,1)
  38. lv = lv - 1
  39. end
  40. if UnitLevel("target") > 0 and UnitLevel("target") < UnitLevel("player") then
  41. mitigation = (effectiveArmor/(effectiveArmor+(467.5*(UnitLevel("target"))-22167.5)));
  42. if mitigation > .75 then
  43. mitigation = .75
  44. end
  45. GameTooltip:AddDoubleLine(UnitLevel("target"),format("%.2f", mitigation*100) .. "%",1,1,1)
  46. end
  47. GameTooltip:Show()
  48. end
  49. end)
  50. Stat:SetScript("OnLeave", function() GameTooltip:Hide() end)
  51. end