Actually the AC-130 is pretty precise. AC-130As (or maybe they were “H”s) were tasked to support the failed Iranian Hostage Rescue mission, where they were supposed to provide “crowd pushback” as the Delta operators effected the rescue.
The U-boat (AC-130U) is at least three and maybe four generations more advanced than those earlier gunships were. 105mm and 40mm guns are very precise, especially when pointed downward as direct fire weapons.
They can even employ mid-air steerable munitions, ala copperheads etc, that will hit the laser dot. Totally precise.