Ive begun doodling around with item data files, and I have a question.
Could someone here elaborate the rarity parameter for me a bit?
I would assume that it has to do with how often the item can be found in the game world, correct me if im wrong.
Is it rarer the lower the number value is, or is it the higher the number the rarer?

the lower the number the harder it is to find for example rarity 2 means out of 100% there is a 2% chance for it to spawn in that location. so when do you get something that are 1-10 rarity then that’s lucky.

When I last checked, most randomized items are selected using a raffle, with the “rarity” of an item type determining how many tickets it gets in the raffle. In order to determine the chance of an item spawning, you need to figure out which items can spawn in that location (which mapitem is used), and divide the rarity of the item you want by the sum of all their rarities.

It’s a very flawed system, but making it better would require a significant degree of effort.

well the thing about rare items being hard to spawn is the division by sum of all rarities instead of actually have it as 1-10% it get’s lowered. (Example more common item spawns in that location=lesser rare loot spawn chance in that location)

The above outlines how it works perfectly.

In the future we want to move item rarity on to the spawn lists themselves, so it’ll be like (I’m not checking for correct syntax here):

{ "spawn_lists: [
 {"location" : "refrigerator",

This would still use relative rarity, I’m not sure how to get around that with items, but this would make it at least manageable since you’d have one place to look and see the ratios for a given location.

yeah that example looks good really somethings that amazes me is the amount of items that can spawn on the ground instead of where they should be like refrigerators. (And it can help fix some rarity issues about it being rarer than supposed to be)

Relative rarity isn’t much of a flaw. Percentages are more appealing, but it’s hard to tell what percentage is good. Usually you express issues relative to the current spawnrates anyway; you don’t know that, hypothetically, a 65% chance of a welder is right, you just know welders are too rare right now.

The big issues I see with the current system are these:

[ol][li]As noted, the rarity of items is shared in every location they spawn in.[/li]
[li]Your only control over how many items spawn is place_items()'s “chance” parameter, which is inadequate for a lot of purposes. You can’t try to spawn 1-2 random, rare items without having a chance of spawning eight items. You can’t try to spawn a backpack’s worth of junk without a chance that you’ll flub the first roll and spawn nothing. For the vast majority of purposes, it would be better to just spawn an exact number of items passed as a parameter, and give full control of any randomization in that regard to whatever’s calling the function.[/li]
[li]You can’t easily make a list that spawns a bunch of separate entries at once; this makes it impossible to spawn a sensible suit of clothes, or a gun and matching ammo, without an awkward hack.[/li]
[li]You can’t nest spawn lists in each other, meaning you need to redefine common components of a more specific list, such as clothing.[/li][/ol]

The last two problems are big issues for complex cases like “a dead soldier, with a random set of equipment”. In my mind, something broadly similar to this is ideal:

[ul][li]100% chance of 1 human corpse[/li]
[li]100% chance of 1 set of military clothing[/li]
[li]50% chance of 1 possibly-loaded military primary weapon and ammo[/li]
[li]25% chance of 1 possibly-loaded military side arm and ammo[/li]
[li]75% chance of 1 combat knife[/li]
[li]20% chance of 1-3 military grenades[/li]
[li]20% chance of 1-2 military medicines[/li]
[li]60% chance of 1-2 military food items[/li][/ul]

Spawning a bunch of subentries separately and nesting further lists makes this a lot easier, because you can say “I need a soldier’s uniform” or “I need a loaded rifle and maybe ammo” and cut to the more important features. The alternative is to hammer out “1 shirt, 1 pants, 1 boots, maybe a vest, maybe a helmet, blah blah blah…” every time you want to give someone a uniform. This way, you can give a dead soldier, a dead soldier zombie, and a locker in the barracks the same type of uniform easily, and it’s guaranteed to result in a coherent uniform rather than something inane.

This kind of list where you have a separate chance of spawning every item on the list is very useful, but the existing kind of raffle-style list is still better for simpler cases. If you’re spawning prescription drugs at a pharmacy, and you just want a bunch of random prescription drugs, you still want to have lists where where each entry is just “x amount of y drug, with z raffle tickets” and you just choose one entry, then probably repeat a bunch of times.

The other downside to this style is that excessive predefined detail and a dearth of random elements can make the world feel flat. You might want dead soldiers to have a low chance of carrying two rifles for whatever reason, or a spare pair of pants, or a bag of pretzels; the above list won’t do that unless you remember to add them. You can mollify the issue by adding low chances of spawning additional items with a very wide range of possible types. It’s still best to reserve this degree of structure for instances where excessive randomness is very noticeable, like the gear on a corpse; it’s acceptable to find a crate or locker holding a weird mix of junk, or a gun shop stocking weapons and ammunition that prove

These lists are the way it’s done in Bethesda Softworks RPGs; I didn’t come up with the system myself. It’s intricate, but not really moreso than necessary, and the system doesn’t need to be conveyed to the player.

It smells like Bethesda alrite.

Thanks guys, you answered everything I was wondering.

And here I was thinking it was a mod that added my favorite marshmallow creature.

Added ted’s outline as an issue in the issue tracker, because yea, there are definitely places where item spawning needs some structure like that.

Thanks. I’m glad my lecturing can be useful. :slight_smile: