Guest User

Untitled

a guest
Jan 28th, 2015
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 12.77 KB | None | 0 0
  1. local _, ns = ...
  2. local oUF = ns.oUF or oUF
  3. assert(oUF, "oUF_Freebgrid was unable to locate oUF install.")
  4.  
  5. local foo = {""}
  6. local spellcache = setmetatable({},
  7. {__index=function(t,id)
  8.     local a = {GetSpellInfo(id)}
  9.  
  10.     if GetSpellInfo(id) then
  11.         t[id] = a
  12.         return a
  13.     end
  14.  
  15.     --print("Invalid spell ID: ", id)
  16.     t[id] = foo
  17.     return foo
  18. end
  19. })
  20.  
  21. local function GetSpellInfo(a)
  22.     return unpack(spellcache[a])
  23. end
  24.  
  25. local GetTime = GetTime
  26.  
  27. local numberize = function(val)
  28.     if (val >= 1e6) then
  29.         return ("%.1fm"):format(val / 1e6)
  30.     elseif (val >= 1e3) then
  31.         return ("%.1fk"):format(val / 1e3)
  32.     else
  33.         return ("%d"):format(val)
  34.     end
  35. end
  36. ns.numberize = numberize
  37.  
  38. local x = "M"
  39.  
  40. local getTime = function(expirationTime)
  41.     local expire = (expirationTime-GetTime())
  42.     local timeleft = numberize(expire)
  43.     if expire > 0.5 then
  44.         return ("|cffffff00"..timeleft.."|r")
  45.     end
  46. end
  47.  
  48. -- Magic
  49. oUF.Tags.Methods['freebgrid:magic'] = function(u)
  50.     local index = 1
  51.     while true do
  52.         local name,_,_,_, dtype = UnitAura(u, index, 'HARMFUL')
  53.         if not name then break end
  54.  
  55.         if dtype == "Magic" then
  56.             return ns.debuffColor[dtype]..x
  57.         end
  58.  
  59.         index = index+1
  60.     end
  61. end
  62. oUF.Tags.Events['freebgrid:magic'] = "UNIT_AURA"
  63.  
  64. -- Disease
  65. oUF.Tags.Methods['freebgrid:disease'] = function(u)
  66.     local index = 1
  67.     while true do
  68.         local name,_,_,_, dtype = UnitAura(u, index, 'HARMFUL')
  69.         if not name then break end
  70.  
  71.         if dtype == "Disease" then
  72.             return ns.debuffColor[dtype]..x
  73.         end
  74.  
  75.         index = index+1
  76.     end
  77. end
  78. oUF.Tags.Events['freebgrid:disease'] = "UNIT_AURA"
  79.  
  80. -- Curse
  81. oUF.Tags.Methods['freebgrid:curse'] = function(u)
  82.     local index = 1
  83.     while true do
  84.         local name,_,_,_, dtype = UnitAura(u, index, 'HARMFUL')
  85.         if not name then break end
  86.  
  87.         if dtype == "Curse" then
  88.             return ns.debuffColor[dtype]..x
  89.         end
  90.  
  91.         index = index+1
  92.     end
  93. end
  94. oUF.Tags.Events['freebgrid:curse'] = "UNIT_AURA"
  95.  
  96. -- Poison
  97. oUF.Tags.Methods['freebgrid:poison'] = function(u)
  98.     local index = 1
  99.     while true do
  100.         local name,_,_,_, dtype = UnitAura(u, index, 'HARMFUL')
  101.         if not name then break end
  102.  
  103.         if dtype == "Poison" then
  104.             return ns.debuffColor[dtype]..x
  105.         end
  106.  
  107.         index = index+1
  108.     end
  109. end
  110. oUF.Tags.Events['freebgrid:poison'] = "UNIT_AURA"
  111.  
  112. -- Priest
  113. local pomCount = {
  114.     [1] = 'i',
  115.     [2] = 'h',
  116.     [3] = 'g',
  117.     [4] = 'f',
  118.     [5] = 'Z',
  119.     [6] = 'Y',
  120. }
  121. oUF.Tags.Methods['freebgrid:pom'] = function(u)
  122.     local name, _,_, c, _,_,_, fromwho = UnitAura(u, GetSpellInfo(33076))
  123.     if name and pomCount[c] then
  124.         if(fromwho == "player") then
  125.             return "|cff66FFFF"..pomCount[c].."|r"
  126.         else
  127.             return "|cffFFCF7F"..pomCount[c].."|r"
  128.         end
  129.     end
  130. end
  131. oUF.Tags.Events['freebgrid:pom'] = "UNIT_AURA"
  132.  
  133. oUF.Tags.Methods['freebgrid:rnw'] = function(u)
  134.     local name, _,_,_,_,_, expirationTime, fromwho = UnitAura(u, GetSpellInfo(139))
  135.     if(fromwho == "player") then
  136.         local spellTimer = GetTime()-expirationTime
  137.         if spellTimer > -2 then
  138.             return "|cffFF0000"..x.."|r"
  139.         elseif spellTimer > -4 then
  140.             return "|cffFF9900"..x.."|r"
  141.         else
  142.             return "|cff33FF33"..x.."|r"
  143.         end
  144.     end
  145. end
  146. oUF.Tags.Events['freebgrid:rnw'] = "UNIT_AURA"
  147.  
  148. oUF.Tags.Methods['freebgrid:rnwTime'] = function(u)
  149.     local name, _,_,_,_,_, expirationTime, fromwho = UnitAura(u, GetSpellInfo(139))
  150.     if(fromwho == "player") then return getTime(expirationTime) end
  151. end
  152. oUF.Tags.Events['freebgrid:rnwTime'] = "UNIT_AURA"
  153.  
  154. oUF.Tags.Methods['freebgrid:pws'] = function(u) if UnitAura(u, GetSpellInfo(17)) then return "|cff33FF33"..x.."|r" end end
  155. oUF.Tags.Events['freebgrid:pws'] = "UNIT_AURA"
  156.  
  157. oUF.Tags.Methods['freebgrid:ws'] = function(u) if UnitDebuff(u, GetSpellInfo(6788)) then return "|cffFF9900"..x.."|r" end end
  158. oUF.Tags.Events['freebgrid:ws'] = "UNIT_AURA"
  159.  
  160. oUF.Tags.Methods['freebgrid:fw'] = function(u) if UnitAura(u, GetSpellInfo(6346)) then return "|cff8B4513"..x.."|r" end end
  161. oUF.Tags.Events['freebgrid:fw'] = "UNIT_AURA"
  162.  
  163. oUF.Tags.Methods['freebgrid:fort'] = function(u) if not(UnitAura(u, GetSpellInfo(21562)) or UnitAura(u, GetSpellInfo(6307)) or UnitAura(u, GetSpellInfo(469)) or UnitAura(u, GetSpellInfo(109773))) then return "|cff00A1DE"..x.."|r" end end
  164. oUF.Tags.Events['freebgrid:fort'] = "UNIT_AURA"
  165.  
  166. oUF.Tags.Methods['freebgrid:pwb'] = function(u) if UnitAura(u, GetSpellInfo(81782)) then return "|cffEEEE00"..x.."|r" end end
  167. oUF.Tags.Events['freebgrid:pwb'] = "UNIT_AURA"
  168.  
  169. -- Druid
  170. local lbCount = { 4, 2, 3}
  171. oUF.Tags.Methods['freebgrid:lb'] = function(u)
  172.     local name, _,_, c,_,_, expirationTime, fromwho = UnitAura(u, GetSpellInfo(33763))
  173.     if(fromwho == "player") then
  174.         local spellTimer = GetTime()-expirationTime
  175.         if spellTimer > -5 then
  176.             return "|cffFF0000"..lbCount[c].."|r"
  177.         elseif spellTimer > -10 then
  178.             return "|cffFF9900"..lbCount[c].."|r"
  179.         else
  180.             return "|cffA7FD0A"..lbCount[c].."|r"
  181.         end
  182.     end
  183. end
  184. oUF.Tags.Events['freebgrid:lb'] = "UNIT_AURA"
  185.  
  186. oUF.Tags.Methods['freebgrid:rejuv'] = function(u)
  187.     local name, _,_,_,_,_, expirationTime, fromwho = UnitAura(u, GetSpellInfo(774))
  188.     if(fromwho == "player") then
  189.         local spellTimer = GetTime()-expirationTime
  190.         if spellTimer > -2 then
  191.             return "|cffFF0000"..x.."|r"
  192.         elseif spellTimer > -4 then
  193.             return "|cffFF9900"..x.."|r"
  194.         else
  195.             return "|cff33FF33"..x.."|r"
  196.         end
  197.     end
  198. end
  199. oUF.Tags.Events['freebgrid:rejuv'] = "UNIT_AURA"
  200.  
  201. oUF.Tags.Methods['freebgrid:rejuvTime'] = function(u)
  202.     local name, _,_,_,_,_, expirationTime, fromwho = UnitAura(u, GetSpellInfo(774))
  203.     if(fromwho == "player") then return getTime(expirationTime) end
  204. end
  205. oUF.Tags.Events['freebgrid:rejuvTime'] = "UNIT_AURA"
  206.  
  207. oUF.Tags.Methods['freebgrid:regrow'] = function(u) if UnitAura(u, GetSpellInfo(8936)) then return "|cff00FF10"..x.."|r" end end
  208. oUF.Tags.Events['freebgrid:regrow'] = "UNIT_AURA"
  209.  
  210. oUF.Tags.Methods['freebgrid:wg'] = function(u) if UnitAura(u, GetSpellInfo(48438)) then return "|cff33FF33"..x.."|r" end end
  211. oUF.Tags.Events['freebgrid:wg'] = "UNIT_AURA"
  212.  
  213. oUF.Tags.Methods['freebgrid:motw'] = function(u) if not(UnitAura(u, GetSpellInfo(1126)) or UnitAura(u,GetSpellInfo(20217)) or UnitAura(u,GetSpellInfo(115921))) then return "|cff00A1DE"..x.."|r" end end
  214. oUF.Tags.Events['freebgrid:motw'] = "UNIT_AURA"
  215.  
  216. -- Warrior
  217. oUF.Tags.Methods['freebgrid:stragi'] = function(u) if not(UnitAura(u, GetSpellInfo(6673)) or UnitAura(u, GetSpellInfo(57330)) or UnitAura(u, GetSpellInfo(8076))) then return "|cffFF0000"..x.."|r" end end
  218. oUF.Tags.Events['freebgrid:stragi'] = "UNIT_AURA"
  219.  
  220. oUF.Tags.Methods['freebgrid:vigil'] = function(u) if UnitAura(u, GetSpellInfo(50720)) then return "|cff8B4513"..x.."|r" end end
  221. oUF.Tags.Events['freebgrid:vigil'] = "UNIT_AURA"
  222.  
  223. -- Shaman
  224. oUF.Tags.Methods['freebgrid:rip'] = function(u)
  225.     local name, _,_,_,_,_,_, fromwho = UnitAura(u, GetSpellInfo(61295))
  226.     if(fromwho == 'player') then return "|cff00FEBF"..x.."|r" end
  227. end
  228. oUF.Tags.Events['freebgrid:rip'] = 'UNIT_AURA'
  229.  
  230. oUF.Tags.Methods['freebgrid:ripTime'] = function(u)
  231.     local name, _,_,_,_,_, expirationTime, fromwho = UnitAura(u, GetSpellInfo(61295))
  232.     if(fromwho == "player") then return getTime(expirationTime) end
  233. end
  234. oUF.Tags.Events['freebgrid:ripTime'] = 'UNIT_AURA'
  235.  
  236. local earthCount = {'i','h','g','f','p','q','Z','Z','Y'}
  237. oUF.Tags.Methods['freebgrid:earth'] = function(u)
  238.     local c = select(4, UnitAura(u, GetSpellInfo(974))) if c then return '|cffFFCF7F'..earthCount[c]..'|r' end
  239. end
  240. oUF.Tags.Events['freebgrid:earth'] = 'UNIT_AURA'
  241.  
  242. -- Paladin
  243. oUF.Tags.Methods['freebgrid:might'] = function(u) if not(UnitAura(u, GetSpellInfo(19740))) then return "|cffFF0000"..x.."|r" end end
  244. oUF.Tags.Events['freebgrid:might'] = "UNIT_AURA"
  245.  
  246. oUF.Tags.Methods['freebgrid:beacon'] = function(u)
  247.     local name, _,_,_,_,_,_, fromwho = UnitAura(u, GetSpellInfo(53563))
  248.     if not name then return end
  249.     if(fromwho == "player") then
  250.         return "|cffFFCC003|r"
  251.     else
  252.         return "|cff996600Y|r" -- other pally's beacon
  253.     end
  254. end
  255. oUF.Tags.Events['freebgrid:beacon'] = "UNIT_AURA"
  256.  
  257. oUF.Tags.Methods['freebgrid:forbearance'] = function(u) if UnitDebuff(u, GetSpellInfo(25771)) then return "|cffFF9900"..x.."|r" end end
  258. oUF.Tags.Events['freebgrid:forbearance'] = "UNIT_AURA"
  259.  
  260. oUF.Tags.Methods['freebgrid:sacred'] = function(u)
  261.     local name, _,_,_,_,_,_, fromwho = UnitAura(u, GetSpellInfo(20925))
  262.     if not name then return end
  263.     if(fromwho == "player") then
  264.         return "|cffFFCC00"..x.."|r"
  265.     end
  266. end
  267. oUF.Tags.Events['freebgrid:sacred'] = "UNIT_AURA"
  268.  
  269. oUF.Tags.Methods['freebgrid:eternalTime'] = function(u)
  270.     local name, _,_,_,_,_, expirationTime, fromwho = UnitAura(u, GetSpellInfo(114163))
  271.     if(fromwho == "player") then return getTime(expirationTime) end
  272. end
  273. oUF.Tags.Events['freebgrid:eternalTime'] = "UNIT_AURA"
  274.  
  275. -- Warlock
  276. oUF.Tags.Methods['freebgrid:di'] = function(u)
  277.     local name, _,_,_,_,_,_, fromwho = UnitAura(u, GetSpellInfo(109773))
  278.     if fromwho == "player" then
  279.         return "|cff6600FF"..x.."|r"
  280.     elseif name then
  281.         return "|cffCC00FF"..x.."|r"
  282.     end
  283. end
  284. oUF.Tags.Events['freebgrid:di'] = "UNIT_AURA"
  285.  
  286.  
  287. -- CUSTOM CODE GNUHEIKE
  288. oUF.Tags.Methods['freebgrid:ss'] = function(u)
  289.     local name, _,_,_,_,_,_, fromwho = UnitAura(u, GetSpellInfo(20707))
  290.     if fromwho == "player" then
  291.         return "|cff6600FFY|r"
  292.     elseif name then
  293.         return "|cffCC00FFY|r"
  294.     end
  295. end
  296. oUF.Tags.Events['freebgrid:ss'] = "UNIT_AURA"
  297.  
  298. oUF.Tags.Methods['freebgrid:pss'] = function(u)
  299.     local name, _,_,_,_,_, expirationTime, fromwho = UnitAura(u, GetSpellInfo(109964))
  300.     if(fromwho == "player") then
  301.         if not expirationTime then return end
  302.         local spellTimer = GetTime()-expirationTime
  303.         if spellTimer > -4 then
  304.             return "|cffFF0000"..x.."|r"
  305.         elseif spellTimer > -7 then
  306.             return "|cffFF9900"..x.."|r"
  307.         else
  308.             return "|cff33FF33"..x.."|r"
  309.         end
  310.     end
  311. end
  312. oUF.Tags.Events['freebgrid:pss'] = "UNIT_AURA"
  313.  
  314. oUF.Tags.Methods['freebgrid:poh'] = function(u)
  315.     local name, _,_,_,_,_, expirationTime, fromwho = UnitAura(u, GetSpellInfo(47753))
  316.     if(fromwho == "player") then
  317.         if not expirationTime then return end
  318.         local spellTimer = GetTime()-expirationTime
  319.         if spellTimer > -4 then
  320.             return "|cffFF0000"..x.."|r"
  321.         elseif spellTimer > -7 then
  322.             return "|cffFF9900"..x.."|r"
  323.         else
  324.             return "|cff33FF33"..x.."|r"
  325.         end
  326.     end
  327. end
  328. oUF.Tags.Events['freebgrid:poh'] = "UNIT_AURA"
  329.  
  330. oUF.Tags.Methods['freebgrid:clw'] = function(u)
  331.     local name, _,_, _, _,_,_, fromwho = UnitAura(u, GetSpellInfo(152118)) 
  332.     local csr = select(15, UnitAura(u, "Ясность воли", nil, "HELP"))  
  333.     if name and csr then       
  334.         local max_health = UnitHealthMax("player");
  335.         local percent = math.floor(csr/max_health*10);     
  336.         if pomCount[percent] then  
  337.             return "|cff66FFFF"..pomCount[percent].."|r"   
  338.         end        
  339.     end
  340. end
  341. oUF.Tags.Events['freebgrid:clw'] = "UNIT_AURA"
  342.  
  343.  
  344. -- END CUSTOM
  345.  
  346.  
  347. -- Mage
  348. oUF.Tags.Methods['freebgrid:int'] = function(u) if not(UnitAura(u, GetSpellInfo(1459)) or UnitAura(u, GetSpellInfo(61316))) then return "|cff00A1DE"..x.."|r" end end
  349. oUF.Tags.Events['freebgrid:int'] = "UNIT_AURA"
  350.  
  351. oUF.Tags.Methods['freebgrid:fmagic'] = function(u) if UnitAura(u, GetSpellInfo(54648)) then return "|cffCC00FF"..x.."|r" end end
  352. oUF.Tags.Events['freebgrid:fmagic'] = "UNIT_AURA"
  353.  
  354. ns.classIndicators={
  355.     ["DRUID"] = {
  356.         ["TL"] = "[freebgrid:rejuv]",
  357.         ["TR"] = "[freebgrid:motw]",
  358.         ["BL"] = "[]",
  359.         ["BR"] = "[freebgrid:lb]",
  360.         ["Cen"] = "",
  361.     },
  362.     ["PRIEST"] = {
  363.         ["TL"] = "[freebgrid:pws][freebgrid:ws]",
  364.         ["TR"] = "[freebgrid:fw][freebgrid:fort]",
  365.         ["BL"] = "[freebgrid:poh][freebgrid:pwb]",
  366.         ["BR"] = "[freebgrid:pss][freebgrid:clw]",
  367.         ["Cen"] = "[freebgrid:rnwTime]",
  368.         --[freebgrid:pom]
  369.     },
  370.     ["PALADIN"] = {
  371.         ["TL"] = "[freebgrid:forbearance]",
  372.         ["TR"] = "[freebgrid:might][freebgrid:motw]",
  373.         ["BL"] = "[freebgrid:sacred]",
  374.         ["BR"] = "[freebgrid:beacon]",
  375.         ["Cen"] = "[freebgrid:eternalTime]",
  376.     },
  377.     ["WARLOCK"] = {
  378.         ["TL"] = "",
  379.         ["TR"] = "[freebgrid:di]",
  380.         ["BL"] = "",
  381.         ["BR"] = "[freebgrid:ss]",
  382.         ["Cen"] = "",
  383.     },
  384.     ["WARRIOR"] = {
  385.         ["TL"] = "[freebgrid:vigil]",
  386.         ["TR"] = "[freebgrid:stragi][freebgrid:fort]",
  387.         ["BL"] = "",
  388.         ["BR"] = "",
  389.         ["Cen"] = "",
  390.     },
  391.     ["DEATHKNIGHT"] = {
  392.         ["TL"] = "",
  393.         ["TR"] = "",
  394.         ["BL"] = "",
  395.         ["BR"] = "",
  396.         ["Cen"] = "",
  397.     },
  398.     ["SHAMAN"] = {
  399.         ["TL"] = "[freebgrid:rip]",
  400.         ["TR"] = "",
  401.         ["BL"] = "",
  402.         ["BR"] = "[freebgrid:earth]",
  403.         ["Cen"] = "[freebgrid:ripTime]",
  404.     },
  405.     ["HUNTER"] = {
  406.         ["TL"] = "",
  407.         ["TR"] = "",
  408.         ["BL"] = "",
  409.         ["BR"] = "",
  410.         ["Cen"] = "",
  411.     },
  412.     ["ROGUE"] = {
  413.         ["TL"] = "",
  414.         ["TR"] = "",
  415.         ["BL"] = "",
  416.         ["BR"] = "",
  417.         ["Cen"] = "",
  418.     },
  419.     ["MAGE"] = {
  420.         ["TL"] = "",
  421.         ["TR"] = "[freebgrid:int]",
  422.         ["BL"] = "",
  423.         ["BR"] = "",
  424.         ["Cen"] = "",
  425.     },
  426.     ["MONK"] = {
  427.         ["TL"] = "",
  428.         ["TR"] = "",
  429.         ["BL"] = "",
  430.         ["BR"] = "",
  431.         ["Cen"] = "",
  432.     },
  433. }
Advertisement
Add Comment
Please, Sign In to add comment