Simple nesting containers system

What the title says. I came up with an idea for a simple way to add this, without the player having to manage their inventory a whole lot.

So, here’s what it might look like:

Storage item || (Worn, durability is shown) [(Current space taken)/(How much item can hold)]:
Item [(Volume)/(weight)]
Item 2 [(Volume)/(Weight)]

This would be shown in the LEFT side of the inventory screen, not in the clothing part [(Space taken)/(How much item can hold)] could still be shown to the right of durability in the clothing part.

If a player picked something up, it would automatically go inside the item with the greatest max volume that still had space left. If we wanted to get really complex (Which I don’t), we could even nest things like “Left pocket” and “Right pocket” inside of “Jeans”.

The player might be able to sort their inventory in a way similar to the clothing layering system. Press a key (Maybe “m” for “Move items between containers”) and then select an item, then move it. Trying to put an item in a container with not enough space, and you get the “Not enough room, try moving or dropping something from here” message.

That’s the basics, it’s a pretty simple idea. Let me know what you think, feel free to make any suggestions.

Swapping things between containers?

Multiple such suggestions have been made (personally, I think mine* was the best, but people generally like their own the best, so that means nothing)… what’s missing is the ability/time/will to implement one of them. I’m not in such a place these days… are you?

*You can put stuff into any specific container, and it reduces the container’s volume by the volume of the item you put into it, but anything not specified is in the general pool, just like now. Anyone who doesn’t want to mess with it can continue to use the current system, people who want to specify everything can, and those who only want to specify things that matter (either for dropping purposes or for safety purposes) are free to mix and match as they like. Best of both worlds plus leaves the game functional while the interface is refined.

I would really like something like this so I could pack all the small quantities of different medicines into a medkit and open it when needed so I didn’t have to look at a list of 10 different medicines in my inventory every time, also I could keep 5 antibiotics on me at all times and any extra I pick up would be separate and more easily drop off in my base med storage bin.

However, I understand that as a relatively minor quality of life improvement with a decent coding requirement it’s pretty low on the priority list.

I was reading the FMS thread about nested containers which suggested that to work it the inventory system would need to do most of the work for players:

Is there any possibility to leverage the autopickup system, which is already well fleshed out, to allow players to set autopickup rules for containers they are carrying?

e.g. my medkit example
pick up, up to 5 units of ANTIBIOTICS/CODEINE/ETC
2 units bandages
3 first aid kits
1 bottle disinfectant

Or for ammo pouch:
FILL TO CAPACITY with 9 mm ammo

This way if you were near your stash you would refil, or if you pickup some outside on a scav run, you would refill then rest would go in your inventory. There could be options to set it to autopickup from your inventory only or from nearby tiles, so if I want to refill my medkit I could just walk up to my medical stash.

Could we accomplish this by defining these nested containers in a similar way to NPCs?

Not familiar with the game code right now so I apologize if these are ridiculous suggestions :slight_smile:

Unfortunately, I’d have to learn whatever language this game is programmed in, then figure out how all the code works, and I don’t even have a charger for my laptop. Regarding the system, meticulous inventory management would be optional as well, or at least only be required every once in a while. I’m not sure how hard the whole thing would be, but making some sort of system to allow players to set which containers should get items first should be easy, right?

Yeah, another nice thing would be the ability to separate items that come in stacks, like “aspirin (25)” or “gasoline (2500)”. This would be especially useful when wanting to unload only a small amount of liquid, or just pick up 5 aspirin.

That could work. You could probably also prioritize containers for any kind of pickup. For example “Put items I grab in my backpack first, if that’s full try to put it in my cargo pants, if that’s full stick it somewhere else…” Seems like something extremely simple to implement. And yes, it could easily do most of the work for the player, with only occasional sorting required (Move this plastic bottle to make room for this aspirin, or something like that.)

You also could do a partial implementation of a nested container system, e.g. have an amalgamated backpack/clothing storage like now then have containers inside that large storage pool with specific rules (like a bag of apples, medkit with all your small amounts of meds in them). Seems like that would get you the desired functionality (declutter the main inventory screen, organize rarely used items, allow grouping of stuff for dropping off in base) without making things really tedious by oversimplifying.

The REAL question is 1) what do you want to accomplish and 2) how to make it option (cause most people won’t want to bother)

Well, first of all, it just doesn’t make sense that wearing 4 pairs of cargo pants will let me put a gallon jug of bleach in my pockets (Not 100% to scale, just an example.) With this system, the containers would have their own individual storage value, so you wouldn’t be able to, I don’t know, carry a tire in your hoodie + long sleeve shirt + whatever other low volume clothes stacked together. Also, it really isn’t an oversimplification. It’s just the addition of a change to how volume works, as well as a slight change to the inventory screen. And yes, the de-cluttering, organizing, and grouping is also a benefit of this system.

What I want to do is make the storage system make just a little bit more sense, as well as adding some level of convenience to the whole thing, while implementing it in a way that doesn’t require constant micro-management from the player. To make it optional, in a way, we could just have a sort of priority system so that the game decides where the player puts things. If they want to, they can organize and what-not later, or just leave it be. It would only be absolutely necessary if the player had to reorganize something to make room for just one more item.

A few drawbacks I can see could be a rare case of not knowing whether you just don’t have enough space for that item, or your inventory isn’t organized enough. Another problem could be that this will make the inventory list be a little bit longer, especially for players who like to wear five backpacks, a rucksack and two tool belts. However, it would only be by a little bit, and if you have that much on, your inventory is probably pretty packed.

Unfortunately, I have no idea how to do any of the coding, and I highly doubt anyone would do this, or even pay attention to this. I mean, my accounts only a few weeks old. And I’ve made like 3 or 4 posts. So I doubt that anyone with the ability to change this (One of the devs) will see this.

I like the cargo pants example, it does highlight the abstraction in the current game - one fix would be to introduced a storage volume penalty that operated in a similar way to clothing encumbrance. E.g. the second set of pants only adds 50% of the storage of the first.

While CDDA is based in reality, the rule of fun is paramount, realism for realism sake is not desirable, especially if it results in more hassles than payoff. For me the entire goal to nested containers would be to make the inventory list SMALLER and free up hotkeys. And, as you mentioned a really crunchy inventory volume simulator would require a lot of coding for little payoff.

I think it’s worth acknowledging that CDDA’s inventory space and weight system is a good deal more realistic than the vast majority of games I’ve played, I think it strikes a good balance between realism and abstraction and any further realism is probably detrimental at this point.l

Agreed, which is why I’ve tried to suggest a system that gives some addition flexibility that is entirely optional, for the benefit of the player, but provides no other required “realism”.

The current level of abstraction is pretty good. The only real improvement would be some way to control what drops with that enormous, encumbering duffel bad you toss before engaging in combat.

Good point, I think this is where the magazine pouches and sheaths/scabbards/holsters really shine - you can drop stuff before combat and not lose your weapons/ammo.

It would be a massively convenient feature for inventory\storage management to be able to allocate items to containers and drop\pick them up this way, much like Project Zomboid does.

Want to leave your base for a major car repair or disassembly trip? Just pick up your tool duffel bag\swag bag\backpack and drop it in your car’s trunk instead of picking up 10 to 40 pieces of tools and materials, moving, and dropping them.
Neverming that switching bases after first week or so would become less of a terrifying prospect of spending hours moving items between old base, vehicle, and new base.

Need to rapidly reduce the encumberance to fight in melee? Drop the backpack or dufflebag with supplies and not get your volume overfilled, dropping some random items you might need in the fight.

1 Like

I don’t get why my idea is getting shot down because of “realism”. Yes, this is more “realistic”, but how does that make it automatically bad? I know there’s a lot of commotion about some of the “realism” additions to the game, and I agree: We should be out there scavenging for supplies and fighting zombies, not adding up our foods nutrition value so that we don’t catch scurvy, or cleaning dirty socks. Magazines, however, are a “realistic” addition that does something good: Allows for the quick loading of weapons, and you can strap them to yourself with certain clothing items (Okay, they were a bit bad when they started, but they are a much more refined feature now). As a few other posters have mentioned, the goal of this idea is much more than making things realistic. The realism idea is more of a convenient afterthought.

I know this sounds backwards, but this would greatly simplify inventory management/sorting. Dropping 40 or so little items can be a pain, especially for survivors who have hoarded a whole ton of loot. If we could get the system to automatically send items to certain containers (Backpack over tool belt, etc), then we could help minimize the amount of time spent sorting your inventory. And if someone didn’t want to use it, they wouldn’t have to: The system wouldn’t require much input from the player, unless it was someone wanting to put certain things in certain containers, for convenience.

[quote=“Inconspicuous, post:13, topic:13539”]I don’t get why my idea is getting shot down because of “realism”. Yes, this is more “realistic”, but how does that make it automatically bad? I know there’s a lot of commotion about some of the “realism” additions to the game, and I agree: We should be out there scavenging for supplies and fighting zombies, not adding up our foods nutrition value so that we don’t catch scurvy, or cleaning dirty socks. Magazines, however, are a “realistic” addition that does something good: Allows for the quick loading of weapons, and you can strap them to yourself with certain clothing items (Okay, they were a bit bad when they started, but they are a much more refined feature now). As a few other posters have mentioned, the goal of this idea is much more than making things realistic. The realism idea is more of a convenient afterthought.

I know this sounds backwards, but this would greatly simplify inventory management/sorting. Dropping 40 or so little items can be a pain, especially for survivors who have hoarded a whole ton of loot. If we could get the system to automatically send items to certain containers (Backpack over tool belt, etc), then we could help minimize the amount of time spent sorting your inventory. And if someone didn’t want to use it, they wouldn’t have to: The system wouldn’t require much input from the player, unless it was someone wanting to put certain things in certain containers, for convenience.[/quote]
Yeah, the extra realism is just a nice bonus. The ability to use containers, wearable and not, for large scale inventory management and moving\sorting tens or hundreds of items per container would be the main point of the feature, and if it is handled well in the UI, in long run it could save at least some players massive amounts of time spent on inventory management.

There are 2 main problems with containers:

Technical:
We can’t use the existing container system for inventory containment because it assumes a degree of structural integration of contained items.
For example, gunmods are contained in the gun. So if the gun was also a backpack, putting a gunmod in it would integrate it. It isn’t the only case where it works like that.
We’ll probably need item IDs to handle that.

UI:
The UI has to handle all of those cases:

[ul][li]Dropping just the container without contents[/li]
[li]Inventory containing a stack of something that is larger than any of the individual containers (say, 300 jerky pieces)[/li]
[li]Player not being required to assign every item to a container for faster drops/pickups (that is, “floating” items have to be handled well, without just assigning them to a container right away)[/li][/ul]

Honestly, the only system I see here is incredibly simple one where items aren’t “in” containers, but rather just assigned to be dropped and picked up with individual containers. Just for convenience (no mechanical changes, just pure UI), not realism.

[list][quote=“Coolthulhu, post:15, topic:13539”][ul][li]Dropping just the container without contents[/li][/ul][/quote]
That sounds more like a need to be able to shift items between containers. Want to drop a container without the items inside, move all the stuff in it to another one. After all, you can’t carry stuff without a container to hold it.

[quote=“Coolthulhu, post:15, topic:13539”][ul][li]Inventory containing a stack of something that is larger than any of the individual containers (say, 300 jerky pieces)[/li]
[li]Player not being required to assign every item to a container for faster drops/pickups (that is, “floating” items have to be handled well, without just assigning them to a container right away)[/li][/ul][/quote]
My idea for that would be something similar to the clothing layering menu, setting a priority list of containers for picked up items to be assigned to, if there is room in them. With possibility to exempt a container from the autoassign.
The same priority list could be used to split a massive stack of things.

[quote=“Coolthulhu, post:15, topic:13539”]There are 2 main problems with containers:

Technical:
We can’t use the existing container system for inventory containment because it assumes a degree of structural integration of contained items.
For example, gunmods are contained in the gun. So if the gun was also a backpack, putting a gunmod in it would integrate it. It isn’t the only case where it works like that.
We’ll probably need item IDs to handle that.[/quote]
What the hell is it with you and item ids? Even if you do need a gun that is also a container (???), you can just have the gunmods system only integrate contents that are marked as installed gunmods, it’s trivial to do. This doesn’t even approach being a problem.

[quote=“Coolthulhu, post:15, topic:13539”]UI:
The UI has to handle all of those cases:

[ul][li]Dropping just the container without contents[/li]
[li]Inventory containing a stack of something that is larger than any of the individual containers (say, 300 jerky pieces)[/li]
[li]Player not being required to assign every item to a container for faster drops/pickups (that is, “floating” items have to be handled well, without just assigning them to a container right away)[/li][/ul][/quote]
First and second are trivial, stacks would be split on insertion and then potentially re-merged by the ui, unceasing a container without dropping the contents would just reinsert the contents in the inventory.
Third is a non-issue, Items would be assigned to containers at all times, that’s the whole point of the system.

The actual issues making this hard are coming up with a good allocation system that stays out of the players way, providing a good ui for allocating specific items to quick access containers, wrangling the terrible existing inventory code, and designing the system in a,way that it can be implemented and tested in pieces.

Not interested, it doesn’t make any real progress toward a complete solution.

Every time I want to implement something item related, I see two solutions:

[ul][li]Use item IDs to make it work[/li]
[li]Invent a horrible workaround that would take way too much work to be worth it and would require significantly more maintenance[/li][/ul]

This happens a lot, so I see a lot of need for item IDs.
Crafting reworks, crafting UI reworks, “continuous” crafting (including constructions, like chainsawing trees), remember reload option, “eat again from the same stack” option, throwing UI rework that doesn’t require selecting the item every time and doesn’t break constantly due to picked up items having a “preferred” tag, zombies “picking up” their worn clothes on rez, container assignment, NPCs caching seen items, player getting a pseudo-safe-mode trigger on seeing a wanted item, and few more I forgot right now.

Item IDs are the right thing - elegant and usable. Every option I listed above requires a workaround for lack of IDs (if it is at all possible without them). Why work around the problem instead of fixing it?

Even if you do need a gun that is also a container (???), you can just have the gunmods system only integrate contents that are marked as installed gunmods, it's trivial to do.

That was mostly just an example of how is “contents” vector used.
If you want more serious problems:

[ul][li]Many display/interact functions assume container has only 0 or 1 contents or has limited content types. Allowing arbitrary containers would results in containers randomly becoming “edible” (first item is food), colored as rotten/filthy and so on.[/li]
[li]Active item processing assumes only 0 or 1 contents[/li][/ul]

$ grep "contents\.front" -r src | wc -l
107

107 lines that assume contents are 0 or 1 elements.
Not all of those are problems, but all of those need to be handled in some way.

And that’s just scratching the surface. Many inventory handling functions would need to be rewritten from scratch to handle recursive items without getting “too recursive”. For example, everything that uses the “inventory” class, which would most likely become implicit.

Third is a non-issue, Items would be assigned to containers at all times, that's the whole point of the system.

A system like that would most likely require tedious adjustments pretty often. Because sooner or later (most likely way too soon), someone would want to add different move costs for drawing items from pockets and backpack, but not want to add a sane UI or automatic system to make sure knife and pistol go into pockets and not duffel bags, while scrap goes into duffel and not pockets.

It is probably doable well, but I’ve seen enough realism to warrant being more skeptical than just “sure, but I won’t be the one implementing it”. Double negativity points and warranted skepticism when said realism is called “sense” or “logic”.
I really do want to be proven wrong here, I honestly do.

Not interested, it doesn't make any real progress toward a complete solution.

Starting with sane UI would be a great sign that the whole thing won’t become an inventory shuffling simulation that only exists to make the author feel good about his PR being merged but a usable addition to the game.
If written without terrible hacks, changing the UI to use a different container system would be just 20 lines or so.

Alright, so the problem we all seem to agree on is that the computer should do most of the sorting for the player.

The solution to this would be a system that prioritized by volume of the item and remaining volume in the container(s). If the item can fit, put it in the smallest container, if not, then the next biggest, if not, etc. We could probably make a much more complex system later on, prioritizing by value and quality and whatnot, but starting with something simple would be the best option, in my opinion.

Later on, a system that moved items between containers to make room if the player chose to use it could be added. It would be a simple matter of the computer figuring out which items it could get in, and moving them. Of course, this could present problems if the player had spent time arranging their inventory so that certain things were in certain containers for convenience, this could become a problem, so it should be something like a button the player presses, or an option they toggle on or off.

I haven’t seen the inventory code, so I can’t judge it, but it seems to work just fine right now. Is it something like bad formatting?