Open a shop¶
Designer · 20 min · No code
Result: a townsperson who talks to you first and then opens a shop selling your own stock. You buy an item with gold, sell one back, and leave.
Before you start¶
- Write an NPC conversation. A shopkeeper is an ordinary NPC with one extra setting.
- Shops and trade explains how prices are worked out.
- The items you want to sell already exist. See Add an armour piece or Add a consumable item.
How a shop is put together¶
A shop is one data asset plus one setting on a placed NPC. There is no shop Blueprint to write.
| Piece | Sample | What it decides |
|---|---|---|
| Shop table | Shop/DA_XenoCore_Shop_Colony9 (Gaur Plain's Kamos Outpost uses Shop/DA_XenoCore_Shop_KamosOutpost) |
What is for sale, in what order, and at what price |
| NPC | Characters/NPC/B_XenoCore_Npc, placed in a level |
Who runs the shop and what they say first |
| Shop screen | UserInterface/HUD/W_XenoCore_ShopScreen, named by Project Settings › Game › XenoCore UI › Screens › Shop Screen |
The screen itself. You don't touch it for this recipe. |
The NPC Blueprint already contains the shop logic. When you talk to an NPC, its On Interact graph plays the NPC's dialogue. Then, if Can Shop is true, it calls the Open Shop node with that NPC's shop table. So a shopkeeper always talks first, and the shop opens at the end of the conversation. There is no separate "Shop" button on the prompt.
Prices come from the item. Every item carries a Sell Value on its
XenoCoreFragment_ItemCategory fragment. A shop charges Sell Value × 10 to buy, and pays
Sell Value to sell. You only type a price on the shop table when you want something different.
Stock never runs out. A shop table is a price list, not an inventory.
What the shop buys is not authored anywhere. Any shop buys anything except key items.
Steps¶
1. Check your items can be sold by a shop¶
For each item you want to stock, open its item definition and find the
XenoCoreFragment_ItemCategory entry in its Fragments list. Check:
- Category is not Materials and not Key. A shop never sells materials or key items.
- Sell Value is above
0. With0, the item has no price.
Fails silently at play time, loudly at save time
An item with no XenoCoreFragment_ItemCategory fragment has no price at all. The shop table
flags this as a red error when you save it (see step 3), but if you skip that check the row
is simply missing from the game.
2. Create the shop table¶
- Create a folder
MyGame/Shopsunder Content. - Right-click in it and choose Data › Data Asset. In the class picker, pick
Xeno Core Shop Table (search
Shop Table). Name itDA_Shop_Blacksmith. - Open it. Under XenoCore › Shop, add one entry to Offers per item:
- Item: the item definition.
- Price Override: leave at
0to charge the item's own buy price. Type a number to charge that instead.
- Look at the greyed-out Resolved Price beside each row. That is exactly what the player will pay. It updates as you edit (on a table you have just opened it may take a moment to fill in while the items load). In game the items load when the shop screen opens, not with the map.
- The order of Offers is the order the rows appear inside each category tab.
- Save.
Price Override 0 means \"use the item's price\", not \"free\"
A shop never gives anything away. If you want a free item, give it as a quest reward instead.
3. Let the editor check the table¶
Right-click DA_Shop_Blacksmith and choose Asset Actions › Validate Assets. The table
reports:
| Message | Meaning |
|---|---|
| sells nothing | Offers is empty, so the Buy list would open empty |
| has no Item set | A row has no item |
| cannot be sold by a shop | The item is a Material or Key item, or has no category fragment and Sell Value |
| prices at 0 | The resolved price is 0 |
| same item as offer n (warning) | The item is listed twice |
Fix every error before you go on.
4. Place the shopkeeper¶
- Open the level you want the shop in. For a first try, use
Maps/L_XenoCore_Gym. - Drag
Characters/NPC/B_XenoCore_Npcinto the level. - With the placed NPC selected, in the Details panel under XenoCore › NPC:
- Display Name:
Blacksmith. - Shop Table:
DA_Shop_Blacksmith.
- Display Name:
- Under XenoCore › NPC › Dialogue, fill in Dialogue with what they say before the shop
opens, for example one line:
Take a look at what I've got. - Save the level.
Set Shop Table on the placed NPC, never in the Blueprint's Class Defaults
Shop Table is a per-instance setting. If you set it in B_XenoCore_Npc's Class Defaults,
every NPC in every level becomes a shop.
A vendor the player visits often
Untick Use Dialogue Camera under XenoCore › NPC › Dialogue, so the camera does not move in and out on every visit. Untick Face Player When Talked To for a shopkeeper behind a counter. See Give an NPC a conversation.
Fails silently: an NPC with no lines
If Dialogue is empty the conversation completes instantly and logs a warning. The shop still opens, but the NPC never speaks. Give every shopkeeper at least one line.
Test it¶
- Press Play in the level with your shopkeeper.
- Give yourself gold: open the console (
`) and typeXenoAwardGold 5000. - Walk up to the Blacksmith. The prompt reads Talk. Press A (keyboard E).
- The line plays. When it ends, the shop opens on the Buy tab with your items, at the Resolved Price you saw in the table.
- Buy one. Your gold goes down by the price and the item is in your bag.
- Switch to Sell and sell something. Your gold goes up by its Sell Value.
- Leave with B (keyboard Escape). The conversation box does not come back.
If it doesn't work¶
The NPC talks but no shop opens
Shop Table is empty on this placed NPC, or you set it on a different copy. Select the NPC in the level and check XenoCore › NPC › Shop Table.
The shop opens and the Buy list is empty
Every row failed its checks, or Offers is empty. Run Validate Assets on the table.
An item can't be sold back
Key items can't be sold. Equipped copies are never sold either: unequip it first. A sell count of zero shows the "in use" message instead of the confirm.
The Output Log says Open Shop could not load XenoCore UI > Shop Screen
The screen named by Project Settings › Game › XenoCore UI › Shop Screen was moved, renamed,
or does not derive from XenoCoreShopScreenBase. A setting that fails to load falls back to the
shipped UserInterface/HUD/W_XenoCore_ShopScreen with a warning; this error means that one is
missing too. Point the setting at a valid screen, or move the shipped one back. See
UI and input.
Going further¶
- Shops and trade: buy and sell prices, carry limits, and what the screen does.
- Set up a trade: the barter version, on the second interaction button.
- Branch a conversation: to open the shop only after a choice, place your own Open Shop node (category XenoCore › Shop) in a conversation. It has two exits, Transacted and Nothing Changed, and exactly one always fires.