Yeah unsigned char tops at 255, but be real careful changing types around.
Can that cause problems? I thought it might, but it doesn't seem to have done anything. I just changed the unsigned char count to an unsigned int. Seems to be working fine. I don't have any experience with what changing a char to an int might do
Now I have ammo stacking and combining weight/volume just fine. Only need to rebalance the volumes of ammo to take into account for the divide by 100 thing.
Oh, ammo stacking is obvious and something I should've done a while ago! Indeed, the game already stacks ammo for you if it can; for instance, carrying a box of 20 5.56 rouns and picking up a box of 15 will combine them into a box of 35. Not entirely sure why I capped it at the default size, but thanks for changing this.
Changing that char to an int shouldn't cause any problems at all.
I thought that the easiest way would be to separate the "spawning stack size" with random amount from 1 to max, and "max stack size". Right now stacks spawn at its highest value.
Making items start with a random number of charges between 1 and default_charges is a one-line change, very easily done. It should be noted that "charges" and "stack size" are distinct concepts. Ammo, tools, and firearms all have a number of "charges;" for ammo this affects the item's weight, but not its volume, and for tools and firearms it won't affect either one. A "stack size" is different, and implies several instances of the same type of item, not just one instance with several uses available.
The "birthday" of items is indeed an issue when combining them into stacks; as is damage level, charge counts, contents,
when to combine items, UI changes to allow the player to drop just one from the stack, when and how to reduce the number in the stack, how to handle the item removed from the stack, etc. etc.
For those of you with C++ experience, one idea I had was to change the player's inventory from
std::vector<item> to
std::vector<std::vector <item>>. This way, several apples can be combined into a stack--and the UI can just use inv[n].size() to display the number of items in the stack--and each apple will maintain its own birthday and damage level. When the player's inventory is accessed (basically via the game::inv() function), the game can iterate over all the items and automatically seperate out any that are spoiled or have been damaged. Thoughts?