PageRenderTime 270ms CodeModel.GetById 214ms app.highlight 3ms RepoModel.GetById 52ms app.codeStats 0ms

/Tukui/modules/datatext/hit.lua

http://github.com/Asphyxia/Tukui
Lua | 45 lines | 32 code | 9 blank | 4 comment | 5 complexity | c89ba64711685f3dc16d00e7d3c7d051 MD5 | raw file
 1local T, C, L = unpack(select(2, ...)) -- Import: T - functions, constants, variables; C - config; L - locales
 2--------------------------------------------------------------------
 3-- Player Hit
 4--------------------------------------------------------------------
 5
 6-- Hit Rating
 7if not C["datatext"].hit == nil or C["datatext"].hit > 0 then
 8	local Stat = CreateFrame("Frame")
 9
10	local Text  = TukuiInfoLeft:CreateFontString(nil, "OVERLAY")
11	Text:SetFont(C.media.pixelfont, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
12	T.PP(C["datatext"].hit, Text)
13
14	local int = 1
15
16	local function Update(self, t)		
17		int = int - t
18		if int < 0 then
19			local base, posBuff, negBuff = UnitAttackPower("player")
20			local effective = base + posBuff + negBuff
21			local Rbase, RposBuff, RnegBuff = UnitRangedAttackPower("player")
22			local Reffective = Rbase + RposBuff + RnegBuff
23
24			local Rattackpwr = Reffective
25			local spellpwr = GetSpellBonusDamage(7)
26			local attackpwr = effective
27			
28			local cac = GetHitModifier() or 0
29			local cast = GetSpellHitModifier() or 0
30			
31			if attackpwr > spellpwr and select(2, UnitClass("Player")) ~= "HUNTER" then
32				Text:SetText("Hit: "..T.datacolor..format("%.2f", GetCombatRatingBonus(6)+cac).."%")
33			elseif select(2, UnitClass("Player")) == "HUNTER" then
34				Text:SetText("Hit: "..T.datacolor..format("%.2f", GetCombatRatingBonus(7)+cac).."%")
35			else
36				Text:SetText("Hit: "..T.datacolor..format("%.2f", GetCombatRatingBonus(8)+cast).."%")
37			end
38			
39			int = 1
40		end
41	end
42
43	Stat:SetScript("OnUpdate", Update)
44	Update(Stat, 10)
45end