Inventool Documentation
  • Inventool Documentation
  • 🕹️Quick Start
    • Installation
    • Start Creating
  • 💡General
    • Running the Demo
    • Menu Options
    • UI Updates
    • UI Customizations
      • uGUI
      • UI Toolkit
    • Custom Item Drops
  • 🎓Tutorials
    • Demo Walkthrough
  • ✏️Editors
    • Inventool
      • Inventory
      • Equipment
      • Items
      • Currencies
      • Crafting
      • Dismantling
      • Enchanting
      • Stats
        • Stat IDs
        • Attributes
      • Settings
    • Item Type Manager
    • Localization Editor
    • Stats Editor
    • Merchants
      • Shopkeeper
      • Craftsman
      • Enchanter
    • Storage
    • Loot
      • Loot Box
      • Item Pouch
      • Currency Pouch
    • Components
      • Initializer
      • UI
        • uGUI
          • Inventool Window
          • Split UI
            • Inventory Window UGUI
            • Equipment Window UGUI
            • Key Items Window UGUI
            • Crafting Window UGUI
            • Enchanting Window UGUI
            • Storage Window UGUI
            • Shop Window UGUI
            • Selector UGUI
          • Action Menu UGUI
          • Hover Details UGUI
          • Confirm Prompt UGUI
          • Quantity Prompt UGUI
          • Character Viewer Element UGUI
        • UI Toolkit
          • Inventool Window
          • Split UI
            • Inventory Window
            • Equipment Window
            • Key Items Window
            • Crafting Window
            • Enchanting Window
            • Storage Window
            • Shop Window
          • Action Menu
          • Hover Details
          • Confirm Prompt
          • Quantity Prompt
        • Character Viewer
      • Overworld Merchant
      • Storage Keeper
      • Item Drop
      • Item Spawner
      • Input
        • Cross Input Support
        • Cross Input Support UGUI
          • Target Selectable
  • 📄Scripting API
    • Initialization
    • Inventory
    • Equipment
      • Equipment Slot
    • Items
      • Item
      • Item Type
      • Item Stack
      • Item Drop
      • Item Spawner
      • Loot Box
      • Item Pouch
    • Currencies
      • Currency Identity
      • Currency
        • Value
      • Currency Pouch
    • Crafting
      • Craft
      • Crafter
    • Enchanting
      • Enchantment
    • Stats
      • Stat Identity
      • Attribute
      • Stat
        • Stat Value
          • Value
        • Effectiveness
      • Stat Profile
    • Storing
      • Storage
      • Storage Keeper
    • Settings
    • Merchants
      • Shopkeeper
      • Craftsman
      • Enchanter
      • Overworld Merchant
    • UI
      • uGUI
        • Inventool Window UGUI
        • Split UI
          • Draggable Window UGUI
            • Inventory Window UGUI
            • Equipment Window UGUI
            • Key Items Window UGUI
            • Crafting Window UGUI
            • Enchanting Window UGUI
            • Storage Window UGUI
            • Shop Window UGUI
          • Selector UGUI
        • Action Menu UGUI
        • Hover Details UGUI
        • Confirm Prompt UGUI
        • Quantity Prompt UGUI
        • Draggable Element UGUI
          • Equipment Slot Element UGUI
          • Item Slot Element UGUI
          • Item Stack Element UGUI
        • Action Menu Option UGUI
        • Currency Element UGUI
        • Inventory Filter UGUI
        • Inventory Slot UGUI
        • Key Item Element UGUI
        • Shop Item Element UGUI
        • Storage Currency Element UGUI
        • Stat Element UGUI
      • UI Toolkit
        • Inventool Window
        • Split UI
          • Draggable Window
            • Inventory Window
            • Equipment Window
            • Key Items Window
            • Crafting Window
            • Enchanting Window
            • Storage Window
            • Shop Window
        • Action Menu
        • Hover Details
        • Confirm Prompt
        • Quantity Prompt
        • Item Elements
          • Item Stack Element
          • Equipment Slot Element
          • Item Slot Element
          • Shop Item Element
      • Action Menu Option
      • Character Viewer
    • Events
    • Sounds
    • Saving & Loading
      • Inventory & Equipment
      • Storage
    • Input
      • Cross Input Support
      • Cross Input Support UGUI
    • Localization
      • Localization Settings
      • Localizer
  • 🛠️Support
    • Getting Help
  • 📚Changelogs
    • Latest Releases
    • Future Plans
  • ⭐Rate Me?
Powered by GitBook
On this page
  • Fields & Properties
  • Combine Type
  • Combine Operator
  • Creating a Stat
  • Merging
  • Combining/Uncombining
  • Combine
  • Uncombine
  • Arithmetic
  • Methods
  • Operators
  • Managing Levels
  • Setting the Level
  • Increasing the Level
  • Decreasing the Level
  • Resetting Values
  • Reset Values
  • Reset Completely
  • Comparison
  • Is Similar
  • Name Matches
  1. Scripting API
  2. Stats

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

Name
Description
Type
Access

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.

Name
Description

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.

Name
Description

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.

// Parameters: StatIdentity abbreviation, Attribute name, initial value, current value
Stat hp = new Stat("HP", "Fire", 100, 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.

myStat.TryMerge(otherStat);

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.

myStat.Combine(otherStat);

Uncombine

Use the Uncombine method to uncombine a combined stat.

myStat.Uncombine(otherStat);

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.

myStat.Add(otherStat, useEffectiveness);

Operators

Similar to the methods, stats support arithmetic operators. Attribute effectiveness will automatically apply when possible.

myStat += otherStat;

Managing Levels

Setting the Level

myStat.SetLevel(1);

Increasing the Level

Use the TryUpgrade method to increase the level by a given amount. The level cannot go over the max level.

myStat.TryUpgrade(1);

Decreasing the Level

Use the TryDowngrade method to decrease the level by a given amount. The level cannot go lower than 0.

myStat.TryDowngrade(1);

Optionally, you can use the Deplete method to set the level to 0.

myStat.Deplete();

Resetting Values

Reset Values

The ResetValues method resets the current and external values.

myStat.ResetValues();

Reset Completely

The Reset method resets a stat completely.

myStat.Reset();

Comparison

Is Similar

The IsSimilar method checks if a stat is similar to another.

bool similar = myStat.IsSimilar(otherStat, Similarity.Everything);

Similarity Types

Name
Description

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.

bool match = myStat.NameMatches("HP");
PreviousAttributeNextStat Value

Last updated 3 days ago

📄