CleverRaven / Cataclysm-DDA

Cataclysm - Dark Days Ahead. A turn-based survival game set in a post-apocalyptic world.
http://cataclysmdda.org
Other
10.33k stars 4.14k forks source link

Books in Jerrycans: Nonsensical Items in Containers #59473

Open Travia21 opened 2 years ago

Travia21 commented 2 years ago

Describe the bug

Books keep auto-inserting into my jerrycans. I will also get nonsensical containment of items with containers like gallon jugs and plastic bottles.

Steps to reproduce

Have a jerrycan in your inventory and pick up a book.

Expected behavior

Liquid containers, especially those with small openings, should probably have their max length explicitly set to 0 or some small value to signify they're only for the containing of liquids. Another option would be to force only the containment of liquids, but this is less than ideal as you can contain sand/soil (technically fluids at the right scale, but that's a digression).

Screenshots

image

Versions and configuration

Additional context

No response

Zireael07 commented 2 years ago

IIRC already reported, but you propose a sensible solution:

max length explicitly set to 0 or some small value to signify they're only for the containing of liquid

ghost commented 2 years ago

i had books placed into water bottles...

chrispikula commented 2 years ago

It's worse when the plastic jerrycan was made from gallon containers which were made from small bottles with copious amounts of duct-tape.

pjf commented 2 years ago

/confirmed

Not sure if the bot will accept my confirmation, but I see this often as well.

KorGgenT commented 2 years ago

i don't think the number should be 0, because there are small items you could technically put into things, but books into a jerrycan is definitely odd.

ghost commented 2 years ago

We almost need in addition to container volume and longest side, a "mouth size", or "smallest opening". Something to determine if items can fit, though that might be getting too complicated.

But also some containers defaulting to liquid only would be great.

x-qq commented 2 years ago

Steel jerrycan already has a restriction like this in place: jv Apparently it just isn't working for whatever reason.

Travia21 commented 2 years ago

Yeah, I just verified by intentionally moving a book into a jerrycan in the Inventory Organization window. It looks like that's a display number without functionality atm.

Trioct commented 2 years ago

It's not working because books are made of paper, and paper is soft, making the book soft. One could imagine jamming a bunch of paper in a jerrycan, but the game doesn't know the difference between a textbook and a stack of paper in terms of rigidity as far as I can tell here. The max item volume should be working, it's just being bypassed because it's for rigid items.

I'm not sure what the best solution here is, because what a book is I think is pretty broad. A magazine is not as rigid as a textbook. You may very well be able to stuff a thin magazine into a jerrycan. Maybe adding a thick material to hard cover books would work, idk.

Relevant code:

// liquids and gases avoid the size limit altogether
// soft items also avoid the size limit
// count_by_charges items check volume of single charge
if( !it.made_of( phase_id::LIQUID ) && !it.made_of( phase_id::GAS ) &&
    !it.is_frozen_liquid() &&
    !it.is_soft() && data->max_item_volume &&
    !it.charges_per_volume( *data->max_item_volume ) ) {
    return ret_val<item_pocket::contain_code>::make_failure(
               contain_code::ERR_TOO_BIG, _( "item too big" ) );
}
chrispikula commented 2 years ago

It would be interesting if we could have materials have a 'bulk' property that is different from normal, individual properties.

  {
    "type": "material",
    "id": "paper",
    "name": "Paper",
    "density": 1.2,
    "specific_heat_liquid": 1.34,
    "specific_heat_solid": 1.34,
    "latent_heat": 333,
    "soft": true,
    "bash_resist": 1,
    "cut_resist": 1,
    "bullet_resist": 1,
    "acid_resist": 1,
    "fire_resist": 0,
    "chip_resist": 0,
    "repaired_with": "paper",
    "salvaged_into": "paper",
    "dmg_adj": [ "ripped", "torn", "shredded", "tattered" ],
    "bash_dmg_verb": "ripped",
    "cut_dmg_verb": "cut",
    "burn_data": [ { "fuel": 10, "smoke": 1, "burn": 10 }, { "fuel": 8, "smoke": 1, "burn": 20 }, { "fuel": 5, "smoke": 1, "burn": 50 } ],
    "burn_products": [ [ "ash", 0.013 ] ],

    "bulk": { "volume": "1 L", [ "soft": false, otherstuffxyz... ] }
  },

Eg, once you've got some volume of object, it no longer behaves the same way. Ream of paper, pile of string or rope, bucket of sand, etc.

NetSysFire commented 2 years ago

As far as I know you can make an item more than one material, I think this was the fix for the books in plastic bottles, too iirc.

Zireael07 commented 2 years ago

@NetSysFire: paper+leather? but softcover books are still all paper IRL so...

NetSysFire commented 2 years ago

Hmm, maybe there should be a value for how rigid an item is, determining how much you can bend it without it becoming damaged. 0 = cloth or something, 100 is stone. Then multiply the effective length with it (but make it a float, so divide by 100, cardboard would be 0.95 or 95 in its JSON value). So if the effective min-length multiplied with this value is within the range it would fit, allow it. But you might need to add a lower cap because even cloth will have some bulk.

Inglonias commented 2 years ago

It's not working because books are made of paper, and paper is soft, making the book soft. One could imagine jamming a bunch of paper in a jerrycan, but the game doesn't know the difference between a textbook and a stack of paper in terms of rigidity as far as I can tell here. The max item volume should be working, it's just being bypassed because it's for rigid items.

I'm not sure what the best solution here is, because what a book is I think is pretty broad. A magazine is not as rigid as a textbook. You may very well be able to stuff a thin magazine into a jerrycan. Maybe adding a thick material to hard cover books would work, idk.

Frankly, not being able to stuff a magazine into a jerrycan is a much more reasonable restriction than the current behavior. I wouldn't mind it as a short term solution.

MochaModifier commented 1 year ago

It's not working because books are made of paper, and paper is soft, making the book soft. One could imagine jamming a bunch of paper in a jerrycan, but the game doesn't know the difference between a textbook and a stack of paper in terms of rigidity as far as I can tell here. The max item volume should be working, it's just being bypassed because it's for rigid items.

I'm not sure what the best solution here is, because what a book is I think is pretty broad. A magazine is not as rigid as a textbook. You may very well be able to stuff a thin magazine into a jerrycan. Maybe adding a thick material to hard cover books would work, idk.

Relevant code:

// liquids and gases avoid the size limit altogether
// soft items also avoid the size limit
// count_by_charges items check volume of single charge
if( !it.made_of( phase_id::LIQUID ) && !it.made_of( phase_id::GAS ) &&
    !it.is_frozen_liquid() &&
    !it.is_soft() && data->max_item_volume &&
    !it.charges_per_volume( *data->max_item_volume ) ) {
    return ret_val<item_pocket::contain_code>::make_failure(
               contain_code::ERR_TOO_BIG, _( "item too big" ) );
}

Perhaps better to describe paper as 'flexible' (if such a thing is possible) rather than 'soft' If anything, paper will more or less hold it's shape unlike a cloth sheet say.

When this kind of insertion happens, in some cases I figure it's a softback book (or magazine if explicitly stated) and that the character has rolled the item to fit through the narrow opening.

Problem is - it would be extremely slow to remove the item, assuming that's even possible. With some containers, you may have to cut it open to remove the book.

It might be practical to whitelist liquids only - but we don't have a way to whitelist or blacklist insertions by material or quality (or atleast I dont think we can