Cataclysm-dda: Crafting mechanics overhaul

Created on 2 Apr 2019  路  21Comments  路  Source: CleverRaven/Cataclysm-DDA

The crafting system could use a lot of work to make things more realistic and sensible. The first step of this has been implementing a craft entity in #28937.

Moving forward, a lot of stuff that is currently only checked for at the beginning/end of crafting should be checked every turn of crafting.

Note:

  • I don't intend to touch craft times yet, those can be extended in follow up prs.
  • This should make enabling npc crafting fairly trivial.

Todo in rough order of priority:

  • [x] Initial Implementation of craft entity mostly preserving old crafting mechanics (#28937)
  • [x] Reimplement something close to the old rot mechanic in the new system.
  • [x] Disallow rotten components in non-perishables + component filtering infrastructure (#29309)
  • [x] Add workbenches (#29434)
  • [x] Item management enhancements (Fixes #29442)
  • [x] Do experience gains incrementally throughout the craft (goes hand in hand with failure)
  • [x] Check for recipe each turn, not just at start (should be easy)
  • [x] Move failure check out of complete_craft, make chance much lower, and check from activity. (This ended up happening somewhat differently in the implementation, see #30460 for details)
  • [x] Implement a sensible way to handle destruction of components caused by "failure." Maybe destroy a couple components and require new ones to continue the craft?
  • [x] Check for tools and consume charges incrementally. Need to store a tool component cache in the craft entity. (Fixes #7126, Fixes #24230)
  • [ ] Figure out a way to store containers for liquid components/products in the craft entity. (#171, #29569)

- [ ] Profile crafting and investigate performance.

At this point craft times can be drastically extended.


  • [ ] Include ease of access to tools/materials in crafting speed calculations (https://github.com/CleverRaven/Cataclysm-DDA/pull/29434#issuecomment-482312190)
  • [ ] Revise assistant bonus to batch time crafting to take tools/batchsize into account instead of hard cap to bonus at 2 assistants. (Maybe this is better solved with NPC crafting)
  • [ ] Crafting menu enhancements (#29546)
  • [ ] Decide if rot needs to be slowed down depending on recipe and how to do that
  • [ ] Disable checks for being able to craft before creation of item. (and allow aborting crafts at 0%) Closes #27285
  • [ ] At least warn about using rotten components, maybe add a prompt to blacklist? (#28250)
  • [ ] Craft item cosmetics. More detailed Rot info? Make the item look like the product? Suggestions?
  • [ ] Figure out if something similar can be done for construction as well, probably in the form of a placeholder "in progress" terrain. (needs to be expanded into a separate issue but leaving it here for now)
(P5 - Long-term) <Suggestion / Discussion> Crafting / Construction / Recipes Mechanics Change

Most helpful comment

I think this is not true for most cooking recipes, from realism perspective.

Need some sourcing for this. Specifically, we need a source that outlines how partial food spoilage transfers to products after cooking, or if it doesn't, we need a clear statement of that principle from a reputable source. If it sometimes matters and other times does not, we need an outline of when.

The status quo of applying component age to products is based on 1. A lack of good information about how it _should_ work, and 2. A fallback to something that makes sense in the context of a game and seems to intuitively make sense.

Not sure if I count as a reputable source but I've done a fair amount of research in to food spoilage over the years.
Food spoilage is pretty complicated, whether spoiled food can be safely eaten depends on the source of the spoilage and other factors.

  • Mouldy food can be either completely safe to eat or make you extremely ill, or even be beneficial depending on the type of mould, whether cooking it or not makes it edible depends on the toxins produced by he mould or moulds.
  • Bacteria can be either harmful, neutral or beneficial, most bacteria is killed by proper cooking or exposure to halogens, strong acids or radiation but not all, some bacteria like Clostridium Botulinum produce toxins which are not destroyed by cooking.
  • Rancid food is safe to eat if produced by oxidization or hydrolysis, but it can also be caused by bacteria, a fine example of this is potato crisps (chips for you Americans) which turn rancid within hours once opened but are still edible.
  • Parasites, not technically rotting but should be considered anyway, food left exposed can become contaminated with various parasites, or even contain them from the start (I.E pork), these are typically destroyed by cooking.

Certain foods are more susceptible to specific forms of spoilage, at least in the early stages, bread and fruit for example are very susceptible to mould which is often present in small quantities even when fresh, bacteria is usually present in or on meat and dairy products, products high in fat can turn rancid extremely fast once exposed to air, eventually once food has really started to rot all of these are present to a lesser or greater degree.

As to wether or not these can make you ill in small quantities the general answer is yes, harmful bacteria can make you ill even with relatively low counts of bacterium present, toxins produced by bacteria or mould tend to be more forgiving with some exceptions, but will still typically make you feel unwell.

The question is to what degree do we simulate the rotting process, for it's current state mixing can be handled as:

  • Old - Unpleasant smell or taste resulting in a morale penalty, overall effect on the finished item should depend on the percentage used or the food item itself, I.E using stale bread for toast is very common practice.
  • Rotten - Spoils the food completely, this is realistic as far as the current rotting system allows.

A more advanced rotting system may not be worth investing time in since there are so many variables to consider, and even if you take those in to account it's very much random as to wether or not spoiled food is safe, unless you want to simulate bacteria and fungal spores moving around it's pretty much impossible to do with any degree of realism.

All 21 comments

Move failure check out of complete_craft, make chance much lower, and check from activity.
Implement a sensible way to handle destruction of components caused by "failure." Maybe destroy a couple components and require new ones to continue the craft?

Failure can be replaced with crafting damaged item instead. Character will get the item, but it will be mostly unusable. It can work for cloth, weapons and tools, but ..cooking meat is as good as reinforced.

Such crafting can be availabled at any skill level with a recipe from the book, but at low skill it will require more materials due to particular fails and much more time, because particular craft will restart after any fail.

It would be really amazing if you could make this so that when batch crafting something that takes a long time like starch from cattails that each crafted portion of starch is actually completed or marked completed so that when you lose light or are interrupted, at least you have some already completed. I know we have the resume task, but, having to fix the issue and finish crafting before you can get anything is really annoying.

Pretty sure that's not what batch crafting is supposed to simulate. It's not do a craft 10x one after the other, it's do one craft with 10x the components to save time (e.g. a massive pot of soup instead of cooking 10 consecutive small pots)

I think what you want to do is use the - key to repeat the last craft.

Oh, I never knew thats why it was like that. I know about -. Thanks!

Regardless of - function, batch crafting should actually work like the guy suggested. It doesn't make any sense (except for cooking, _maybe_) to work otherwise.

Figure out what to do with rot. Current plan: let the components rot normally and display the craft item itself as rotten based on the most rotten component. Then at the end just copy the rot from the craft item to the product.

I think this is not true for most cooking recipes, from realism perspective. I also think this is a major issue because shelf life management is a huge part of survival. I would suggest either implementing a flexible rot derivation based on recipe or at least replacing current solution with using average rot of components.

There are IRL examples when slight rot of one or more components is negated by the cooking process or can be even desirable (e.g. spoiled milk for pancakes).

That bullet point is a little out of date after recent changes to #28937. My goal there was to keep the current behavior and to reimplement it in the new system. Edited that bullet to reflect that better.

Farther down the list I have another bullet saying.

Decide if rot needs to be slowed down depending on recipe and how to do that

I haven't looked into this and the realism of rot transfer aspect of it too much yet, seems like there will probably be edge cases no matter what the calculation if there is not some field added to recipies. It may be that using the average of the components would be a better approximation, but I'd need some sources to back up that change.

Also, I think #29153 might be related to that bullet point. The first comment puts it nicely:

Sometimes you want to craft with aging food before it rots completely, sometimes you want the freshest stuff available.

Resolution of that issue would be dependent on the final rot transfer solution.

I think this is not true for most cooking recipes, from realism perspective.

Need some sourcing for this. Specifically, we need a source that outlines how partial food spoilage transfers to products after cooking, or if it doesn't, we need a clear statement of that principle from a reputable source. If it sometimes matters and other times does not, we need an outline of when.

The status quo of applying component age to products is based on 1. A lack of good information about how it should work, and 2. A fallback to something that makes sense in the context of a game and seems to intuitively make sense.

I think this is not true for most cooking recipes, from realism perspective.

Need some sourcing for this. Specifically, we need a source that outlines how partial food spoilage transfers to products after cooking, or if it doesn't, we need a clear statement of that principle from a reputable source. If it sometimes matters and other times does not, we need an outline of when.

The status quo of applying component age to products is based on 1. A lack of good information about how it _should_ work, and 2. A fallback to something that makes sense in the context of a game and seems to intuitively make sense.

Not sure if I count as a reputable source but I've done a fair amount of research in to food spoilage over the years.
Food spoilage is pretty complicated, whether spoiled food can be safely eaten depends on the source of the spoilage and other factors.

  • Mouldy food can be either completely safe to eat or make you extremely ill, or even be beneficial depending on the type of mould, whether cooking it or not makes it edible depends on the toxins produced by he mould or moulds.
  • Bacteria can be either harmful, neutral or beneficial, most bacteria is killed by proper cooking or exposure to halogens, strong acids or radiation but not all, some bacteria like Clostridium Botulinum produce toxins which are not destroyed by cooking.
  • Rancid food is safe to eat if produced by oxidization or hydrolysis, but it can also be caused by bacteria, a fine example of this is potato crisps (chips for you Americans) which turn rancid within hours once opened but are still edible.
  • Parasites, not technically rotting but should be considered anyway, food left exposed can become contaminated with various parasites, or even contain them from the start (I.E pork), these are typically destroyed by cooking.

Certain foods are more susceptible to specific forms of spoilage, at least in the early stages, bread and fruit for example are very susceptible to mould which is often present in small quantities even when fresh, bacteria is usually present in or on meat and dairy products, products high in fat can turn rancid extremely fast once exposed to air, eventually once food has really started to rot all of these are present to a lesser or greater degree.

As to wether or not these can make you ill in small quantities the general answer is yes, harmful bacteria can make you ill even with relatively low counts of bacterium present, toxins produced by bacteria or mould tend to be more forgiving with some exceptions, but will still typically make you feel unwell.

The question is to what degree do we simulate the rotting process, for it's current state mixing can be handled as:

  • Old - Unpleasant smell or taste resulting in a morale penalty, overall effect on the finished item should depend on the percentage used or the food item itself, I.E using stale bread for toast is very common practice.
  • Rotten - Spoils the food completely, this is realistic as far as the current rotting system allows.

A more advanced rotting system may not be worth investing time in since there are so many variables to consider, and even if you take those in to account it's very much random as to wether or not spoiled food is safe, unless you want to simulate bacteria and fungal spores moving around it's pretty much impossible to do with any degree of realism.

Ok, so as far as implementation is concerned I could take the relative mass of components into account and calculate a weighted average for rot transfer. If something is rotten then that causes the product to be rotten no matter what.

Maybe I don't understand how workbenches are supposed to work, but I had a really hard time crafting a minifreezer today... To be able to use a workbench for a craft in progress you need to put it into the workbench, but the storage space is not enough for most of the large/heavy crafts... I thought it was supposed to make it possible to craft items without the need to hold them in your hands/inventory...
If there is a workbench - skip the holding/weight/space check... Or simply make it so that crafts in progress size doesn't count when you put them onto workbenches...

In short: if craft in progress is too big to fit in the workbench inventory space, you can't use workbench to craft that item...

Maybe I don't understand how workbenches are supposed to work, but I had a really hard time crafting a minifreezer today... To be able to use a workbench for a craft in progress you need to put it into the workbench, but the storage space is not enough for most of the large/heavy crafts... I thought it was supposed to make it possible to craft items without the need to hold them in your hands/inventory...
If there is a workbench - skip the holding/weight/space check... Or simply make it so that crafts in progress size doesn't count when you put them onto workbenches...

In short: if craft in progress is too big to fit in the workbench inventory space, you can't use workbench to craft that item...

Not quite sure what you mean. Considering that there is 1000L of available space on a workbench, there should be plenty for crafting pretty much anything. An in progress minifreezer is certainly well below that threshold. Not 100% sure that there is no craft in game right now which could reach 1000L, but If there is I'm not aware of it.

1000L of available space on a workbench

On a vehicle-mounted workbench it's only about 5L...

The smallest one is 80L.

image
Not according to the game...

Just made an issue for this discussion #29925

A big issue I have with this system is incomplete crafts for which you fail and destroy components but don't have spare components of that type OR of other ingredients.

You can be left with a craft that you can't finish, but "holds" components that prevent you from building another with some different components. It always requires the ingredients you started the craft on, even when the recipe offers variation in what can be used for that part. Which means the moment you "create" the work piece ALL the components are in, even though the work piece is 0% complete.

I see two solutions:

  1. Allow disassembly of work pieces, return all non-failed components.
  2. % progress on work piece relates to progress through component addition, for example; knife spear
    0% check for success adding broom/stick/cue, 25% check for success adding spike, 50% check for success adding felt/fur/leather/rag, 75% check for success adding string/straw/plants/duct tape. At least with this option, the check would allow for changing components where there is variety in recipe.

The last point is made worse by batch-crafting.

If you have, say, 10 chunks of meat on hand, and try to cook them all at once, and mess up, losing the ingredient - you now have an item which is 10-almost-completed-cooked meats which you can't do anything about.

I had this happen to me when extracting seeds from some vegetables, and it's especially annoying there as batch-crafting doesn't even give crafting speedup there, only convenience.

If you have, say, 10 chunks of meat on hand, and try to cook them all at once, and mess up, losing the ingredient - you now have an item which is 10-almost-completed-cooked meats which you can't do anything about.
That's realistic, actually... That has happened to me IRL more than once when I screwed up cooking something and had to throw the whole batch (a full oven) in the trash...

That's realistic, actually... That has happened to me IRL more than once when I screwed up cooking something and had to throw the whole batch (a full oven) in the trash...

This analogy works for recipes that have batch craft time savings, yes.
It fails for things like crafting seeds from vegetables, where crafting a batch of 10 is exactly as time-consuming as crafting a recipe individually 10 times. In effect the "optimal" play is to never batch-craft those, but that gameplay is simply annoying for no good reason.

Also, unlike the oven analogy, if I find another chunk of meat several days later somewhere, I'd be able to add it to 9 partially-cooked ones, and finally finish the craft resulting in 10 perfectly fine cooked meats...

Was this page helpful?
0 / 5 - 0 ratings