# How to get Gameplay Effect Magnitude before applying Effect?

**URL:** <https://forums.unrealengine.com/t/how-to-get-gameplay-effect-magnitude-before-applying-effect/533928>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [April 19, 2022, 9:18pm UTC](https://forums.unrealengine.com/t/how-to-get-gameplay-effect-magnitude-before-applying-effect/533928 "2022-04-19T21:18:07Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Blitzpotz](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Blitzpotz](https://forums.unrealengine.com/u/Blitzpotz)\
**Post date:** [April 19, 2022, 9:18pm UTC](https://forums.unrealengine.com/t/how-to-get-gameplay-effect-magnitude-before-applying-effect/533928/1 "2022-04-19T21:18:08Z")

</div>

I’m trying to get the magnitude by which a Gameplay Effect _would_ change a certain base attribute if it where applied. Whithout actually having to apply the effect.

The only thing i found so far is this [Get Gameplay Effect Magnitude](http://ddns.myredstone.top:4100/BlueprintAPI-HTML/en-US/BlueprintAPI/GameplayEffects/GetGameplayEffectMagnitude/index.html) node. However it needs an Active Gameplay Effect Handle Structure as input. So (if i understand correctly) the GE has to be already applied.

To clarify:  
I set up armor items so that they apply Gameplay Effects to the player. These effects increase certain base attributes. Now i would like to show the potential increase of attributes for each item in a UI Tooltip. So when the player hovers the mouse over an item in his inventory a tooltip appears, showing the increase or deacrese per attribute that would result from equippng the item.

How would i go about doing that?

---

<div class="post-metadata">

**Author:** ![Countsie](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/countsie/32/1194632_2.png) [@Countsie](https://forums.unrealengine.com/u/Countsie)\
**Post date:** [April 19, 2022, 11:45pm UTC](https://forums.unrealengine.com/t/how-to-get-gameplay-effect-magnitude-before-applying-effect/533928/2 "2022-04-19T23:45:26Z")

</div>

How are you handling these values, are they set in the GE, or are you passing them in?

For this type of situation, I tend to hold the values as floats in my UObject items, then pass in values to an ExecCalc GE using GetSetByCallerMagnitude. This way I have only 1 GE for many types of items.

For example, food items have water, protein, carbs floats. I have a single ‘ConsumeFoodGamplayEffect’ execcalc class. In there I have

```auto
float protein = FMath::Max<float>(Spec.GetSetByCallerMagnitude(FGameplayTag::RequestGameplayTag(FName("Data.Nutrition.Protein")), false, -1.0f), 0.0f);

OutExecutionOutput.AddOutputModifier(FGameplayModifierEvaluatedData(NutritionStatics().ProteinProperty, EGameplayModOp::Additive, protein));

```

Alternatively, you can get a reference to the GE class you are using and expand out a class defaults node. This should give access to most of your GE settings.

---

<div class="post-metadata">

**Author:** ![Countsie](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/countsie/32/1194632_2.png) [@Countsie](https://forums.unrealengine.com/u/Countsie)\
**Post date:** [April 19, 2022, 11:49pm UTC](https://forums.unrealengine.com/t/how-to-get-gameplay-effect-magnitude-before-applying-effect/533928/3 "2022-04-19T23:49:09Z")

</div>

Here are some docs that go over that stuff, in section 4.5.12:

> **[GitHub - tranek/GASDocumentation: My understanding of Unreal Engine 4's...](https://github.com/tranek/GASDocumentation#concepts-ge-spec)**
>
> My understanding of Unreal Engine 4's GameplayAbilitySystem plugin with a simple multiplayer sample project. - GitHub - tranek/GASDocumentation: My understanding of Unreal Engine 4's Gamepl...

---

<div class="post-metadata">

**Author:** ![L.F.A](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/l.f.a/32/1194525_2.png) [@L.F.A](https://forums.unrealengine.com/u/L.F.A)\
**Post date:** [April 20, 2022, 12:42am UTC](https://forums.unrealengine.com/t/how-to-get-gameplay-effect-magnitude-before-applying-effect/533928/4 "2022-04-20T00:42:10Z")

</div>

Please refer to the previous thread in this forum, ‘dynamic cooldowns’

> [@Gameplay Ability System - dynamic cooldowns](https://forums.unrealengine.com/t/gameplay-ability-system-dynamic-cooldowns/522829):
>
> Hello, We’ve implemented the GAS in our game with basic cooldowns; each GA has a GE\_cooldown with a fixed cooldown value. How could we make it so the cooldowns are dynamic ? IE: the cooldown for a fireball ability is 10 seconds, if the player activates a “boost” the next fireball would have a 20% cooldown reduction, so would be 8 seconds. One way we could do this would be with ability level table but I don’t think this would be flexible enough for us. Thanks

---

<div class="post-metadata">

**Author:** ![Blitzpotz](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Blitzpotz](https://forums.unrealengine.com/u/Blitzpotz)\
**Post date:** [April 22, 2022, 6:37pm UTC](https://forums.unrealengine.com/t/how-to-get-gameplay-effect-magnitude-before-applying-effect/533928/5 "2022-04-22T18:37:55Z")

</div>

Thanks alot for the idea, that sounds like an elegant solution, i like it 🙂

I’ll try and implement that over the weekend.

---

<div class="post-metadata">

**Author:** ![Kiry](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Kiry](https://forums.unrealengine.com/u/Kiry)\
**Post date:** [July 10, 2023, 9:14pm UTC](https://forums.unrealengine.com/t/how-to-get-gameplay-effect-magnitude-before-applying-effect/533928/6 "2023-07-10T21:14:28Z")

</div>

I know its abit late but maybe someone get food for thoughts from this. i found some hacky solution to predict Gameplay effect change values without dissecting whole system into bits.  
First you have to deep copy ability component:

```auto
UPJCAbilitySystemComponent* UPJCAbilitySystemComponent::CreateAbilityComponentCopy()
{
	auto AbilitySystemComponentCopy = DuplicateObject(this,this->GetOwner());
	AbilitySystemComponentCopy->SetOwnerActor(this->GetOwnerActor());
	AbilitySystemComponentCopy->RemoveAllSpawnedAttributes();

	TArray<UAttributeSet*> AttributeSets;
	for(auto AttSet:this->GetSpawnedAttributes())
	{
		auto NewSet = DuplicateObject(AttSet,this->GetOwner());
		AttributeSets.Add(NewSet);
	}
	AbilitySystemComponentCopy->SetSpawnedAttributes(AttributeSets);

	
	AbilitySystemComponentCopy-> GetActiveGameplayEffectsMutable().RegisterWithOwner(AbilitySystemComponentCopy);
AbilitySystemComponentCopy-> GetActiveGameplayEffectsMutable().CloneFrom(ActiveGameplayEffects);

// this is needed if bSupressGameplayCues false.
	/*AbilitySystemComponentCopy->AbilityActorInfo = TSharedPtr<FGameplayAbilityActorInfo>(UAbilitySystemGlobals::Get().AllocAbilityActorInfo());*/
	AbilitySystemComponentCopy->bSuppressGameplayCues = true;
	return AbilitySystemComponentCopy;
}

```

Then create a prediction function of somekind :

```auto
		TMap<FGameplayAttribute,float> Result;
		
		auto AbilitySystemCompCopy = AbilitySystem->GetAbilityComponentCopy();
		AbilitySystemCompCopy->ApplyGameplayEffectToSelf(GameplayEffect,0,Context);
		
		TArray<FGameplayAttribute> SourceAttributes;
		AbilitySystem->GetAllAttributes(SourceAttributes);
		for(auto const &Attribute: SourceAttributes)
		{
			float SourceValue = AbilitySystem->GetNumericAttribute(Attribute);
			float TargetValue = AbilitySystemCompCopy->GetNumericAttribute(Attribute);
			if (!(TargetValue == SourceValue))
			{
				
				Result.Add(Attribute,TargetValue - SourceValue );
			}
		}

```
