Stat Modificiation
Stat modification occurs when a buff or debuff is applied to a target, and an array of stats is changes either additively (positive or negative) or multiplicatively (with values greater than or less than 1).
apply_buff
This function applies the stat modifications of a buff to the stats_add and stats_mult dictionaries of the target, and calls the calc_current_from_base_partial function, which recalculates the modified stats with the newly updated modifiers. It uses the spell, the source name, and the target as arguments.
remove_buff
This function removes the stat modifications of a buff or debuff from the stats_add and stats_mult dictionaries of the target, and calls the calc_current_from_base_partial function, which recalculates the modified stats with the newly updated modifiers. It uses the spell, the source name, and the target as arguments.
calc_current_from_base_partial
This function calculates the current stat values from the base value and modifiers. The word partial refers to the fact that not all stats are recalculated. It is intended for use when the character is affected by a buff or debuff, or a talent that increases a singular or only few stats. The function uses the target and an array of modified stats as arguments. The array of modified stats are looped over, and the additive and multiplicative modifiers are first then determined, and then applied to the base stats. For changes in maximum health and resource, the difference to the previous value is stored. If this difference is negative, i.e., the maximum values decrease, the current value of health or resource are set to the minimum of either itself or the new maximum, to avoid overcapping.
calc_current_from_base_full
This function calculates the current stat values from the base value and modifiers. The word full refers to the fact that all stats are recalculated. It is intended for use when the character class or role is changed, as this affects most or all stats. The function uses the target and an array of modified stats as arguments. The array of modified stats are looped over, and the additive and multiplicative modifiers are first then determined, and then applied to the base stats. For changes in maximum health and resource, the difference to the previous value is stored. If this difference is negative, i.e., the maximum values decrease, the current value of health or resource are set to the minimum of either itself or the new maximum, to avoid overcapping.
No Comments