# Merchants won’t carry anything

**URL:** https://discourse.cataclysmdda.org/t/merchants-won-t-carry-anything/20069
**Category:** The Bunker
**Created:** [May 14, 2019, 3:03pm UTC](https://discourse.cataclysmdda.org/t/merchants-won-t-carry-anything/20069 "2019-05-14T15:03:28Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Strangelove](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/strangelove/32/5982_2.png) [@Strangelove](https://discourse.cataclysmdda.org/u/Strangelove)
#### Post date: [May 14, 2019, 3:03pm UTC](https://discourse.cataclysmdda.org/t/merchants-won-t-carry-anything/20069/1 "2019-05-14T15:03:28Z")

</div>

I’ve tried to trade with the merchant at the refugee centre, I had a spare acetylene torch but trying to sell it I got a message that he can’t carry all that. Is there a way to fix that?

---

<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: [May 14, 2019, 5:22pm UTC](https://discourse.cataclysmdda.org/t/merchants-won-t-carry-anything/20069/2 "2019-05-14T17:22:13Z")

</div>

Not currently. The problem is that NPCs only trade what they can carry. It wouldn’t be too hard to fix that in the C++ code, and if you know how to program I can point you to the relevant sections, but no one has fixed it yet.

---

<div class="post-metadata">

### Author: ![nhkun](https://avatars.discourse-cdn.com/v4/letter/n/ed655f/32.png) [@nhkun](https://discourse.cataclysmdda.org/u/nhkun)
#### Post date: [May 15, 2019, 4:49am UTC](https://discourse.cataclysmdda.org/t/merchants-won-t-carry-anything/20069/3 "2019-05-15T04:49:32Z")

</div>

I can try to do it. You can point us both.

---

<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: [May 15, 2019, 12:36pm UTC](https://discourse.cataclysmdda.org/t/merchants-won-t-carry-anything/20069/4 "2019-05-15T12:36:09Z")

</div>

The NPC trading code is in src/npctrade.cpp.

It needs a lot of code clean-up but it mostly works so polishing it has been low priority for me.

The weight and volume of stuff that the NPC can trade is set on lines 191-192

```auto
    units::volume volume_left = p.volume_capacity() - p.volume_carried();
    units::mass weight_left = p.weight_capacity() - p.weight_carried();

```

your trading inventory is set in `init_buying()` on lines 79-115, and the NPC’s trading inventory is set in `init_selling()` on lines 48-67.

and the code to transfer inventory is `inventory_exchange()` at the top of the file.

if you compare `init_buying()` to `init_selling()`, you’ll notice that you add items from the ground an adjacent vehicle to your inventory, but the NPC does not. 90% of the time, that’s appropriate, but shopkeepers should be allowed to sell inventory from the ground.

You can check if an `npc &guy` is a shopkeeper with `guy.mission == NPC_MISSION_SHOPKEEP`.

So what needs to happen is `init_selling()`, there needs to be check for `p.mission == NPC_MISSION_SHOPKEEP`, and if it is true, the NPC adds inventory from the ground. Lines 191-192 need a similar check that lets the shopkeeper carry an unlimited amount of inventory, something like:

```auto
if( p.mission == NPC_MISSION_SHOPKEEP() ) {
    volume_left += 8000_liters;
    mass_left += 8000_kilograms;
}

```

and shopkeepers should use `p.i_add_or_drop( it, true );` in `inventory_exchange()` except you’ll need to rewrite `inventory_exchange()` and that entire logic quite a bit; probably break it into two functions: one that removes items from inventory and one that adds them; both should use the inventory accessors from character.h instead of manipulating the inventories directly.

Thanks for volunteering to do this!
