Skip to content

Merchants & Economy

Merchants are NPCs with the merchant trait, allowing players to buy and sell items. The merchant system supports per-item pricing, stock limits, and automatic restock.

Add the merchantTrait to any NPC:

{
"name": "Bramwick",
"description": "A stout merchant with a calculating smile and ink-stained fingers.",
"merchantTrait": {
"inventory": [
{
"templateId": "ITM0012",
"name": "Weak Health Potion",
"stock": 10,
"maxStock": 10,
"price": 8,
"restockTime": 3600
},
{
"templateId": "ITM0001",
"name": "Dusty Torch",
"stock": 20,
"maxStock": 20,
"price": 2,
"restockTime": 1800
}
]
}
}
FieldDescription
templateIdItem template ID to sell
nameDisplay name in the shop listing
stockCurrent stock count
maxStockMaximum stock (for restock)
priceBuy price in gold
restockTimeSeconds until stock is replenished
talk [merchant] — Start conversation (shows merchant option)
list — Show merchant's inventory with prices
buy [item] — Buy an item from the merchant
sell [item] — Sell an item to the merchant
value [item] — Check how much the merchant will pay

The buy price is set per-item in the merchant inventory.

The sell price (what the merchant pays) is typically a percentage of item.basePrice. The exact sell multiplier is configured server-side.

Stock replenishes automatically after restockTime seconds since the last purchase depleted the stock. maxStock is the stock level restocked to.

A restockTime of 0 means infinite stock (useful for basic supplies like potions).

TalesMUD uses a gold-based economy. Characters have a gold field tracking their currency.

Example currency items:

  • ITM0006 — Copper Bits (stackable, max 999)
  • ITM0015 — Silver Mark (stackable, max 999)

These are collectible items used as currency drops, separate from the character’s gold balance.