Skip to content

Instantly share code, notes, and snippets.

@obble

obble/heal.lua Secret

Last active October 29, 2015 22:46
Show Gist options
  • Save obble/21a8e0545c25a02e1c1e to your computer and use it in GitHub Desktop.
Save obble/21a8e0545c25a02e1c1e to your computer and use it in GitHub Desktop.
local Heal = {}
Heal.__index = Heal
Heal.create = function(n, no, crit, time)
local acnt = {}
setmetatable(acnt,Heal)
acnt.target = n
acnt.amount = no
acnt.crit = crit
acnt.timeStart = time
acnt.timeEnd = time + 2
acnt.y = 0
return acnt
end
-- create and use an Account
local heals = {}
local function newHeal(n, no, crit)
local time = GetTime()
local h = Heal.create(n, no, crit, time)
table.insert(heals, h)
end
local function IsNamePlateFrame(frame)
local overlayRegion = frame:GetRegions()
if not overlayRegion or overlayRegion:GetObjectType() ~= "Texture" or overlayRegion:GetTexture() ~= "Interface\\Tooltips\\Nameplate-Border" then
return false
end
return true
end
local plate_OnUpdate = function()
local frames = { WorldFrame:GetChildren() }
for _, namePlate in ipairs(frames) do
if IsNamePlateFrame(namePlate) then
local Border, Glow, Name, Level, _, RaidTargetIcon = namePlate:GetRegions()
if not namePlate.heal then
namePlate.heal = namePlate:CreateFontString(nil, 'OVERLAY')
namePlate.heal:SetTextColor(0, .6, 0, .6)
namePlate.heal:Hide()
end
local name = Name:GetText()
for k,v in pairs(heals) do
if v.target == name then
if GetTime() < v.timeEnd then
local y = 14
if v.crit == 1 then
namePlate.heal:SetFont(STANDARD_TEXT_FONT, 38, 'OUTLINE')
else
namePlate.heal:SetFont(STANDARD_TEXT_FONT, 24, 'OUTLINE')
y = y + v.y
if y + v.y < y + 20 then v.y = v.y + 1 end
end
namePlate.heal:SetPoint('CENTER', Name, 0, y)
if (v.timeEnd - GetTime()) < .6 then
namePlate.heal:SetAlpha(mod((v.timeEnd - GetTime()), 1))
else
namePlate.heal:SetAlpha(.6)
end
namePlate.heal:SetText(v.amount)
namePlate.heal:Show()
else
namePlate.heal:Hide()
end
end
end
end
end
end
local handler = function()
local h = 'Your (.+) heals (.+) for (.+).'
local c = 'Your (.+) critically heals (.+) for (.+).'
if string.find(arg1, h) or string.find(arg1, c) then
local n = gsub(arg1, h, '%2')
local no = gsub(arg1, h, '%3')
newHeal(n, no, string.find(arg1, c) and 1 or 0)
end
end
local f = CreateFrame'Frame'
f:RegisterEvent'CHAT_MSG_SPELL_SELF_BUFF'
f:SetScript('OnEvent', handler)
f:SetScript('OnUpdate', plate_OnUpdate)
--
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment