Applying multiple stacks of a gameplay effect will only trigger the Stack Limit logic if there was already an existing applied effect

TLDR: If you have an effect with a stack limit of 3, and you apply 10 stacks of the effect, the limit wont be applied. If you instead first apply 1 stack, then apply 10, it will properly limit it to 3 stacks.

In GameplayEffect.cpp - FActiveGameplayEffectsContainer::ApplyGameplayEffectSpec there is a branch based on if we found a matching existing stackable gameplay effect. In the case that there is an existing one, the code will limit the stacks applied to the StackLimitCount:

NewStackCount = ExistingSpec.GetStackCount() + Spec.GetStackCount();
if (ExistingSpec.Def->StackLimitCount > 0)
{
	NewStackCount = FMath::Min(NewStackCount, ExistingSpec.Def->StackLimitCount);
}

However in the Else section of the branch, no such limit is applied. It’s likely that code similar to this snippet should be added to the else branch.

Separately Ill note that there is some odd behavior around the GameplayEffectStackOverflow feature that is supposed to apply an additional secondary effect when you try to go over the stack limit. The behavior currently is that it only applies these secondary effects if you were at the stack limit, then go to apply more. If you had an effect with a stack limit of 4, and currently had 3 stacks of it, applying 2 more stacks would currently limit you to 4 stacks, but not apply the secondary effects. This seems unintuitive and like a bug to me, but there is a comment calling out that it works that way “for now”.

1 Like