StatInstance ​
Inherits: RefCounted
StatInstance with effect application logic removed for cached query system
Variables ​
StatDefinition # StatDefinition with stat_effects array | definition | |
float | base | 0.0 |
float | bonus | 0.0 |
float | growth | 0.0 |
float | multiplier | 1.0 |
bool | is_active | true |
bool | in_combat | false |
Methods ​
void | setup_from_definition( stat_def: Resource, initial_base: float = -1.0 ) |
void | set_active( active: bool ) |
void | update_combat_state( p_in_combat: bool ) |
void | set_base( new_base: float ) |
void | modify_bonus( amount: float ) |
void | set_growth( new_growth: float ) |
void | set_bonus( new_bonus: float ) |
void | modify_multiplier( amount: float ) |
void | set_multiplier( new_multiplier: float ) |
float | get_total() |
Array[StatEffect] | get_effects_by_type( effect_type: StatEffect.EffectType ) |
Array[StatEffect] | get_all_effects() |
Array | get_pool_restoration_effects( trigger_type: String ) |
Array | get_reactive_damage_effects() |
String | get_display_name() |
String | get_tooltip_text() |
Color | get_display_color() |
bool | is_valid() |
void | cleanup() |
Signals ​
stat_changed( stat_id: int, old_value: float, new_value: float ) ​
========== SIGNALS ==========
Variable descriptions ​
StatDefinition # StatDefinition with stat_effects array definition ​
========== CORE PROPERTIES ==========
float base = 0.0 ​
The base value of the stat.
float bonus = 0.0 ​
The flat bonus added to the base.
float growth = 0.0 ​
Level growth (derived from the entity level by StatsComponent.set_level, never saved): total = (base + growth + bonus) x multiplier
float multiplier = 1.0 ​
The multiplier applied to the base and the bonus (1 = none).
bool is_active = true ​
Simple enable/disable flag
bool in_combat = false ​
Combat state for context-aware effects
Method descriptions ​
void setup_from_definition( stat_def: Resource, initial_base: float = -1.0 ) ​
Sets the stat up from its definition: the base is initial_base (or the definition's default value), the bonus and growth are 0, the multiplier is 1, and the stat is active
void set_active( active: bool ) ​
Switches the stat on or off. An inactive stat is worth 0 (the Set Stat Active State effect uses this)
void update_combat_state( p_in_combat: bool ) ​
Tells the stat whether the entity is in combat, and recalculates when one of its effects depends on it
void set_base( new_base: float ) ​
Sets the base value (the value at level 1, before growth, bonuses and the multiplier)
void modify_bonus( amount: float ) ​
Adds amount to the bonus (negative to take it away). Equipment, effects and the multiplier effects of other stats work through the bonus
void set_growth( new_growth: float ) ​
Sets the growth: what the stat has gained from the entity's level. Set by the stats component when the level changes
void set_bonus( new_bonus: float ) ​
Sets the bonus outright
void modify_multiplier( amount: float ) ​
Adds amount to the multiplier (it starts at 1.0)
void set_multiplier( new_multiplier: float ) ​
Sets the multiplier outright
float get_total() ​
The value of the stat: (base + growth + bonus) x multiplier, kept between the minimum and the maximum of the definition and rounded as it says. 0 while the stat is inactive
Array[StatEffect] get_effects_by_type( effect_type: StatEffect.EffectType ) ​
Get all effects of a specific type from this stat's definition
Array[StatEffect] get_all_effects() ​
Get all enabled effects from this stat's definition
Array get_pool_restoration_effects( trigger_type: String ) ​
Get pool restoration effects that match a trigger type
Array get_reactive_damage_effects() ​
Get the reactive damage effects of this stat (damage reflection); which hits trigger them is up to each effect (matches_hit)
String get_display_name() ​
The name of the stat for the interface
String get_tooltip_text() ​
A tooltip that shows the total and where it comes from (base, growth, bonus, multiplier)
Color get_display_color() ​
The color of the value in the interface: gray when inactive, green with a positive bonus, red with a negative one, white otherwise
bool is_valid() ​
Does the instance have a definition with an id?
void cleanup() ​
Switches the stat off. Called when the entity is freed