Advertisement
Guest User

Untitled

a guest
Sep 12th, 2016
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 19.29 KB | None | 0 0
  1.  
  2. Skada:AddLoadableModule("Damage", function(Skada, L)
  3.     if Skada.db.profile.modulesBlocked.Damage then return end
  4.  
  5.     local mod = Skada:NewModule(L["Damage"])
  6.     local dpsmod = Skada:NewModule(L["DPS"])
  7.     local playermod = Skada:NewModule(L["Damage spell list"])
  8.     local spellmod = Skada:NewModule(L["Damage spell details"])
  9.     local damagedmod = Skada:NewModule(L["Damaged mobs"])
  10.  
  11.     local function getDPS(set, player)
  12.         local totaltime = Skada:PlayerActiveTime(set, player)
  13.  
  14.         return player.damage / math.max(1,totaltime)
  15.     end
  16.  
  17.     local function getRaidDPS(set)
  18.         if set.time > 0 then
  19.             return set.damage / math.max(1, set.time)
  20.         else
  21.             local endtime = set.endtime
  22.             if not endtime then
  23.                 endtime = time()
  24.             end
  25.             return set.damage / math.max(1, endtime - set.starttime)
  26.         end
  27.     end
  28.  
  29.     local function log_damage(set, dmg)
  30.         -- Get the player.
  31.         local player = Skada:get_player(set, dmg.playerid, dmg.playername)
  32.         if player then
  33.  
  34.             -- Subtract overkill
  35.     --      local amount = math.max(0,dmg.amount - dmg.overkill)
  36.             -- Or don't. Seems to be the way other meters do it.
  37.             local amount = dmg.amount
  38.     --      self:Print(player.name..": "..dmg.spellname.." for "..tostring(amount))
  39.  
  40.             -- Also add to set total damage.
  41.             set.damage = set.damage + amount
  42.  
  43.             -- Add spell to player if it does not exist.
  44.             if not player.damagespells[dmg.spellname] then
  45.                 player.damagespells[dmg.spellname] = {id = dmg.spellid, totalhits = 0, damage = 0}
  46.             end
  47.  
  48.             -- Add to player total damage.
  49.             player.damage = player.damage + amount
  50.  
  51.             -- Get the spell from player.
  52.             local spell = player.damagespells[dmg.spellname]
  53.  
  54.             if not dmg.multistrike then
  55.                 spell.totalhits = spell.totalhits + 1
  56.  
  57.                 if spell.max == nil or amount > spell.max then
  58.                     spell.max = amount
  59.                 end
  60.  
  61.                 if (spell.min == nil or amount < spell.min) and not dmg.missed then
  62.                     spell.min = amount
  63.                 end
  64.             end
  65.  
  66.             spell.damage = spell.damage + amount
  67.  
  68.             if dmg.multistrike then
  69.                 spell.multistrike = (spell.multistrike or 0) + 1
  70.             elseif dmg.critical then
  71.                 spell.critical = (spell.critical or 0) + 1
  72.             elseif dmg.missed ~= nil then
  73.                 spell[dmg.missed] = (spell[dmg.missed] or 0) + 1
  74.             elseif dmg.glancing then
  75.                 spell.glancing = (spell.glancing or 0) + 1
  76.             elseif dmg.crushing then
  77.                 spell.crushing = (spell.crushing or 0) + 1
  78.             else
  79.                 spell.hit = (spell.hit or 0) + 1
  80.             end
  81.  
  82.             -- For now, only save damaged info to current set.
  83.             -- Saving this to Total may become a memory hog deluxe, and besides, it does not make much sense
  84.             -- to see in Total. Why care which particular mob you damaged the most in a whole raid, for example?
  85.             if set == Skada.current and dmg.dstname and amount > 0 then
  86.                 -- Make sure destination exists in player.
  87.                 if not player.damaged[dmg.dstname] then
  88.                     player.damaged[dmg.dstname] = 0
  89.                 end
  90.  
  91.                 -- Add to destination.
  92.                 player.damaged[dmg.dstname] = player.damaged[dmg.dstname] + amount
  93.             end
  94.  
  95.         end
  96.     end
  97.  
  98.     local dmg = {}
  99.  
  100.     local function SpellDamage(timestamp, eventtype, srcGUID, srcName, srcFlags, dstGUID, dstName, dstFlags, spellId, spellName, spellSchool, samount, soverkill, sschool, sresisted, sblocked, sabsorbed, scritical, sglancing, scrushing, soffhand, smultistrike)
  101.         -- Spell damage.
  102.         if srcGUID ~= dstGUID then
  103.             -- XXX WoD quick fix for Mage's Prismatic Crystal talent
  104.             -- All damage done to the crystal is transferred, so ignore it
  105.             -- Now with extra Legion "quick fix" for Warlock's Soul Effigy!
  106.             if dstGUID:match("^Creature%-0%-%d+%-%d+%-%d+%-76933%-%w+$") or dstGUID:match("^Creature%-0%-%d+%-%d+%-%d+%-103679%-%w+$") then
  107.                 return
  108.             end
  109.  
  110.             if spellId == 191259 or spellId == 190893 and srcFlags == 0x511 then
  111.                 srcGUID = UnitGUID("player")
  112.                 srcName = UnitName("player")
  113.             end
  114.            
  115.            
  116.            
  117.             dmg.playerid = srcGUID
  118.             dmg.playerflags = srcFlags
  119.             dmg.dstname = dstName
  120.             dmg.playername = srcName
  121.             dmg.spellid = spellId
  122.             dmg.spellname = spellName
  123.             dmg.amount = samount
  124.             dmg.overkill = soverkill
  125.             dmg.resisted = sresisted
  126.             dmg.blocked = sblocked
  127.             dmg.absorbed = sabsorbed
  128.             dmg.critical = scritical
  129.             dmg.glancing = sglancing
  130.             dmg.crushing = scrushing
  131.             dmg.offhand = soffhand
  132.             dmg.multistrike = smultistrike
  133.             dmg.missed = nil
  134.  
  135.             Skada:FixPets(dmg)
  136.             log_damage(Skada.current, dmg)
  137.             log_damage(Skada.total, dmg)
  138.         end
  139.     end
  140.  
  141.     local function SwingDamage(timestamp, eventtype, srcGUID, srcName, srcFlags, dstGUID, dstName, dstFlags, samount, soverkill, sschool, sresisted, sblocked, sabsorbed, scritical, sglancing, scrushing, soffhand, smultistrike)
  142.         -- White melee.
  143.         if srcGUID ~= dstGUID then
  144.             dmg.playerid = srcGUID
  145.             dmg.playername = srcName
  146.             dmg.playerflags = srcFlags
  147.             dmg.dstname = dstName
  148.             dmg.spellid = 6603
  149.             dmg.spellname = L["Attack"]
  150.             dmg.amount = samount
  151.             dmg.overkill = soverkill
  152.             dmg.resisted = sresisted
  153.             dmg.blocked = sblocked
  154.             dmg.absorbed = sabsorbed
  155.             dmg.critical = scritical
  156.             dmg.glancing = sglancing
  157.             dmg.crushing = scrushing
  158.             dmg.offhand = soffhand
  159.             dmg.multistrike = smultistrike
  160.             dmg.missed = nil
  161.  
  162.             Skada:FixPets(dmg)
  163.             log_damage(Skada.current, dmg)
  164.             log_damage(Skada.total, dmg)
  165.         end
  166.     end
  167.  
  168.     local function SpellAbsorbed(timestamp, eventtype, srcGUID, srcName, srcFlags, dstGUID, dstName, dstFlags, ...)
  169.         local chk = ...
  170.         local spellId, spellName, spellSchool, aGUID, aName, aFlags, aRaidFlags, aspellId, aspellName, aspellSchool, aAmount
  171.  
  172.         if type(chk) == "number" then
  173.             -- Spell event
  174.             spellId, spellName, spellSchool, aGUID, aName, aFlags, aRaidFlags, aspellId, aspellName, aspellSchool, aAmount = ...
  175.            
  176.             -- Exclude Spirit Shift damage
  177.             if aspellId == 184553 then
  178.                 return
  179.             end
  180.                
  181.             if aAmount then
  182.                 SpellDamage(timestamp, eventtype, srcGUID, srcName, srcFlags, dstGUID, dstName, dstFlags, spellId, spellName, spellSchool, aAmount)
  183.             end
  184.         else
  185.             -- Swing event
  186.             aGUID, aName, aFlags, aRaidFlags, aspellId, aspellName, aspellSchool, aAmount = ...
  187.  
  188.             -- Exclude Spirit Shift damage
  189.             if aspellId == 184553 then
  190.                 return
  191.             end
  192.                
  193.             if aAmount then
  194.                 SwingDamage(timestamp, eventtype, srcGUID, srcName, srcFlags, dstGUID, dstName, dstFlags, aAmount)  
  195.             end
  196.         end
  197.     end
  198.        
  199.     local function SwingMissed(timestamp, eventtype, srcGUID, srcName, srcFlags, dstGUID, dstName, dstFlags, missed)
  200.         if srcGUID ~= dstGUID then
  201.             -- Melee misses
  202.  
  203.             dmg.playerid = srcGUID
  204.             dmg.playername = srcName
  205.             dmg.playerflags = srcFlags
  206.             dmg.dstname = dstName
  207.             dmg.spellid = 6603
  208.             dmg.spellname = L["Attack"]
  209.             dmg.amount = 0
  210.             dmg.overkill = 0
  211.             dmg.resisted = nil
  212.             dmg.blocked = nil
  213.             dmg.absorbed = nil
  214.             dmg.critical = nil
  215.             dmg.glancing = nil
  216.             dmg.crushing = nil
  217.             dmg.offhand = nil
  218.             dmg.multistrike = nil
  219.             dmg.missed = missed
  220.  
  221.             Skada:FixPets(dmg)
  222.             log_damage(Skada.current, dmg)
  223.             log_damage(Skada.total, dmg)
  224.         end
  225.     end
  226.  
  227.     local function SpellMissed(timestamp, eventtype, srcGUID, srcName, srcFlags, dstGUID, dstName, dstFlags, spellId, spellName, spellSchool, missType)
  228.         -- Misses
  229.         if srcGUID ~= dstGUID then
  230.             dmg.playerid = srcGUID
  231.             dmg.playername = srcName
  232.             dmg.playerflags = srcFlags
  233.             dmg.dstname = dstName
  234.             dmg.spellid = spellId
  235.             dmg.spellname = spellName
  236.             dmg.amount = 0
  237.             dmg.overkill = 0
  238.             dmg.resisted = nil
  239.             dmg.blocked = nil
  240.             dmg.absorbed = nil
  241.             dmg.critical = nil
  242.             dmg.glancing = nil
  243.             dmg.crushing = nil
  244.             dmg.offhand = nil
  245.             dmg.multistrike = nil
  246.             dmg.missed = missType
  247.  
  248.             Skada:FixPets(dmg)
  249.             log_damage(Skada.current, dmg)
  250.             log_damage(Skada.total, dmg)
  251.         end
  252.     end
  253.  
  254.     -- Damage overview.
  255.     function mod:Update(win, set)
  256.         -- Max value.
  257.         local max = 0
  258.  
  259.         local nr = 1
  260.         for i, player in ipairs(set.players) do
  261.             if player.damage > 0 then
  262.                 local dps = getDPS(set, player)
  263.  
  264.                 local d = win.dataset[nr] or {}
  265.                 win.dataset[nr] = d
  266.                 d.label = player.name
  267.  
  268.                 d.valuetext = Skada:FormatValueText(
  269.                     Skada:FormatNumber(player.damage), self.metadata.columns.Damage,
  270.                     Skada:FormatNumber(dps), self.metadata.columns.DPS,
  271.                     string.format("%02.1f%%", player.damage / set.damage * 100), self.metadata.columns.Percent
  272.                 )
  273.  
  274.                 d.value = player.damage
  275.                 d.id = player.id
  276.                 d.class = player.class
  277.                 d.role = player.role
  278.                 if player.damage > max then
  279.                     max = player.damage
  280.                 end
  281.                 nr = nr + 1
  282.             end
  283.         end
  284.  
  285.         win.metadata.maxvalue = max
  286.     end
  287.  
  288.     -- Tooltip for a specific player.
  289.     local function dps_tooltip(win, id, label, tooltip)
  290.         local set = win:get_selected_set()
  291.         local player = Skada:find_player(set, id)
  292.         if player then
  293.  
  294.             local activetime = Skada:PlayerActiveTime(set, player)
  295.             local totaltime = Skada:GetSetTime(set)
  296.             tooltip:AddLine(player.name.." - "..L["DPS"])
  297.             tooltip:AddDoubleLine(L["Segment time"], totaltime.."s", 255,255,255,255,255,255)
  298.             tooltip:AddDoubleLine(L["Active time"], activetime.."s", 255,255,255,255,255,255)
  299.             tooltip:AddDoubleLine(L["Damage done"], Skada:FormatNumber(player.damage), 255,255,255,255,255,255)
  300.             tooltip:AddDoubleLine(Skada:FormatNumber(player.damage) .. " / " .. activetime .. ":", ("%02.1f"):format(player.damage / math.max(1,activetime)), 255,255,255,255,255,255)
  301.  
  302.         end
  303.     end
  304.  
  305.     -- Tooltip for a specific player.
  306.     local function player_tooltip(win, id, label, tooltip)
  307.         local player = Skada:find_player(win:get_selected_set(), playermod.playerid)
  308.         if player then
  309.             local spell = player.damagespells[label]
  310.             if spell then
  311.                 tooltip:AddLine(player.name.." - "..label)
  312.                 if spell.max and spell.min then
  313.                     tooltip:AddDoubleLine(L["Minimum hit:"], Skada:FormatNumber(spell.min), 255,255,255,255,255,255)
  314.                     tooltip:AddDoubleLine(L["Maximum hit:"], Skada:FormatNumber(spell.max), 255,255,255,255,255,255)
  315.                 end
  316.                 tooltip:AddDoubleLine(L["Average hit:"], Skada:FormatNumber(spell.damage / spell.totalhits), 255,255,255,255,255,255)
  317.             end
  318.         end
  319.     end
  320.  
  321.     -- Tooltip for a specific player.
  322.     -- This is a post-tooltip
  323.     local function damage_tooltip(win, id, label, tooltip)
  324.         local set = win:get_selected_set()
  325.         local player = Skada:find_player(set, id)
  326.         --ChatFrame4:AddMessage(("Set: %s, id: %s"):format(set, id))
  327.         if player then
  328.             local activetime = Skada:PlayerActiveTime(set, player)
  329.             local totaltime = Skada:GetSetTime(set)
  330.             tooltip:AddDoubleLine(L["Activity"], ("%02.1f%%"):format(activetime/math.max(1,totaltime)*100), 255,255,255,255,255,255)
  331.         end
  332.     end
  333.  
  334.     function playermod:Enter(win, id, label)
  335.         local player = Skada:find_player(win:get_selected_set(), id)
  336.         if player then
  337.             playermod.playerid = id
  338.             playermod.title = player.name..L["'s Damage"]
  339.         end
  340.     end
  341.  
  342.     -- Detail view of a player.
  343.     function playermod:Update(win, set)
  344.         -- View spells for this player.
  345.  
  346.         local player = Skada:find_player(set, self.playerid)
  347.         local max = 0
  348.  
  349.         -- If we reset we have no data.
  350.         if player then
  351.  
  352.             local nr = 1
  353.             if player then
  354.                 for spellname, spell in pairs(player.damagespells) do
  355.  
  356.                     local d = win.dataset[nr] or {}
  357.                     win.dataset[nr] = d
  358.                     d.label = spellname
  359.                     d.id = spellname
  360.                     local _, _, icon = GetSpellInfo(spell.id)
  361.                     d.icon = icon
  362.                     d.spellid = spell.id
  363.                     d.value = spell.damage
  364.                     d.valuetext = Skada:FormatValueText(
  365.                         Skada:FormatNumber(spell.damage), self.metadata.columns.Damage,
  366.                         string.format("%02.1f%%", spell.damage / player.damage * 100), self.metadata.columns.Percent
  367.                     )
  368.                     if spell.damage > max then
  369.                         max = spell.damage
  370.                     end
  371.                     nr = nr + 1
  372.                 end
  373.             end
  374.         end
  375.  
  376.         win.metadata.maxvalue = max
  377.     end
  378.  
  379.     function damagedmod:Enter(win, id, label)
  380.         local player = Skada:find_player(win:get_selected_set(), id)
  381.         damagedmod.playerid = id
  382.         damagedmod.title = (player and player.name or "Unknown")..L["'s "]..L["Damaged mobs"]
  383.     end
  384.  
  385.     -- Player view showing damaged mobs.
  386.     function damagedmod:Update(win, set)
  387.         local player = Skada:find_player(set, self.playerid)
  388.         local max = 0
  389.  
  390.         -- If we reset we have no data.
  391.         if player then
  392.  
  393.             local nr = 1
  394.             if player then
  395.                 for mob, amount in pairs(player.damaged) do
  396.  
  397.                     local d = win.dataset[nr] or {}
  398.                     win.dataset[nr] = d
  399.                     d.label = mob
  400.                     d.id = mob
  401.                     d.value = amount
  402.                     d.valuetext = Skada:FormatValueText(
  403.                         Skada:FormatNumber(amount), self.metadata.columns.Damage,
  404.                         string.format("%02.1f%%", amount / player.damage * 100), self.metadata.columns.Percent
  405.                     )
  406.                     if amount > max then
  407.                         max = amount
  408.                     end
  409.                     nr = nr + 1
  410.                 end
  411.             end
  412.         end
  413.  
  414.         win.metadata.maxvalue = max
  415.     end
  416.  
  417.     local function add_detail_bar(win, title, value)
  418.         local nr = spellmod.nr + 1
  419.         spellmod.nr = nr
  420.         local d = win.dataset[nr] or {}
  421.         win.dataset[nr] = d
  422.  
  423.         d.value = value
  424.         d.label = title
  425.         d.id = title
  426.         d.valuetext = Skada:FormatValueText(
  427.             value, mod.metadata.columns.Damage,
  428.             string.format("%02.1f%%", value / spellmod.totalhits * 100), mod.metadata.columns.Percent
  429.         )
  430.  
  431.         win.metadata.maxvalue = math.max(win.metadata.maxvalue, value)
  432.     end
  433.  
  434.     function spellmod:Enter(win, id, label)
  435.         local player = Skada:find_player(win:get_selected_set(), playermod.playerid)
  436.         spellmod.spellname = label
  437.         spellmod.title = player.name..L["'s "]..label
  438.     end
  439.  
  440.     function spellmod:Update(win, set)
  441.         local player = Skada:find_player(set,playermod.playerid)
  442.  
  443.         if player then
  444.             local spell = player.damagespells[self.spellname]
  445.  
  446.             if spell then
  447.                 spellmod.totalhits = spell.totalhits
  448.                 spellmod.nr = 0
  449.                 win.metadata.maxvalue = 0
  450.  
  451.                 if spell.hit and spell.hit > 0 then
  452.                     add_detail_bar(win, L["Hit"], spell.hit)
  453.                 end
  454.                 if spell.critical and spell.critical > 0 then
  455.                     add_detail_bar(win, L["Critical"], spell.critical)
  456.                 end
  457.                 if spell.multistrike and spell.multistrike > 0 then
  458.                     add_detail_bar(win, L["Multistrike"], spell.multistrike)
  459.                 end
  460.                 if spell.glancing and spell.glancing > 0 then
  461.                     add_detail_bar(win, L["Glancing"], spell.glancing)
  462.                 end
  463.                 if spell.crushing and spell.crushing > 0 then
  464.                     add_detail_bar(win, L["Crushing"], spell.crushing)
  465.                 end
  466.                 if spell.ABSORB and spell.ABSORB > 0 then
  467.                     add_detail_bar(win, L["Absorb"], spell.ABSORB)
  468.                 end
  469.                 if spell.BLOCK and spell.BLOCK > 0 then
  470.                     add_detail_bar(win, L["Block"], spell.BLOCK)
  471.                 end
  472.                 if spell.DEFLECT and spell.DEFLECT > 0 then
  473.                     add_detail_bar(win, L["Deflect"], spell.DEFLECT)
  474.                 end
  475.                 if spell.DODGE and spell.DODGE > 0 then
  476.                     add_detail_bar(win, L["Dodge"], spell.DODGE)
  477.                 end
  478.                 if spell.EVADE and spell.EVADE > 0 then
  479.                     add_detail_bar(win, L["Evade"], spell.EVADE)
  480.                 end
  481.                 if spell.IMMUNE and spell.IMMUNE > 0 then
  482.                     add_detail_bar(win, L["Immune"], spell.IMMUNE)
  483.                 end
  484.                 if spell.MISS and spell.MISS > 0 then
  485.                     add_detail_bar(win, L["Missed"], spell.MISS)
  486.                 end
  487.                 if spell.PARRY and spell.PARRY > 0 then
  488.                     add_detail_bar(win, L["Parry"], spell.PARRY)
  489.                 end
  490.                 if spell.REFLECT and spell.REFLECT > 0 then
  491.                     add_detail_bar(win, L["Reflect"], spell.REFLECT)
  492.                 end
  493.                 if spell.RESIST and spell.RESIST > 0 then
  494.                     add_detail_bar(win, L["Resist"], spell.RESIST)
  495.                 end
  496.  
  497.             end
  498.         end
  499.  
  500.     end
  501.  
  502.     -- DPS-only view
  503.     function dpsmod:GetSetSummary(set)
  504.         return Skada:FormatNumber(getRaidDPS(set))
  505.     end
  506.  
  507.     function dpsmod:Update(win, set)
  508.         local max = 0
  509.         local nr = 1
  510.  
  511.         for i, player in ipairs(set.players) do
  512.             local dps = getDPS(set, player)
  513.  
  514.             if dps > 0 then
  515.                 local d = win.dataset[nr] or {}
  516.                 win.dataset[nr] = d
  517.                 d.label = player.name
  518.                 d.id = player.id
  519.                 d.value = dps
  520.                 d.class = player.class
  521.                 d.role = player.role
  522.                 d.valuetext = Skada:FormatNumber(dps)
  523.                 if dps > max then
  524.                     max = dps
  525.                 end
  526.  
  527.                 nr = nr + 1
  528.             end
  529.         end
  530.  
  531.         win.metadata.maxvalue = max
  532.     end
  533.  
  534.     function mod:OnEnable()
  535.         dpsmod.metadata =       {showspots = true, tooltip = dps_tooltip}
  536.         playermod.metadata =    {tooltip = player_tooltip, click1 = spellmod, columns = {Damage = true, Percent = true}}
  537.         mod.metadata =          {post_tooltip = damage_tooltip, showspots = true, click1 = playermod, click2 = damagedmod, columns = {Damage = true, DPS = true, Percent = true}}
  538.         damagedmod.metadata =   {columns = {Damage = true, Percent = true}}
  539.         spellmod.metadata =     {columns = {Damage = true, Percent = true}}
  540.  
  541.         Skada:RegisterForCL(SpellDamage, 'DAMAGE_SHIELD', {src_is_interesting = true, dst_is_not_interesting = true})
  542.         Skada:RegisterForCL(SpellDamage, 'SPELL_DAMAGE', {src_is_interesting = true, dst_is_not_interesting = true})
  543.         Skada:RegisterForCL(SpellAbsorbed, 'SPELL_ABSORBED', {src_is_interesting = true, dst_is_not_interesting = true})
  544.         Skada:RegisterForCL(SpellDamage, 'SPELL_PERIODIC_DAMAGE', {src_is_interesting = true, dst_is_not_interesting = true})
  545.         Skada:RegisterForCL(SpellDamage, 'SPELL_BUILDING_DAMAGE', {src_is_interesting = true, dst_is_not_interesting = true})
  546.         Skada:RegisterForCL(SpellDamage, 'RANGE_DAMAGE', {src_is_interesting = true, dst_is_not_interesting = true})
  547.  
  548.         Skada:RegisterForCL(SwingDamage, 'SWING_DAMAGE', {src_is_interesting = true, dst_is_not_interesting = true})
  549.         Skada:RegisterForCL(SwingMissed, 'SWING_MISSED', {src_is_interesting = true, dst_is_not_interesting = true})
  550.  
  551.         Skada:RegisterForCL(SpellMissed, 'SPELL_MISSED', {src_is_interesting = true, dst_is_not_interesting = true})
  552.         Skada:RegisterForCL(SpellMissed, 'SPELL_PERIODIC_MISSED', {src_is_interesting = true, dst_is_not_interesting = true})
  553.         Skada:RegisterForCL(SpellMissed, 'RANGE_MISSED', {src_is_interesting = true, dst_is_not_interesting = true})
  554.         Skada:RegisterForCL(SpellMissed, 'SPELL_BUILDING_MISSED', {src_is_interesting = true, dst_is_not_interesting = true})
  555.  
  556.         Skada:AddFeed(L["Damage: Personal DPS"], function()
  557.             if Skada.current then
  558.                 local player = Skada:find_player(Skada.current, UnitGUID("player"))
  559.                 if player then
  560.                     return Skada:FormatNumber(getDPS(Skada.current, player)).." "..L["DPS"]
  561.                 end
  562.             end
  563.         end)
  564.         Skada:AddFeed(L["Damage: Raid DPS"], function()
  565.             if Skada.current then
  566.                 return Skada:FormatNumber(getRaidDPS(Skada.current)).." "..L["RDPS"]
  567.             end
  568.         end)
  569.         Skada:AddMode(self)
  570.     end
  571.  
  572.     function mod:OnDisable()
  573.         Skada:RemoveMode(self)
  574.  
  575.         Skada:RemoveFeed(L["Damage: Personal DPS"])
  576.         Skada:RemoveFeed(L["Damage: Raid DPS"])
  577.     end
  578.  
  579.     function dpsmod:OnEnable()
  580.         Skada:AddMode(self)
  581.     end
  582.  
  583.     function dpsmod:OnDisable()
  584.         Skada:RemoveMode(self)
  585.     end
  586.  
  587.     function mod:AddToTooltip(set, tooltip)
  588.         GameTooltip:AddDoubleLine(L["DPS"], Skada:FormatNumber(getRaidDPS(set)), 1,1,1)
  589.     end
  590.  
  591.     function mod:GetSetSummary(set)
  592.         return Skada:FormatValueText(
  593.             Skada:FormatNumber(set.damage), self.metadata.columns.Damage,
  594.             Skada:FormatNumber(getRaidDPS(set)), self.metadata.columns.DPS
  595.         )
  596.     end
  597.  
  598.     -- Called by Skada when a new player is added to a set.
  599.     function mod:AddPlayerAttributes(player)
  600.         if not player.damage then
  601.             player.damage = 0
  602.             player.damagespells = {}
  603.         end
  604.         if not player.damaged then
  605.             player.damaged = {}
  606.         end
  607.     end
  608.  
  609.     -- Called by Skada when a new set is created.
  610.     function mod:AddSetAttributes(set)
  611.         if not set.damage then
  612.             set.damage = 0
  613.         end
  614.     end
  615. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement