Advertisement
Guest User

Untitled

a guest
Oct 20th, 2014
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.15 KB | None | 0 0
  1. local function CreateBar(unit, uf, name, db) -- create status bars for health or power
  2. local f = uf[name]
  3. local ishp = (name == "hpbar")
  4. if db.hide or (name == "mpbar" and UnitPowerMax(unit) > 0) then
  5. if f then
  6. f:Hide()
  7. Stuf:RegisterElementRefresh(uf, name, (ishp and "healthelements") or "powerelements", nil)
  8. end
  9. return
  10. end
  11. if not f then
  12. f = Stuf:CreateBase(unit, uf, name, db)
  13. f.bg = f:CreateTexture(nil, "BACKGROUND")
  14. f.bg:SetAllPoints(f)
  15. f.barbase = CreateFrame("Frame", nil, uf)
  16. f.bar = f:CreateTexture(nil, "ARTWORK")
  17.  
  18. uf.refreshfuncs[name] = UpdateStatusBar
  19. uf.refreshfuncs["barcolors"] = UpdateBarColors
  20. else
  21. f:Show()
  22. end
  23. if db.fade and not f.barfade then
  24. f.barfade = f:CreateTexture(nil, "BORDER")
  25. end
  26. if ishp then
  27. if db.inc then
  28. f.incbar = f.incbar or f:CreateTexture(nil, "ARTWORK")
  29. f.incbar:SetAlpha(1)
  30. Stuf:AddEvent("UNIT_HEAL_PREDICTION", IncomingHeal)
  31. elseif f.incbar then
  32. f.incbar:SetAlpha(0)
  33. end
  34. end
  35.  
  36. -- five second rule mana tick
  37. if unit == "player" and not ishp and not db.hidemanatick and CLS ~= "HUNTER" and CLS ~= "ROGUE" and CLS ~= "WARRIOR" and CLS ~= "DEATHKNIGHT" then
  38. if not f.spark then
  39. local spark = f:CreateTexture(nil, "OVERLAY")
  40. spark:SetTexture("Interface\\CastingBar\\UI-CastingBar-Spark")
  41. spark:SetBlendMode("ADD")
  42. f.spark = spark
  43.  
  44. local lastmana, fivestart, recentcast = 1000000, 0, 0
  45. local function SparkOnUpdate(this, a1)
  46. local frac = (GetTime() - fivestart) * 0.2062
  47. if frac > 1 then
  48. f.barbase:SetScript("OnUpdate", nil)
  49. spark:Hide()
  50. else
  51. spark:SetAlpha(frac > 0.1 and frac or 0.1)
  52. spark:SetSparkPoint(f.bvalue * frac)
  53. end
  54. end
  55. local function manatick(unit)
  56. if unit ~= "player" or not showtick then return end
  57. if not uf or uf.hidden then return end
  58. if uf.cache.powertype ~= 0 then
  59. spark:Hide()
  60. f.barbase:SetScript("OnUpdate", nil)
  61. return
  62. end
  63. local current = UnitPower(unit)
  64. if current < lastmana and GetTime() - recentcast < 0.6 then
  65. fivestart = recentcast
  66. recentcast = 0
  67. spark:Show()
  68. f.barbase:SetScript("OnUpdate", SparkOnUpdate)
  69. end
  70. lastmana = current
  71. end
  72. Stuf:AddEvent("UNIT_SPELLCAST_SUCCEEDED", function(unit)
  73. if unit == "player" and showtick then
  74. recentcast = GetTime()
  75. end
  76. end)
  77. Stuf:AddEvent("UNIT_POWER", manatick)
  78. uf.refreshfuncs["manatick"] = manatick
  79. Stuf:RegisterElementRefresh(uf, "manatick", "powercolorelements", true)
  80. end
  81. showtick = true
  82. elseif f.spark and db.hidemanatick then
  83. f.spark:Hide()
  84. showtick = nil
  85. end
  86.  
  87. UpdateBarLook(unit, uf, f, db)
  88.  
  89. if f.spark then
  90. f.spark:Hide()
  91. if db.vertical then
  92. if db.reverse then
  93. f.spark.SetSparkPoint = function(this, value) this:SetPoint("CENTER", f.barbase, "TOP", 0, -value) end
  94. else
  95. f.spark.SetSparkPoint = function(this, value) this:SetPoint("CENTER", f.barbase, "BOTTOM", 0, value) end
  96. end
  97. else
  98. if db.reverse then
  99. f.spark.SetSparkPoint = function(this, value) this:SetPoint("CENTER", f.barbase, "RIGHT", -value, 0) end
  100. else
  101. f.spark.SetSparkPoint = function(this, value) this:SetPoint("CENTER", f.barbase, "LEFT", value, 0) end
  102. end
  103. end
  104. end
  105. local barcm, bgcm = db.barcolormethod or "blah", db.bgcolormethod or "blah"
  106. f.barth = (barcm == "hpthreshold" or barcm == "hpthresholddark") and barcm or nil
  107. f.bgth = (bgcm == "hpthreshold" or bgcm == "hpthresholddark") and bgcm or nil
  108.  
  109. if not ishp and (strmatch(barcm, "power") or strmatch(bgcm, "power")) then
  110. f.colorchanges = true
  111. Stuf:RegisterElementRefresh(uf, "barcolors", "powercolorelements", true)
  112. end
  113. if strmatch(barcm, "reaction") or strmatch(bgcm, "reaction") then
  114. f.colorchanges = true
  115. Stuf:RegisterElementRefresh(uf, "barcolors", "reactionelements", true)
  116. end
  117. Stuf:RegisterElementRefresh(uf, name, ishp and "healthelements" or "powerelements", true)
  118. if Stuf.inworld then
  119. UpdateStatusBar(unit, uf, f, true, uf.cache[ishp and "frachp" or "fracmp"])
  120. end
  121. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement