Skip to content

Commit

Permalink
Constantly update DPS if we need to
Browse files Browse the repository at this point in the history
  • Loading branch information
Zariel committed Jun 20, 2010
1 parent 4a6f897 commit 39dd6da
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 24 deletions.
4 changes: 2 additions & 2 deletions core.lua
Expand Up @@ -130,8 +130,8 @@ function addon:COMBAT_LOG_EVENT_UNFILTERED(timeStamp, event, sourceGUID, sourceN
over = over or 0 over = over or 0


-- Track over kill ? -- Track over kill ?
-- local damage = ammount - (over + resist) local damage = ammount - (over + resist)
local damage = ammount --local damage = ammount


local overHeal local overHeal
if (event == "SPELL_HEAL" or event == "SPELL_PERIDOIC_HEAL") and over > 0 then if (event == "SPELL_HEAL" or event == "SPELL_PERIDOIC_HEAL") and over > 0 then
Expand Down
56 changes: 34 additions & 22 deletions display.lua
Expand Up @@ -62,19 +62,18 @@ function View:UpdateDPS(time)
local t local t
for unit, guid in fiend:IterateUnitRoster() do for unit, guid in fiend:IterateUnitRoster() do
t = self.dps[guid] t = self.dps[guid]
if fiend:InCombat(guid) then if(fiend:InCombat(guid)) then
if t.timer < 5 then if(t.reset) then
t.timer = t.timer + time t.damage = 0
else t.time = 0
t.time = t.time + 1 t.reset = false
t.damage = t.damage + (t.segment / t.timer)

t.timer = 0
t.segment = 0
end end

t.damage = t.damage + t.segment

t.time = t.time + time
else else
--t.damage = 0 t.reset = true
t.timer = 0
end end
end end
end end
Expand All @@ -87,16 +86,19 @@ function View:Update(guid, ammount, name)
local bar = self.guids[guid] local bar = self.guids[guid]
bar.name = string.match(name, "(.*)\-?") bar.name = string.match(name, "(.*)\-?")


if not self.showDPS then self.dps[guid].damage = self.dps[guid].damage + ammount

if(not self.showDPS) then
bar.total = bar.total + ammount bar.total = bar.total + ammount
self.total = self.total + ammount else
bar.total = self:GetDPS(bar.guid)
end end


self.dps[guid].segment = self.dps[guid].segment + ammount self.total = self.total + ammount


-- bar.per = math.floor(bar.total / self.total * 100) -- bar.per = math.floor(bar.total / self.total * 100)


if bar.total > 1e3 then if(bar.total > 1e3) then
bar.right:SetText(math.floor((bar.total * 10) / 100) / 100 .. "k") bar.right:SetText(math.floor((bar.total * 10) / 100) / 100 .. "k")
else else
bar.right:SetText(bar.total) bar.right:SetText(bar.total)
Expand All @@ -106,11 +108,13 @@ function View:Update(guid, ammount, name)
end end


function View:UpdateDisplay() function View:UpdateDisplay()
if not self.isActive or #self.bars == 0 or not self.display.frame:IsShown() then return end if not self.isActive or #self.bars == 0 or not self.display.frame:IsShown() or self.updating then return end
self.updating = true


if self.showDPS then if self.showDPS then
for guid, bar in pairs(self.bars) do for guid, bar in pairs(self.bars) do
bar.total = self:GetDPS(bar.guid) --bar.total = self:GetDPS(bar.guid)
self:Update(bar.guid, 0, bar.name)
end end
end end


Expand All @@ -126,6 +130,7 @@ function View:UpdateDisplay()
local bar local bar
for i = 1, #self.bars do for i = 1, #self.bars do
bar = self.bars[i] bar = self.bars[i]

if i > total then if i > total then
bar.pos = 0 bar.pos = 0
bar:Hide() bar:Hide()
Expand All @@ -145,6 +150,7 @@ function View:UpdateDisplay()
end end


self.dirty = false self.dirty = false
self.updating = false
end end


function View:RemoveAllBars() function View:RemoveAllBars()
Expand Down Expand Up @@ -238,18 +244,24 @@ function View:Output(count, where, player)
for i = 1, count or #self.bars do for i = 1, count or #self.bars do
if not self.bars[i] then break end if not self.bars[i] then break end
bar = self.bars[i] bar = self.bars[i]
output(string.format("%d. %s - %d %d%%", i, bar.name, bar.total, (math.floor(bar.total * 10000 / self.total) / 100))) local dps = self:GetDPS(bar.guid)

if(dps > 0) then
output(string.format("%d. %s - %d %d%% - %d dps", i, bar.name, bar.total, (math.floor(bar.total * 10000 / self.total) / 100), dps))
else
output(string.format("%d. %s - %d %d%%", i, bar.name, bar.total, (math.floor(bar.total * 10000 / self.total) / 100)))
end
end end
end end


function Display:OnUpdate(elapsed) function Display:OnUpdate(elapsed)
if self.currentView and self.currentView.dirty then
self.currentView:UpdateDisplay()
end

for i, view in pairs(self.views) do for i, view in pairs(self.views) do
view:UpdateDPS(elapsed) view:UpdateDPS(elapsed)
end end

if((self.currentView and self.currentView.dirty) or self.currentView.showDPS) then
self.currentView:UpdateDisplay()
end
end end


function Display:CreateFrame(title) function Display:CreateFrame(title)
Expand Down

0 comments on commit 39dd6da

Please sign in to comment.