Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- SimpleDPS.lua
- -- Simply tells you how much DPS and damage you did during the last fight.
- -- Potential damage meter will come soon.
- local s=CreateFrame("Frame", "SimpleDPS");
- s:RegisterEvent("PLAYER_ENTERING_WORLD");
- s:RegisterEvent("PLAYER_REGEN_DISABLED");
- s:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");
- s:RegisterEvent("PLAYER_REGEN_ENABLED");
- function s:OnEvent(event, ...)
- if event == "PLAYER_ENTERING_WORLD" then
- DEFAULT_CHAT_FRAME:AddMessage("SimpleDPS loaded!");
- elseif event == "PLAYER_REGEN_DISABLED" then
- self.sDps = {};
- self.sDps.start = time();
- elseif event == "PLAYER_REGEN_ENABLED" then
- local t = time();
- local totalTime = t - self.sDps.start;
- local actualTotalDPS = self.sDps.actual / totalTime;
- if self.sDps.destName == nil or type(self.sDps.destName) ~= "string" then
- DEFAULT_CHAT_FRAME:AddMessage("Combat ended.");
- else
- DEFAULT_CHAT_FRAME:AddMessage("Combat against "..self.sDps.destName.." ended.");
- end
- DEFAULT_CHAT_FRAME:AddMessage("Actual Damage Output: "..self.sDps.actual.." ("..actualTotalDPS.." DPS).");
- self.sDps = nil;
- elseif event == "COMBAT_LOG_EVENT_UNFILTERED" then
- if self.sDps ~= nil then
- local _, combatlog_Type, _, sourceName, _, _, destName = ...;
- if sourceName == UnitName("player") and destName ~= UnitName("player") then
- local actualDamage;
- self.sDps.destName = destName;
- if combatlog_Type == "SWING_DAMAGE" then
- local amount, overkill, school, resist, block, absorb = select(9, ...);
- if amount == nil then
- amount = 0;
- end
- if overkill == nil then
- overkill = 0;
- end
- if resist == nil then
- resist = 0;
- end
- if block == nil then
- block = 0;
- end
- if absorb == nil then
- absorb = 0;
- end
- actualDamage = amount - (overkill + resist + block + absorb);
- elseif combatlog_Type == "SPELL_DAMAGE" or "SPELL_PERIODIC_DAMAGE" then
- local amount, overkill, school, resist, block, absorb = select(12, ...);
- if amount == nil then
- amount = 0;
- end
- if overkill == nil then
- overkill = 0;
- end
- if resist == nil then
- resist = 0;
- end
- if block == nil then
- block = 0;
- end
- if absorb == nil then
- absorb = 0;
- end
- actualDamage = amount - (overkill + resist + block + absorb);
- end
- if self.sDps.actual == nil then self.sDps.actual = math.floor(actualDamage) else self.sDps.actual = math.floor(self.sDps.actual + actualDamage) end
- end
- end
- end
- end
- s:SetScript("OnEvent", s.OnEvent);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement