Two little requests.  One is please put the comments on their own lines, generally above the code.  These can scroll off the right side of my editor and make them hard to read.  Generally the break is at column 100.
Second consider sticking these in their own function.  It's a sizeable chunk of related game logic centered on the gun and ammo objects and giving it it;s on function makes it easier to find among other things.