CleverRaven / Cataclysm-DDA

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

Ability to blacklist item variations #77732

Open randyk97 opened 4 days ago

randyk97 commented 4 days ago

Is your feature request related to a problem? Please describe.

Currently, putting an ID like: "knife_large_var_knife_chef", into an item blacklist results in an error, and since strings are expected, a format like: { "item": "knife_large", "variant": "knife_chef" } throws an error as well. With the increasingly larger amount of items being converted to variations, it makes sense that you should be able to blacklist them like before.

Solution you would like.

Ideally, the ID with the var extension should get recognized by the game, in a similar manner to how it is recognized by a graphics pack JSON, or at the least you should be able to use: { "item": "knife_large", "variant": "knife_chef" }, which is the same format used to select a specific variation for professions.

Describe alternatives you have considered.

No response

Additional context

No response

RenechCDDA commented 4 days ago

You should use copy-from and delete the blacklisted variants from the variants array.

randyk97 commented 4 days ago

When I use copy-from, the copied item loses all its variants anyway, so you have to redefine all of them in the new item.

randyk97 commented 4 days ago

For example, in the guns.json for the Classic Zombies mod, a new item is created called "m1911a1", and since the variants array is empty in that new item despite being copied from "m1911", the "m1911" variant has to be redefined (a problem if the original m1911 variant gets changed).

RenechCDDA commented 4 days ago

When I use copy-from, the copied item loses all its variants anyway, so you have to redefine all of them in the new item.

You don't make a new item. The ID of your item should remain the same.

https://github.com/CleverRaven/Cataclysm-DDA/blob/6efe7a3cc98ba1ec327ed2405bb04d9004430870/data/mods/Aftershock/items/containers.json#L27-L29

randyk97 commented 4 days ago

I did do it with the ID the same; it does not make a difference: the overwritten item will inherit all properties except the variants array which remains empty. You can overwrite any item in game that has variants like this and see that even if you do not add anything new to the overwritten code, that item will lose all its variants.

Procyonae commented 1 day ago

https://github.com/CleverRaven/Cataclysm-DDA/blob/daebd7d7ab2ab99a3c8edfe1d43e69cfd2dd3836/src/item_factory.cpp#L4238 Yeh variants explicitly aren't copy_frommed, the false here would need to be was_loaded