Only thoughts I have on the matter are maybe to have them try to shoot, and if it hits an obstacle, send a behavior or effect back at the caster which can disable the weapon/issue order to move closer to the intended target. Might have to use some triggers to make the movement believable, a create persistent would likely fail on this since the facing of the units isn't certain when the bullet hits the wall.
Edit: Another thought for you, this would require considerably less work, I have used it on a few of my monsters already. If the bullet hits an obstacle, apply a behavior to the marine that disables the range weapon and enables a hidden melee weapon. Just make it have period 60 and damage 0 or something. This will cause the marine to appear to go after the unit. Then when behavior wears off, back to shooting.
after having difficulties finding a data way for this I did it with triggers:
distance_pathing = (Pathing cost for unit (Triggering unit) to point (Position of FollowedUnit), considering buildings of type Include All Buildings) <Integer>
(Owner of (Triggering unit)) == 15
((Triggering unit) has Deactivate Weapon) == False
(The line from (Position of (Triggering unit)) to (Position of FollowedUnit) crosses a cliff edge.) == True
(Real(distance_pathing)) != distance
Unit - Add 1 Deactivate Weapon to (Triggering unit) from FollowedUnit
Unit - Add Dummy Melee to (Triggering unit) using turret No Game Link
General - Wait 1.0 Game Time seconds
Unit - Remove Dummy Melee from (Triggering unit)
Unit - Remove 1 Deactivate Weapon from (Triggering unit)
FollowedUnit is the player unit for testing purposes, seems to work VERY accurate actually :P
@Deadzergling: Go Thanks for the melee weapon idea! :)