In this tutorial we’ll add items and a currency to the game.
Items can do the same things abilites can, but are (usually) consumables that are removed from the inventory upon use. You can also create non-consumable and even non-useable items, e.g. for quests or crafting recipes, or to progress in your game. Learn more about items in this documentation.
Currency can be used to purchase things in shops, to pay for status upgrades (e.g. via research trees) and more. Learn more about currencies in this documentation.
We’ll set up multiple inventory-related things:
- inventory settings
- item types
- currency
- 5 items (potions)
- loot
- start inventory
Let’s get to it!
Inventory Settings #
Navigate to Inventory > Inventory Settings, we’ll check how the inventory system is set up. You can learn more about the inventory system in this documentation.
We’ll use the group inventory (i.e. all combatants in a group share the inventory), auto stack items and equipment and not use any kind of quantity or stack size limit – so, we’ll stick with the default setup of a new project.
- Inventory Type
Select Group. - Item Stack Type
Select Auto Stack.
Items will automatically stack when added to the inventory. - Equipment Stack Type
Select Auto Stack.
Equipment will automatically stack when added to the inventory. - Limit Quantity
Disable this setting. - Limit Stack
Disable this setting.
There’s a lot more settings available to control inventory related things, but we don’t really need to change anything for now. We’ll later revisit this, e.g. to set up item collection dialogues.
Item Types #
Next, we’ll set up item types.
Navigate to Inventory > Item Types, we’ll change the Default type and add two new item types.
0: Potions #
All potions will be part of this item type.
Content Information #
- Name
Set to: Potions
Item Type Settings #
- Damage Type
Select Default.
The damage type manages which animations will be used on targets to animate damage, evade, etc.
The default damage type is already set up to use the default animation types added for these.
1: Equipment #
Copy the Potions item type and change the following settings.
Content Information #
- Name
Set to: Equipment
2: Valueables #
Copy the Potions item type and change the following settings.
Content Information #
- Name
Set to: Valueables
Currencies #
Next, we’ll set up the currency for our game. You can add multiple currencies, but we’ll just use one. You can learn more about currencies in this documentation.
Navigate to Inventory > Currencies and select the Default currency.
Content Information #
- Name
Set to: Gold - Sprite (Icon)
Select icons_116.
Click on the Find TMP Tag button to get the icon’s tag for displaying it in texts (via text codes). This uses TextMesh Pro’s sprite asset setup.
Base Settings #
- Item Type
Select Valueables.
Potion #
Our first item will be a potion to restore some HP.
Navigate to Inventory > Items, we’ll change the Default item.
Content Information #
- Name
Set to: Potion - Description
Set to: Restores 100 HP - Sprite (Icon)
Select icons_164.
Click on the Find TMP Tag button to get the icon’s tag for displaying it in texts (via text codes). This uses TextMesh Pro’s sprite asset setup.
Item Settings #
- Item Type
Select Potions.
Price Settings #
You can set a price to purchase the potion in shops here.
We don’t add a shop in this tutorial series, though.
Use Settings #
- Useable In
Select Both.
Target Selection Settings #
We’ll use the Ally Single default target selection.
- Target Selection Type
Select Default Ally > Ally Single.
User Settings > Use Cost #
- Consume
Enable this setting. - Auto Consume
Select On Selection.
This’ll automatically remove the item from the user’s inventory when selecting a target (i.e. when the action was registered with the system)
You can also use other options, e.g. consuming it when the outcome is calculated (select No for that).
Target Settings > Target Changes #
Click on Add Target Change.
Click on Add Status Change.
- Change Type
Select Status Value. - Status Value
Select HP. - Operator
Select Add. - Change Value
Select Value > Value.
Select 100.
Battle Animation #
We’ll use the Use schematic and replace the prefab.
Click on Add Battle Animation.
- Schematic Asset
Select the Use schematic.
Resource Overrides #
Click on Add Prefab Override.
- Auto Destroy After Time
Enable this setting. - Time
Set to 0.55. - Prefab
Select the SmokeGreen prefab.
You can find it in Assets/Tutorial Assets/Prefabs/Effects/.
High Potion #
The high potion does the same as the potion – it just heals more HP.
Copy the Potion item and change the following settings.
Content Information #
- Name
Set to: High Potion - Description
Set to: Restores 500 HP - Sprite (Icon)
Select icons_167.
Click on the Find TMP Tag button to get the icon’s tag for displaying it in texts (via text codes). This uses TextMesh Pro’s sprite asset setup.
Target Settings > Target Changes > Target Change 0 > Status Change 0 #
- Change Value
Select Value > Value.
Set the value to 500.
Magic Potion #
The magic potion restores MP instead of healing HP.
Copy the High Potion item and change the following settings.
Content Information #
- Name
Set to: Magic Potion - Description
Set to: Restores 50 MP - Sprite (Icon)
Select icons_155.
Click on the Find TMP Tag button to get the icon’s tag for displaying it in texts (via text codes). This uses TextMesh Pro’s sprite asset setup.
Target Settings > Target Changes > Target Change 0 > Status Change 0 #
- Status Value
Select MP. - Change Value
Select Value > Value.
Set the value to 50.
Battle Animation > Battle Animation 0 > Resource Overrides #
We’ll change the prefab.
- Prefab
Select the SmokeBlue prefab.
Revive Potion #
The revive potion revives the target and restores a 50 HP.
Copy the Potion item and change the following settings.
Content Information #
- Name
Set to: Revive Potion - Description
Set to: Revives the target with 50 HP - Sprite (Icon)
Select icons_173.
Click on the Find TMP Tag button to get the icon’s tag for displaying it in texts (via text codes). This uses TextMesh Pro’s sprite asset setup.
Use Settings #
- Revive Target
Enable this setting.
Target Selection Settings #
We need to be able to target dead combatants – let’s limit the use on dead combatants.
We’ll set up a Custom target selection, but you can also set up a new target selection template (or later create a template out of the custom setup).
- Target Selection Type
Select Custom. - Target Type
Select Ally. - Target Range
Select Single. - Is Dead
Select Yes.
If you select Ignore you can also target alive combatants.
Target Settings > Target Changes > Target Change 0 > Status Change 0 #
- Change Value
Select Value > Value.
Set the value to 50.
Battle Animation #
We’ll add the revive schematic.
Click on Add Battle Animation.
- Schematic Asset
Select the PlayerRevive schematic.
Cure Potion #
The cure potion will remove all negative status effects.
Copy the Potion item and change the following settings.
Content Information #
- Name
Set to: Cure Potion - Description
Set to: Removes all negative effects - Sprite (Icon)
Select icons_185.
Click on the Find TMP Tag button to get the icon’s tag for displaying it in texts (via text codes). This uses TextMesh Pro’s sprite asset setup.
Target Settings > Target Changes > Target Change 0 > Status Change 0 #
Instead of changing a status value, we’ll change status effects.
- Change Type
Select Status Effect. - Change
Select Remove. - Use Effect Type
Enable this setting.
We’ll remove based on the status effect type. - Status Effect Type
Select Negative. - Remove Type
Select All.
Battle Animation > Battle Animation 0 > Resource Overrides #
We don’t replace the prefab, using the schematic’s original (Smoke) effect.
Remove Prefab Override 0.
Loot #
Loot allows setting up different loot tables, optionally based on level checks or other conditions, e.g. an enemy can drop a regular Potion for level 1 to 25 and a High Potion for level 26 to 50. Learn more about loot in this documentation.
We’ll set up 2 loot tables for our enemies to give gold and potions as battle spoils, without any level checks or other conditions.
Navigate to Combatants > Loot, we’ll change the Default loot and add another new loot.
Gold #
We’ll give a random amount of gold between 1 and 20.
- Name
Set to: Gold
Loot Table 0 #
Click on Add Loot Table.
Click on Add Item in the Loot Settings.
- Type
Select Currency. - Currency
Select Gold. - Quantity
Select Value > Random.
Set the 1st value to 1.
Set the 2nd value to 20.
Potion #
Add a new Loot setup.
- Name
Set to: Random Potion
Loot Table 0 #
Click on Add Loot Table.
We’ll add multiple potions and randomly get one in the Loot Settings.
- Get Random
Enable this setting.
We’ll get one of the defined items randomly – the individual item’s chance check is still used.
Click on Add Item.
- Type
Select Item. - Item
Select Potion. - Quantity
Select Value > Value.
Set the value to 1. - Chance
Select Value > Value.
Set the value to 75.
Copy the Potion item.
- Item
Select Magic Potion. - Chance
Set the value to 40.
Copy the Magic Potion item.
- Item
Select Cure Potion. - Chance
Set the value to 30.
Copy the Cure Potion item.
- Item
Select High Potion. - Chance
Set the value to 20.
Copy the High Potion item.
- Item
Select Revive Potion. - Chance
Set the value to 10.
Combatants General Settings #
We’ll add the loot as default loot for all combatants.
Navigate to Combatants > Combatants > General Settings.
Inventory & Equipment > Default Loot Settings #
We’ll use both Gold and Random Potion as loot.
- Loot Origin
Select Loot.
Click on Add Loot.
- Loot
Select Gold.
Click on Add Loot again.
- Loot
Select Random Potion.
Player Start Inventory #
We’ll add some items to the start inventory of our player combatant.
Navigate to Combatants > Combatants and select the Fighter combatant.
Inventory & Equipment > Start Inventory #
Click on Add Item.
- Type
Select Currency. - Currency
Select Gold. - Quantity
Select Value > Value.
Set the value to 50.
Click on Add Item.
- Type
Select Item. - Item
Select Potion. - Quantity
Select Value > Value.
Set the value to 5.
Copy the Potion item.
- Item
Select Magic Potion. - Quantity
Set the value to 3.
Copy the Magic Potion item.
- Item
Select Cure Potion.
Copy the Cure Potion item.
- Item
Select High Potion. - Quantity
Set the value to 1.
Copy the High Potion item.
- Item
Select Revive Potion.
Save Changes #
And that’s it for now!
Save the changes using the Save Settings button at the bottom of the editor.
Testing #
Hit play and start a battle.
You now have items available and can use them in battle.
And we get loot from killed enemies.
Next, we’ll add equipment.