View Issue Details

IDProjectCategoryView StatusLast Update
0003712Dwarf FortressAdventure Mode -- Reactionspublic2016-03-26 11:35
ReporterAescula Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
Product Version0.31.18 
Summary0003712: Product dimensions act weird
DescriptionAn item with [PRODUCT_DIMENSION:15000], such as thread, needs to be consumed all at once. But to do this, you need to make it use 15000 thread. The game sees this as using multiple things, and makes you choose at least two -- even if you're only using 5000 thread for the item. This can result in disastrously weird things, like a reaction that should have produced one piece of cloth producing 15,000 pieces of cloth.
Steps To ReproduceTry out the Tanmod and Wanderer's Friend, on the Dwarf Fortress File Depot.
Additional InformationA workaround exists, for modders! In the adventure mode things, make every thread reaction use [PRODUCT_DIMENSION:1]. That should prevent thousands of pieces of cloth or what have you.
Tagsadventure mode, long-standing bug, modding, PRODUCT_DIMENSION, stack, thread

Activities

user6

2010-11-22 07:18

  ~0014137

I couldn't follow your explanation. Please post some raws demonstrating what you're talking about.

user1294

2010-11-22 09:46

  ~0014142

I just tested this, so I'll try to explain - Adventure mode reactions do not seem to properly recognize that a single item can be of a dimension other than 1. When you use a reaction requiring a full thread (15000 units of thread), and choose a thread, then the game asks you to choose a second thread, claiming that 0/15000 are still needed. Similar things happen with smaller amounts of thread needed (such as the game claiming that -12000/15000 thread are still needed).

The following raws should be sufficient to demonstrate:

[REACTION:KO_DF_THREAD_PLANTS]
    [NAME:conjure thread]
    [ADVENTURE_MODE_ENABLED]
    [PRODUCT:100:1:THREAD:NO_SUBTYPE:PLANT_MAT:REED_ROPE:THREAD][PRODUCT_DIMENSION:15000]
    [SKILL:PROCESSPLANTS]

[REACTION:SEW_CLOTH_PANTS_ADV]
   [NAME:make cloth pants]
   [ADVENTURE_MODE_ENABLED]
   [REAGENT:A:3000:THREAD:NONE:NONE:NONE:NONE]
   [PRODUCT:100:1:PANTS:ITEM_PANTS_PANTS:GET_MATERIAL_FROM_REAGENT:A:NONE]
   [SKILL:CLOTHESMAKING]

[REACTION:CRAFT_BOWSTRING_ADV]
    [NAME:weave a toy boat]
    [ADVENTURE_MODE_ENABLED]
    [REAGENT:A:15000:THREAD:NONE:NONE:NONE:NONE]
    [PRODUCT:100:1:TOY:ITEM_TOY_BOAT:GET_MATERIAL_FROM_REAGENT:A:NONE][PRODUCT_DIMENSION:15000]
    [SKILL:WEAVING]

(mostly adapted from Wanderer's Friend: http://dffd.wimbli.com/file.php?id=2665 )

Crunchepillar

2013-07-20 19:45

reporter   ~0024071

I know this is super old, but this annoying scenario also applies to using stacks of objects in reactions. For an example reaction that requires 10 coins selecting a stack greater than 10 will make the game ask for another stack with a negative number of coins required, a stack with the needed 10 coins will again require a second stack this time with the message 0/10 required and selecting multiple stacks with greater than the amount required between them will consume all stacks involved rather than removing the required amount. This problem is compounded exponentially if the reaction requires multiple of more than one item consuming significantly more of the required items than just reading the raws would lead one to believe should be required.

BenLubar

2014-05-09 15:20

reporter   ~0024751

I figured out what happens:

When you select an item, the game checks to see if you have enough selected items by adding 1 to the number of selected items and comparing that to the amount it wants. Then it adds the actual number of stacked items you selected.

For example, a reaction requiring 3 eyes would work properly if you gave it a stack of 2 eyes followed by a single eye, but if you gave the single eye followed by the stack of 2 eyes, it would ask for more reagents because 1+1<3. It should be checking if 1+2<3 instead, which is false.

RadHazard

2014-07-27 14:13

reporter   ~0027711

I can confirm this still happens in 0.40.04.

For any item with a size (thread, bars, glob, cloth, etc.), when using a product tag such as [REAGENT:A:1:THREAD:NONE:NONE:NONE:NONE], the game asks for 1 unit of the item, but consumes the entire item.

Setting it to [REAGENT:A:2:THREAD:NONE:NONE:NONE:NONE] or more results in the game asking for two items, with the second item having a negative size corresponding to the difference between the stack size and the expected size, e.g. requiring 2 thread results in the game asking for -14998 thread for the second item.

If the number is equal or greater than the item's normal size, e.g. [REAGENT:A:15001:THREAD:NONE:NONE:NONE:NONE], the all the items except the last will correctly reduce it by the item size (meaning in this example after supplying 1 thread item the game will ask for 1 more unit of thread). The final, partial-sized item will still exhibit this bug, asking for an additional stack with -14999 units of thread. This occurs even if the requested size is an exact multiple of the item size, e.g. 15000 or 30000 for thread, in which case the final, buggy item asks for 0 units. As far as I can tell, the last item (where it asks for negative or zero units) is not consumed. Any items that should only be partially used ARE consumed in there entirety, however.

chaosvolt

2015-02-25 05:24

reporter   ~0032286

Last edited: 2015-02-28 13:19

I've found that the old fix of making reactions spit out a product size of 1 and specifying [DOES_NOT_DETERMINE_PRODUCT_AMOUNT] no longer works.

Before, for example, you could have a reaction like...

[REACTION:SPIN_HAIR_ADV]
    [NAME:spin hair/wool thread]
    [ADVENTURE_MODE_ENABLED]
    [REAGENT:hair:1:NONE:NONE:NONE:NONE][USE_BODY_COMPONENT][UNROTTEN][ANY_STRAND_TISSUE][DOES_NOT_DETERMINE_PRODUCT_AMOUNT]
    [PRODUCT:100:2:THREAD:NONE:GET_MATERIAL_FROM_REAGENT:hair:NONE][PRODUCT_DIMENSION:1]
    [SKILL:SPINNING]

And that would give you 2 units of thread, both with a product dimension of 1, and consuming the hair entirely if I recall.

Now however, it will happily only consume enough of the hair to produce the requested amount and size of thread, making a single source of hair an effectively infinite source of thread. If you didn't insist on a product dimension of 1, you'd start running into the bug you originally reported.

Meanwhile if I use this reaction:

[REACTION:HAIR_CLOTH_ADV]
    [NAME:weave hair/wool cloth from 2 lengths of thread]
    [ADVENTURE_MODE_ENABLED]
    [REAGENT:thread:1:THREAD:NONE:NONE:NONE][REACTION_CLASS:NOT_GUT][DOES_NOT_DETERMINE_PRODUCT_AMOUNT]
    [REAGENT:thread:1:THREAD:NONE:NONE:NONE][REACTION_CLASS:NOT_GUT][DOES_NOT_DETERMINE_PRODUCT_AMOUNT]
    [PRODUCT:100:1:CLOTH:NONE:GET_MATERIAL_FROM_REAGENT:thread:NONE][PRODUCT_DIMENSION:1]
    [SKILL:WEAVING]

This reaction still works correctly, taking 2 stacks of thread, subtracting 1 thread from each, and outputting 1 cloth. If I tried demanding normal-sized thread instead, it would start acting up. Meanwhile, if I gathered normal pieces of yarn (in this mod, the hair template has been given REACTION_CLASS:NOT_GUT) available in towns or otherwise made by worldgen or Fortress Mode, THEY would become effectively infinite sources of cloth for this reaction.

Technically this way of bypassing the bugs still works, except for reactions now taking into account how much hair is available, without any similar fix occurring for other reactions involving thread.

While I'm at it, at least one of my earlier attempts to fix this resulted in getting buried under thousands of cloth items. To demonstrate:

[REACTION:MAKE_CLOTH_SLING_ADV]
    [NAME:craft cloth sling]
    [ADVENTURE_MODE_ENABLED]
    [REAGENT:cloth:1:CLOTH:NONE:NONE:NONE:NONE][DOES_NOT_DETERMINE_PRODUCT_AMOUNT]
    [PRODUCT:100:1:WEAPON:ITEM_WEAPON_SLING:GET_MATERIAL_FROM_REAGENT:cloth:NONE]
    [SKILL:CLOTHESMAKING]

If used with a cloth generated by the last reaction I demonstrated, it would work correctly and give you 1 sling for 1 unit of cloth. What happens when you use a normal stack of cloth varies depending on the presence of the [DOES_NOT_DETERMINE_PRODUCT_AMOUNT] bit. With it present, that single bit of cloth is good for presumably 10000 slings. WITHOUT that token however, it happily decides to make all of those slings at once, with predictable results.

EDIT: I found a workaround that bypasses PART of this issue, basically restoring my old workaround for making hair thread produce single-unit threads.

[REACTION:SPIN_HAIR_ADV]
    [NAME:spin hair/wool thread]
    [ADVENTURE_MODE_ENABLED]
    [REAGENT:hair:1:NONE:NONE:NONE:NONE][USE_BODY_COMPONENT][UNROTTEN][REACTION_CLASS:NOT_GUT]
    [PRODUCT:100:2:THREAD:NONE:GET_MATERIAL_FROM_REAGENT:hair:NONE][PRODUCT_DIMENSION:1]
    [SKILL:SPINNING]

Following the earlier mention of material template edits, the hair template would be given REACTION_CLASS:NOT_GUT to make it usable. By replacing ANY_STRAND_TISSUE from the earlier example, it makes it take a full stack of the hair instead of only using how much that amount of hair could make.

I found this because the new reaction tweaks also broke reactions for making bone weapons, but when I noticed that bone/shell ARMOR wasn't broken, nor were none/horn/tooth/etc sewing needles, I soon realized it was my use of ANY_BONE_COMPONENT for weapons instead of REACTION_CLASS:CARVE_LARGE (for the armor, allowing bones or shells) or REACTION:CARVE_SMALL (for tools and other minor things, allows bone and other things) that caused the issue.

Add Note

Note

Issue History

Date Modified Username Field Change
2010-11-22 01:21 Aescula New Issue
2010-11-22 07:18 user6 Note Added: 0014137
2010-11-22 09:46 user1294 Note Added: 0014142
2013-07-20 19:45 Crunchepillar Note Added: 0024071
2014-05-09 15:20 BenLubar Note Added: 0024751
2014-07-27 14:13 RadHazard Note Added: 0027711
2015-02-25 05:24 chaosvolt Note Added: 0032286
2015-02-25 05:27 chaosvolt Tag Attached: adventure mode
2015-02-25 05:27 chaosvolt Tag Attached: modding
2015-02-25 05:27 chaosvolt Tag Attached: stack
2015-02-25 05:27 chaosvolt Tag Attached: thread
2015-02-25 05:27 chaosvolt Tag Attached: PRODUCT_DIMENSION
2015-02-28 13:18 chaosvolt Note Edited: 0032286
2015-02-28 13:19 chaosvolt Note Edited: 0032286
2016-03-26 11:35 chaosvolt Tag Attached: long-standing bug