Steamworks документация
Steam Inventory Item Accessories
Item accessories provide a way for players to customize their in-game items, and to create more valuable, interesting, and even unique versions of common items used in your game.

Attached accessories will be visible in the Inventory view on the community, and will create "Unique" (non-commodity) item listings when they are offered on the Steam Community Market.

It's up to you to decide what accessory types to support, and what cosmetic or gameplay effects different accessory types might have. You may also choose to support different types of accessories on different item types in your game.

backpackcomic_resize30.png

As a concrete example, we'll look at defining a familiar type of accessory item - stickers.

Unique_backpack.png

In this example, the "Unique" prefix is automatically added.

Marking an item as customizable

Players can only attach accessories to items that you have expressly configured for that type of accessory. To mark an item as being customizable, update the ItemDef with the property "accessory_tag" whose value is a per-item tag category token.

Пример:
"accessory_tag": "sticker",

For this ItemDef, a per-item tag whose category is "sticker" will be treated as an attached accessory. The value of the per-item tag will be the ItemDefID of the accessory item.

Recall that per-item tags persist for the life of an item, including through ownership changes.

One item can have multiple accessories attached, as in the example shown above. You can limit the number of accessories on a single item with the property "accessory_limit":

"accessory_limit": 3,

Ограничението по подразбиране е 4. Larger limits are not recommended.

In-game, if an item is customizable, you can find the attached accessories by examining the per-item tags (call the SDK method ISteamInventory::GetResultItemProperty() with the property name "tags").

Defining an accessory

Because each accessory is actually an ItemDef, you can use existing tools to define the appearance of the accessory - including most importantly the icon_url property and localized names.

The generated description of customized items will use the information from the ItemDef. If you change the ItemDef, accessories already in user inventories will be updated as well.

A simple sticker definition:
{ "appid": 480, "name": "Blue Star", "description": "A blue star sticker with mysterious powers", "icon_url": ...

Creating single-use accessories

Any method that adds per-item tags can be used to attach accessories. The most interesting case is defining a consumable accessory that players can earn or buy, trade, and then use.

This functionality is provided by the "tag_tool" item type. The tag_tool is consumed in order to modify a target item.

First, to enable the tag tool, we need to enable the accessory tag on the customizable item (in our example, this is the backpack):
{ "appid": 480, "itemdefid": 2000, "type": "item", "name": "Everyday backpack", "description": "A good place to keep things, with lots of room for stickers.", "icon_url":..., "accessory_tag": "sticker", "accessory_limit": 3, "allowed_tags_from_tools": "sticker" }

Each sticker type is created with the "type" set to a "tag_tool". The action of the tag tool will be to apply the accessory tag, with the itemdef of this sticker as the argument. So our sticker ItemDef will look like this:
{ "appid": 480, "itemdefid": 1001, "name": "Blue Star", "description": "A blue star sticker with mysterious powers", "price_category": "1;VLV25", "icon_url"..., "type": "tag_tool", "tags": "sticker:1001", }

Note that the "tags" value will apply the ItemDef ID of this sticker to the target item.

Also note that accessory items support all the normal Inventory actions and drop methods - including defining price categories and selling them on the Item Store.

Using accessories

To actually apply the sticker to an item, call the ExchangeItems (crafting) method from the Steamworks SDK (or via the WebAPI from a trusted server). Pass the sticker and the customizable item as materials, and set the target ItemDef type to match the original customizable item. This will apply the tag_tool and update the target.

If the request is valid, the ExchangeItems call will atomically consume the sticker and update the tags on the target item.

Per-item tags can also be set other ways, including by item generators - see the Item Tag page.

Localization and appearance

Accessories are automatically rendered in the web view including the users' backpack and the Community Market. The description block will include a small version of the icon for each attached accessory, and list the localized names of each accessory.

As usual, item names are localized by providing values in the ItemDef Schema.

See the "Item Tags" section on the Steam Inventory Service page to provide localized text for the internal name. In our example, the internal name "sticker" is simply mapped to "Sticker" in all supported languages.

You can also specify special text that will be displayed before the aforementioned special description block. Simply provide a accessory_description_<language> API language code property on your item description; in combination with dynamic properties, you can set tokens that will be replaced with dynamic property values.

Пример:


If the item instance (that has the "sticker" accessory attached) has the dynamic property num_times_stickered set to 123, then specifying this on the sticker item definition:

{ "accessory_description_english": "Stickers applied %num_times_stickered% times" }

will output the following text in the web view.

Stickers applied 123 times

Removing or replacing accessories

Once consumed, an accessory item can't be restored by removing it from the customized item. Accessories can of course be removed - see the per-item tags documentation for methods to remove tags from an item.

For user customization, you may choose to offer a tag_tool whose only purpose is to remove existing accessories.

Adding two instances of the same accessory to an item is not currently supported. Attempting to do so will fail in the ExchangeItems call and will not consume the accessory item.