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 do this, we set a Gameplay Effect on the casting character, and each time they are attacked, we check to see if the Gameplay Effect is there, and if so to damage to the attacker.

cpp``` /* This is the calling */

ApplyReflect(FName(TEXT("GE_ReflectShield")), Data, attackingCharacter, receiverCharacter); ```

/*
    Apply the Reflect effect on the attackingCharacter (that is the caster). 
    Having this effect for the lifetime of the effect means that whenever the attackingCharacter is hit, we check for the reflection, 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 UAttributeSetBase::ApplyReflect(FName reflectTagName, struct FGameplayEffectModCallbackData &Data, ACharacterBase* attackingCharacter, ACharacterBase* receiverCharacter)
{
    if ((receiverCharacter) && (attackingCharacter))
    {
        /* Cause Effect on the Attacker */
        UGameplayEffect* effect = NewObject