Not logged in - Login
< back

Reflection Ability

In our game we have the concept of casting a "reflection" ability. This ability lasts for a few seconds and causes a set amount of damage to the attacker each time they hit the caster.


/*

To Determinedo ifthis, Reflectwe shieldset isa active ParamsGameplay : receiverCharacter - character that is being inspected tagName - tagEffect on the receiverCharactercasting thatcharacter, indicatesand each time they are attacked, we check to see if the reflectGameplay shieldEffect is active */ boolthere, UAttributeSetBase::IsReflectShieldActive(ACharacterBase*and receiverCharacter,if FNameso tagName) { FGameplayTagto ReflectShieldTagdamage = UGameplayTagsManager::Get().RequestGameplayTag(tagName, false); // If we get nothing back fromto the UGameplayTagsManagerattacker.


/* indicatesThis is the shieldcalling 
ApplyReflect(FName(TEXT("GE_ReflectShield")), isData, notattackingCharacter, active
    if (ReflectShieldTag.EmptyTag == ReflectShieldTag)
    {
        UE_LOG(LogAttributes,
            Warning,
            TEXT("Reflect Shield Tag not present"));

        return false;
    }
    // Logging for debugging :) If the receiverCharacter has the reflect shield tag, log all their tags
    if (receiverCharacter && receiverCharacter->GetAbilitySystemComponent()->HasAllMatchingGameplayTags(FGameplayTagContainer(ReflectShieldTag)))
    {
        receiverCharacter->LogOwnedTags();

        UE_LOG(LogAttributes,
            Warning,
            TEXT("Reflect Shield is active for %s"), *receiverCharacter->CharacterName);

        return true;
    }

    return false;
}receiverCharacter);
///*
    Apply Displaythe listReflect effect on the attackingCharacter (that is the caster). 
    Having this effect for the lifetime of currentlythe ownedeffect tagsmeans that whenever the attackingCharacter is hit, we check for thisthe actorreflection, and cause damage back to the attacker.

    The attackingCharacter has a GameplayEffect ability called "BaneShieldReflect" in BP (allowing different reflection choices for the designer).
*/
void ACharacterBase::LogOwnedTags()UAttributeSetBase::ApplyReflect(FName reflectTagName, struct FGameplayEffectModCallbackData &Data, ACharacterBase* attackingCharacter, ACharacterBase* receiverCharacter)
{
    TArrayif ((receiverCharacter) && (attackingCharacter))
    {
        // Cause Effect on the Attacker
        UGameplayEffect* effect = NewObject