This is not a trivial issue I'm afraid and can be broken down:
* Detect when gunner has line-of-sight to a position.
* Detect when in a hull-down position with respect to that position (as you say, a reasonable way to do this would be to detect when the driver does not have line-of-sight).
The problem with this approach is that there is no easy way to determine if someone can see something. There is also no way to work out arbitrary LOS in ArmA (is the path A->B clear of obstacles?)! You also can't work out exactly where someone's "eye" is, but you can make a good enough approximation, especially for this purpose.
* Using an addon, fire an invisible, infinitely fast, no-damage bullet and see where it hits something. Still has issues, but will detect all objects in ArmA.
* Using scripts, check ground height at each position along the path from A->B. You can do this by creating a game-logic at position A and pointing its vectorDir directly at B. Take heights at positions along that path with modelToWorld, then when _logic modelToWorld [0, _i, 0] < 0 (i.e. height above ground level) is negative, then you have hit the ground, so LOS is blocked. This will ignore buildings, folliage, people, etc, only taking into account the terrain.
- Alternatively, you could move the logic at a constant 10000m ASL, but along this path (path x,y component, but constant z), and check the height AGL (getPos) from that position in comparison to the ASL height of the calculated path. If the height AGL of the logic was greater than the difference in ASL heights, then you have "hit" ground. This technique would then take into account buildings as well as terrain, even if the other objects were still ignored.
Searching for line of sight might find you some solutions.