Stat Profile
Scripting with the StatProfile class.
The StatProfile
class can be used to provide stats to any object. This is used by all of Inventool's items.
Fields & Properties
target
The target object.
object
public
level
The current level. Use LevelUp, LevelDown, or SetLevel to change this value.
int
public
maxLevel
The max level.
int
public
weight
The amount the target weighs.
float
public
experience
The experience points. Use AddExp or RemoveExp to manage this value.
ScalingValue
public
durability
The durability points. Use AddDurability or ReduceDurability to manage this value.
ScalingValue
public
stats
A list of all stats in this profile.
List<Stat>
public
IsMaxed
If the level is maxed.
bool
public
Creating a Stat Profile
var myStatProfile = new StatProfile();
Managing Stats
Adding/Removing Stats
To add or remove a stat, simply use the Add
or Remove
methods of the stats
field.
myStatProfile.stats.Add(myStat);
myStatProfile.stats.Remove(myStat);
Getting Stats
You can get a specific stat in the profile with the stat's ID, name or abbreviation.
var hpStat = myStatProfile.GetStat("HP");
Merging Stats
You can merge a list of stats with the MergeStats
method. Stat merging is the process of permanently adding a stat's value to another of the same identity. If the stat cannot be merged with any existing stat in the profile, it will be added as a new stat instead.
myStatProfile.MergeStats(stat1, stat2); //stat3, etc...
Combining/Uncombining Stats
Stat combining is the process of temporarily adding a stat's value to another of the same identity.
Combining
You can combine a list of stats with the CombineStats
method. Only similar stats can be combined with each other. Stats that aren't identical to any stat in the profile will be ignored.
myStatProfile.CombineStats(stat1, stat2); //stat3, etc..
Uncombining
Use the UncombineStats
method to have the opposite effect.
myStatProfile.UncombineStats(stat1, stat2); //stat3, etc..
Managing Levels
When setting the level of a StatProfile
, the methods below should be used as they will update all stats in the profile.
Set the Level
To set the max value, use the SetMaxLevel
method.
myStatProfile.SetMaxLevel(100);
The SetLevel
will set the current level to a specific value.
myStatProfile.SetLevel(1);
Level Up
The LevelUp
method increases the level by 1.
myStatProfile.LevelUp();
Level Down
The LevelDown
method decreases the level by 1.
myStatProfile.LevelDown();
Manage Experience
Add Exp
The AddExp
method adds experience points. This will result in a level up if the high value reached.
myStatProfile.AddExp(100);
Remove Exp
The RemoveExp
method removes experience points. This will result in a level down if the value goes below zero.
myStatProfile.RemoveExp(100);
Manage Durability
Increase Durability
The IncreaseDurability
method increases the durability. The durability cannot go over the high value.
myStatProfile.IncreaseDurability(100);
Remove Exp
The ReduceDurability
method reduces the durability. The durability cannot go below the low value.
myStatProfile.ReduceDurability(100);
Text Interpolation
You can use the GetInterpolatedText
method to convert a string with stat text tags to correctly display the stats from a stat profile (e.g. "Character has {stat1_value} {stat1_abbr}" becomes "Character has 100 HP").
string original = "Character has {stat1_value} {stat_abbr}.";
string interpolatedText = myStatProfile.GetInterpolatedText(original);
Supported Stat Text Tags
{stat0_value}
The value of the stat at the current level without any changes.
{stat0_name}
The name of the stat.
{stat0_abbr}
The abbreviated name of the stat.
{stat0_lvl}
The current level of the stat.
{stat0_mlvl}
The max level of the stat.
{stat0_curr}
The current value of the stat.
{stat0_next}
The value of the stat at the next level.
{stat0_max}
The max value of the stat at the current level.
{stat0_maxed}
The max value of the stat at the max level.
{stat0_scaling}
The scaling of the stat. Note: this will not work correctly when stat scaling is set to Curve.
{stat0_init}
The initial value of the stat.
Last updated