2

During analyzing the lifetime of a GameplayEffect modifier and execution, I've stumbled across attribute aggregators or GameplayEffect aggregators (both terms are used in source code). These are used to evaluate modified attribute values (they are modified by GameplayEffects).

However, I don't understand how those aggregators influence the actual GameplayAbilitySystem attributes which are attached (as part of an AttributeSet) to the actor:

  1. Does an attribute/GameplayEffect aggregator FAggregator influence the base value or the current value of a gameplay attribute FGameplayAttributeData?
  2. Is the base value of an attribute/GameplayEffect aggregator float FAggregator::BaseValue related to the base value of a gameplay attribute float FGameplayAttributeData::BaseValue?

The vital components of attribute/GameplayEffect aggregators are

  • so called gameplay modifier evaluation channels EGameplayModEvaluationChannel, which are used sequentially during value evaluation (the result of channel0 is passed as base value to channel1 etc)
  • storing modifiers (with its magnitude, operation, tags and link to the applying GameplayEffect) in certain channels, which define the actual numerical evaluation

Those are used for doing the evaluation of

  • a final value
  • a base value by evaluating a final value in reverse, attempting to determine the base value from the modifiers (deprecated b/c GAS now has struct-based attributes - according to documentation)
  • a bonus value (final value - base value)

(all of them are just return values of functions and are not member variables of the aggregator)

To notify other classes of an evaluation (or changes to the aggregator), two methods are used

  1. a delegate FOnAggregatorDirty is broadcasted which contains a reference to the aggregator
  2. every GameplayEffect, which is registered in the AbilitySystemComponent, updates the change to its affected attribute(s) (via FActiveGameplayEffectsContainer::UpdateAggregatorModMagnitudes()) by updating the aggregator FAggregator for the attribute (which is determined or set via FindOrCreateAttributeAggregator()) in FAggregator::UpdateAggregatorMod())

I don't see, how one or both of those notification methods update the actual attribute values.

(The official documentation/source code as well as the excellent GAS: Comprehensive Analysis and GAS and you unfortunately don't shed light on GameplayEffect aggregators.)

Roi Danton
  • 7,933
  • 6
  • 68
  • 80

1 Answers1

2
  1. The attribute/GameplayEffect aggregator influences the current value of a gameplay attribute.
  2. Partly yes. They are related in one direction: the base value of the gameplay attribute is used to set the base value of the attribute/GameplayEffect aggregator, but not the other way around. The aggregator does not change the attribute base value.

Explanation for (1)

I was on the right track by looking at the notification methods. In fact, both in conjunction are updating the gameplay attribute:

  1. FActiveGameplayEffectsContainer::FindOrCreateAttributeAggregator() applies UAbilitySystemComponent::OnAttributeAggregatorDirty() to the OnDirty delegate (that delegate is executed when the aggregator changes as written in the question).
  2. OnAttributeAggregatorDirty() calls FActiveGameplayEffectsContainer::InternalUpdateNumericalAttribute(), which calls
  3. UAbilitySystemComponent::SetNumericAttribute_Internal(), which calls
  4. FGameplayAttribute::SetNumericValueChecked(). That sets the current value of a gameplay attribute.

Explanation for (2)

The base value of the attribute/GameplayEffect aggregator is set only using the gameplay attribute base value FGameplayAttributeData::BaseValue in:

  • FActiveGameplayEffectsContainer::OnAttributeAggregatorDirty()
  • FActiveGameplayEffectsContainer::SetAttributeBaseValue()

The base value of the gameplay attribute is set by:

  • UAttributeSet::InitFromMetaDataTable()
  • FActiveGameplayEffectsContainer::SetAttributeBaseValue()

In both functions, the attribute base value has no relation to the base value of the aggregator.

Roi Danton
  • 7,933
  • 6
  • 68
  • 80