You can use CharacterGetRelationToCharacter and check for a value less than 25 (so < 25).
Note that this will only work for Global characters. Local characters in your combat won't be handled by it.