I've heard of this problem, and I think that it's important to focus on the roots of the issue and preventive measures (positive, not negative ones) to help make things better. So ships should not travel too close to the shores, disrupting the fish movement patterns and polluting the seaside where people rely so heavily on it as a source of food and work. It would also be good to invest, if possible, into programs that would help people from these regions to obtain additional education and skills and find reasonable jobs. Ultimately, piracy is having a very bad impact because people don't want to invest in a region where it's happening, don't want to risk going on a holiday there etc.
Investing in those environments is rare, because they stay far from the main town of any state. Although their natural ways of fishing may be affected, piracy isn't good for the economy. Ships are expected to be equipped with few naval officers to guide goods from pirates. Fighting the hijackers is better than paying those huge ransom. Pirates are also heavily equipped and fight well at sea, but when intercepted by the military Navy, the hijacking won't be simpler for them. Thereby reducing the rate of kidnapping and stealing of people's properties. Whatever it is they're fighting for, the innocent businessmen shouldn't suffer for it. Lots of money goes into those imported goods, meant to be marketed in the local market. Pirates spoil the market for many and hike the price of commodities due to scarcity. Imagine a country where a cargo of car tires gets intercepted by pirates and hijacked, there'll be a limited supply of car spare tires in the region where it's meant to be delivered.
So, ship crews should figure out a way of preventing pirates from evading their ships. There are multiple precautionary methods for preventing pirates from hijacking a ship. Coupled with the security, most ships will be able to bypass the pirates. When ships don't travel too close to the shores like you suggested, what exactly would it prevent? because these pirates move with boats and are better swimmers. That part of the sea is mainly their territory and they grew up there. Hence, shooting will be easier for them, increasing crime. So, they'll have fewer people visiting such environments, for safety reasons. Due to such acts the government is favorable to the locality, and the poverty will increase, causing people to migrate to a greener pasture. Many kids around such vicinity, will grow up looking to join pirates since it's part of their livelihood. Only a few of them would cherish formal education.