Skip to content

custom merchant stock โ€‹

You can define a custom merchant stock using tag addStock and a stock file.

img

Trait Change

CWL 1.19.21 has removed the Merchant trait requirement for adding custom stocks, this is mainly an API change. If you are not using CWL API, you should still give your chara a Merchant or MerchantXXX trait so you can trade with them.

The stock file is a simple JSON file placed in your LangMod/**/Data/ folder, with the name stock_ID.json. The ID is the unique identifier for this stock file or character. For example: stock_my_cnpc.json or stock_unique_armor.json.

When using the addStock tag, the stock ID will default to the character ID. You may also specify and/or combine multiple stock files using multiple tags, such as: addStock,addStock_unique_items,addStock_unique_armor.

Within the stock file, the structure is as follows:

json
{
  "Items": [
    {
      "Id": "example_item",
      "Material": "",
      "Num": 1,
      "Restock": true,
      "Type": "Item",
      "Rarity": "Random",
      "Identified": true
    },
    {
      "Id": "example_item_limited",
      "Material": "granite",
      "Num": 1,
      "Restock": false,
      "Type": "Item",
      "Rarity": "Artifact",
      "Identified": true
    },
    {
      "Id": "example_item_craftable",
      "Material": "",
      "Num": 1,
      "Restock": false,
      "Type": "Recipe",
      "Rarity": "Random",
      "Identified": true
    },
    {
      "Id": "SpShutterHex",
      "Num": 5,
      "Type": "Spell"
    }
  ]
}

Items is an array of items in the stock.

Fields โ€‹

  • Id The ID of the item (Thing). This field is required. For some stock types, this can be an alias of an element or a numeric ID, or a name.
  • Material The material the item is made of. Leave it blank to use the default material defined in the Thing data. Default value: ""
  • Num The number of items. Default value: 1
  • Restock Determines whether the item restocks. Set to false for limited items that can only be purchased once. Default value: true
  • Rarity Possible values: Random, Crude, Normal, Superior, Legendary, Mythical, Artifact Default value: Normal
  • Identified (deprecated, still accepted) Determines the initial identification state of the item. Default value: true
  • IdentifyLevel (new) Determines the initial identification state of the item. Possible values: Identified, RequireSuperiorIdentify, KnowQuality, Unknown Default value: Identified
  • Blessed Determines the blessed state of the item. Possible values: Doomed, Cursed, Normal, Blessed Default value: Normal

Notes โ€‹

  • You can omit any fields to use their default values. For example, this is a valid stock item:
json
{
  "Id": "example_item"
}

Available Types โ€‹

TypeDescription
ItemA standard item. Supports material, level, and stack count.
BlockA placeable block item created from a block alias and material.
CassetteA music cassette. If the bgm id is invalid, a random track will be used.
CurrencyCurrency item. Id can be money money2 plat medal influence casino_coin ecopo. Num defines the amount.
CategoryGenerates an item from a category.
FilterGenerates an item based on a filter. Id is the name of the filter.
TagGenerates an item based on a tag. Id is the name of the tag.
LetterA letter item. Id is the name of the letter.
ObjAn Obj. Id is the object alias.
PerfumeA perfume. Id is the element alias or id.
PlanA plan. Id is the element alias or id.
PotionA potion item. Id is the element alias or id. Num defines stack size.
RecipeA recipe item for crafting.
RedBookA red book item. Id is the book id. Num defines stack size.
RodA rod item. Id is the element alias or id. Num defines charges or stack size.
RuneA rune item. Id is the element alias or id.
RuneFreeA rune_free item. Id is the element alias or id.
ScrollA scroll item. Id is the element alias or id.
SkillA skill book. Id is the element alias or id.
SpellA spell book. Id is the element alias or id.
UsuihonA special item. Id is the religion id.

If you are not using a code editor, you can use JSONLint to validate your JSON.

For API related usages, see Custom Merchant API.

Spec Change

  • CWL 1.22.14 added ItentifyLevel entry, to allow customized identify level. This change is optional and backwards compatible.
  • CWL 1.19.21 added Identified entry, to allow unidentified items to be sold. This change is backwards compatible.
  • CWL 1.18.13 removed Owner entry and added Rarity entry, to allow stock ID based indexing instead of chara ID. This change is backwards compatible.

This project is an unofficial documentation site and is not affiliated with, endorsed by, or associated with Elin or Lafrontier / Noa. All trademarks are the property of their respective owners.