How to edit traders
Tutorial help with editing existing traders or adding new ones to the game
Files & folders needed:
assets/creatures/traders.json
assets/creatures/characters.json
This is JSON structure of trader items data:
"village_trader": {
"dont_want_to_buy": [
"w_pistol",
"radio_first",
"flashlight"
],
"items": [
"medkit",
"antirad",
"w_viper5",
"ammo_viper5",
"jacket",
"jacket_bandit"
]
}
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
This is JSON structure of trader character data:
"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"
}
]
}
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,
weapon = Model name from assets/models/
gasmask = Show/hide gasmask
gasmask_type = Type of gasmask ( or )
weapon_hold = = where weapon model will be attached
dialogues = Array of dialogues, for trader it must contain same structure as above
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:
How to add new eventsFiles & 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 assets/creatures/traders.json
"my_mod_trader": {
"dont_want_to_buy": [
"w_pistol",
"radio_first",
"flashlight"
],
"items": [
"medkit_army",
"ammo_ak",
"ammo_viper5",
"jacket_bandit"
]
}
Add new character structure to assets/creatures/characters.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 assets/scripts/p_game.gd and spawn NPC using new profile ID with function SpawnNPC() from:
How to add new eventsAfter spawning check game:


Last updated