Find Matching Target Tag from different category than Source Tags

I have SourceTags and TargetTags in a UGameplayEffectExecutionCalculation Execute_Implementation function.

Like so:

const FGameplayTagContainer* SourceTags = Spec.CapturedSourceTags.GetAggregatedTags();
	const FGameplayTagContainer* TargetTags = Spec.CapturedTargetTags.GetAggregatedTags();

I need to determine if a value in the calculation will be: 1 if normal, 2 if target is weak against source DamageType, or 0.5 if target is protected against source DamageType.

How would I?

  • Get “DamageType” Tags from Source tags.

  • Check the “Weakness” Tags in Target tags for the matching end “DamageType” tag to determine if weak against DamageType.

  • Check the “Protection” Tags in Target tags for the matching end “DamageType” tag to determine if strong against DamageType

For example:
Source has DamageType.Axe in it’s Tags and Target has Weakness.Axe in it’s Tags so the value would be 2. If the Target had Protection.Axe then the value would be 0.5. If no tags in target then the value would be 1. If there were both Protection and Weakness then it would be an error but I guess I would swallow it and the value would still be 1.

Is there a function already that would do what I want or how would I write it? It seems simple if I was familiar with Unreal C++ with GameplayTags and GameplayTag Containers I don’t program with C++ much and use Blueprints most of the time.

I found how I wanted to do this in blueprint:

DetermineWeaknessValue.

IsAWeakOrProtectedValue.

Now I just need to convert it to C++. Do you know how?

I did it a hacky way with blueprints and attributes. I made an attribute named WeaknessValue before the effect is applied in the base Gameplay Ability Blueprint, I calculated the weakness value in a Blueprint Library function shown here: Find Matching Target Tag from different category than Source Tags - #2 by CureDespair which gets the gameplay tags from the source & target from their AbilitySystemComponent then I set the WeaknessValue using a setter I created instead of using a Gameplay Effect then in the GameplayEffectExecutionCalculation I capture the WeaknessValue attribute and use that in the calculation for the damage done by that ability.