Don't forget friendly fire. If you've already got the sourceFlags, though, it's just easier to check those than to try to account for a bunch of special exceptions, since that's exactly what they're there for. Try this:
Code:
local HOSTILE_PLAYER = bit_bor(COMBATLOG_OBJECT_REACTION_HOSTILE, COMBATLOG_OBJECT_CONTROL_PLAYER)
if bit_band(sourceFlags, HOSTILE_PLAYER) ~= 0 then
-- source is a hostile player
end
You can find a complete list of combat log bitmasks here:
http://wow.go-hero.net/framexml/16309/Constants.lua#374