You are viewing documentation for v1.1. Switch to current version โ†’

๐Ÿ“Š Stats Foundation

Short Description

The Stats Foundation provides a flexible, tag-driven system for managing actor attributes (Health, Mana, Speed) with integrated networking and access control.

Long Description

The Stats system is built on top of Object Variables and the Signal Bridge. It allows you to define numerical stats identified by FGameplayTag. Each actor with a UGorgeousStatComponent_AC can host its own set of stats. The system handles authoritative mutation on the server, automatic replication to clients, and provides a library of functions for querying and modifying values with minimal boilerplate.

๐Ÿš€ Features

  • Tag-Driven Identification: Stats are identified by hierarchical tags (e.g., Stat.Combat.Health).
  • Authority Managed: Stat mutations are restricted to the server to prevent cheating.
  • Component Based: Easily add stats to any actor by attaching a UGorgeousStatComponent_AC.
  • Global Storage: Centralized registry for all active stats in the world.
  • Reactive UI: Stats automatically dispatch signals via the Signal Bridge when their values change, allowing for instant UI updates.

๐Ÿ“š Usage Examples

UGorgeousStatBlueprintFunctionLibrary::ModifyStatValue(GetWorld(), GetPawn(), Stat_Health, -10.0f);

Use the Modify Stat node to change an actor's attributes. The system will automatically find the stat component and apply the change.

GetStatValue

Retrieves the current value of a stat for a specific actor.

Parameter Name Type Description
Actor AActor* The target actor.
StatTag FGameplayTag The tag identifying the stat.
Parameter Name Type Description
ReturnValue float The current numerical value of the stat.

SetStatValue

Directly sets the value of a stat. Must be called on the Server.

Parameter Name Type Description
Actor AActor* The target actor.
StatTag FGameplayTag The stat to set.
Value float The new value.

ModifyStatValue

Adds or subtracts from a stat's current value. Must be called on the Server.

Parameter Name Type Description
Actor AActor* The target actor.
StatTag FGameplayTag The stat to modify.
Delta float The amount to add (positive) or subtract (negative).

GetStatComponent

Helper to find the stat component on an actor.

Parameter Name Type Description
Actor AActor* The target actor.

๐Ÿ—๏ธ Stat Architecture

graph LR
    Logic[Gameplay Logic] --> Lib[Stat Lib]
    Lib -->|Server Only| Comp[Stat Component]
    Comp -->|Updates| Storage[Stat Storage (Object Variable)]
    Storage -->|Dispatches| Bridge[Signal Bridge]
    Bridge -->|Notifies| UI[UI Progress Bar]

Best Practices

  • Naming Hierarchy: Use a clear hierarchy for your stat tags (e.g., Stat.Combat.*, Stat.Attribute.*) to stay organized.
  • Server Authority: Always perform stat changes (damage, healing, buffs) on the server to ensure game state integrity.
  • Initial Values: Configure your default stat values in a UGorgeousStatConfig_DA data asset for easy balancing.

Troubleshooting

  • Mutation Failed: Verify that ModifyStatValue is being called from a server context (HasAuthority).
  • Component Missing: GetStatValue will return 0.0 if the target actor does not have a UGorgeousStatComponent_AC attached.
  • UI Not Updating: Ensure your UI widget is listening for the correct stat tag on the Signal Bridge.