# Stats Overview

The **Stats** module is divided in two main sections:

* **Stats tab in Preferences Window:** Allows to define all the different stats, attributes and status effects and their initial default values.
* **The Stats component for Game Objects:** This is where the current values are stored for each game object's stat and attributes, as well as all of its status effects and stat modifiers.

![(Stats defined in the Preferences Window work as the blueprint for the rest of Game Objects)](https://2174264233-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAqwYovmUPn5V6CMeID%2F-LL-m-AEM376UqkINHYB%2F-LL-qCdvPeXeXZW4gAJ5%2Fstats-pref-stats.jpg?alt=media\&token=0af596d9-69f1-4d19-9fbb-13656ef226ab)

The Stats *Preference Window* has 3 distinct tabs that separate the 3 concepts that shape an entire progression system: **Stats**, **Attributes** and **Status Effects**.

## Stats

Stats are numeric values that represent a particular characteristic of a character or object. For example, how strong a character is or what is his maximum amount of health.

![](https://2174264233-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAqwYovmUPn5V6CMeID%2F-LL04UptXY975vZ6hUKV%2F-LL-sLtJATPDp4gVZ0Z8%2Fstat-pref.jpg?alt=media\&token=2fb33bb7-cff7-40a8-9df0-dbd4bf4a49f3)

A stat has the following properties:

* **Unique Name (ID):** This is for internal use only and uniquely identifies that stat among the rest
* **Title:** The title or name of the Stat. This text can be localized
* **Description:** A small description of the Stat. This text can be localized
* **Short Name:** Some games prefer to show an acronym of the stat instead of the full name
* **Color:** The color that represents the Stat
* **Icon:** The icon that represents the Stat

These properties are common between **Stats**, **Attributes** and **Status Effects**. A Stat has also a *base* (or default) value and a *Formula* object field.

Because a **Stat** is something that dynamically changes during gameplay, the **Stat** value is the result of applying the *base value* to a pre-defined *formula*.

{% hint style="info" %}
**Formulas** are a very powerful objects that parse a mathematical expression and return the result. More information about Formulas in the [Formulas](https://docs.gamecreator.one/stats/stats/stats-overview/formulas) section.
{% endhint %}

For example, a common case is where the **`Strength`** stat is the current strength base power. The formula in this case would be the returning the *base value* of the **Stat**.

## Attributes

**Attributes** are very similar to **Stats** but their value ranges from 0 up to a maximum defined by a **Stat**. For example, the current health of a character is an attribute.

![(A Stat defined the maximum value of an Attribute)](https://2174264233-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAqwYovmUPn5V6CMeID%2F-LL-vaS_Xr0C7M-COF43%2F-LL-ymg1ReeRthJT31XF%2Fattribute-pref.jpg?alt=media\&token=31247bda-4ef1-4126-81ad-11dcb845075f)

Apart from the common properties with a **Stat** (title, description, short name, color and icon) an **Attribute** also has a reference to another **Stat**, which defines the maximum value that **Attribute** will have during runtime and the percentage filled at the beginning.

For example, you can use the **`vitality`** stat as the maximum amount of **`health`** a character can have and have it filled only 50% at the beginning of the game.

## Status Effects

The **Status Effects** are, as their name implies, temporary effects that happen to a character or object that enhance or decrease one or more of it **Stats**.

![](https://2174264233-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAqwYovmUPn5V6CMeID%2F-LL04UptXY975vZ6hUKV%2F-LL05pBF34Ron5A03eu-%2Fstatus-effect-pref.jpg?alt=media\&token=5b1a20fc-04a8-4c90-b811-426b6b8cc0b5)

A common example of a **Status Effect** is the **Poison**, which drains life from the affected character over time. Here's a breakdown of a Poison Status Effect:

* **Type:** There are Positive (or Buffs) status effects, Negative (or Debuffs) and Other.
* **Duration:** If a Status Effect has a duration, it wears off passed a certain amount of seconds.
* **Max Stack:** The amount of Status Effects of the same type a character can have active at a given time.

A **Status Effect** also has 3 Action objects that are executed at different life cycles.

* **On Start:** These Actions are called when a Status Effect is added to a object
* **While Active:** These Actions are *constantly* executed while the Status Effect is active
* **On End:** These Actions are called right after the status effect is removed or wears off

{% hint style="info" %}
Notice that the **While Active Actions** are executed again after finishing. It's a good idea to add a **Wait** action so it halts the execution for 0.1 seconds at least.
{% endhint %}

## Formulas

Formulas are one of the key components of the Stats module. They allow to execute mathematic expressions at runtime as well as using custom Game Creator symbols.

For example, the formula **`stat[strength] + dice(2,6) - 10`** returns the final value of the stat named strength plus a random value of 2 rolls of a dice of 6 faces minus 10.

{% hint style="info" %}
The full list of all available symbols can be found in the **Formulas** section as well as in the built-in documentation of the **Formula** object in Unity (so it is easier to write them).
{% endhint %}

## The Stats Component

Once you have all your **Stats**, **Attributes** and **Status Effects** defined in the *Preferences Window*, you can add the **Stats** **component** to any game object.

![](https://2174264233-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAqwYovmUPn5V6CMeID%2F-LL07tmLF9LjwCEPiuZY%2F-LL0AolRS-9PFiAWQ1GU%2Fstats-component.jpg?alt=media\&token=fae04aa4-e8d8-4d8b-b5c2-622b35e65f36)

The **Stats** **component** tracks the information of the scene instance. You can add a **Stats** component to any game object and even modify each **Stat's** default values per object.

{% hint style="success" %}
During game play, the **Stats** component information changes and displays the current runtime values so it is easier to debug.
{% endhint %}
