Shops and trade¶
All · 12 min read · No code
There are two ways to get items from an NPC. A shop sells for gold and buys almost anything back. A trade is a barter: the NPC hands over one item for one of yours that is worth at least as much. Each is a data asset (a shop table or trade table) set on a placed NPC, opened by a node in that NPC's On Interact graph. Neither has any state of its own: stock never runs out, so the party bag and the party's gold are the only things that change. The idea that makes the rest make sense: every price comes from one number on the item, its Sell Value, and each system applies its own multiplier to it.
What you can change¶
- A shopkeeper and what they sell: Open a shop.
- A trader and what they offer: Set up a trade.
- An item's price: its Sell Value (on the item), or Price Override on one row of a table.
- The screens' wording and look: their Blueprints' class defaults (see Settings).
How it fits together¶
| Piece | Kind | Job |
|---|---|---|
Shop/DA_XenoCore_Shop_Colony9 |
Shop table (data asset) | The Gym sample shop's stock: seven pieces of equipment |
Shop/DA_XenoCore_Shop_KamosOutpost |
Shop table | The Gaur Plain shop at Kamos Outpost, which also sells rank I gems |
Trade/DA_XenoCore_Trade_Colony9 |
Trade table (data asset) | The sample trader's offers and overtrade bonus |
| Open Shop | Blueprint node | Opens the shop, continues on Transacted or Nothing Changed |
| Open Trade | Blueprint node | Opens the barter screen, continues on Traded or Cancelled |
UserInterface/HUD/W_XenoCore_ShopScreen |
Screen | Buy / Sell / Quit, lists, quantity confirm, "equip now?" |
UserInterface/HUD/W_XenoCore_TradeScreen |
Screen | Their item, your item, confirm |
UserInterface/W_XenoCore_TradeRow |
Row widget | One list row on either screen |
| Shop and trade nodes | Blueprint nodes (XenoCore › Shop, XenoCore › Trade) | Prices, what may be bought, sold or offered, and the buy and sell actions |
Both screens are pushed onto the menu layer, so the world pauses while they are open. The NPCs
using the Colony 9 tables are placed in Maps/L_XenoCore_Gym; the Kamos Outpost shopkeeper is in
Maps/L_XenoCore_GaurPlain.
Stock loads when the screen opens. Every Item in a shop or trade table (offers and the overtrade bonus) is a soft reference, so a placed shopkeeper does not load its stock, with its weapon meshes and abilities, along with the map. The shop and trade screens load the table's items as they open. See Loading and ticking.
Where gold lives. The party's gold is held by the progression component
(Game/BP_XenoCore_Progression, on the player controller). See Progression.
Lifecycle¶
A shop¶
A shopkeeper talks first. There is no "Shop" verb on the prompt. The NPC's On Interact graph plays its dialogue, then checks Can Shop, and if the NPC has a Shop Table it runs Open Shop with Get Shop Table and the NPC itself:
- The player chooses Buy, Sell or Quit.
- Buy lists the table's items in tabs (equipment split by slot). Choosing one opens a quantity confirm showing the total and the player's gold. The most you can buy is the smallest of: what your gold covers, the room left under the item's Max Carried, and 99.
- Buying takes the gold first, then adds the items. Anything that did not fit is refunded.
- After buying equipment, the shop asks whether to equip it now, on a character you pick.
- Sell lists your bag. Worn copies cannot be sold ("You cannot sell weapons that are in use"). Key items never appear.
- The list stays open after each purchase or sale, with the numbers updated in place.
- Leaving fires Transacted if anything was bought or sold, otherwise Nothing Changed.
A trade¶
A trader is any NPC with Trade Offers set. That adds a Trade verb on X to the prompt. The NPC's graph checks Is Trade Verb and runs Open Trade with Get Trade Offers:
- The player picks what they want from the NPC's list first.
- Then what they give from their own bag. Only Materials and Collectables can be offered.
- The trade clears when the offered item's value is at least the wanted item's price. If it is also at least the price plus the table's bonus value, the NPC throws in the Overtrade Bonus item too, and the screen says so before you confirm.
- One item for one item. The NPC never runs out; a second copy is a second trade.
- Leaving fires Traded if at least one exchange happened, otherwise Cancelled.
Both nodes hide the interaction prompt and the dialogue box while the screen is up and restore them afterwards. Neither closes the conversation: the graph usually has a line to say after.
Prices¶
| Price | Rule |
|---|---|
| Shop buy price | Sell Value × 10, or the row's Price Override |
| Shop sell price | Sell Value × 1, rounded down once |
| Trade value of Materials | Sell Value × 1 |
| Trade value of everything else | Sell Value × 10 |
| A trade row's price | the item's trade value, or the row's Price Override |
| The overtrade threshold | row price + the bonus item's trade value (or its Value Override) |
Sell Value and Max Carried are on the item's XenoCoreFragment_ItemCategory fragment. See Items and inventory.
Materials cannot be bought from a shop, and Key items cannot be sold. The shop table's data validation refuses stocking either.
Rarity does not change any price. Xenoblade 3 makes value independent of rarity. The sort cycle (Y) adds Rarity, which lists the rarest first and then A–Z, beside Most Recent, Name and Value. Names are drawn in their rarity colour; see Set and style item rarity.
Trading at ten times a collectable's sell value is deliberate: it makes items picked up while exploring worth more in barter than in the shop.
The multipliers are fixed
The ×10 buy price, the ×1 and ×10 trade values and the 99-per-purchase limit are fixed in C++. To price one item differently, use Price Override on its row; to make a whole shop dearer or cheaper, a programmer has to change the multiplier.
Settings¶
| Setting | Where it lives | What it does |
|---|---|---|
| Offers › Item | Shop table › XenoCore › Shop | An item the shop sells, in list order |
| Offers › Price Override | Shop table › XenoCore › Shop | Its price. 0 means "use the item's buy price", not free |
| Resolved Price | Shop table (read only) | The price that 0 resolves to, so you can see it |
| Offers › Item, Price Override | Trade table › XenoCore › Trade › Offers | An item the NPC will part with, and its price (0 = its trade value) |
| Resolved Price, Overtrade At | Trade table (read only) | The actual price, and what earns the bonus |
| Overtrade Bonus › Item | Trade table › XenoCore › Trade › Overtrade Bonus | The bonus item. Empty means this NPC never gives one |
| Overtrade Bonus › Value Override | same | Extra value needed on top of the price. 0 = the bonus item's own trade value |
| Shop Table, Trade Offers | Placed NPC › XenoCore › NPC | Which tables this NPC uses |
| Complete Heading | W_XenoCore_TradeScreen › XenoCore › Trade › Completion |
The heading of the banner after a trade |
| Celebrate On Trade | same | Confetti and fanfare after a trade. Off by default |
| Tab Button Class, Row Class, Stat Row Class, Icon Set, icon sizes | Both screens › XenoCore › Merchant | Which widgets and icons the lists use |
| Texts under XenoCore › Shop › Text | W_XenoCore_ShopScreen |
The shop's panel wording |
Set Shop Table and Trade Offers on the placed NPC, never on the Blueprint
Set on B_XenoCore_Npc's class defaults, every NPC in the game becomes a shopkeeper or a
trader, including your quest givers. These are per-instance settings.
Fails silently: an item with no category fragment
An item without a XenoCoreFragment_ItemCategory, or with Sell Value 0, has no price.
In a shop it cannot be bought; in a trade table it is priced 0 and trades for anything.
Right-click your tables in the Content Browser and choose Asset Actions › Validate Assets:
both report such rows as errors.
Price Override 0 means derive, never free
There is no way to give an item away through a shop or a trade. A gift belongs in a quest reward.
Extending it¶
- A new shop or trader: duplicate the sample table into
Content/MyGame/, change its rows, and set it on a placed NPC. See Open a shop and Set up a trade. - Different wording after a shop or trade: add Show Dialogue nodes on the node's output pins in the NPC's graph.
- Stock that changes over time is a different table swapped in by your own logic (for example on quest state, through Get Party Quests). Tables have no stock count or conditions.
- Skill bonuses to prices and a third screen of this kind (a crafting bench, say) need a programmer; see the note below.
Never edit the sample tables in place if you want to keep them as reference; they are overwritten by template updates.
For programmers: classes and extension points
Tables are UXenoCoreShopTable and UXenoCoreTradeTable; the nodes are the latent actions
UXenoCoreOpenShop and UXenoCoreOpenTrade; the screens derive from
UXenoCoreShopScreenBase / UXenoCoreTradeScreenBase, both on UXenoCoreMerchantScreenBase,
with rows on UXenoCoreTradeRowBase. Prices are in UXenoCoreShopStatics and
UXenoCoreTradeStatics (BuyMultiplier, MaterialMultiplier, StandardMultiplier,
MaxPerTransaction). GetSellPriceMultiplier and GetOfferValueMultiplier are the single
place a skill bonus would go; both return 1.0 today. A third merchant-style screen derives from
UXenoCoreMerchantScreenBase, which supplies the Menu input mode, back handling, the finish
callback, rows, tabs, focus restore and the details card.
Why it's built this way¶
For programmers
- One base for the shared mechanics. The trade screen came first; the shop is the second screen of the kind, which is the point at which the shared parts moved into a base. Neither child duplicates the focus, tab and pooling fixes.
- One number per item. Baking a multiplier into the item would be wrong for the other two consumers, so the item carries Sell Value and each system applies its own rule.
- One resolver per price. Rows, the confirm total and the actual transaction all read the same
GetPrice, so nothing can be shown at one price and charged at another. The read-only Resolved Price fields in the editor are a display of that same function. - Every bag change goes through
UXenoCoreInventoryStatics, and every gold change through the progression component, so the change messages fire and open screens stay current. See Events you can listen to. -
The finish pin always fires. The NPC graph is suspended on the node. If the screen were torn down without answering, the conversation could never finish, so the answer is delivered when the screen deactivates, however that happens.
-
CommonUI reuses screens. CommonUI's layer pools activatable widgets, so the same shop or trade screen instance is shown again on the next visit. Anything that must be fresh per visit is reset in
BeginShowing, which a child's show function must call first. A latch set once at construction survives into the next visit and, for example, stops the finish callback from ever firing a second time.
Next: Save and front end · Quests