Different types of ammo in a magazine

I am trying to make different types of rounds that can go into the same magazine. For example 5.56 ball, 5.56 tracer and 5.56 ap. I want to be able to mix them inside a magazine, such as 1 tracer, 5 ball, 5 ap, 5 ball, 5 ap, 1 tracer. I cannot do this with something like an array because it would just go: 2 tracer, 10 ball, 10 ap right? I could use BPs but would that be very cost ineffective?

Any other ideas on how to do this?

Use a common base class for the ammo that can mix, set the magazine variable array type to the common class and then you can insert any ammo that inherits from that class.

Alternatively you could make an array of type actor and filter incoming objects via the actor tag or via in interface.

If you don’t need a physical representation of the bullets in the magazine then you could just have an array of structs which holds the current ammo mix info. Then you could retrieve the needed ammo via an object pooler upon firing.

So far, i am using an array of structs of BPs, I am just trying to see if there is a better way. But thanks for the info!

Well I would recommend something else which is data assets, its a struct after all.

I have a generic item struct and i branch to many things from there like ammo

My inventory subsystem distinguishes what its picked up, used, in bag etc. Keeps track of it and talks with player inventory component. So basically with that you can define different ammo types to same weapon type and it will just keep track of those in magazine.

If you want them ordered in a magazine that is a different question and I think arrays is the answer like 3dRaven said.

My weapon system only talks with inventory subsystem and asks couple of things like.

CanShoot?
CanReload?
SpendItem(Ammo)

etc

You can also do this with an Enum array in the weapon class.

An enum would work too, but probably better to make it a Bitmask, BitmaskEnum if you want to make some calibers interchangeable at some point.