#Custom EffectContext simpler way to access no Blueprint Library functions

7 messages · Page 1 of 1 (latest)

snow kettle
#

Guys I was talking with someone very experienced in GAS, and he taught me a different method of getting the context struct. This is very easy to use and requires no BlueprintLibrary functions to access it. Posts below

#

Inside the header file you'll need this declared in the custom effect context

    static ONELIFEWITHFRIENDS_API
    FOneLifeGameplayEffectContext* GetEffectContext(FGameplayEffectContextHandle Handle);```
#

In the cpp file create a definition

#
FOneLifeGameplayEffectContext* FOneLifeGameplayEffectContext::GetEffectContext(FGameplayEffectContextHandle Handle)
{
    FGameplayEffectContext* EffectContext = Handle.Get();
    if (EffectContext && EffectContext->GetScriptStruct()->IsChildOf(StaticStruct()))
    {
        return static_cast<FOneLifeGameplayEffectContext*>(EffectContext);
    }
    return nullptr;
}```
#

This is what it looks like inside my exec calc. You can just call this anywhere you have that EffectSpecHandle available

wind spruce
#

👍 😎

naive olive
#

AuraEffectContext->SetIsCriticalHit(bCriticalHit);```
I just casted at the top of the function like so and used it ^_^