Sections: 
(Method 1) Its recommended to have a common name for your unit's main turret, like vanilla does. Eg: turret_1. This is so the mod automatically adds line of sight to any new units you create, very useful and time saving if you're making a mod from scratch. Also check all-units.template "turret_1" and change it to your turret's common name.
(Method 2) Now if your mod does not share common turret name or wish not to change name for any reason, you have to copy '@copyFromSection: template_checkLoS' to your unit's main turret (and "base" or "body" turret, if your unit has any, specially hovers or mechs) and change the [turret_1] section name to [comment_turret_1] in all-units.template.
#==========================================#
Simply copy: 
[projectile_checkLoS]
spawnUnit: checkLoSUnderwater"
Example unit: Light Sub, Attack Sub, Heavy Sub
#==========================================#
Due to having different parameters for checking LoS on land and underwater, you'll notice that unit's like a Heavy Battleship will be able to fire torpedos thru ground, so you'll have to add extra code for checking LoS underwater, its simple: 
So, first you should make a new turret section, any name, and copy '@copyFromSection: template_checkLoSUnderwater' under it, this will check line of sight underwater.
Now for your actual anti-sub turret copy '@copyFromSection: template_turretLoSUnderwater'.
Example unit: Combat Engineer, Heavy Battleship, Experimental Carrier
#==========================================#
To fix this you'll add "@copyFrom_skipThisSection" on your main turret (if you choose method 1, if not ignore) and also copy this under main turret: 
canAttackCondition: if self.tags(includes='losCheckPassed') and not self.tags(includes='searchForNewTarget') or attacking.isFlying or self.isOverClift or attacking.isOverClift
Them copy: 
x: 0
y: 0
projectile: blank
delay: 30
onShoot_triggerActions: losCheckReset
Example unit: Flame Mech
#==========================================#
You may notice that units with multiple main turrets (not secondary turrets) that use linkDelayWithTurret will instead only fire the first turret but not the others, to fix this you copy: "onShoot_triggerActions: NONE" on all turrets but on last you copy: "onShoot_triggerActions: losCheckReset"
#==========================================#
To change LoS update delay: Go to all-units.template and change the 'delay' under [turret_checkLoS] section to whatever you like.
#==========================================#