Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: [Science] How butchery yields are calculated  (Read 1074 times)

Atkana

  • Bay Watcher
  • [CURIOUSBEAST]
    • View Profile
[Science] How butchery yields are calculated
« on: February 02, 2021, 10:32:57 am »

So after doing a bunch of butchery-related science, I've figured out some things like how item yields are calculated, and thought I'd share the write-up of my results. Maybe someone will find them useful (or it's already been done before, and I've seriously wasted my time :P). I've not really shown my working (my notes are long and messy), aside from a few examples to better explain a point, but I have conducted enough tests that I'm fairly confident on my conclusions.

Most of the information is written assuming that you already know mostly how modding works (for example, I don't go into any explanation about what tissues are), and it's a bit unstructured, so just bear those in mind.

Calculating Yields
Yields are calculated on a per part, per layer basis. Each tissue layer on a part is considered individually, even if multiple layers of the same part are made of the exact same materials. (footnote 1)

Step 1: Get the base volume of the tissue layer
I'm not going to explain how RELSIZEs and RELATIVE_THICKNESSes work exactly, because I'm terrible at explaining things, so I'll just operate on the assumption that you know how they work, or have looked elsewhere for an explanation :P

The base volume of a tissue layer is based on what percent of its body part volume it represents (based on the layer's RELATIVE_THICKNESS compared to the RELATIVE_THICKNESS of all other layers), which is based on what percent of the whole body's unmodified base volume (defined with BODY_SIZE) that the part represents (based on the part's RELSIZE compared to the RELSIZE of all other parts).

Only these aspects - the relsizes of body parts, the base body size, and the relative thickness of a tissue layer compared to others on its part - are what are considered at this stage. Things like whether the layer thickens with strength, if the part has size modifiers, etc. aren't factored in here. This is an important thing to note: they have no impact on the relative base volumes of parts in this calculation! (footnote 2)

Even if a layer is now missing (like fat having melted off), its defined relative thickness is still factored in to the calculations - the volume of muscle on a part doesn't suddenly increase because the fat layer is gone or anything like that.

Step 2: Apply modifiers to each tissue layer's base volume to get its modified volume
There are multiple different modifiers that affect the base volume to get the modified volume. Because these modifications happen after relsizes and such have been considered, they don't impact the volume / yields of any of the other layers on its body part, or any other body parts.

Each of these modifiers is applied as a multiplier to the base volume.
Body Modifiers
The HEIGHT, BROADNESS, and LENGTH of the creature's whole body is used as a modifier. The values for these can be set using the BODY_APPEARANCE_MODIFIER token (whenever these tokens are omitted, the default values are 100).

Modifier = (Body Height / 100) *(Body Broadness / 100) * (Body Length / 100)

Body Part Modifiers
The HEIGHT, BROADNESS, and LENGTH of the body part are used as a modifier. The values for these can be set using the BP_APPEARANCE_MODIFIER token after selecting the part (whenever these tokens are omitted, the default values are 100).

Modifier = (Part Height / 100) * (Part Broadness / 100) * (Part Length / 100)

Stronk and chonk - THICKENS_ON_STRENGTH and THICKENS_ON_ENERGY_STORAGE
If the tissue has the THICKENS_ON_STRENGTH or THICKENS_ON_ENERGY_STORAGE tokens, modifiers based on the creature's stats are applied.
  • If a layer has just THICKENS_ON_STRENGTH, the multiplier is the creature's STRENGTH/1000.
  • If a layer has just THICKENS_ON_ENERGY_STORAGE, the multiplier is the creature's fat amount / 250,000. Because a creature's "normal" fat level is 500,000, you'll likely notice adding this token to a tissue will double the yields from that tissue, as that value gives a 2x multiplier.
  • If a layer has both THICKENS_ON_STRENGTH and THICKENS_ON_ENERGY_STORAGE, the multiplier is the mean average of the two multipliers combined (so the multiplier is: (Strength/1000 + Fat amount/250,000) / 2). This means that it some cases, you could end up getting lower item yields having both tokens than just having one.
Other Modifiers
The amount of a layer that's remaining after some of it has been lost does have some impact on its yield volume, however I didn't purposely investigate it. I'd assume that the % of layer that's remaining is used as a modifier. I did test what happens when a layer is fully gone, however - it yields 0 of its item, regardless of the special clauses (see: later).

Step 3: Get the item yields
The number of items yielded from butchering the tissue layer is based on a simple formula (however, there are some special cases that can modify the number of items):

Number of items = Modified volume / 25,000 (rounded down)

In cases where the yield from this calculation is 0, there are two special clauses that can apply, based on the body part's size, and the modified volume of the tissue.
  • Volume Clause: If the modified volume of a layer is at least 260, any yield of 0 is changed to 1.
  • Part Size Clause: If the size of the body part that the tissue layer is a part of is at least 260, any yield of 0 is changed to 1. A layer could in practice represent even a tiny fraction of a volume unit, and yet still yield 1 item just because its part is 260 or bigger.
Butcher Items
What items are actually yielded from butchering a tissue layer is based on the material it's made from. There are some specially-coded cases based on the materials tokens - for example, materials with the MEAT token will yield meat, materials with the BONE token will yield bone. The token BUTCHER_SPECIAL can be used to set the item yield to be any particular item you desire.

The item count isn't at all impacted by the size of the item being produced. If a layer's modified volume is big enough to yield 40 items, it'll yield 40 meat or 40 statues all the same.
Items with standard dimensions (e.g. BARS, THREAD, CLOTH) seem to be produced at those standard dimensions. For example, with a BUTCHER_SPECIAL:THREAD:NONE material that has a modified volume large enough for an item yield of 10, a stack of 10 thread items will be produced, each item being at 15000 dimensions.

Extra Butcher Objects
Extra butcher objects don't impact the yields of butchering layers associated with the parts at all. They also don't care if the part they're attached to is big enough to yield at least 1 item if it was butchered regularly. So, an extra butcher object that's attached to a body part whose volume is below 260 will still drop its item, even if butchering the layers on that part might not yield anything.

NOMEAT, NOBONES etc.
So how do the creature tokens such as NOMEAT and the like factor into yields for their items? They don't at all, as far as I can tell. Perhaps the tokens affect fort-mode butchering (not adventure mode/arena that I tested with), or the tokens are depreciated from an old version, or they're not supposed to do anything to do with butchering and handle something like whether entries show up in the stockpiles screen or not.

Footnotes
Spoiler: (1) (click to show/hide)
Spoiler: (2) (click to show/hide)

Fleeting Frames

  • Bay Watcher
  • Spooky cart at distance
    • View Profile
Re: [Science] How butchery yields are calculated
« Reply #1 on: February 02, 2021, 11:12:07 am »

For reference, earlier (comparatively incomplete) thread: Butchering results vs critter size (rabbit skull issue) .


However, note that this code doesn't take modifiers and butchers/nonstandard tags into account. Good work on researching those!
« Last Edit: February 03, 2021, 03:35:28 am by Fleeting Frames »
Logged

FantasticDorf

  • Bay Watcher
    • View Profile
Re: [Science] How butchery yields are calculated
« Reply #2 on: February 02, 2021, 07:08:55 pm »

Interesting, so this sort of confirms that a acorn fly's brain is acutely size 1 unit but ordering 20 of them at embark-start is enough to sustain a dwarf for the duration of the initial embarking phase. weird.

Can any of this research accurately account for the effect on pulping/mangling in whether it negatively affects volume on corpses given that the musculature doesn't actually seem to regrow suggesting its not there anymore, i've always noticed reduced yields in these creatures coinciding with the actual limit where that rounding comes into effect seeming to lie at about the size of a creepy-crawler's one unit of extractable muscle meat to things over the size of a buzzard that's been drowned instead of shot out of the sky.

I wonder how this research can be utilized, besides from FF's recent script that uh on initial inspection sounds good but needs more clarity for a layman to explain exactly what it does, which i wonder might be interesting for the skin-glob-mod did actually clarify that animals of larger sizes do actually possess skin equal to their size but because it lacks any sort of additional stuff only yields a small amount or none at all lest they have the "skin of a rhino" to actually tip combat if based solely on thickness.

I will say though, this does scale to giant elephants who are proficiently fat, fat enough to actually deflect a large amount of attacks in a fullbodied adult giant elephant you might find in the wild within adventuremode because they wear it like a giant fleshy armor.
Logged