# How to edit traders

Files & folders needed:

> assets/creatures/traders.json
>
> assets/creatures/characters.json

This is JSON structure of trader items data:

{% code title="traders.json" %}

```json
"village_trader": {
  "dont_want_to_buy": [
    "w_pistol",
    "radio_first",
    "flashlight"
  ],
  "items": [
    "medkit",
    "antirad",
    "w_viper5",
    "ammo_viper5",
    "jacket",
    "jacket_bandit"
  ]
}
```

{% endcode %}

{% code title="Properties description" %}

```ini
village_trader = Unique ID, used in assets/creatures/characters.json
dont_want_to_buy = list of items IDs, player can't sell to trader
items = list of items IDs, player can buy
```

{% endcode %}

This is JSON structure of trader character data:

{% code title="characters.json" %}

```json
"village_trader_profile":{
  "name": "npc.village.trader.name",
  "trader_profile": "village_trader",
  "texture": "pstalker",
  "idle_animation": "sit_on_greenbox_2",
  "weapon": "w_ak",
  "gasmask": false,
  "gasmask_type": "antigas",
  "weapon_hold": "r_hand",
  "dialogues": [
    {
  	"dialogue": "no_dialogue"
    }
  ]
}
```

{% endcode %}

<pre class="language-ini"><code class="lang-ini">village_trader_profile = Profile unique ID, used when NPC spawn
name = Hint name text, that appear when player look at NPC
trader_profile = Unique ID from traders.json
texture = Texture name of NPC model from assets/textures/
idle_animation = Base idle animation that plays after spawning, <a data-footnote-ref href="#user-content-fn-1">list in p_game.gd</a>
weapon = Model name from assets/models/
gasmask = Show/hide gasmask
gasmask_type = Type of gasmask (<a data-footnote-ref href="#user-content-fn-2">antigas</a> or <a data-footnote-ref href="#user-content-fn-3">antigas_elite</a>)
weapon_hold = <a data-footnote-ref href="#user-content-fn-4">Bone name</a> = where weapon model will be attached
dialogues = Array of dialogues, for trader it must contain same structure as above
</code></pre>

You can edit existing values and see how it works.

***

To create new trader, we need to create new character structure and new trader structure. How to spawn NPC, you can learn in this tutorial:

{% content-ref url="/pages/6efTHWpL2pp4W8SwXTUt" %}
[How to add new events](/assets/modding/how-to-add-new-events.md)
{% endcontent-ref %}

Files & folders needed for adding new trader NPC:

> assets/creatures/traders.json
>
> assets/creatures/characters.json
>
> assets/scripts/p\_game.gd

Add new trader structure to <mark style="color:orange;">assets/creatures/traders.json</mark>

{% code title="traders.json" %}

```json
"my_mod_trader": {
  "dont_want_to_buy": [
    "w_pistol",
    "radio_first",
    "flashlight"
  ],
  "items": [
    "medkit_army",
    "ammo_ak",
    "ammo_viper5",
    "jacket_bandit"
  ]
}
```

{% endcode %}

Add new character structure to <mark style="color:orange;">assets/creatures/characters.json</mark>&#x20;

```json
"my_mod_new_trader_profile":{
  "name": "npc.village.trader.name",
  "trader_profile": "my_mod_trader",
  "texture": "pbandit",
  "idle_animation": "sit_ground",
  "weapon": "w_ak",
  "gasmask": false,
  "gasmask_type": "antigas",
  "weapon_hold": "backpack",
  "dialogues": [
    {
  	"dialogue": "no_dialogue"
    }
  ]
}
```

Now open <mark style="color:orange;">assets/scripts/p\_game.gd</mark> and spawn NPC using new profile ID with function <mark style="color:blue;">**SpawnNPC**</mark>**()** from:

{% content-ref url="/pages/6efTHWpL2pp4W8SwXTUt" %}
[How to add new events](/assets/modding/how-to-add-new-events.md)
{% endcontent-ref %}

After spawning check game:

<figure><img src="/files/MAq94xFLDpMkGeXtIFXq" alt=""><figcaption><p>Trader with sit animation</p></figcaption></figure>

<figure><img src="/files/gJcZt6VMA1z7bwGAgFId" alt=""><figcaption><p>Trader's goods based on list from traders.json</p></figcaption></figure>

[^1]: List of available game NPC

    animations can be found in&#x20;

    assets/scripts/p\_game.gd file.

[^2]: stalker texture

[^3]: mercenary texture

[^4]: l\_hand, r\_hand, backpack


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://picnic-in-the-oblivion.gitbook.io/assets/modding/how-to-edit-traders.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
