Create a new item.
The following sections will show you how to create a new item and then add it to the shop. For this tutorial will be using the Ultimate RPG Pack.
We really recommend Quaternius assets as a source of CC0 licensed models. Download the model and import the OBJ and Icons folder to the project.
A brief explanation of what an item can provide:
Stats modification: When equipped on a character, the character's stats increase or decrease depending on the item's modifier.
On-hit effect: The character applies an effect when hitting an enemy. This can be in the form of a buff, apply a debuff to the enemy, apply extra damage.
Attack effect: In addition to the effect that all characters have, it applies another additional effect. For example, if a Ranger performs the animation of throwing an arrow, he can also apply the Wizard's effect, which makes him throw a fireball at the enemy.
We will create an item that includes all three types of modification. This will increase magic damage (Stat modification), poison enemies when the equipped character does damage (On-hit effect) and gain an attack speed buff when attacking (Attack effect).
Add the item component.
Drag the Skull model from "OB/Skull.obj" to the scene. Drag the Skull model to the scene.
Select the Skull in the scene and click on Add Component and attach the Game Item component to it. Add the GameItem component.
To create a new Stats Modicator, in Item Modifier we create a new Stat Modificator in the list. Then choose the stat we want to modify, the type of modifier and the value. Each stat is briefly described below:
- Health: Life points possessed by the character. When it reaches 0, the character is defeated. A fixed or percentage modifier can be chosen.
- Damage: Physical damage to the character. Applies if some attack effect applies physical damage. A fixed or percentage modifier can be chosen.
- Magic Damage: Magic damage to the character. Applies if some attack effect applies magic damage. A fixed or percentage modifier can be chosen.
- Defense: Physical defense of the character. Reduces physical damage received. A fixed or percentage modifier can be chosen.
- Magic defense: Magic defense of the character. Reduces magic damage received. A fixed or percentage modifier can be chosen.
- Attack speed: Speed of the attack animation. A percentage modifier should be chosen.
- Movement Speed: Movement speed of a character. A fixed or percentage modifier can be chosen.
- Range: Character's attack range. Make sure it is greater than 0. A fixed or percentage modifier can be chosen.
- Critical Probability: Probability of critical damage from basic attacks. A percentage modifier should be chosen.
- Critical Damage: Damage bonus from critical attacks. A percentage modifier should be chosen.
- Energy: Amount of energy needed to activate the special attack. A fixed or percentage modifier can be chosen.
- Energy Recovery Per Attack: Amount of energy generated by each basic attack. A fixed or percentage modifier can be chosen.
Energy Recovery On Hit: Percentage of damage received that is transformed into energy. A percentage modifier should be chosen.
We will create a fixed magic damage Stat Modificator, and set its value to 30. Set a new Stat Modificator of the Magic Damage, fixed and set its value to 30.
To add an Attack Effect to the item, add one to the Attack Effects list. In our case we will add AttackSpeedEffect. Add the AttackSpeedEffect to the Attack Effects list.
To add an On-Hit Effect to the item, add one to the On-Hit Effects list. In our case we will add ApplyFixedDamageOverTimeOnHit. Add the ApplyFixedDamageOverTimeOnHit to the On-Hit Effects list.
Create a new folder in the Project window. Drag the scene witch to the new folder to create a prefab. Make a Skull prefab by dragging it to the Project window.
Right click on the prefab. Select "Auto-Battle Framework/Create Shop Game Item". This will create a Shop Game Item Scriptable Object. Right click and select Create Shop Game Item.
Select the new created Shop Character (WitchShopItem.asset). Select a sprite
- Select a sprite for Item Image (we will use the Skull.png). This image will be displayed when available for purchase in the store.
- In the same way, select another sprite for Description Image (we will select the Skull.png again). This image will be displayed when the character's statistics panel is displayed.
- Add an Item Description if desired.
Select the images used in the shop and item description.
Add the Shop Game Item to the Shop List. Open the "Auto-Battle" object hierarchy and select Shop Manager. Open the "Shop Level Manager/Shop Levels" list and select a list of stores. We will select the one called "Level 1-2-3". Add the skull's store item. Add the item to a shop level.
Remove the skull from the scene and press play. The skull should be purchasable in the store, and be an equippable item. The skull can be purchased at the shop.