Hey, I’d like to provide a more complex system for item spawning. The idea is a domain-specific language which can be specified in JSON, as the current one is, but with more clear semantics. I hope to code this over thanksgiving, but I want to make sure it’s useful before I start, so feedback would be great.
Spawn would still be specified by lists of item+number pairs in JSON, with each list being identified as either a Collection or a Distribution. In a Collection each line item is an independent event–you get back a list of items, each item with a probability equal to the number associated. In a Distribution, it’s a weighted list like the current system–you always get a single item, with higher numbers more likely. Importantly, you can nest them within each other or recurse by replacing items w/ groups and the @ sign (so we can keep groups straight from items).
For example, a dead scientist loot tables might look like this:
… long list of potential drops
That table creates a scientist that’s always dressed, has a labcoat 80% of the time, an ID card 50% of the time, etc, and 10% of the item will have a backstuff stuffed full of cool science loot. This is hopefully easier to reason about, but doesn’t make it hard to add new science loot–if it’s a new piece of loot added to science_gear everything will shift around, if it’s added to dead_scientist_loot then every corpse will get it (with some probability).
Ideally I can also get to a full language you can use when specifying a line item, instead of just specifying an item, collection, or distribution, which would let you make specify collections or distributions in a terse way that’s fairly self-explanatory. This would be the order of operations:
returns some quantity of a line item, possibly variable., ("@textbooks#1-3" returns one, two, or three books with equal probability, where each book rolled separately).
- specifies damage to an item, possibly variable, with values between 0 for reinforced and 5 for tattered/shattered/broken ("tshirt3-4" would give a shredded or tattered shirt, equal chance. @clothes1#5-10 would make a discount rack of ripped clothes)
^ upgrades or loads an item (“usp^9mm#15” would return a 9mm gun loaded with 15 9mm rounds. “@rifle^rifle_scope” gives some kind of scoped rifle)
- returns multiple items (“holster+@handgun” returns a holster plus whatever @handgun returned)
| selects one item from the list, equal probability ("@shirt+@pants|blouse+skirt|@dress" gives an equal chance of the three outfits)
The operators don’t do much that couldn’t be done with lots and lots of lists, but they should make it easier. For instance, @bag_of_science above can just become a single line item: “backpack+@science_gear#1-3”. Is this approach easy to understand? Are there better symbols to choose for operations, or operations that are necessary but missing? I’m intentionally avoiding parenthesis or custom functions in the first go, though it would be nice to eventually be able to vary the operator order with () or have some terse ways to do common things like fully load something by saying $loaded after the item.