A Norwegian firm (DDG) has made a breakthrough in bullet design with supercavitating bullets that travel a lot farther in the water. Traditional bullet designs do not get very far in water. Most pistol bullets become harmless (to people) after going through about 600mm (two feet) of water and lose all momentum after going about five meters (15 feet) when fired underwater. When fired from close to the surface (from a dock or ship) bullets pick up a lot of speed before hitting the water and will hurt someone up to about three meters (10 feet) underwater for a rifle and half that for most pistols.
The DDG bullet uses a shape designed to create an air bubble (supercavitating) around the bullet and carry it much further underwater. The DDG bullets are also balanced to enhance the supercavitating duration. Thus a 5.56mm rifle bullet is effective at up to 14 meters while larger bullets like the 7.62mm are good to 22 meters and the 12.7mm (.50 caliber) is good out to 60 meters once entering the water. There is a market for these bullets because of concern about terrorists using underwater swimmers to plant bombs or simply to reach a heavily guarded area. Thus ships that have 12.7mm machine-guns for defense against small boats can use these weapons (normally effective out to 2,000 meters in the air) to hit underwater swimmers that are close enough to the surface.
There have been attempts to develop projectiles with better underwater range for combat divers to use. For a while during the Cold War, especially in the 1970s, the Soviet Union and the United States (with a lot of help from West Germany) came up with some more effective underwater weapons usable while underwater. These weapons fired heavier bullets that created an air bubble around them (supercavitating) which enabled them to maintain higher speeds for longer distances. These projectiles could hurt you out to about a 30 meters (a hundred feet). Beyond that, most of the time, you can't make out a target. The Russians still have their underwater "nail gun" (as underwater warriors call this type of weapon), in both pistol and assault rifle (it looks like a bulked up AK-47) forms. The U.S. still arms underwater troops with a similar pistol. And then there's also the spear gun. It's used for hunting fish, is a one shot affair, and has a range of about 4-8 meters (14-24 feet).
Meanwhile, British, U.S. and Israeli firms have developed special sonar systems for detecting divers. These devices are about the size of a barrel, and will detect swimmers within at least an 800 meter radius. The diver detectors can be linked to automatic ASG (underwater grenades) dispensers that will electronically set the depth, then release the ASGs which act like depth charges. Divers can't swim deeper than 30 meters, because most ships are not that deep in the water. Even the largest supertanker has a draft of less than 60 feet. Combining sensors like ASG with the new DDG bullets greatly enhances protection for ships in harbor.