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();

            SendChatMessage((interp(KillingBlowAnnouncer:GetAnnounceMessage(info),{player = playerName,enemy = name,class = className,zone = mapName})),KillingBlowAnnouncer:GetChatAnnounceChannel(info))

        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
            sound = KillingBlowAnnouncer:GetRandomSound();
            if sound ~= nil then
                PlaySoundFile(Media:Fetch("sound", sound, KillingBlowAnnouncer:GetSoundLevel(info)));
            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);