Inventory #
The Inventory meta-system in Hiro enables players to collect, upgrade, and consume items in your game. These in-game items can be anything from a piece of equipment like a sword or chestplate, to a cosmetic item like a flag or costume, to a power up like a spawner or boost.
Inventory items can be purchased from the virtual store, or earned through gameplay.
Customization parameters #
The following JSON represents the customization parameters you can use to configure the default user experience for the inventory system.
|
|
The JSON schema defines several objects which define the various items and item sets that will be available in your game. You can configure as few or as many of each as needed for your desired gameplay.
Property | Type | Description |
---|---|---|
items | string:Item | A map of all items. |
limits | ConfigLimits | Any limits to the quantity of items a user can hold from specific Categories or Item Sets. |
Config Limits #
ConfigLimits
can be used to restrict how many items are able to be held at a given time from specified Categories or Item Sets.
In the case that an item is restricted by its Category AND
its Item Set:
- Assume there is an item with category
armor
from the item setshield
that is being granted. - The inventory limits are set to a maximum of 10
armor
and 5shields
. - Even if the user has fewer than 10 pieces of
armor
, they won’t be able to receive the item if they currently have 5shields
.
Property | Type | Description |
---|---|---|
categories | string:int64 | A map of Categories to the maximum quantity of items a user can hold from the specified Category. |
item_sets | string:int64 | A map of Item Sets to the maximum quantity of items a user can hold from the specified Item Set. |
Each individual item is keyed by id and may define the following:
Item #
Property | Type | Description |
---|---|---|
name | string | The name for this item. |
description | string | The description for this item. |
category | string | The category for this item. |
item_sets | []string | An array of values that indicate which item sets this item belongs to. |
max_count | int64 | The maximum number of this item a user can own. |
stackable | bool | Whether this item can stack. |
consumable | bool | Whether this item can be consumed. |
consume_reward | Reward | The rewards that a user can or will receive for consuming the item. |
string_properties | string:string | A map of string values that define item specific metadata. |
numeric_properties | string:float64 | A map of numberic values that define item specific metadata. |
disabled | bool | Used to disable this item without removing it from the data definition. |
keep_zero | bool | Used to make this item stay in a user’s inventory, even when there are none left. Useful for displaying certain items that have been aquired, regardless of whether the user still has any. |
Item Definitions #
Item Categories #
Every item definition has a category
property. This is a simple string
property that defines which broad collection the item belongs to and is useful for listing items. For example, you may wish to separate your items into categories such as weapons
, armor
, and potions
.
Item Sets #
Item definitions can optionally define an array of item_sets
that they belong to. Item sets differ from categories in that an item can belong to multiple sets at once. These item sets can be used as tags for the items in your game such as rare
and sword
.
Item sets are used in the reward system to allow users to be rewarded with a random item that belongs to specific sets (see example below).
Item Rewards #
A powerful feature of the Inventory system is the ability for game designers to add consume rewards to item definitions. When a user consumes the item, they will be granted the reward accordingly. Due to the power and flexibility of the Hiro reward system, this allows game designers the opportunity to create all manner of consumables.
Consider the following scenarios and associated item definitions:
A potion that restores 50 health
|
|
A coin pouch that rewards between 100 and 500 gold coins in multiples of 10
|
|
A loot chest that rewards a sword and a random rare weapon
|
|
A loot chest that rewards a weighted random currency
|
|
Item Instances #
When a user is granted an item, whether from a Store Purchase, as a Reward, or any other means, it is stored as an item instance inside their inventory. The inventory itself is stored inside the Storage Engine under a special collection/key for that user.
A user’s inventory has the following JSON schema.
|
|
The inventory is a map of item instance IDs and the associated item instance data, where each item instance has the following structure.
Property | Type | Description |
---|---|---|
item_id | string | The ID of the item definition this is an instance of. |
owned_time | int64 | The time that this item was acquired. |
update_time | int64 | The time that this item was last updated. |
count | int64 | How many of this item the user currently has. |
string_properties | string:string | A map of string values that define item instance specific metadata. |
numeric_properties | string:float64 | A map of numeric values that define item instance specific metadata. |
Item Properties #
Item instances have their own metadata, stored within the string_properties
and numeric_properties
fields. This allows you to build systems where a user can customize, rank up, or modify the items they own. For example, you may have a weapon rank system that allows your players to “level up” their weapons, or a “gem slot” system that allows players to improve the stats of their items by socketing various gems to them, or perhaps you just want to keep track of how many monsters a user has defeated with a particular weapon as shown in the example above.
string_properties
and numeric_properties
which will be copied across to an item instance when it is retrieved. The values specified in the item definition will always override the value in the item instance. This allows you to update things like stats or XP curves for an item globally across all existing item instances.Item Stacking #
Where an item is granted that is defined as stackable
, the inventory system will first check to see if the user currently has an item instance for that item ID. If they do, the count
property of that particular instance will be increased accordingly. If they don’t, or if the item is not stackable
, a new item instance will be generated instead and added to the user’s inventory.