Skip to content

Set up a trade

Designer · 20 min · No code

Result: an NPC whose prompt shows a second button, Trade. You offer them collectables from your bag in exchange for an item they want to part with, and a generous offer earns a bonus item on top.

Before you start

How trading works

Trading is barter, not gold. The NPC offers a short list of items. The player picks one and puts up items from their bag. If what the player offers is worth at least the item's price, the trade goes through.

What the player may offer: only Materials and Collectables. Equipment, key items, gems, crystals and arts manuals are never shown on the player's side.

What things are worth on the trade table, from each item's Sell Value:

Item category Trade value
Materials Sell Value × 1
Everything else (collectables, weapons, armour…) Sell Value × 10

So collectables picked up in the world are worth ten times their shop sell price in a trade. That is the point of trading: it turns exploration into gear.

The bonus ("overtrade"). Each NPC can hold one bonus item. If the player offers at least the item's price + the bonus item's value, they get the bonus too.

Setting a trade table is all it takes. An NPC with a trade table automatically shows Trade as their second prompt, on pad X (keyboard F). You never type "Trade" anywhere.

Piece Sample
Trade table Trade/DA_XenoCore_Trade_Colony9
NPC Characters/NPC/B_XenoCore_Npc, placed
Trade screen UserInterface/HUD/W_XenoCore_TradeScreen

Steps

1. Check the items

Each item on either side of a trade needs a XenoCoreFragment_ItemCategory fragment with a Sell Value above 0. An item without one is worth nothing and can't be traded.

For testing, make sure you know one or two Collectables the player can pick up in your level. The gym has collectable orbs placed.

2. Create the trade table

  1. In MyGame/Trades, create a Data Asset of class XenoCoreTradeTable. Name it DA_Trade_Fisher.
  2. Open it. Under XenoCore › Trade › Offers, add one or two entries to Offers:
    • Item: what the NPC hands over.
    • Price Override: 0 to ask the item's own trade value, or a number to ask that.
  3. Read the greyed-out columns on each row:
    • Resolved Price: what the player must offer for this item.
    • Overtrade At: what the player must offer to get the bonus too. 0 when there is no bonus.

On a table you have just opened these may take a moment to fill in while the items load. In game the items load when the trade screen opens, not with the map. 4. Under XenoCore › Trade › Overtrade Bonus, optionally set: - Item: the bonus item. Leave empty for an NPC who never gives a bonus. - Value Override: how much extra the player must offer on top of a row's price. 0 uses the bonus item's own trade value. Resolved Value shows the result. 5. Save, then right-click the asset and choose Asset Actions › Validate Assets. Fix any error (no offers, an offer with no item, a row priced at 0).

Keep the list short. A trader offers one or two things, not a shop's stock.

Price Override 0 means \"use the item's value\", not \"free\"

Nothing is ever traded for free. A gift belongs in a quest reward.

The bonus is one per NPC, not one per row

Overtrade Bonus belongs to the trader. The threshold moves with whichever row the player is trading for (row price + bonus value), but the bonus item is always the same one.

3. Give the table to an NPC

  1. Place Characters/NPC/B_XenoCore_Npc in your level, or select one already there.
  2. In Details › XenoCore › NPC, set Display Name and set Trade Offers to DA_Trade_Fisher.
  3. Optionally set Portrait. The trade screen shows it beside the NPC's half of the exchange.
  4. Save the level.

Set it on the placed NPC, never in Class Defaults

Trade Offers is per instance. In the Blueprint's Class Defaults it makes every NPC a trader.

4. (Optional) Change what they say afterwards

The NPC Blueprint's On Interact graph already handles trading. When the press was the Trade button, it calls Open Trade, which has two exits:

  • Traded: at least one exchange happened.
  • Cancelled: the player backed out, or the screen could not open.

The stock graph does nothing on either exit: the trade screen closes and the NPC says no more. To give the NPC a closing line, make a child Blueprint of B_XenoCore_Npc in MyGame/NPCs, override its On Interact, and after Open Trade add a Play Dialogue on Traded (for example "Pleasure doing business.") and another on Cancelled ("Come back any time."). Working in a child means a template update does not overwrite your lines.

Branch on Is Trade Verb, never on the verb number

On Interact receives a Verb Index. Trade is index 1 today, but adding an entry to Extra Interact Verbs shifts it. Use the Is Trade Verb node to ask. A graph comparing Verb Index to 1 opens the wrong thing silently.

Test it

  1. Press Play. Pick up a few collectables.
  2. Walk up to your NPC. The prompt shows Talk and Trade.
  3. Press X (keyboard F). The trade screen opens with the NPC's offers.
  4. Pick an offer. Your side lists only materials and collectables.
  5. Offer items worth at least the Resolved Price. The trade goes through, the item is in your bag and your offered items are gone.
  6. If you set a bonus, offer at least the Overtrade At value on another trade. You receive the bonus item as well.

If it doesn't work

No Trade prompt appears, and X changes the party's orders instead

Trade Offers is empty on this placed NPC. X opens a trade only while the prompt offers Trade; anywhere else a tap of X switches the party's Attack tactic (see Party tactics).

My items aren't listed on my side

Only Materials and Collectables can be offered. Check the item's category fragment.

An offer can never be afforded

The item has no category fragment or a Sell Value of 0, so it has no value to derive a price from. The table's validation reports it.

The Output Log says Open Trade could not load W_XenoCore_TradeScreen

The trade screen asset was moved or renamed. See UI and input.

Going further