LYRA Reverse damage if you hit teammate

Hello everyone!
I want to do reverse damage if you hit your teammate, but so that your teammate doesn’t take damage.
I found something in LyraDamageExecution.cpp , but it doesn’t works.


I try change HitActor, if i hit my teammate, but my teammate still gets damage and damage it’s not reversed to me.
But I did find something else interesting.

That’s row applying damage, but i don’t understand how it do this, because it doesn’t have HitActor and/or EffectCauser

Your team member likely has a different team id, you can debug to verify:
TeamSubsystem->CanCauseDamage(EffectCauser, HitActor)

That last line you refer to will apply those attributes against the target character. This execution is targeting the hit character so their ability system and attributes.
Open GA_Weapon_Fire and you’ll see where the info for the execution comes from:

Hi Highly recommend you read this to get a better understanding of what GAS has to offer:
GAS

Thank you. But i wanna make this. Return the damage to me, if i try hit my teammate


The red is a damage

1 Like

Okay, didn’t quite understand the reverse you mentioned. You could change the GA_Weapon_Fire, before applying the GameplayEffect check the targets team, if on the same team then change the targetdata to the current player.

You might have to tweak the logic around TeamSubsystem->CanCauseDamage in that case.

1 Like

Given it some more thought, you could leave the ApplyGamplayEffectToTarget as is and after it fires in the GA add a check as to whether you are on the same team then fire off another GE but with the current character as the target. You might want to then create a new Execution for TeamDamage and use that with whatever changes it might need.

Even better would be to check the team first then do a branch to the existing ApplyGamplayEffectToTarget and have the else run the TeamDamage execution, since you won’t need to have both GE run.

1 Like