# Stat/Attribute Manager

<div align="left"><figure><img src="/files/Pxb9F1D6r6SRb7Q5t5rd" alt=""><figcaption></figcaption></figure></div>

The **Stat Manager (AC\_StatManager)** is responsible for managing all stats and attributes in the project, both for player and AI. It works similarly to the Action Manager by instantiating each stat as a UObject at runtime, based on either a provided map or a data table. This component is designed to be **data-oriented** and **event-driven**, ensuring real-time responsiveness and integration with other systems.

It is added to the **Base Character** class by default **(B\_Base\_Character).**

### **How It Works**

1. **Stat Initialization**:
   * At startup, the **AC\_StatManager**:
     * Loads stats from the provided **data table** or **Stats\[] map**.
     * Creates an instance of each stat as a UObject for modular and extensible management.
   * The player's class asset provides base values for the attributes.
2. **Stat Tracking**:
   * Maintains a centralized map of stat instances, allowing quick retrieval through Gameplay Tags.
3. **Stat Modification**:
   * Provides methods to:
     * Increment or decrement a stat by a given value (e.g., apply damage, buffs).
     * Query the current or base value of a stat.
     * Level up the player.
4. **Event Dispatching**:
   * Changes to stat values automatically trigger event dispatchers, which are typically listened to by:
     * **UI Widgets** (e.g., updating health bars, stamina meters).
     * **Other Components** (e.g., triggering status effects or activating abilities).

### Adjusting Which Stats/Attributes to Initialize

The Stats/Attributes a character will have depends on what the Stat Manager is provided. Stats can be provided through a data table or through the Stats\[] map in **AC\_StatManager:**

<figure><img src="/files/scvKizKUowv5uJ9IOVxG" alt=""><figcaption></figcaption></figure>

### Example Usages

#### Adjust Stats:

<figure><img src="/files/4MNxXjRDzYFY9b01nCLa" alt=""><figcaption><p>Will adjust "MyPrimaryStat"'s Current Value by +1 and level up the player. </p></figcaption></figure>

#### Find/Get Stats:

<figure><img src="/files/ikycVNJ4Z3AhQf6dyW8c" alt=""><figcaption><p>GetStat() will return the Stat/Attribute Object, as well as the Stat Info struct.</p></figcaption></figure>

#### Toggle Regeneration for Compatible Stats/Attributes:

<figure><img src="/files/3VBdsmf4RYm9NsZOCHwp" alt=""><figcaption><p>Will try to Toggle Regeneration on the Stat Object with the provided tag.</p></figcaption></figure>

#### Adjust Player Level Manually

Player level is handled automatically through attribute increase from the Campfire. However, you can also manually increase/decrease level using the Stat Manager.

<figure><img src="/files/7jHDqT9Umxqmo82xgfK6" alt=""><figcaption><p>Will increase player level by 1.</p></figcaption></figure>

#### Compare Stat to a Threshold Value

<figure><img src="/files/fhu2xWNDOjXUPNHfmPJ5" alt=""><figcaption><p>Will check if Stamina is ≥ 25.0f.</p></figcaption></figure>

### See Next: [**How to Create/Edit Stats/Attributes?**](/workflow/editor-1.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://soulslike-framework.isik.vip/components-managers/shared-components/stat-attribute-manager.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
