damageEvent = {
    ["SWING_DAMAGE"] = true,
    ["RANGE_DAMAGE"] = true,
    ["SPELL_DAMAGE"] = true,
    ["SPELL_PERIODIC_DAMAGE"] = true,
}

checkKill = CreateFrame("Frame")
checkKill:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");
checkKill:SetScript("OnEvent", function(self, event, timestamp, subevent, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags, ...)
    local spellID, spellName, spellSchool, amount, overkill
    local playerName = UnitName("player");
    local petName = UnitName("pet");
    local _, overkill

    if(damageEvent[subevent] and sourceName == petName) then
        if subevent == "SWING_DAMAGE" then
            _, overkill = ...
        else
            _, _, _, _, overkill = ...
        end
    else
        overkill = 0;
    end

    --IF event = a kill that happens within party(yours or anyone else in your raid/party) and the source is the player
    --because PARTY_KILL doesn't get triggered for pets we check the overkill instead of the subevent PARTY_KILL
    if ((subevent == "PARTY_KILL" and sourceName == playerName) or (overkill > 1 and sourceName == petName))
            --AND if the killed enemy is a player instead of an npc/monster etc
            and (destFlags == 66888  or KillingBlowAnnouncer:EnablePVP(info) == false)
        --THEN add the message KILLING BLOW! to the messageframe, and update the kbs_tracker
    then
        if(destFlags == 66888 and KillingBlowAnnouncer:EnableMSGAnnounce(info) == true)then

            local className, classId, raceName, raceId, gender, name, realm = GetPlayerInfoByGUID(destGUID)
            local mapID = GetCurrentMapAreaID()
            SetMapToCurrentZone()
            local mapName = GetMapNameByID(GetCurrentMapAreaID())
            local className = className:lower();

            if(KillingBlowAnnouncer:GetChatAnnounceChannel(info) == "private") then
                print(interp(KillingBlowAnnouncer:GetAnnounceMessage(info),{player = playerName,enemy = name,class = className,zone = mapName}))
            else
                SendChatMessage((interp(KillingBlowAnnouncer:GetAnnounceMessage(info),{player = playerName,enemy = name,class = className,zone = mapName})),KillingBlowAnnouncer:GetChatAnnounceChannel(info))
            end

        end

        --IF enableKB = true
        if (KillingBlowAnnouncer:EnableKB(info) == true)
            --THEN addMessage
        then
            if(KillingBlowAnnouncer:GetModus(info) == 1) then
                message:AddMessage(KillingBlowAnnouncer:GetKillingMessage(info),KillingBlowAnnouncer:GetRed(info),KillingBlowAnnouncer:GetGreen(info),KillingBlowAnnouncer:GetBlue(info))
            elseif(KillingBlowAnnouncer:GetModus(info) == 2) then
                imageAnimationIn:Stop();
                imageAnimationOut:Stop();
                fade();
            end
        end

        if (KillingBlowAnnouncer:EnableEmotes(info) == true)
            --THEN do random emote
        then
            emote = KillingBlowAnnouncer:GetRandomEmote();
            if emote ~= nil then
                 DoEmote(KillingBlowAnnouncer:GetRandomEmote());
            end
        end
       

        --IF enableKBSound = true
        if (KillingBlowAnnouncer:EnableKBSound(info) == true)
            --THEN playsoundfile
        then
            if(KillingBlowAnnouncer:GetSoundModus(info) == 1) then
                local index = KillingBlowAnnouncer:GetSoundsOrderedOrder(info)
                local sound = KillingBlowAnnouncer:GetSoundOrderedListItem(info, index)
                if sound ~= nil then
                    PlaySoundFile(Media:Fetch("sound", sound, KillingBlowAnnouncer:GetSoundLevel(info)));
                    KillingBlowAnnouncer:IncrementSoundsOrderedOrder();

                    if (KillingBlowAnnouncer:EnableSoundOrderedRestartTime()) then
                        resetSoundsOnTimer(KillingBlowAnnouncer:GetSoundsOrderedOrder(info));
                    end
                end
            elseif(KillingBlowAnnouncer:GetSoundModus(info) == 2) then
                local sound = KillingBlowAnnouncer:GetRandomSound();
                if sound ~= nil then
                    PlaySoundFile(Media:Fetch("sound", sound, KillingBlowAnnouncer:GetSoundLevel(info)));
                end
            end
        end

        --IF enableKBT = true
        if (KillingBlowAnnouncer:EnableKBT(info) == true)
            --THEN update kbtracker
        then
            updateKbtracker();
        end

        --IF chat message is enabled(variable enableMSG needs to be true for this)
        if (KillingBlowAnnouncer:EnableMSG(info) == true)
            --THEN get message from variable message and send it to the chat chat
        then
            if(KillingBlowAnnouncer:GetChatChannel(info) == "private") then
                print(KillingBlowAnnouncer:GetMessage(info))
            else
                SendChatMessage(KillingBlowAnnouncer:GetMessage(info),KillingBlowAnnouncer:GetChatChannel(info));
            end
        end
    end
end);