Create a new trait
The following sections will show you how to create a new trait and then attach it to a character.
A brief explanation of what a trait can provide:
Stats modification: When several characters with the same trait are on the battlefield, the character's stats increase or decrease depending on the item's modifier.
On-hit effect: When several characters with the same trait are on the battlefield, the character's attacks apply an effect when hitting an enemy. This can be in the form of a buff, apply a debuff to the enemy or apply extra damage.
Attack effect: When several characters with the same trait are on the battlefield, in addition to the effect that all characters have, it applies another additional effect.
We will create a new Witch Trait that will increase magic damage and get a health stealing effect when the character does damage (On-hit effect). A Trait Option is a set of bonuses that characters gain depending on the number of characters in battle that shares the trait. We will create two Trait Options, one will need a witch to activate and only the effects will be applied on her, another will need 3 witches to activate, but all the team members will gain the bonuses.
Right click on a project folder and click on "Create/Auto-Battle Framework/Traits/Trait". This will create a new Trait Scriptable Object. Creation of a new Trait Scriptable Object
Select the newly created feature and fill in the following fields.
- Trait Name: The name of the trait. Enter "Witch".
- Trait Image: The sprite of the trait. Select "glare-star".
- Trait Description: The description of the trait. Enter "Witches gain magic damage and steal life from their enemies.". Complete trait basic information.
To create a new Trait Option, create it in the Trait Options list, the fields required to complete a Trait Option are as follows.:
- Number of Traits: Necessary number of characters with this trait for this Trait Option to be activated. It is necessary that the Trait Options are always ordered in ascending order in the list according to this number.
- Modificator: Here are the modifications that will be applied to the character once this option is activated.
- 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. The description and requirements of the stats are the same as when creating an item.
- To add an Attack Effect to the item, add one to the Attack Effects list.
To add an On-Hit Effect to the item, add one to the On-Hit Effects list.
For our example:
Create a first Trait Option, with a Number of Traits with value 1.
That increases magic damage by 20.
Add HealthSteal to the list of On-Hit Effects.
As Option Description enter "Gain 20 Magic damage and steals Health".
Select any color for the Trait Option. To follow the package color style, choose FFA858 (hexadecimal). Make sure that alpha is 255.
Leave the Target as Character With Trait.Then, add a second one, but with a Number of Traits with value 3.
That increases magic damage by 50.
Make sure HealthSteal is still in the On-Hit Effects list.
As Option Description enter "All Team members gain 50 Magic damage and steals Health".
Select any color for the Trait Option. To follow the package color style, choose D2D2D2 (hexadecimal). Make sure that alpha is 255.
Set the Target to All Characters.
Adding the Trait Options to the trait.
Select the Witch character created in create a new character, and add the new created Trait in her Game Character Inspector. Add the AttackSpeedEffect to the Attack Effects list.
Select the Auto-Battle GameObject in the scene, and add the newly created Witch Trait to the Traits to Check Team 1 in the Battle Inspector. Add the trait to the Traits To Check list.
Test the game and make sure that the witch has the Witch Trait, and that its effects and descriptions are applied correctly. The Witch now has the Witch Trait.