/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
- local T, C, L = unpack(select(2, ...)) -- Import: T - functions, constants, variables; C - config; L - locales
- --------------------------------------------------------------------
- -- player Armor
- --------------------------------------------------------------------
- if C["datatext"].armor and C["datatext"].armor > 0 then
- local Stat = CreateFrame("Frame")
- Stat:EnableMouse(true)
- Stat:SetFrameStrata("HIGH")
- Stat:SetFrameLevel(3)
- local Text = TukuiInfoLeft:CreateFontString(nil, "OVERLAY")
- Text:SetFont(C.media.pixelfont, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
- T.PP(C["datatext"].armor, Text)
- local function Update(self)
- baseArmor , effectiveArmor, armor, posBuff, negBuff = UnitArmor("player");
- Text:SetText(L.datatext_armor..": "..T.datacolor..(effectiveArmor))
- --Setup Armor Tooltip
- self:SetAllPoints(Text)
- end
- Stat:RegisterEvent("UNIT_INVENTORY_CHANGED")
- Stat:RegisterEvent("UNIT_AURA")
- Stat:RegisterEvent("PLAYER_ENTERING_WORLD")
- Stat:SetScript("OnMouseDown", function() ToggleCharacter("PaperDollFrame") end)
- Stat:SetScript("OnEvent", Update)
- Stat:SetScript("OnEnter", function(self)
- if not InCombatLockdown() then
- local anchor, panel, xoff, yoff = T.DataTextTooltipAnchor(Text)
- GameTooltip:SetOwner(panel, anchor, xoff, yoff)
- GameTooltip:ClearLines()
- GameTooltip:AddLine(L.datatext_mitigation)
- local lv = 83
- for i = 1, 4 do
- local format = string.format
- local mitigation = (effectiveArmor/(effectiveArmor+(467.5*lv-22167.5)));
- if mitigation > .75 then
- mitigation = .75
- end
- GameTooltip:AddDoubleLine(lv,format("%.2f", mitigation*100) .. "%",1,1,1)
- lv = lv - 1
- end
- if UnitLevel("target") > 0 and UnitLevel("target") < UnitLevel("player") then
- mitigation = (effectiveArmor/(effectiveArmor+(467.5*(UnitLevel("target"))-22167.5)));
- if mitigation > .75 then
- mitigation = .75
- end
- GameTooltip:AddDoubleLine(UnitLevel("target"),format("%.2f", mitigation*100) .. "%",1,1,1)
- end
- GameTooltip:Show()
- end
- end)
- Stat:SetScript("OnLeave", function() GameTooltip:Hide() end)
- end