In some parts of the world, gunpowder is only about 100 times more expensive, per unit of energy, than gasoline (petrol engines and machine guns have similar levels of energy efficiency, by the way -a surprising 30%). These always seem to be the places where a profusion of weapons constitutes a major barrier to economic development and social stability (think Belfast, eg).
Today’s invention is a simple motor that can be used to do valuable work, in places without cash to buy engines, whilst also soaking up any bullets which happen to be lying around waiting to create further tragedies.
Take an automatic rifle, such as the ubiquitous AK47, and place it handle-down between two metal rails. These are to guide the weapon. A return spring attaches the gun to the wall of the factory. It is pointed through a hole in the wall into an oil drum full of wet sand -oriented so that the long axis of the drum is in line with the barrel (wet sand is particularly effective at slowing bullets -hence sandbags). You might need to weld a couple of drums together lengthwise, but at least you get to reclaim all that lead (as well as the brass cartridges).
The butt end of the weapon can now be attached to eg a mechanical linkage or a hammer. When the gun is set to ‘semiautomatic’ and the trigger pulled, it will repeatedly recoil along the rails, and be returned by the spring. In this way, some of the recoli energy can be used to break rocks, hammer nails or drive production machinery.
The most obvious way to work this is to have a few such weapons linked to a flywheel, so that firing need not be continuous (although using a drum magazine or ammunition belt feed would also make things simpler).