FormulaContext ​
Inherits: RefCounted
What a CalculationFormula / DiminishingReturns can see when it is evaluated: who owns the stat, who is attacking and defending, their levels, the damage type, the size of the incoming hit and the DamageResult being built. Outside combat (pool capacity from a stat, stat-to-stat effects, level growth) only the owner part is filled. See docs/systems/entity-stats.md, section 18.2.
Variables ​
Variant | owner | null |
int | owner_level | 1 |
Variant | attacker | null |
int | attacker_level | 1 |
Variant | defender | null |
int | defender_level | 1 |
int | damage_type | 0 |
float | incoming_amount | 0.0 |
bool | in_combat | false |
DamageResult | result | null |
Methods ​
FormulaContext | for_owner( p_owner: Variant ) static |
FormulaContext | for_hit( p_owner: Variant, p_result: DamageResult, p_incoming_amount: float = 0.0 ) static |
int | get_level( source: LevelSource ) |
int | level_of( unit: Variant ) static |
Enumerations ​
enum LevelSource ​
Whose level a formula reads
- OWNER =
0- The entity that owns the stat - ATTACKER =
1- The entity dealing the hit - DEFENDER =
2- The entity receiving the hit
Variable descriptions ​
Variant owner = null ​
The entity that owns the stat being evaluated
int owner_level = 1 ​
The level of the owner of the stat.
Variant attacker = null ​
The attacker of the hit being worked out.
int attacker_level = 1 ​
The level of the attacker.
Variant defender = null ​
The defender of the hit being worked out.
int defender_level = 1 ​
The level of the defender.
int damage_type = 0 ​
The damage type of the hit.
float incoming_amount = 0.0 ​
Size of the hit being calculated (for formulas such as armor / (armor + 10 * hit)); 0 when not in a hit
bool in_combat = false ​
True when the owner is in combat.
DamageResult result = null ​
The result being built, when there is one
Method descriptions ​
FormulaContext for_owner( p_owner: Variant ) ​
A context with only the owner filled (no hit)
FormulaContext for_hit( p_owner: Variant, p_result: DamageResult, p_incoming_amount: float = 0.0 ) ​
A context for a stat that belongs to p_owner while p_result is being calculated
int get_level( source: LevelSource ) ​
The level of the source asked for (owner, attacker or defender).
int level_of( unit: Variant ) ​
Level of any unit: entities answer get_current_level(); anything else (objects, null, an unleveled entity) is 1