How do I make a weapon contain its ammo in the magazine and the ammo you had for it in the weapon itself.
So like AK-47 gun has 30/30 ammo in the magazine and 360/500 ammo in the inventory,
Shoot 3 rounds now the weapon is 27/30 (In the magazine) then when the weapon is dropped the magazine ammo is still 27/30 and the bullets in the weapons inventory is 360/500 when another player picks it up they will have the amount of magazine ammo and weapon inventory ammo what you had before dropping the weapon,
A player finds the dropped weapon picks it up, AK-47 magazine contains 27/30 bullets plus an inventory of 360/500 7.62x39 so you can now reload and get 30/30 in the magazine and 356/500 in the weapons inventory.
How can I make the weapon keep the magazine ammo and the inventory ammo?
I noticed this system is how a game called Killing floor dose it for all its weapons so that you can drop your weapon for another player:
How would I go to make this work to have the weapon store ammo in the magazine and the ammo inventory in itself?
Thats the reason why most game don’t care about single ammo count magazine, instead count single bullets for weapon, limiting amount of ammo you can fire before reload, and ammo change is just visual animation, i requires more complex system which is usually not needed for the game
It all depends on you pickup and inventory system (and no body gonna tell you “how” to do it as they don’t know how it works which you didnt describe, we can only speculate here), if you store individual ammo magazines as individual inventory items then this is simple, pick first most full ammo magazine and store reference ot it in weapon do it use it and deceres ammo from magazine item, on reload pick next most full ammo. If you don’t want to keep used ammo magazine in inventory, make inventory slot on weapon it self (object reference variable, same as you may do with used weapon), where you drop it, make that ammo being held in weapon pick up too.
In most simplest form, you could have seperate ammo count for weapon and inventory, when you reload, subtract amount of missing weapon ammo from inventory. When you drop weapon you store that value on it’s pickup. And can assume that player will give full magazines of ammo until they give there last one which is incomplete and substruct amount of inventory ammo from inventory and last one substact from weapon count, or drop weapon all toghther.
Think how this suppose to work and just try to program that and divide ammo storage as much as you need to execute to make it work as you want it to work