/Tukui/modules/datatext/crit.lua
http://github.com/Asphyxia/Tukui · Lua · 37 lines · 29 code · 5 blank · 3 comment · 6 complexity · 4a5daf5e146f5e225444b4834a7859a6 MD5 · raw file
- local T, C, L = unpack(select(2, ...)) -- Import: T - functions, constants, variables; C - config; L - locales
- --------------------------------------------------------------------
- -- Crit (Spell or Melee.. or ranged)
- --------------------------------------------------------------------
- if C["datatext"].crit and C["datatext"].crit > 0 then
- local Stat = CreateFrame("Frame")
- 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"].crit, Text)
- local int = 1
- local function Update(self, t)
- int = int - t
- meleecrit = GetCritChance()
- spellcrit = GetSpellCritChance(1)
- rangedcrit = GetRangedCritChance()
- if spellcrit > meleecrit then
- CritChance = spellcrit
- elseif select(2, UnitClass("Player")) == "HUNTER" then
- CritChance = rangedcrit
- else
- CritChance = meleecrit
- end
- if int < 0 then
- Text:SetText(SPELL_CRIT_CHANCE..": "..T.datacolor..format("%.2f", CritChance) .. "%")
- int = 1
- end
- end
- Stat:SetScript("OnUpdate", Update)
- Update(Stat, 10)
- end