# Need help on item-spawning for mod

**URL:** <https://discourse.cataclysmdda.org/t/need-help-on-item-spawning-for-mod/17732>\
**Category:** The Toolbox\
**Created:** [December 4, 2018, 6:22am UTC](https://discourse.cataclysmdda.org/t/need-help-on-item-spawning-for-mod/17732 "2018-12-04T06:22:35Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ricky\_Van](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/ricky_van/32/4666_2.png) [@Ricky\_Van](https://discourse.cataclysmdda.org/u/Ricky_Van)\
**Post date:** [December 4, 2018, 6:22am UTC](https://discourse.cataclysmdda.org/t/need-help-on-item-spawning-for-mod/17732/1 "2018-12-04T06:22:35Z")

</div>

so basically i’ve been working on a mod and follows the rule of making mods and all but something makes me stuck here,

to make item spawn naturally in the world, i have to create an item group, and i’ve already made it. but then here comes the question:

1. where does the item spawn? is it set automatically by the game or  
user-set spawn?
2. how much spawn weight should i put for an item that is rare to be found, but not too rare?

that’s all the question i had… please let me know.

---

<div class="post-metadata">

**Author:** ![Malkeus](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/malkeus/32/12037_2.png) [@Malkeus](https://discourse.cataclysmdda.org/u/Malkeus)\
**Post date:** [December 4, 2018, 6:24am UTC](https://discourse.cataclysmdda.org/t/need-help-on-item-spawning-for-mod/17732/2 "2018-12-04T06:24:14Z")

</div>

There are two methods for getting your item in the game, that I’m aware of. You can add it to a preexisting item group, which will then make it appear anywhere the mapgen places that group. If you create your own group, you wiull nbeed to make some corresponding mapgen that includes it.

edit: So if you’ve got a rare gun, add it to the ‘rare’ item group (I’m not clear on the syntax for this, I think you just create a copy of the group which only contains your item additons, these will be added to the itemgroup on load.) and give it a number corresponding to how rare you want it to be. Look at the other items in the goruip to get an idea of rarity.

---

<div class="post-metadata">

**Author:** ![Ricky\_Van](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/ricky_van/32/4666_2.png) [@Ricky\_Van](https://discourse.cataclysmdda.org/u/Ricky_Van)\
**Post date:** [December 4, 2018, 6:25am UTC](https://discourse.cataclysmdda.org/t/need-help-on-item-spawning-for-mod/17732/3 "2018-12-04T06:25:56Z")

</div>

owh, now that makes sense, since i made its own item group, it doesn’t spawn anywhere in the game (not even in science lab weaponry) even after playing for 2 hours.

---

<div class="post-metadata">

**Author:** ![Azure\_Soul\_Azur](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/azure_soul_azur/32/2835_2.png) [@Azure\_Soul\_Azur](https://discourse.cataclysmdda.org/u/Azure_Soul_Azur)\
**Post date:** [December 4, 2018, 6:26am UTC](https://discourse.cataclysmdda.org/t/need-help-on-item-spawning-for-mod/17732/4 "2018-12-04T06:26:50Z")

</div>

You can use the spawn weight for diamonds if you want rare…  
Or lower if you think diamonds are too easy too find.

---

<div class="post-metadata">

**Author:** ![Malkeus](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/malkeus/32/12037_2.png) [@Malkeus](https://discourse.cataclysmdda.org/u/Malkeus)\
**Post date:** [December 4, 2018, 6:27am UTC](https://discourse.cataclysmdda.org/t/need-help-on-item-spawning-for-mod/17732/5 "2018-12-04T06:27:27Z")

</div>

One thing I’d absolutely recommend is a program similar to grepWin that will allow you to search all the json files quickly and easily. That makes hunting down examples of what you want to get done much easier. Notepad++ makes an excellent editor as well.

---

<div class="post-metadata">

**Author:** ![Ricky\_Van](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/ricky_van/32/4666_2.png) [@Ricky\_Van](https://discourse.cataclysmdda.org/u/Ricky_Van)\
**Post date:** [December 4, 2018, 6:27am UTC](https://discourse.cataclysmdda.org/t/need-help-on-item-spawning-for-mod/17732/6 "2018-12-04T06:27:33Z")

</div>

i was planning to set it to around 20-30. is it rare enough?

---

<div class="post-metadata">

**Author:** ![Ricky\_Van](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/ricky_van/32/4666_2.png) [@Ricky\_Van](https://discourse.cataclysmdda.org/u/Ricky_Van)\
**Post date:** [December 4, 2018, 6:28am UTC](https://discourse.cataclysmdda.org/t/need-help-on-item-spawning-for-mod/17732/7 "2018-12-04T06:28:30Z")

</div>

yes, i use notepad++, it is a perfect software for making JSON file, and also where i made the mod itself too.

---

<div class="post-metadata">

**Author:** ![Azure\_Soul\_Azur](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/azure_soul_azur/32/2835_2.png) [@Azure\_Soul\_Azur](https://discourse.cataclysmdda.org/u/Azure_Soul_Azur)\
**Post date:** [December 4, 2018, 6:30am UTC](https://discourse.cataclysmdda.org/t/need-help-on-item-spawning-for-mod/17732/8 "2018-12-04T06:30:53Z")

</div>

{  
“id”: “mansion\_safe”,  
“type”: “item\_group”,  
“subtype”: “collection”,  
“items”: [  
[“diamond”, 20],  
{ “group”: “stash\_drugs”, “prob”: 5 },  
[“file”, 70],  
{ “group”: “jewelry\_front”, “prob”: 40 },  
[“money\_bundle”, 50],  
{ “group”: “mansion\_guns”, “prob”: 95 },  
{ “group”: “mansion\_guns”, “prob”: 80 }  
]  
},

Back when i was trying to do a gem mod i set my gems to around… What was it 5-10 IIRC :3

Edit : Just checked it was 10.

---

<div class="post-metadata">

**Author:** ![Ricky\_Van](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/ricky_van/32/4666_2.png) [@Ricky\_Van](https://discourse.cataclysmdda.org/u/Ricky_Van)\
**Post date:** [December 4, 2018, 6:32am UTC](https://discourse.cataclysmdda.org/t/need-help-on-item-spawning-for-mod/17732/9 "2018-12-04T06:32:50Z")

</div>

that’s good tho, sounds like robbery safe.

---

<div class="post-metadata">

**Author:** ![Malkeus](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/malkeus/32/12037_2.png) [@Malkeus](https://discourse.cataclysmdda.org/u/Malkeus)\
**Post date:** [December 4, 2018, 6:35am UTC](https://discourse.cataclysmdda.org/t/need-help-on-item-spawning-for-mod/17732/10 "2018-12-04T06:35:22Z")

</div>

Be aware of the difference between a collection and a distribution(the default). A collection will go down the list giving each item or group a chance to get called. A distribution will only spawn one item, the first item that succeeds in it’s roll. Items at the top are more likely to get a chance to roll.

---

<div class="post-metadata">

**Author:** ![Azure\_Soul\_Azur](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/azure_soul_azur/32/2835_2.png) [@Azure\_Soul\_Azur](https://discourse.cataclysmdda.org/u/Azure_Soul_Azur)\
**Post date:** [December 4, 2018, 6:37am UTC](https://discourse.cataclysmdda.org/t/need-help-on-item-spawning-for-mod/17732/11 "2018-12-04T06:37:35Z")

</div>

didn’t know that… Learn something new every day 😃

---

<div class="post-metadata">

**Author:** ![Ricky\_Van](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/ricky_van/32/4666_2.png) [@Ricky\_Van](https://discourse.cataclysmdda.org/u/Ricky_Van)\
**Post date:** [December 4, 2018, 6:38am UTC](https://discourse.cataclysmdda.org/t/need-help-on-item-spawning-for-mod/17732/12 "2018-12-04T06:38:42Z")

</div>

if i remember correctly, how i set my item group is :

“id”: “GT\_guns\_rifle”,  
“type”: “item\_group”,  
“items”: [  
[“xvr\_88”, 30]  
]

---

<div class="post-metadata">

**Author:** ![Malkeus](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/malkeus/32/12037_2.png) [@Malkeus](https://discourse.cataclysmdda.org/u/Malkeus)\
**Post date:** [December 4, 2018, 6:43am UTC](https://discourse.cataclysmdda.org/t/need-help-on-item-spawning-for-mod/17732/13 "2018-12-04T06:43:14Z")

</div>

I’m glad my hours of pounding my head against this game’s code have been helpful 😉

@Ricky_Van That will be a distribution with a 30 percent chance to spawn the xvr\_88. If you want to do some debugging, add the group to an existing item group, using the method shown in the mansion listing above. So your mods itemgroups json would include an entry like this, below the definition for the GT\_guns\_rifle group. This will call your group 100 percent of the time the game calls for a mansion\_safe drops.  
{  
“id”: “mansion\_safe”,  
“type”: “item\_group”,  
“subtype”: “collection”,  
“items”: [  
{ “group”: “GT\_guns\_rifle”, “prob”: 100 }  
]

---

<div class="post-metadata">

**Author:** ![Ricky\_Van](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/ricky_van/32/4666_2.png) [@Ricky\_Van](https://discourse.cataclysmdda.org/u/Ricky_Van)\
**Post date:** [December 4, 2018, 6:55am UTC](https://discourse.cataclysmdda.org/t/need-help-on-item-spawning-for-mod/17732/14 "2018-12-04T06:55:19Z")

</div>

allright, i’ll put it on debug test now…

thanks for the help, will be back with the test result.

---

<div class="post-metadata">

**Author:** ![Ricky\_Van](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/ricky_van/32/4666_2.png) [@Ricky\_Van](https://discourse.cataclysmdda.org/u/Ricky_Van)\
**Post date:** [December 4, 2018, 8:09am UTC](https://discourse.cataclysmdda.org/t/need-help-on-item-spawning-for-mod/17732/15 "2018-12-04T08:09:59Z")

</div>

debug test successful, yes it turns out i have to make a new mapgen for that which is not my specialty. so i have to rebuild the itemgroup from start again, now it uses default itemgroup.

---

<div class="post-metadata">

**Author:** ![Malkeus](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/malkeus/32/12037_2.png) [@Malkeus](https://discourse.cataclysmdda.org/u/Malkeus)\
**Post date:** [December 4, 2018, 8:16am UTC](https://discourse.cataclysmdda.org/t/need-help-on-item-spawning-for-mod/17732/16 "2018-12-04T08:16:45Z")

</div>

That will tie it to a particular overmap special in order to get it spawning. Please set it’s freq from 0-whatever so you don’t add to the plague of ‘required’ overmap specials in the modding community. It should only have a minimum freq higher than 0 if you add missions that require that location to spawn in order to be completed.  
Alternatively, I think it’s possible to make variants of existing mapgen that include your itemgroup. Like there’s a call for ‘gas station’ and the game has several different ‘gas station’ maps to choose from. I’m not sure how that’s done, maps aren’t my focus either.

---

<div class="post-metadata">

**Author:** ![Ricky\_Van](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/ricky_van/32/4666_2.png) [@Ricky\_Van](https://discourse.cataclysmdda.org/u/Ricky_Van)\
**Post date:** [December 4, 2018, 8:19am UTC](https://discourse.cataclysmdda.org/t/need-help-on-item-spawning-for-mod/17732/17 "2018-12-04T08:19:12Z")

</div>

me too, maps is just too difficult for me.

so i change all my itemgroups, instead of GT-weapon group, i use default group like “guns\_rifle\_rare” and more like that…

is it ok? and how about itemgroups for melee weapons?

---

<div class="post-metadata">

**Author:** ![Malkeus](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/malkeus/32/12037_2.png) [@Malkeus](https://discourse.cataclysmdda.org/u/Malkeus)\
**Post date:** [December 4, 2018, 8:29am UTC](https://discourse.cataclysmdda.org/t/need-help-on-item-spawning-for-mod/17732/18 "2018-12-04T08:29:43Z")

</div>

Yeah, that works. Be aware you can nest collections and groups as deep as you want, which can give you amazing control over the spawns. You can also call an item\_group from a monster via it’s death\_drops. And when spawning guns, you can specify what ammo and whether or not to include a magazine for the entire group. The format for that is in the doc’s, can’t recall which file on the top of my head. Here’s an example from the fiasco that is the Bandit’s mod:  
“type” : “item\_group”,  
“id” : “bandit\_remington\_700”,  
“ammo”: 60,  
“magazine”: 60,  
“items”:[  
[“remington\_700”, 4],  
[“3006”, 4]  
]  
}  
This is a distribution(the default), has a small chance to spawn one of these rifles, and if it does theres a 60% chance of getting ammo and a 60% chance of a magazine in the rifle. I think these are being used redundantly here, one or the other probably is all that’s needed.

edit: As far as melee goes, you’ll have to go digging in the json 😛

---

<div class="post-metadata">

**Author:** ![Ricky\_Van](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/ricky_van/32/4666_2.png) [@Ricky\_Van](https://discourse.cataclysmdda.org/u/Ricky_Van)\
**Post date:** [December 4, 2018, 8:32am UTC](https://discourse.cataclysmdda.org/t/need-help-on-item-spawning-for-mod/17732/19 "2018-12-04T08:32:37Z")

</div>

yes i use the same format like that for the guns in my mod, and i set it so at 30 (maybe will change to 40) percent it will fully loaded with ammo and its magazine.

😄 digging the docs again…

---

<div class="post-metadata">

**Author:** ![Malkeus](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/malkeus/32/12037_2.png) [@Malkeus](https://discourse.cataclysmdda.org/u/Malkeus)\
**Post date:** [December 4, 2018, 8:35am UTC](https://discourse.cataclysmdda.org/t/need-help-on-item-spawning-for-mod/17732/20 "2018-12-04T08:35:43Z")

</div>

well…you could make a change to an existing monster by using copy-from and just including your modified death\_drops entry. Or make your own monster with it’s custom deathdrops, add THAT to a monstergroup.

[Next page](https://discourse.cataclysmdda.org/t/need-help-on-item-spawning-for-mod/17732.md?page=2)
