UGameplayModMagnitudeCalculation - Can't get FGameplayAttributeData captured value

Hey guys!

I’m making an RPG game, and I’m using GameplayAbilities plug-in. Everything was excellent until now, so I’ll try to explain my problem in detail.

I want to use custom calculation class for applying damage. I’ve setup GameplayEffect to use custom calculation class derived from UGameplayModMagnitudeCalculation.
I made a blueprint from my custom calculation class and selected relevant attributes to capture. I’m planning to use those values to calculate damage (only using one at the moment, for presentational purposes).

UGameplayModMagnitudeCalculation class has this:

UFUNCTION(BlueprintNativeEvent, Category="Calculation")
float CalculateBaseMagnitude(const FGameplayEffectSpec& Spec) const;

All fine, I can override this in blueprint.

I created BlueprintCallable UFUNCTION

UFUNCTION(BlueprintCallable, Category = "Calculation")
float GetMagnitudePerAttribute(FGameplayEffectAttributeCaptureDefinition captureAttribute) const;

in my class that will get the value that I need to pass that value to CalculateBaseMagnitude in Blueprint. Except I have a problem getting the value. I think that I pinpointed the problem, and it’s casting to my class that holds GameplayAttributes derived from AttributeSet.
This should’ve done it:

return captureAttribute.AttributeToCapture.GetNumericValueChecked(CastChecked<UUrathaTalentSet>(captureAttribute.AttributeToCapture.GetAttributeSetClass()));

I tried different types of casts (const, static, dynamic), and nothing works.
After using CastChecked, I’m getting this error:
Fatal error: [File:\Build++UE4\Sync\Engine\Source\Runtime\CoreUObject\Private\Templates\Casts.cpp] [Line: 10] Cast of Class /Script/UrathaTheFirstHunt.UrathaTalentSet to UrathaTalentSet failed

GetAttributeSetClass()->GetFullName returns /Script/UrathaTheFirstHunt.UrathaTalentSet and not UrathaTalentSet.
Is this some kind of problem I’m not aware of?

Thanks in advance!

Extra info:

GetNumericValueChecked asks for *const UAttributeSet **;
UUrathaTalentSet is derived from UAttributeSet;
BUT
GetAttributeSetClass return *UClass **; That’s why I’m casting to my UUrathaTalentSet class.
I tried this as well, and no luck:

return captureAttribute.AttributeToCapture.GetNumericValueChecked(CastChecked<UUrathaTalentSet>(captureAttribute.AttributeToCapture.GetUProperty()->GetOuter()));

I solved it by doing a workaround that I’m not proud of.

I expanded the UFUNCTION parameters, since FGameplayEffectSpec is available in the GetBaseMagnitude:

UFUNCTION(BlueprintCallable, Category = "Calculation") 
float GetMagnitudePerAttribute(FGameplayEffectSpec spec, FGameplayEffectAttributeCaptureDefinition captureAttribute) const;

This UFUNCTION is called inside a blueprint override of GetBaseMagnitude, and it has to be a const UFUNCTION.

FGameplayEffectSpec contains the specification of GameplayEffect that is being applied. I have everything there except the FGameplayAttributes that I need.
That was the whole point of having a custom calculation class blueprint - so I could add FGameplayAttributes that are needed for calculation.

So, this the blasphemy that I came up with:

//Instigator is a player character (AUrathaCharacter in my case).
auto talentSet = (UUrathaTalentSet)spec.GetContext().GetInstigator()->GetSubobjectByName("UrathaAttributeTalentSetComponent");

//GetAttribute(FName name) is my method for getting the FGameplayAttribute by using reflection.
//Only using the FGameplayAttribute name from custom calculation class. :(
return talentSet->GetAttribute(*captureAttribute.AttributeToCapture.AttributeName)->GetCurrentValue();

And this works. Not how I intended, but it’s a workaround.
It contains some NO-NOs, like getting components by name (strings).

I really hope that someone had a similar problem, so we can solve it together, because calculation class should calculate, not provide lookup strings.