chart-simple-horizontalPlayer Stats

A large part of the player’s behavior - damage, attack speed, movement speed, dodge chance, and more - is controlled through Stats. A Stat is a value with an initial base amount that can be modified by multipliers or adders applied by abilities, upgrades, status effects, and other systems.

There are two types of Stats:


Multiplicative Stat

  • Stores float values.

  • The initial value is usually 1.

  • Contains a list of Stat Multipliers.

  • Its final value is calculated by multiplying the initial value by each multiplier in the list.

Example: Initial damage = 20 Multipliers = 1.1 and 1.2 Final value = 20 Ă— 1.1 Ă— 1.2 = 26.4


Additive Stat

  • Stores int values.

  • The initial value is usually 0.

  • Contains a list of Stat Adders.

  • Its final value is calculated by adding all adders to the initial value.

Example: Initial dodge chance = 1% Adders = +2% and +3% Final value = 1 + 2 + 3 = 6%


Stat Events and Automatic Updates

  • Each Stat has an onStatChanged event, fired whenever:

    • its initial value changes,

    • one of its multipliers or adders changes value,

    • a multiplier/adder is added or removed.

  • StatMultipliers and StatAdders also expose onMultiplierChanged and onAdderChanged events.

  • The Stat automatically listens to these events, so you never need to manually recalculate a Stat’s value.


Example

If the player fires a front arrow using: player.Stats.FrontArrowDamageStat

…and then an ability modifies a multiplier on that stat, the next arrow automatically uses the newly recalculated damage value - no extra work required.

Last updated