Stat
Scripting with the Stat class.
The Stat
class is the main class you'll be using when scripting with the stats system. The advantage of this class is that it allows you to easily create stats of a specific type using Stat Identity, while also assigning strengths and weaknesses with Attribute.
Fields & Properties
initialValue
The starting value of the stat.
StatValue
public
currentValue
The current value of the stat.
StatValue
public
scaling
The amount this stat will scale each level.
StatValue
public
excessValue
The last calculated excess value.
StatValue
protected
externalValue
The amount gained/lost from external stats added together.
StatValue
public
externalStats
A list of stats buffing or debuffing this stat.
List<Stat>
public
level
The current level of this stat.
int
public
maxLevel
The max level of this stat.
int
public
combineType
The combine type used for mathematical operations.
CombineType
public
combineOperator
The combine operator used for mathematical operations.
CombineOperator
public
attribute
The attribute of this stat.
Attribute
public
statID
The ID of the stat identity.
int
public
identity
The stat identity. Use Identity or SetIdentity instead.
StatIdentity
public
BaseValue
The base value of the stat at the current level.
StatValue
public
MaxValue
The max value of the stat.
StatValue
public
NextBaseValue
The value of the stat if leveled up.
StatValue
public
MaxBaseValue
The max value of the stat if it reaches the max level.
StatValue
public
IsMaxed
If this stat is maxed.
bool
public
Identity
The stat identity.
StatIdentity
public
Combine Type
Supported stat combine types.
Value
When combined with another stat, the stat's value will be treated as is.
PercentMax
When combined with another stat, the stat's value will be treated as a percentage of the other stat's max value.
PercentCurrent
When combined with another stat, the stat's value will be treated as a percentage of the other stat's current value.
Combine Operator
Supported stat combine operators.
Add
Add the value to the other stat.
Subtract
Subtract the value from the other stat.
Creating a Stat
A Stat requires a StatIdentity
. Stats can have an Attribute
but they are optional.
The Stat
class has many constructors you can use, however, the one used in the example below is the easiest and most common one. In the example, an HP stat with the Fire attribute is being created with the initial and current values of 100.
Merging
Use the TryMerge
method to permanently increase the value of a stat based on the value of a given stat. This method will return true or false, depending on whether the merge was successful. Merging may fail if the stats were not identical—only identical stats can be merged.
Combining/Uncombining
Combining a stat with another temporarily increases its value based on the value of a given stat until the other stat is uncombined.
Combine
Use the Combine
method to combine a stat with another. Combining may fail if the StatIdentity
and Attribute
of the stats are not the same.
Uncombine
Use the Uncombine
method to uncombine a combined stat.
Arithmetic
Methods
You can use the Add
, Subtract
, Multiply
, and Divide
to perform mathematically operations on stats. You will need to provide another Stat
, a StatValue
, float
, or int
as a parameter.
When using arithmetic methods on 2 stats, you will have the option to apply the attribute effectiveness with the second bool parameter.
Operators
Similar to the methods, stats support arithmetic operators. Attribute effectiveness will automatically apply when possible.
Managing Levels
Setting the Level
Increasing the Level
Use the TryUpgrade
method to increase the level by a given amount. This method returns true or false, depending on if the level was actually increased. The level cannot go over the max level.
Decreasing the Level
Use the TryDowngrade
method to decrease the level by a given amount. This method returns true or false, depending on if the level was actually lowered. The level cannot go lower than 0.
Optionally, you can use the Deplete
method to set the level to 0.
Resetting Values
Reset Values
The ResetValues
method resets the current and external values.
Reset Completely
The Reset
method resets a stat completely.
Comparison
Is Similar
The IsSimilar
method checks if a stat is similar to another.
Similarity Types
Nothing
No similarity requirement.
IdentityAndAttribute
If the StatIdentity and Attribute are identical.
Everything
If the StatIdentity, Attribute, CombineType, and CombineOperator are identical.
Name Matches
Use the NameMatches
method to check if a string matches either the name or abbreviation of a stat.
Last updated