Merchants & Economy
Merchants & Economy
Section titled “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.
Creating a Merchant
Section titled “Creating a Merchant”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 } ] }}Merchant Inventory Fields
Section titled “Merchant Inventory Fields”| Field | Description |
|---|---|
templateId | Item template ID to sell |
name | Display name in the shop listing |
stock | Current stock count |
maxStock | Maximum stock (for restock) |
price | Buy price in gold |
restockTime | Seconds until stock is replenished |
Player Commands
Section titled “Player Commands”talk [merchant] — Start conversation (shows merchant option)list — Show merchant's inventory with pricesbuy [item] — Buy an item from the merchantsell [item] — Sell an item to the merchantvalue [item] — Check how much the merchant will payPricing
Section titled “Pricing”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.
Restock
Section titled “Restock”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).
Currency
Section titled “Currency”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.
Next Steps
Section titled “Next Steps”- NPCs & Spawners — Creating NPC templates
- Items & Equipment — Item template creation