Magazines for firearms

You should load guns with magazines rather than loose rounds. Switching magazines is quick, but if you get caught in the middle of a hoard with none loaded you’re going to get eaten while you load one. I should be able to implement it when I unfuck my IDE.

I agree this is the way to go, we just haven’t gotten around to it yet, partially because the gun handling code is a bit of a mess.
In broad strokes, what seems to make sense and be most manageable:
Add a number of magazine items, at least one per ammo type, but in some cases different sizes and such. Some guns would have integrated magazines, which should probably be handled as a magazine item that can’t be removed from the gun.
Overhaul the reload logic to replace the current gun-mod based logic with handling these new magazine items.
Adjust gun spawning logic to normally spawn at least one magazine with each gun.
Adjust spawn lists to spawn magazines instead of gunmods, and probably some additional ones as well.
Update loading code to convert magazine-based gunmods into the equivalent magazine item, which might require some guessing, or might require a magic item that turns into a particular type of magazine when rounds are inserted into it.

Some misc details about reloading mechanics in a post I made quite a while ago: http://smf.cataclysmdda.com/index.php?topic=2032.msg27284#msg27284

Would it also be possible to have mods available for those magazines? such as adding something to increase its size, or fire rate, maybe even make it possible to switch magazines faster?

Mods for magazines doesn’t really make sense, just make a new magazine with the properties you need.

I’m thinking that magazines will have to be containers. They can’t use ammo as charges like batteries because that couldn’t handle different ammo variants properly. The gun’s ammo type could be the mag type it uses. The ammo in it would be objects stored in a container. The reloading logic could mostly stay similar to now but using the ammo in the magazine rather than in the gun itself.

Yes, treating them as individual items is better. The only reason items have charges is for when a single unit of an item is less than the minimum volume we track, which is about 250mL. At some point we want to overhaul that and drop the unit of volume to 1mL or so and completely get rid of the concept of charges (except in batteries I guess, where it has a different meaning).

Mugling beat me to it.