In the late nineties, I read a novel in which the protagonist wielded a modular energy rifle. I remember that only three modules could be inserted into the gun at a time, but that more existed, the functions of which I do not recall. The wielder had to "budget" the amount of energy in the gun, as it could not be recharged and some modules used more power than others.
Unfortunately, the most specific piece of identifying information I have is also a major plot point later in the book, so I'll spoiler it here:
Eventually, the protagonist comes to the idea of forcing one of the modules in backwards (not normally possible; I believe wire had to be wrapped around the gun to hold it in), allowing the gun to recharge by "absorbing" energy-wraith-like enemies.