Cataclysm-dda: Deprecate terrible "chance" and "prob" JSON attributes

Created on 10 Jan 2020  Â·  3Comments  Â·  Source: CleverRaven/Cataclysm-DDA

Is your feature request related to a problem? Please describe.
The terms "chance" and "prob" are used in JSON in places like mapgen and item lists. They are not self-explanatory and famously can mean different things depending on where they appear, or not work in almost identical situations that demand either "chance" or "prob" apparently at random.

Describe the solution you'd like
Deprecate these terms in JSON. Obviously for backwards compatibility we'd leave them doing what they do, but add the following new terms to be used preferentially:
"one-in": Use for anything where the chance of it appearing is one-in x.
"percent": Use to create a chance of something appearing that is a percentage.
"weight": use in distributions and things to assign a weight to a particular value.

If multiple of these terms make sense, for example with place_items, let the JSON understand either one-in OR percent. Throw an error if both are used of course.

Make distribution based itemgroups expect Weight. Let collection based itemgroups understand either Percent or One-in.

Describe alternatives you've considered
Keeping it as is, but it is currently a mess, and it's also annoying to have a number of things where you can't express a chance lower than 1%, or where you can't have any better granularity for high chance of appearance than 100%, 50%, 33%, etc with one-in.

Additional context
It would be worth considering letting distributions treat Percent as meaning the same as Weight, but I think that just contributes to messy code and it's not hard to do a quick find-and-replace.

While we should continue supporting the legacy code, at least for version 0.F, we should probably have a script scrub it out of existing json in mainline and perhaps have a CI that reports it as an error on github so we don't add it back in by accident.

(P3 - Medium) [JSON]

All 3 comments

Instead of "percent" (%, per 100) we could use "permille" (‰, per 1000) so it would be possible to go all the way down to 1/1000 chance. IIRC monsters in monster groups already have their chances as 1/1000.

I don't see the reason to have both "one-in" and "permille". Any "one-in" can be easily converted to "permille".

I can see reasons to go lower than 1/1000, particularly as we get more detailed spawn information for items.

I am bumping the priority of this after the use of freq in monstergroups led to a majority of monster evolutions and spawns not working as expected, and the problem solving process took four devs over an hour.

Was this page helpful?
0 / 5 - 0 ratings