Two other ideas that just popped into my head: use a gas-operated generator (pressurize a chamber when a round is fired, and then meter out the stored gas to run a mini-turbine/generator), or, use the "Polaroid SX-70 Solution" -- put a battery in every magazine, and give it enough capacity to run several (10 or more) magazines of ammunition. (The overkill will compensate for reduced output due to age or temperature, and also allow several hasty reloads from stripper clips in the field.)