[json] How to make items spawn in certain places?

Okay, I’m trying to mod in a military anti-materiel rifle. I want it to spawn at military outposts, bunkers, bases and helicopter crashes.

From what I collected from docs, this is achieved by adding its id to certain item_groups. Now, to which item groups should I add it? So far I have located “helicopter”, “military” and “mil_hw”, which seem appropiate but I want to be sure and not waste hours testing uselessly.
Thus, battery of questions:

-Do outposts, bunkers and bases share the same item_groups for loot?
-Are those the right groups to add?
-Do I need to include it in “allguns” as well (I suppose yes)?
-Would NPCs spawn with it?

And for another mod, I want to make items (ammo, specifically) that can’t spawn anywhere, except by crafting. I suppose that by simply not adding them to any item_group I achieve that. Am I correct (in the sense of both “right” and “formally correct”)?

NPCs spawn with weapons placed in groups with names like skill group. In this case you’d need to add it to “rifles” group if you want NPCs to be able to spawn with it. Though if it requires mounting, NPCs shouldn’t spawn with it (they don’t understand how to do it yet).
“allguns” isn’t special in any way, it is just an item group with all guns.

Bases, bunkers etc. have different drop groups. Those aren’t in jsons yet, but in mapgen.cpp.
From relevant groups, helicopter has “military” and “allguns”, bunker has “mil_rifles” and “mil_hw” and outpost has “mil_rifles”.

Not adding item to item groups will make it not spawn and it’s OK for the item not to be in any group.

I also have some questions.

  1. I have created several types of bullets and I want them to appear only in certain places. Does this mean that I do not need to add them to the group of ‘ammo’? I added ammunition to the group and his own, and was surprised to see them on sale in the gun shop.

  2. if I have added weapons to the group ‘allguns’, does this mean that it will appear on the shelves of gun shops?

  3. what is the group ‘rare’?

  4. what are units of measure the frequency of occurrence of certain items mentioned near each item in each group of subjects?

  5. maybe is there a document where this information is available?

thanks a lot!

  1. Yes. Groups aren’t actually necessary for stuff to work, only to spawn. Many crafted items have no groups for them.

  2. Yes. And in some houses.

  3. Group for rare, expensive stuff. It spawns in military bunkers and I think in labs.

  4. In most cases those are distributions. That means that if you’ve got a group with [“item1”, 2], [“item2”, 3] and nothing else, the item2 will spawn in 60% of cases and item1 in remaining 40%. Adding new item (for example from mod) makes all other items less likely to spawn.

  5. Check out the doc directory in the sources. It will not document what each group is for, but has some useful notes about how to use the json-related stuff.

Coolthulhu, thx a lot! it’s very useful and necessary!