Just so that you get an overall concept of this;
Essentially you’re dealing with a single concept: the number of magazines. In reality, each magazine has its own value for how much ammo it contains. However, unless you’re actually implementing magazines as separate objects, we tend to merge this into a single object. So, we’d create a property “mag” that represents how many magazines we have available. Then the ammo count represents the amount of ammo in the current magazine.
We then decrement (reduce) the ammo count by one every time we make a shot. To make a shot, we must check that it is valid, meaning that we have ammo (ammo > 0) and we have clicked the left mouse. You can use the expression controller for this; assuming your ammo property is called “ammo” and your mouse sensor is called “shoot”:
ammo > 0 and shoot
This would connect to your shooting actuators, and a property actuator that adds -1 to the ammo count.
Now, to facilitate reloading, use a similar expression controller, with the reload key “reload”
ammo == 0 and reload and mag > 0
This would activate a property actuator setting the ammo to full. We’d have another property actuator that adds -1 to the magazine count. It will only do this if we have a magazine available.
We could also add support for a reload delay. Simply add a timer property called “delay” and a float property called “shoot_interval”, which represents the time between shots. Now, our shooting logic controller looks like this:
shoot and ammo > 0 and delay >= shoot_interval
Now we add another actuator to the shoot controller that sets the delay property to 0.0
In this instance you don’t need to use the expression controller; you can use property sensors (for the most part) however, It’s cleaner to use in my opinion.