Getting & Setting Stats
Learn how to make changes to stats.
Remember to use Esper.SkillTree.Stats
namespace when scripting with stats.
Access the Stats
You can access stats by getting the UnitStatsProvider
component of a GameObject
.
Here's how you can get a stat called 'HP':
You can get a stat by both its full name and abbreviation. The GetStat
method returns an UpgradableStat
.
Reading Stat Values
There are a few key values of an UpgradableStat
to take note of.
Name | Description |
---|---|
baseValue | The base value of the stat. Automatically updated when the stat level is changed. |
currentValue | The current value of the stat. Requires manual updates. |
currentMaxValue | The max value that the current value can go up to. Automatically updated when the stat level is changed. |
The current and current max values can be used to keep track of the unit's stat changes. For the HP example, the currentValue
would be the unit's current HP, which should decrease as the unit gets damaged. The currentMaxValue
would be the unit's HP without any damage taken.
Setting Stat Values
Updating Base and Current Max Values
These values can be changed by Upgrading Stats.
Updating Current Value
The current value should be updated manually as required by your game. You can set the current value in multiple ways.
From UnitStatsProvider
From UpgradableStat
Last updated