Hi!
I never really tried that although perhaps you could try experimenting with the "knowsabout" command. There are values you could assign to knowsabout which determines how much a certain unit knows about another unit.
example would probably go like this:
?friendlygoon1 knowsAbout enemygoon8 > 0.105:busted=true
or in trigger:
condition: friendlygoon1 knowsAbout enemygoon8 > 0.105
on activation: busted = true
0.105 i think is a certain value where a unit knows exactly about the other unit. Try looking it up, i'm not entirely sure. Then you could perhaps experiment to find which value exactly of knowsabout is returned when a unit actually targets another.
In the above example, 'busted' is the variable.
If the above don't work, well, maybe try eventhandlers. but I really don't know much about those...
Cheers!