If you know where he is aiming and what unit he knows about you can tell which unit his target is. By checking the height distance between player & target and the distance you can calculate the elevation.
Yes, this is true. The problem is to know where he's aiming, especially
if he's in a turret. If I am right getdir returns the direction where is
pointed the nose of the vehicle, or can getdir returns the direction
of the gunner too (i.e. : getdir gunner vehicle player) ?
If knowsabout goes up to a certain value when the unit fires a shot
at his intended target, then this can lead to an interesting application:
giving the unit an eventhandler "fired", you could guess his target.
Then suppose the unit is a gunner of a car: if you replace the shell
with a beatiful missile, you could have a car launching a missile.
For guidance purpose you could use SEFE's script. I did a crappy
jeep firing SAMS, AI could engage too, but I used the method
to catch the shell and then go all along the shell's trajectory to
search for a suitable target, having found one I passed this to
SEFE's script.
But I think I'm gone a little off-topic so I stop here.