Advertisement
Guest User

Untitled

a guest
May 23rd, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.56 KB | None | 0 0
  1. -- SimpleDPS.lua
  2. -- Simply tells you how much DPS and damage you did during the last fight.
  3. -- Potential damage meter will come soon.
  4. local s=CreateFrame("Frame", "SimpleDPS");
  5. s:RegisterEvent("PLAYER_ENTERING_WORLD");
  6. s:RegisterEvent("PLAYER_REGEN_DISABLED");
  7. s:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");
  8. s:RegisterEvent("PLAYER_REGEN_ENABLED");
  9.  
  10.  
  11. function s:OnEvent(event, ...)
  12.     if event == "PLAYER_ENTERING_WORLD" then
  13.         DEFAULT_CHAT_FRAME:AddMessage("SimpleDPS loaded!");
  14.     elseif event == "PLAYER_REGEN_DISABLED" then
  15.         self.sDps = {};
  16.         self.sDps.start = time();
  17.     elseif event == "PLAYER_REGEN_ENABLED" then
  18.         local t = time();
  19.         local totalTime = t - self.sDps.start;
  20.         local actualTotalDPS = self.sDps.actual / totalTime;
  21.         if self.sDps.destName == nil or type(self.sDps.destName) ~= "string" then
  22.             DEFAULT_CHAT_FRAME:AddMessage("Combat ended.");
  23.         else
  24.             DEFAULT_CHAT_FRAME:AddMessage("Combat against "..self.sDps.destName.." ended.");
  25.         end
  26.         DEFAULT_CHAT_FRAME:AddMessage("Actual Damage Output: "..self.sDps.actual.." ("..actualTotalDPS.." DPS).");
  27.         self.sDps = nil;
  28.     elseif event == "COMBAT_LOG_EVENT_UNFILTERED" then
  29.         if self.sDps ~= nil then
  30.             local _, combatlog_Type, _, sourceName, _, _, destName = ...;
  31.             if sourceName == UnitName("player") and destName ~= UnitName("player") then
  32.                 local actualDamage;
  33.                 self.sDps.destName = destName;
  34.                 if combatlog_Type == "SWING_DAMAGE" then
  35.                     local amount, overkill, school, resist, block, absorb = select(9, ...);
  36.                     if amount == nil then
  37.                         amount = 0;
  38.                     end                
  39.                     if overkill == nil then
  40.                         overkill = 0;
  41.                     end
  42.                     if resist == nil then
  43.                         resist = 0;
  44.                     end
  45.                     if block == nil then
  46.                         block = 0;
  47.                     end
  48.                     if absorb == nil then
  49.                         absorb = 0;
  50.                     end
  51.                     actualDamage = amount - (overkill + resist + block + absorb);
  52.                 elseif combatlog_Type == "SPELL_DAMAGE" or "SPELL_PERIODIC_DAMAGE" then
  53.                     local amount, overkill, school, resist, block, absorb = select(12, ...);
  54.                     if amount == nil then
  55.                         amount = 0;
  56.                     end
  57.                     if overkill == nil then
  58.                         overkill = 0;
  59.                     end
  60.                     if resist == nil then
  61.                         resist = 0;
  62.                     end
  63.                     if block == nil then
  64.                         block = 0;
  65.                     end
  66.                     if absorb == nil then
  67.                         absorb = 0;
  68.                     end
  69.                     actualDamage = amount - (overkill + resist + block + absorb);
  70.                 end
  71.                 if self.sDps.actual == nil then self.sDps.actual = math.floor(actualDamage) else self.sDps.actual = math.floor(self.sDps.actual + actualDamage) end
  72.             end
  73.         end
  74.     end
  75. end
  76.  
  77. s:SetScript("OnEvent", s.OnEvent);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement