If the units A and B are on the same side, how about checking unit A's rating?
According to Biki:
Each hit in a single player game will affect the player's rating. If it goes below -2000, he will be considered an enemy, and be attacked by all units.
So you'd need to check if unit A's rating is below -2000, which happens like this (I think):
rating unit_A = -2000 : goto "enemy"
goto "friendly"
#enemy
Hint "Unit A is an enemy"
Exit
#friendly
Hint "Unit A is friendly"
Exit
Just a thought, not sure if it works.