# .Json mod info

**URL:** <https://discourse.cataclysmdda.org/t/json-mod-info/10769>\
**Category:** The Lab\
**Created:** [October 29, 2015, 11:10pm UTC](https://discourse.cataclysmdda.org/t/json-mod-info/10769 "2015-10-29T23:10:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Noctifer](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/noctifer/32/458_2.png) [@Noctifer](https://discourse.cataclysmdda.org/u/Noctifer)\
**Post date:** [October 29, 2015, 11:10pm UTC](https://discourse.cataclysmdda.org/t/json-mod-info/10769/1 "2015-10-29T23:10:11Z")

</div>

I want to start this thread for querstions and answers of what specific things in .json files do to make modding easier. I will start by asking how the item groups works.`
    "type" : "item_group",
    "id" : "child_items",
    "items":[
      ["chocolate", 50]]`  
In this bit of code, what does the 50 do?

---

<div class="post-metadata">

**Author:** ![Godworrior](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/godworrior/32/2567_2.png) [@Godworrior](https://discourse.cataclysmdda.org/u/Godworrior)\
**Post date:** [November 8, 2015, 2:28am UTC](https://discourse.cataclysmdda.org/t/json-mod-info/10769/2 "2015-11-08T02:28:23Z")

</div>

Looking at the code, the ‘50’ seems to be the probability of the item spawning:

(src\item\_factory.cpp:1348)

```auto
    if (subtype == "old") {
        JsonArray items = jsobj.get_array("items");
        while (items.has_more()) {
            if( items.test_object() ) {
                JsonObject subobj = items.next_object();
                add_entry( ig, subobj );
            } else {
                JsonArray pair = items.next_array();
                ig->add_item_entry(pair.get_string(0), pair.get_int(1));
            }
        }
        return;
    }
```

Don’t know if this makes sense to you, but it assigns the second value in the array (the 50 in your example), to the ‘probability’ attribute in the code below:

(src\item\_group.cpp:325)

```auto
        for( const auto &elem : items ) {
            if( rng( 0, 99 ) >= ( elem )->probability ) {
                continue;
            }
            ItemList tmp = ( elem )->create( birthday, rec );
            result.insert(result.end(), tmp.begin(), tmp.end());
        }
```

This tells me that the value is a percentage of spawning, when it’s 100 the item always spawns. I think it is used in map generation. Sorry, I’m not an expert on the Cataclysm code ☹ (yet).

---

<div class="post-metadata">

**Author:** ![vache](https://avatars.discourse-cdn.com/v4/letter/v/ea666f/32.png) [@vache](https://discourse.cataclysmdda.org/u/vache)\
**Post date:** [November 8, 2015, 2:56am UTC](https://discourse.cataclysmdda.org/t/json-mod-info/10769/3 "2015-11-08T02:56:17Z")

</div>

Actually, its a weighted average. It totals up all of those numbers and then uses that to determine what spawns. So, if the total adds up to 700, then chocolate will spawn 50/700 times.

---

<div class="post-metadata">

**Author:** ![Random\_dragon](https://avatars.discourse-cdn.com/v4/letter/r/4da419/32.png) [@Random\_dragon](https://discourse.cataclysmdda.org/u/Random_dragon)\
**Post date:** [November 8, 2015, 5:30pm UTC](https://discourse.cataclysmdda.org/t/json-mod-info/10769/4 "2015-11-08T17:30:00Z")

</div>

I was gonna say yeah, weight. In monster drop and some mapgen entries you’ll see a different type of item\_group, with subtype collection. These can use percentages, whereas normal itemgroups use weighted lists.

```auto
  },{
        "type" : "item_group",
        "subtype": "collection",
        "id": "cleansing_flame_casualties",
        "entries":
        [
            { "group": "underwear", "damage": [1, 4]}, 
            { "group": "shirts", "damage": [1, 4]},
            { "group": "pants", "damage": [1, 4]},
            { "group": "shoes", "damage": [1, 4]},
            { "group": "cleansing_flame_gear", "damage": [1, 4], "prob": 10 },
            { "group": "cleansing_flame_gear_magic", "prob": 25 },
            { "item": "corpse"}
        ]
  },{
```

This spawns a corpse 100% of the time, calls various clothing item groups 100% of the time (with varying damage levels), calls an item group 10% of the time (with random damage), and calls another item group 25% of the time.
