local totals = {} local last = 0 local incomplete = false local function on_combat(batch) local friendly = {} local self = l2.units.self() if self then friendly[self.id] = true end for _, member in ipairs(l2.units.party()) do friendly[member.id] = true end if batch.overflow then incomplete = true end for _, event in ipairs(batch.records) do local source = event.owner > 0 and event.owner or event.source if friendly[source] and (event.kind == "damage" or event.kind == "heal") then if last > 0 and event.server_ms - last > 12000 then totals, incomplete = {}, batch.overflow end last = math.max(last, event.server_ms) local row = totals[source] or { damage = 0, healing = 0 } if event.kind == "damage" then row.damage = row.damage + event.hp + event.cp else row.healing = row.healing + event.hp + event.cp end totals[source] = row end end end local function draw() if not l2.has("combat") then l2.ui.panel("meter", "Combat meter", "Waiting for a compatible L2G combat feed.") return end local names = {} local player = l2.units.self() if player then names[player.id] = player.name end for _, member in ipairs(l2.units.party()) do names[member.id] = member.name end local rows = {} for id, row in pairs(totals) do if names[id] then rows[#rows + 1] = { name = names[id], damage = row.damage, healing = row.healing } end end table.sort(rows, function(a, b) return a.damage > b.damage end) local lines = { "Damage / Healing" } for i = 1, math.min(6, #rows) do local row = rows[i] lines[#lines + 1] = string.format("%s %d / %d", row.name, math.floor(row.damage), math.floor(row.healing)) end if #rows == 0 then lines[#lines + 1] = "Waiting for combat." end if incomplete then lines[#lines + 1] = "Some combat events were dropped." end l2.ui.panel("meter", "Combat meter", table.concat(lines, "\n")) end function main() l2.on("combat.batch", on_combat) l2.on("party.changed", function() totals, last, incomplete = {}, 0, false end) l2.on("tick", draw) end