Skip to content
This repository has been archived by the owner on Jan 22, 2020. It is now read-only.

Commit

Permalink
update LibHealComm-4.0 library
Browse files Browse the repository at this point in the history
call unit map less often
apply modifier to incoming heals to be more accurate
  • Loading branch information
Evilpaul committed Sep 13, 2009
1 parent 635dec7 commit 25b1552
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 42 deletions.
42 changes: 19 additions & 23 deletions libs/LibHealComm-4.0/LibHealComm-4.0.lua
@@ -1,5 +1,5 @@
local major = "LibHealComm-4.0"
local minor = 15
local minor = 17
assert(LibStub, string.format("%s requires LibStub.", major))

local HealComm = LibStub:NewLibrary(major, minor)
Expand All @@ -16,9 +16,11 @@ HealComm.playerModifiers = HealComm.playerModifiers or {}
HealComm.guidToGroup = HealComm.guidToGroup or {}
HealComm.guidToUnit = HealComm.guidToUnit or {}
HealComm.pendingHeals = HealComm.pendingHeals or {}
HealComm.spellData = HealComm.spellData or {}
HealComm.hotData = HealComm.hotData or {}
HealComm.tempPlayerList = HealComm.tempPlayerList or {}

-- These shouldn't be persistant between versions because if healing data changes it should reload all the spells inside regardless
local spellData, hotData, tempPlayerList = {}, {}, {}
local spellData, hotData, tempPlayerList = HealComm.spellData, HealComm.hotData, HealComm.tempPlayerList

-- Figure out what they are now since a few things change based off of this
local playerClass = select(2, UnitClass("player"))
Expand Down Expand Up @@ -118,9 +120,9 @@ end
HealComm.averageHeal = HealComm.averageHeal or {}
HealComm.averageHealMT = HealComm.averageHealMT or {
__index = function(tbl, index)
local rank = HealComm.rankNumbers[index]
local playerLevel = UnitLevel("player")
local spellData = spellData[tbl.spell]
local rank = HealComm.rankNumbers[index]
local spellData = HealComm.spellData[tbl.spell]
local spellLevel = spellData.levels[rank]

-- No increase, it doesn't scale with level
Expand Down Expand Up @@ -997,7 +999,7 @@ if( playerClass == "SHAMAN" ) then

-- Cast was interrupted, recheck if we still have the auras up
ResetChargeData = function(guid)
riptideData[guid] = guidToUnit[guid] and unitHasAura(guidToUnit[unit], Riptide) and true or nil
riptideData[guid] = guidToUnit[guid] and unitHasAura(guidToUnit[guid], Riptide) and true or nil
end

-- Lets a specific override on how many people this will hit
Expand Down Expand Up @@ -1914,32 +1916,26 @@ function HealComm:COMBAT_LOG_EVENT_UNFILTERED(timestamp, eventType, sourceGUID,
-- Single stack of a hot was removed, this only applies when going from 2 -> 1, when it goes from 1 -> 0 it fires SPELL_AURA_REMOVED
elseif( eventType == "SPELL_AURA_REMOVED_DOSE" and bit.band(sourceFlags, COMBATLOG_OBJECT_AFFILIATION_MINE) == COMBATLOG_OBJECT_AFFILIATION_MINE ) then
local spellID, spellName, spellSchool, auraType, stacks = ...
--print(sourceName, sourceGUID, destName, destGUID, spellName, auraType, stacks)
local pending = sourceGUID and pendingHeals[sourceGUID] and pendingHeals[sourceGUID][spellID]
if( pending ) then
--print(UnitAura("player", spellName))
if( pending and pending.bitType ) then
local amount
for i=1, #(pending), 4 do
if( pending[i] == destGUID ) then
--print("Found", pending[i + 1])
amount = pending[i + 1]
amount = pending[i + 1] / pending[i + 2]
break
end
end
--print("Proceeding", amount, pending.tickInterval)
if( amount ) then
parseHotHeal(sourceGUID, sourceName, true, spellID, amount, pending.tickInterval, compressGUID[destGUID])
if( pending.hasBomb and pendingHeals[sourceGUID][spellName] ) then
local bombPending = pendingHeals[sourceGUID][spellName]
local bombPending = pending.hasBomb and pendingHeals[sourceGUID][spellName]
if( bombPending and bombPending.bitType ) then
local bombAmount
for i=1, bombPending, 4 do
for i=1, #(bombPending), 4 do
if( bombPending[i] == destGUID ) then
bombAmount = bombPending[i + 1]
bombAmount = bombPending[i + 1] / bombPending[i + 2]
break
end
end
Expand Down Expand Up @@ -2312,9 +2308,6 @@ end
-- Initialize the library
function HealComm:OnInitialize()
if( self.initialized ) then return end
self.initialized = true
-- Load all of the classes formulas and such
LoadClassData()
Expand Down Expand Up @@ -2373,11 +2366,14 @@ function HealComm:OnInitialize()
self.frame:RegisterEvent("GLYPH_UPDATED")
self.frame:RegisterEvent("UNIT_PET")
self.frame:RegisterEvent("UNIT_AURA")
if( self.initialized ) then return end
self.initialized = true
self.resetFrame = self.resetFrame or CreateFrame("Frame")
self.resetFrame = CreateFrame("Frame")
self.resetFrame:Hide()
self.resetFrame:SetScript("OnUpdate", function(self) self:Hide() end)
-- You can't unhook secure hooks after they are done, so will hook once and the HealComm table will update with the latest functions
-- automagically. If a new function is ever used it'll need a specific variable to indicate those set of hooks.
-- By default most of these are mapped to a more generic function, but I call separate ones so I don't have to rehook
Expand Down
8 changes: 4 additions & 4 deletions libs/LibHealComm-4.0/LibHealComm-4.0.toc
@@ -1,9 +1,9 @@
## Interface: 30200
## Title: Lib: Heal Comm - 4.0
## Notes: Pending heals library
## Author: Shadowed and xbeeps
## Title: Lib: HealComm-4.0
## Notes: Library for showing incoming heals and hots
## Author: Shadowed
## X-Category: Library
## X-Curse-Packaged-Version: r20090907184301
## X-Curse-Packaged-Version: b2.2
## X-Curse-Project-Name: LibHealComm-4.0
## X-Curse-Project-ID: libhealcomm-4-0
## X-Curse-Repository-ID: wow/libhealcomm-4-0/mainline
Expand Down
34 changes: 19 additions & 15 deletions oUF_HealComm4.lua
Expand Up @@ -28,17 +28,11 @@ local oUF_HealComm = {}

local healcomm = LibStub("LibHealComm-4.0")

local unitMap = {}

-- update a specific bar
local updateHealCommBar = function(frame, playerGUID)

unitMap = healcomm:GetGuidUnitMapTable() -- doing this every time??? blargh
local unitName = playerGUID and unitMap[playerGUID]

local updateHealCommBar = function(frame, unitName, playerGUID)
if not unitName then return end

local maxHP = UnitHealthMax(unitName)
local maxHP = UnitHealthMax(unitName) or 0

-- hide if unknown max hp
if maxHP == 0 or maxHP == 100 then
Expand All @@ -54,6 +48,9 @@ local updateHealCommBar = function(frame, playerGUID)
return
end

-- apply heal modifier
incHeals = incHeals * healcomm:GetHealModifier(playerGUID)

frame.HealCommBar:Show()

local percInc = incHeals / maxHP
Expand All @@ -66,15 +63,22 @@ end

-- used by library callbacks, arguments should be list of units to update
local updateHealCommBars = function(...)
local playerGUID, frameGUID
local playerGUID, unit, frameGUID

-- update the unitMap to make sure it is current
local unitMap = healcomm:GetGuidUnitMapTable()

for i = 1, select("#", ...) do
playerGUID = select(i, ...)

-- search current oUF frames for this unit
for frame in pairs(oUF.units) do
frameGUID = UnitGUID(frame)
if frameGUID == playerGUID and not oUF.units[frame].ignoreHealComm then
updateHealCommBar(oUF.units[frame], frameGUID)
unit = unitMap[playerGUID]

if unit then
-- search current oUF frames for this unit
for frame in pairs(oUF.units) do
frameGUID = UnitGUID(frame)
if frameGUID == playerGUID and not oUF.units[frame].ignoreHealComm then
updateHealCommBar(oUF.units[frame], unit, frameGUID)
end
end
end
end
Expand Down

0 comments on commit 25b1552

Please sign in to comment.