# Merchant inventory

**URL:** <https://discourse.cataclysmdda.org/t/merchant-inventory/17543>\
**Category:** The Garage\
**Created:** [November 20, 2018, 2:28am UTC](https://discourse.cataclysmdda.org/t/merchant-inventory/17543 "2018-11-20T02:28:45Z")\
**Posts on this page:** 15\
**Page:** 2

<div class="post-metadata">

**Author:** ![hydroplatypus](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/hydroplatypus/32/4070_2.png) [@hydroplatypus](https://discourse.cataclysmdda.org/u/hydroplatypus)\
**Post date:** [December 7, 2018, 1:02am UTC](https://discourse.cataclysmdda.org/t/merchant-inventory/17543/21 "2018-12-07T01:02:40Z")

</div>

Someone who knows the code well enough should really put a quick-builder thread, with details on how to relatively quickly add new stuff. Something like:

If you want to add a new mission:

- Add new mission title in 
- Add new mission dialogue in 
- add new mission goal in 
- etc.

If you want to add a new building:

- create file in 
- set spawn details in 
- etc.

Would help new people get into helping the project if there was an instruction list for the simpler stuff.

---

<div class="post-metadata">

**Author:** ![mlangsdorf](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/mlangsdorf/32/2462_2.png) [@mlangsdorf](https://discourse.cataclysmdda.org/u/mlangsdorf)\
**Post date:** [December 7, 2018, 1:32am UTC](https://discourse.cataclysmdda.org/t/merchant-inventory/17543/22 "2018-12-07T01:32:03Z")

</div>

Missions are defined in data/json/npcs/missiondef.json and data/json/npcs/npcs.json.  
There’s a bunch of hard-coded parsing behind the scenes, but I’m pretty sure you can add a new quests without adding new code.

Each type of NPC in npcs.json can have a “mission\_offered” string, like

```auto
"mission_offered" : "MISSION_OLD_GUARD_REP_1"

```

Each mission is defined in missiondef.json, like so:

```auto
  {
    "id": "MISSION_OLD_GUARD_REP_1",
    "type": "mission_definition",
    "name": "Kill Bandits",
    "goal": "MGOAL_ASSASSINATE",
    "dialogue": {
      "describe": "We need help...",
      "offer": "I don't like sending untested men into the field but if you have stayed alive so far you might have some skills. There are at least a pair of bandits squatting in a local cabin, anyone who preys upon civilians meets a quick end... execute both of them for their crimes. Complete this and the Old Guard will consider you an asset in the region.",
      "accepted": "Contractor, I welcome you aboard.",
      "rejected": "The States will remain a wasteland unless good men choose to save it.",
      "advice": "They might suspect you are coming, keep an eye out for traps.",
      "inquire": "Have you completed your mission?",
      "success": "The Old Guard thanks you for eliminating the criminals. You won't be forgotten.",
      "success_lie": "What good does this do us?",
      "failure": "It was a lost cause anyways..."
    }
  }

```

The important bits here are the “name”, which is what is displayed in your Missions list, the dialogue, which I think is more or less self-explanatory, and the goal. Goals are semi-harded from this list:  
MGOAL\_FIND\_ANY\_ITEM, MGOAL\_FIND\_ITEM - find some item or items  
MGOAL\_GO\_TO\_TYPE - move to a specific type of location  
MGOAL\_KILL\_MONSTER - kill a specific monster  
MGOAL\_ASSASSINATE - kill a specific NPC  
MGOAL\_KILL\_MONSTER\_SPEC - kill a bunch of monsters

I don’t think you can currently implement anything but MGOAL\_GO\_TO\_TYPE or MGOAL\_FIND\_ITEM without some C++ support for the “start” function. I’m working to fix that, but stuff takes time.

However, you can implement fetch quests! This is the scavenger quest from the Tacoma Commune:

```auto
  {
    "id": "MISSION_RANCH_SCAVENGER_4",
    "type": "mission_definition",
    "name": "Make 12 Molotov Cocktails",
    "goal": "MGOAL_FIND_ITEM",
    "difficulty": 5,
    "value": 50000,
    "item": "molotov",
    "count": 12,
    "dialogue": { blah blah blah }
  }

```

there’s technically a start function, but all it does it build up the Tacoma Commune - it’s not strictly relevant to the quest.

I think you can also implement MGOAL\_GO\_TO\_TYPE but you’d have to experiment.

I’m pretty sure the dialogue bits are just standard dynamic lines for npcs, which are heavily documented in doc/NPCs.md.

I’ll try to add a “how to contribute” doc/thread, though it’d would mostly be pointers to other, existing documentation.

---

<div class="post-metadata">

**Author:** ![Erk](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/erk/32/3871_2.png) [@Erk](https://discourse.cataclysmdda.org/u/Erk)\
**Post date:** [December 7, 2018, 1:34am UTC](https://discourse.cataclysmdda.org/t/merchant-inventory/17543/23 "2018-12-07T01:34:02Z")

</div>

Thanks for the breakdown! Maybe my next dialogue step then will be to set up some new overmap terrain types and associated NPC quests to go there.

---

<div class="post-metadata">

**Author:** ![kevin.granade](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/kevin.granade/32/1316_2.png) [@kevin.granade](https://discourse.cataclysmdda.org/u/kevin.granade)\
**Post date:** [December 7, 2018, 7:12pm UTC](https://discourse.cataclysmdda.org/t/merchant-inventory/17543/24 "2018-12-07T19:12:11Z")

</div>

Split this topic on December 7, 2018, 7:12pm UTC

6 posts were split to a new topic: [Setting timers for game events](https://discourse.cataclysmdda.org/t/setting-timers-for-game-events/17783)

---

<div class="post-metadata">

**Author:** ![mlangsdorf](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/mlangsdorf/32/2462_2.png) [@mlangsdorf](https://discourse.cataclysmdda.org/u/mlangsdorf)\
**Post date:** [December 7, 2018, 6:23pm UTC](https://discourse.cataclysmdda.org/t/merchant-inventory/17543/29 "2018-12-07T18:23:38Z")

</div>

First pass (general overview, setup, and recipes) here:

> [@Guide to adding new content to CDDA for first time modders](https://discourse.cataclysmdda.org/t/guide-to-adding-new-content-to-cdda-for-first-time-modders/17781):
>
> The [Guide to Adding New Content to CDDA for 1st Time Modders](https://github.com/CleverRaven/Cataclysm-DDA/wiki/Guide-to-adding-new-content-to-CDDA-for-first-time-contributors) now lives on github and you should follow that fine hand-crafted link to the current version. This thread is meant to provide a quick, accessible overview of how to add specific features to CDDA. It’s intended for people who want to add a thing, but don’t know where to start. Hey, what if CDDA had a new way to craft an item (a [recipe!](https://discourse.cataclysmdda.org/t/guide-to-adding-new-content-to-cdda-for-first-time-modders/17781/3)) new [item!](https://discourse.cataclysmdda.org/t/guide-to-adding-new-content-to-cdda-for-first-time-modders/17781/7) new [location!](https://discourse.cataclysmdda.org/t/guide-to-adding-new-content-to-cdda-for-first-time-modders/17781/13) better [NPC dialogue!](https://discourse.cataclysmdda.org/t/guide-to-adding-new-content-to-cdda-for-first-time-modders/17781/16) new [quest!](https://discourse.cataclysmdda.org/t/guide-to-adding-new-content-to-cdda-for-first-time-modders/17781/18) new [monster!](https://discourse.cataclysmdda.org/t/guide-to-adding-new-content-to-cdda-for-first-time-modders/17781/19) new [morale effect!](https://discourse.cataclysmdda.org/t/guide-to-adding-new-content-to-cdda-for-first-time-modders/17781/20) new…

I’ll add more as I have time.

---

<div class="post-metadata">

**Author:** ![hydroplatypus](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/hydroplatypus/32/4070_2.png) [@hydroplatypus](https://discourse.cataclysmdda.org/u/hydroplatypus)\
**Post date:** [December 10, 2018, 1:04am UTC](https://discourse.cataclysmdda.org/t/merchant-inventory/17543/30 "2018-12-10T01:04:27Z")

</div>

Is there a way to specify a category of items for a retrieval quest? The ones I’ve been noticing so far seem to be for a single specific item. But for the merchant canned food quest I’m working on, I would like any canned food to qualify, as there’s no reason to prefer one over another. Also, how many cans seems good for a fetch quest?

---

<div class="post-metadata">

**Author:** ![mlangsdorf](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/mlangsdorf/32/2462_2.png) [@mlangsdorf](https://discourse.cataclysmdda.org/u/mlangsdorf)\
**Post date:** [December 10, 2018, 1:35am UTC](https://discourse.cataclysmdda.org/t/merchant-inventory/17543/31 "2018-12-10T01:35:02Z")

</div>

“item” needs to be a single item. Fortunately for you, canned foods are actually instances of the “can\_food” container item with different contents, so I think the mission will take “can\_food” just fine. Opened cans are “can\_food\_unsealed” so the player won’t be able to turn in empty cans.

I can add an `"items": ["item1_id", "item2_id", ...]` list option, but I don’t want to do that right now because I’m trying to move some more of mission\_start into JSON.

Canned food is pretty common, so 12 for a minor quest, 30 for a major quest? I mean, the Evac center expects you to turn in 25 plutonium cells and they don’t give you the keys to the place or anything.

---

<div class="post-metadata">

**Author:** ![hydroplatypus](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/hydroplatypus/32/4070_2.png) [@hydroplatypus](https://discourse.cataclysmdda.org/u/hydroplatypus)\
**Post date:** [December 10, 2018, 1:38am UTC](https://discourse.cataclysmdda.org/t/merchant-inventory/17543/32 "2018-12-10T01:38:46Z")

</div>

30 cans it is. 12 is just too few, as my real goal is to make the evac center storage room look more full, and 12 cans just won’t do that. Might increase it if it still happens to look empty after I add in the quest-end trigger to populate that room.

---

<div class="post-metadata">

**Author:** ![TheZoneWizard](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/thezonewizard/32/1397_2.png) [@TheZoneWizard](https://discourse.cataclysmdda.org/u/TheZoneWizard)\
**Post date:** [December 11, 2018, 10:52am UTC](https://discourse.cataclysmdda.org/t/merchant-inventory/17543/33 "2018-12-11T10:52:50Z")

</div>

Seems fine. Do you happen to have a way to place all the loot onto those shelves? Would be really cool after several missions to see the room rather full up.

Not sure if you or anyone would know how to make entering the room a trigger to have the guards warn you. Then attack you if you took items or entered a second time 😉

---

<div class="post-metadata">

**Author:** ![hydroplatypus](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/hydroplatypus/32/4070_2.png) [@hydroplatypus](https://discourse.cataclysmdda.org/u/hydroplatypus)\
**Post date:** [January 14, 2019, 4:27pm UTC](https://discourse.cataclysmdda.org/t/merchant-inventory/17543/34 "2019-01-14T16:27:02Z")

</div>

> [@mlangsdorf](#):
>
> Fortunately for you, canned foods are actually instances of the “can\_food” container item with different contents, so I think the mission will take “can\_food” just fine

Turns out that “can\_food” also accepts empty tin cans. Any idea how to make it only accept full tin cans?

---

<div class="post-metadata">

**Author:** ![mlangsdorf](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/mlangsdorf/32/2462_2.png) [@mlangsdorf](https://discourse.cataclysmdda.org/u/mlangsdorf)\
**Post date:** [January 14, 2019, 4:46pm UTC](https://discourse.cataclysmdda.org/t/merchant-inventory/17543/35 "2019-01-14T16:46:54Z")

</div>

I’d have to go fix some issues in the mission code and I have a different big project I’m working on right now. Ping me in a week or two.

---

<div class="post-metadata">

**Author:** ![hydroplatypus](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/hydroplatypus/32/4070_2.png) [@hydroplatypus](https://discourse.cataclysmdda.org/u/hydroplatypus)\
**Post date:** [January 14, 2019, 5:00pm UTC](https://discourse.cataclysmdda.org/t/merchant-inventory/17543/36 "2019-01-14T17:00:14Z")

</div>

Can you give me a TLDR of where and what changes are needed? I might be able to change things around if I have a bit of guidance around what needs to be done.

---

<div class="post-metadata">

**Author:** ![mlangsdorf](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/mlangsdorf/32/2462_2.png) [@mlangsdorf](https://discourse.cataclysmdda.org/u/mlangsdorf)\
**Post date:** [January 14, 2019, 6:42pm UTC](https://discourse.cataclysmdda.org/t/merchant-inventory/17543/37 "2019-01-14T18:42:08Z")

</div>

Sure! src/mission.cpp’s is\_complete() currently has this bit:

```auto
        case MGOAL_FIND_ITEM: {
            inventory tmp_inv = u.crafting_inventory();
            // TODO: check for count_by_charges and use appropriate player::has_* function
            if( !tmp_inv.has_amount( type->item_id, item_count ) ) {
                return tmp_inv.has_amount( type->item_id, 1 ) && tmp_inv.has_charges( type->item_id, item_count );
            }
            if( npc_id != -1 && npc_id != _npc_id ) {
                return false;
            }
        }
        return true;

```

so you’ll want to add some logic to:

1. tell the mission code that for this mission, empty containers aren’t acceptable
2. include that check in the above logic.

For the first bit, you’d add

```auto
   bool no_empties = false;

```

to `struct mission_type` in mission.h, and

```auto
    assign( jo, was_loaded, "no_empties", no_empties" );

```

to `mission_type::load` in missiondef.cpp.

For the second bit, you’d add something here like:

```auto
    if( type->no_empties ) {
       // whatever logic detects empty stuff
    }

```

which I think involves finding the actual items in the inventory and checking their content.

Please debug carefully because I am making educated guesses here and may not be describing a fully correct solution and I’m also probably skipping some bits that seem obvious to me but may confuse you since you don’t know the code as well.

---

<div class="post-metadata">

**Author:** ![hydroplatypus](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/hydroplatypus/32/4070_2.png) [@hydroplatypus](https://discourse.cataclysmdda.org/u/hydroplatypus)\
**Post date:** [January 14, 2019, 6:46pm UTC](https://discourse.cataclysmdda.org/t/merchant-inventory/17543/38 "2019-01-14T18:46:18Z")

</div>

That seems like a bit of a hacky way to fix the issue. Thinking it might be better to add an MGOAL\_FIND\_ITEM\_GROUP mission type, and then just define a list of items in item\_groups.json, which would make it more reusable. Wouldn’t be restricted to a particular container type, but could define arbitrary lists for later missions, in case someone wants a more eclectic group of acceptable items.

Confusingly there already exists a cannedfood item group, but it contains things that are not cans, like toastems. So I’ll have to define a new item list too for this mission.

---

<div class="post-metadata">

**Author:** ![mlangsdorf](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/mlangsdorf/32/2462_2.png) [@mlangsdorf](https://discourse.cataclysmdda.org/u/mlangsdorf)\
**Post date:** [January 14, 2019, 10:40pm UTC](https://discourse.cataclysmdda.org/t/merchant-inventory/17543/39 "2019-01-14T22:40:18Z")

</div>

Sure, go with the better solution.

[Previous page](https://discourse.cataclysmdda.org/t/merchant-inventory/17543.md?page=1)
