if ( not LynStats ) then return end if ( not LynStats.plugins ) then LynStats.plugins = {} end local gPeen = CreateFrame("Button", "gPeen", LynStats) gPeen.text = gPeen:CreateFontString(nil, "OVERLAY") gPeen.channel = "GUILD" local bit_bor = bit.bor local COMBATLOG_FILTER_ME = COMBATLOG_FILTER_ME local hit, crit = 0, 0 local lastHit, lastCrit = 0, 0 local spellHit, spellCrit local font = "Fonts\\skurri.ttf" local size = 16 local color = { r = 0, g = 0.8, b = 1 } function gPeen:getHighest() local hit, crit = 0, 0 local lastHit, lastCrit = 0, 0 local spellHit, spellCrit for spell in pairs(gPeenDB) do if ( gPeenDB[spell].normal > lastHit ) then hit = gPeenDB[spell].normal lastHit = hit spellHit = spell end if ( gPeenDB[spell].critical > lastCrit ) then crit = gPeenDB[spell].critical lastCrit = crit spellCrit = spell end end return hit, crit, spellHit, spellCrit end function gPeen:BuffPeen(spellName, amount, critical) assert(type(spellName) == "string", format("bad argument #1 to 'BuffPeen' (string expected, got %s)", type(spellName))) assert(type(amount) == "number", format("bad argument #2 to 'BuffPeen' (number expected, got %s)", type(amount))) if ( not gPeenDB[spellName] ) then gPeenDB[spellName] = { normal = 0, critical = 0 } end if ( critical ) then if ( amount > gPeenDB[spellName].critical ) then gPeenDB[spellName].critical = amount --gPeen:AddMessage(spellName.." : "..amount.." (CRIT)", 1, 1, 1, 1, 2) if ( MikSBT and not MikSBT.IsModDisabled() ) then MikSBT.DisplayMessage(spellName.." : "..amount.." (CRIT)", MikSBT.DISPLAYTYPE_NOTIFICATION, true, 255, 255, 255, 30, nil, nil, nil) elseif ( SCT ) then SCT:DisplayMessage(spellName.." : "..amount.." (CRIT)", {1, 1, 1}) elseif ( COMBAT_TEXT_SCROLL_FUNCTION ) then CombatText_AddMessage(spellName.." : "..amount.." (CRIT)", COMBAT_TEXT_SCROLL_FUNCTION, 1, 1, 1, "crit", nil) end end else if ( amount > gPeenDB[spellName].normal ) then gPeenDB[spellName].normal = amount --gPeen:AddMessage(spellName.." : "..amount, 1, 1, 1, 1, 2) if ( MikSBT and not MikSBT.IsModDisabled() ) then MikSBT.DisplayMessage(spellName.." : "..amount, MikSBT.DISPLAYTYPE_NOTIFICATION, true, 255, 255, 255, 32, nil, nil, nil) elseif ( SCT ) then SCT:DisplayMessage(spellName.." : "..amount, {1, 1, 1}) elseif ( COMBAT_TEXT_SCROLL_FUNCTION ) then CombatText_AddMessage(spellName.." : "..amount, COMBAT_TEXT_SCROLL_FUNCTION, 1, 1, 1, nil, nil) end end end hit, crit = self:getHighest() self.text:SetText("|cffffffff"..hit.."|r/|cffffffff"..crit.."|r") self:SetWidth(self.text:GetStringWidth()) end local function onEnter(self) GameTooltip:SetOwner(self, "ANCHOR_NONE") GameTooltip:SetPoint("BOTTOM", self, "TOP", 0, 20) GameTooltip:AddDoubleLine("Spell Name", "Normal / Critical", 0, .8, 1, 0, .8, 1) GameTooltip:AddLine(" ") for spell in pairs(gPeenDB) do GameTooltip:AddDoubleLine(spell, gPeenDB[spell].normal.." / "..gPeenDB[spell].critical, 1, 1, 1, 1, 1, 1) end GameTooltip:AddLine("----------------------------------------------------------------------------------", 1, 1, 1) GameTooltip:AddLine("ALT + Right-click to reset database", 0, .8, 1) GameTooltip:AddLine("SHIFT + Left-click to announce highest records to "..string.lower(self.channel), 0, .8, 1) GameTooltip:Show() end local function onClick(self, button) if ( IsAltKeyDown() and button == "RightButton" ) then gPeenDB = {} self.text:SetText("|cffffffff0|r/|cffffffff0|r") self:SetWidth(self.text:GetStringWidth()) elseif ( IsShiftKeyDown() and button == "LeftButton" ) then hit, crit, spellHit, spellCrit = self:getHighest() SendChatMessage("gPeen: Highest Damage/Healing Records", self.channel) SendChatMessage("-----------------------------------------------", self.channel) SendChatMessage("(Normal) "..spellHit..": "..hit, self.channel) SendChatMessage("(Critical) "..spellCrit..": "..crit, self.channel) end end local function onEvent(self, event, time, eventType, srcGUID, srcName, srcFlags, dstGUID, dstName, dstFlags, spellID, spellName, spellSchool, amount, school, resisted, blocked, absorbed, critical) if ( not self.text:GetText() ) then hit, crit = self:getHighest() self.text:SetText("|cffffffff"..hit.."|r/|cffffffff"..crit.."|r") self:SetWidth(self.text:GetStringWidth()) return end if ( eventType == "SPELL_DAMAGE" or eventType == "SPELL_PERIODIC_DAMAGE" or eventType == "SPELL_HEAL" or eventType == "SPELL_PERIODIC_HEAL" ) then if ( bit_bor(srcFlags, COMBATLOG_FILTER_ME) == COMBATLOG_FILTER_ME ) then if ( not (resisted and blocked and absorbed) ) then self:BuffPeen(spellName, amount, critical) end end end end gPeenDB = {} gPeen.text:SetFont(font, size, "OUTLINE") gPeen.text:ClearAllPoints() gPeen.text:SetPoint"CENTER" gPeen.text:SetTextColor(color.r, color.g, color.b) gPeen.text:Show() gPeen:SetWidth(gPeen.text:GetStringWidth()) gPeen:SetHeight(15) gPeen:SetScript("OnEnter", onEnter) gPeen:SetScript("OnLeave", function() GameTooltip:Hide() end) gPeen:SetScript("OnClick", onClick) gPeen:SetScript("OnEvent", onEvent) gPeen:SetPoint("RIGHT", LynStats, "LEFT", -((#LynStats.plugins + 1) * 20), 0) gPeen:RegisterForClicks("AnyUp") gPeen:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED") gPeen:RegisterEvent("PLAYER_LOGIN") tinsert(LynStats.plugins, gPeen)