Attribute's Modifiers

Introduction

Attributes in Alacrity can be affected by buff modifiers, which can modify their values based on specific conditions. Buff modifiers are applied to target attributes, and a read-only copy of the modifier is pushed into the target attribute, triggering a recalculation. This modifies the attribute's nominal value.

Modifiers can affect different aspects of the final calculation of an attribute's value. An attribute's value is composed of three parts or locations used to calculate the final value.

The base value part

The base part of an attribute represents the raw value without any modifiers applied. Buff modifiers that apply a percentage over the attribute's value affect this part.

Let's take an example from the game Genshin Impact. The character Bennet has a skill called "Fantastic Voyage" that adds a percentage of Bennet's own ATK attribute to any character within its area of effect (AoE). If we were to model this effect using Alacrity, we would use the base part of Bennet's ATK value to calculate the additional ATK provided to affected players.

In Genshin Impact, a character's base ATK can be increased by leveling up the character and equipping a weapon. The ATK attribute of the weapon adds a flat value to the character's base ATK. In Alacrity, this system could be modeled using passive buffs in weapons that add flat values to the entity's ATK attribute value base part.

On the other hand, if a character receives a flat ATK bonus from Bennet's elemental burst, that bonus would not be affected by other buffs. It would be independent of subsequent calculations. This is because Bennet's bonus ATK is not considered in the calculations of other buffs. In order to model that in Alacrity we would target Bennet's bonus value into an special part of our attributes values called "calculated part". We will review this port later below.

The intermediate value part

The intermediate part of an attribute's value is used to grant bonuses that can be further augmented by final bonus modifiers (the "calculated part"). If we wanted Bennet's elemental burst ATK bonus to be affected by additional buffs, we would target this part of the attribute.

The intermediate value part has no value or meaning on its own; it is used to augment the value contained in the base part.

The calculated value part

The calculated part of an attribute's value is calculated last and is not subject to further buffs. It represents the final value of the attribute. If you want a bonus to be unaffected by other buffs (except global multipliers), you would target this part.

The calculated value part cannot be affected by any further buffs, as it is calculated last and is not part of subsequent calculations. It also hosts a special multiplier that adds a global bonus or malus to the calculated attribute's value.

The final value of an attribute is calculated using the following formula:

value = (
    attribute_base_value + (  // attribute initial base value as defined in specs
        (sum(modifiers.flat_base) * (1 + sum(modifiers.percent_base))) +  // base part
        (sum(modifiers.flat) * (1 + sum(modifiers.percent))) +            // intermediate part
        (sum(modifiers.flat_calculated))                                 // calculated part
    ) * (1 + sum(modifiers.percent_global))                             // global multiplier 
)

Each part adds to the previous part's calculation. In our example of Bennet's skill, the bonus would be pushed into the target's ATK attribute as a flat_calculated value, ensuring it is not affected by anything else except a global multiplier.

Global multipliers are used to apply a multiplier or divider to an attribute's value globally. For example, an area that unconditionally adds 20% to the character's traveling speed could be expressed as a global multiplier.

We will learn much more about modifiers and how to use them to model different effects in the Modifiers section.