StatDefinition ​
Inherits: DatabaseResource < Resource
The definition of one stat (Strength, Armor, Haste): its name, color and icon, whole numbers or decimals, the default value and the limits, whether it can be on items, and the effects it has on other stats and pools. (How stats grow with the level is the entity's: see GrowthProfile.) Made in Entity Stats > Stats. Every entity has one instance of every stat definition.
Properties ​
Color | color | Color.WHITE |
float | default_value | 0.0 |
float | min_value | 0.0 |
float | max_value | -1.0 |
ValueType | value_type | ValueType.FLOAT |
int | decimal_places | 1 # Only used for FLOAT, and only for display (the value... |
String | display_suffix | "" # "", "%", "sec", "pts", etc. |
bool | allow_negative_values | false |
Array[int] | groups | [] |
bool | on_items | false |
float | budget_cost | 1.0 |
Array[StatEffect] | stat_effects | [] # Composable effects |
Methods ​
bool | is_virtual() |
bool | is_item_stat( stat: Resource ) static |
bool | is_in_group( group_id: int ) |
String | format_display_value( raw_value: float ) |
float | validate_and_format_value( raw_value: float ) |
String | get_value_type_description() |
bool | is_percentage_display() |
float | calculate_final_value( instance_data: Dictionary ) |
StatInstance | create_instance( initial_base: float = -1.0 ) |
String | format_tooltip( instance_data: Dictionary ) |
Enumerations ​
enum ValueType ​
The options of value type: integer, float.
- INTEGER =
0
Constants ​
intVIRTUAL_ID_BASE =500000000- The ids from here up belong to the hidden stats that carry the effects of proficiencies (ProficiencyDefinition.get_virtual_stat)
Property descriptions ​
Color color = Color.WHITE ​
The color that stands for this in the interface
Value Settings
float default_value = 0.0 ​
The base value of the stat when an entity is created
float min_value = 0.0 ​
The value cannot go below this
float max_value = -1.0 ​
The value cannot go above this (-1 = no limit)
Value Display
ValueType value_type = ValueType.FLOAT ​
Whole numbers (INTEGER) or decimals (FLOAT)
int decimal_places = 1 # Only used for FLOAT, and only for display (the value it ​
How many decimals are shown, 0 to 3. Only for FLOAT, and only for display (the value itself keeps 4 decimals)
String display_suffix = "" # "", "%", "sec", "pts", etc. ​
Text shown after the value: "", "%", "sec", "pts" ...
bool allow_negative_values = false ​
Can the value be negative (debuffs, penalties)?
Stat Groups
Array[int] groups = [] ​
The stat groups this stat is in (StatGroupDefinition ids: Primary, Offensive, Defensive ...). Effects can target a whole group, and the character sheet and tooltips list the stat under the heading of its first group. A group that hides its stats (Hidden) keeps the stat off the sheet and out of tooltips
Items
bool on_items = false ​
Can this stat be put on items (equipment bonuses and affixes)? Only the stats that can be are offered in the item editors, so the list stays short
float budget_cost = 1.0 ​
What one point of this stat costs in the budget of a generated item (see ItemBudget). 1 = a point of this stat costs as much as a point of Strength, 2 = it costs double, so an item can hold half as many points of it. Only used for items that are generated or scale with their item level
Stat Effects
Array[StatEffect] stat_effects = [] # Composable effects ​
What the stat does: each effect turns the points of the stat into something (another stat, pool capacity, a damage change, a crit chance, leech ...)
Method descriptions ​
bool is_virtual() ​
Is this the hidden stat of a proficiency?
bool is_item_stat( stat: Resource ) ​
Can this stat be on items? (for the pickers of the item editors: only of StatPropertyFields.add_database_picker)
bool is_in_group( group_id: int ) ​
Is the stat in this stat group?
String format_display_value( raw_value: float ) ​
Format a raw float value according to this stat's display settings
float validate_and_format_value( raw_value: float ) ​
Apply value type constraints and formatting to a raw value
String get_value_type_description() ​
Get human-readable description of the value type
bool is_percentage_display() ​
Check if this stat displays as a percentage (based on suffix)
float calculate_final_value( instance_data: Dictionary ) ​
Calculate final stat value from instance data
StatInstance create_instance( initial_base: float = -1.0 ) ​
Makes the instance of the stat for an entity (with a starting base value, or the default).
String format_tooltip( instance_data: Dictionary ) ​
Format a tooltip string for this stat with breakdown information